/* L.A.I.A. floating assistant. Everything is fixed-position and scoped under
   its own ids, so it neither reflows the host page nor inherits from it. */

#laiaBtn {
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: #2b579a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
    cursor: pointer;
    padding: 0;
    z-index: 100000;
}

#laiaBtn:hover { background: #1e3f73; }
#laiaBtn img { width: 32px; height: 32px; vertical-align: middle; }

#laiaPanel {
    position: fixed;
    right: 18px;
    bottom: 80px;
    width: 380px;
    height: 520px;
    max-height: calc(100vh - 110px);
    background: #fff;
    border: 1px solid #b9c6d4;
    border-radius: 8px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, .28);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 100000;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    color: #22303f;
    text-align: left;
    line-height: normal;
}

#laiaHead {
    background: #2b579a;
    color: #ffffff;
    /* Left padding clears the resize grip sitting in that corner. */
    padding: 8px 12px 8px 20px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: default;
}

/* Resize grip. The panel is anchored bottom-right, so it grows up and to the
   left - which is why this sits in the top-left corner and not the usual
   bottom-right one. */
#laiaGrip {
    position: absolute;
    top: 0;
    left: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    z-index: 2;
    background: linear-gradient(135deg, rgba(255,255,255,.85) 0 2px, transparent 2px 4px,
                                        rgba(255,255,255,.85) 4px 6px, transparent 6px 100%);
}

#laiaModel {
    margin-left: auto;
    margin-right: 6px;
    max-width: 165px;
    font-size: 11px;
    border: none;
    border-radius: 3px;
    padding: 2px 4px;
    background: #ffffff;
    color: #22303f;
}

#laiaClose {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

#laiaBar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px;
    background: #22303f;
    color: #cfd8e3;
    font-size: 11px;
    font-family: Arial, Helvetica, sans-serif;
    white-space: nowrap;
    overflow: hidden;
}

#laiaScreenWrap {
    cursor: pointer;
    color: #cfd8e3;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: none;
}

#laiaScreen { margin: 0; vertical-align: middle; }

#laiaToolsWrap {
    cursor: pointer;
    color: #cfd8e3;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: none;
}

#laiaTools { margin: 0; vertical-align: middle; }

#laiaStats {
    margin-left: auto;
    overflow: hidden;
    text-overflow: ellipsis;
}

#laiaBar .k { color: #8b9aad; }
#laiaBar .v { color: #ffb74d; font-weight: bold; }
#laiaBar #laiaAvail { color: #1a7f37; }

#laiaBody {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: #f7f9fc;
    color: #22303f;
}

/* Every colour here is stated, never inherited. This panel is injected into
   sixty-odd pages with their own stylesheets, and one of them setting a white
   colour on a container is all it takes for the replies to come out white on
   white - which is exactly what happened. */
.laia-msg {
    margin: 0 0 8px 0;
    padding: 7px 10px;
    border-radius: 10px;
    max-width: 85%;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.35;
    color: #22303f;
    background: #fff;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    text-align: left;
}

.laia-user { background: #2b579a; color: #ffffff; margin-left: auto; border-bottom-right-radius: 2px; }
.laia-bot  { background: #ffffff; color: #22303f; border: 1px solid #dde5ee; border-bottom-left-radius: 2px; }
.laia-note { background: transparent; color: #6b7785; font-size: 12px; font-style: italic; max-width: 100%; }

#laiaFoot {
    border-top: 1px solid #dde5ee;
    padding: 8px;
    display: flex;
    gap: 6px;
    background: #fff;
}

#laiaInput {
    flex: 1;
    resize: none;
    border: 1px solid #c3cedb;
    border-radius: 4px;
    padding: 6px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    color: #22303f;
    background: #ffffff;
}

#laiaSend {
    background: #2b579a;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    padding: 0 14px;
    cursor: pointer;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
}

#laiaSend:disabled { background: #9aa9bd; cursor: default; }

/* Phones: fill the screen rather than float a card on top of one. */
@media (max-width: 600px) {
    #laiaPanel {
        /* !important because the stored size is applied inline, and on a phone the
           panel fills the screen regardless of what was dragged on a desktop. */
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0;
        border: none;
    }

    /* Nothing to resize when it already fills the screen. */
    #laiaGrip { display: none; }
}
