/* Lagerboks AI Chat Widget — lagerboks-ai-chat.css */

/* ── Container ── */
.lgbx-chat {
    margin-top: 12px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
}

/* ── Toggle-knapp ── */
.lgbx-chat__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: #0071e3;
    color: #fff;
    border: none;
    border-radius: 980px;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    line-height: 1.2;
}
.lgbx-chat__toggle:hover  { background: #0077ed; }
.lgbx-chat__toggle:active { transform: scale(0.98); }

/* ── Chat-boks ── */
.lgbx-chat__box {
    display: none;
    flex-direction: column;
    margin-top: 10px;
    background: #fff;
    border: 1px solid #d2d2d7;
    border-radius: 12px;
    overflow: hidden;
}
.lgbx-chat.is-open .lgbx-chat__box {
    display: flex;
}

/* ── Header med X-knapp (skjult på desktop) ── */
.lgbx-chat__box-header {
    display: none;
}
.lgbx-chat__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    border-radius: 50%;
    color: #1d1d1f;
    cursor: pointer;
    transition: background 0.12s;
}
.lgbx-chat__close:hover { background: #f5f5f7; }

/* ── Velkomst-skjerm ── */
.lgbx-chat__welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px 20px 16px;
    overflow-y: auto;
}
.lgbx-chat__welcome-icon {
    font-size: 36px;
    line-height: 1;
    margin-bottom: 16px;
}
.lgbx-chat__welcome-text {
    font-size: 17px;
    font-weight: 600;
    color: #1d1d1f;
    margin: 0 0 20px;
    line-height: 1.4;
}
.lgbx-chat__sug-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #86868b;
    margin: 0 0 8px;
}

/* ── Forslag som vertikal liste ── */
.lgbx-chat__suggestions {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.lgbx-chat__sug {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    background: none;
    font-size: 14px;
    font-family: inherit;
    color: #1d1d1f;
    cursor: pointer;
    transition: background 0.12s;
}
.lgbx-chat__sug:hover {
    background: #f5f5f7;
}

/* ── Samtale-meldinger ── */
.lgbx-chat__messages {
    flex: 1;
    max-height: 280px;
    overflow-y: auto;
    padding: 14px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.lgbx-chat__msg { display: flex; }
.lgbx-chat__msg--user { justify-content: flex-end; }
.lgbx-chat__msg--ai   { justify-content: flex-start; }

.lgbx-chat__bubble {
    max-width: 85%;
    padding: 9px 13px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
}
.lgbx-chat__msg--user .lgbx-chat__bubble {
    background: #0071e3;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.lgbx-chat__msg--ai .lgbx-chat__bubble {
    background: #f5f5f7;
    color: #1d1d1f;
    border-bottom-left-radius: 4px;
}

/* Blinkende cursor under streaming */
.lgbx-chat__cursor {
    display: inline-block;
    width: 2px;
    height: 13px;
    background: #86868b;
    margin-left: 2px;
    vertical-align: middle;
    animation: lgbx-chat-blink 0.7s infinite;
}
@keyframes lgbx-chat-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* ── Input-bar ── */
.lgbx-chat__input-bar {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding: 10px 12px;
    border-top: 1px solid #d2d2d7;
    flex-shrink: 0;
}
.lgbx-chat__input {
    flex: 1;
    resize: none;
    max-height: 80px;
    overflow-y: auto;
    line-height: 1.4;
}
.lgbx-chat__input:focus {
    box-shadow: none;
}
.lgbx-chat__send {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    background: #0071e3;
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.lgbx-chat__send:hover    { background: #0077ed; }
.lgbx-chat__send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Mobil — fullskjerm ved åpning ── */
@media (max-width: 768px) {
    .lgbx-chat {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 9999;
        margin-top: 0;
        display: flex;
        flex-direction: column-reverse;
    }

    .lgbx-chat__toggle {
        border-radius: 0;
        padding: 16px 20px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.1);
    }

    /* Skjul trigger-knappen når chat er åpen */
    .lgbx-chat.is-open .lgbx-chat__toggle {
        display: none;
    }

    /* Chat-boksen dekker nesten hele skjermen */
    .lgbx-chat.is-open .lgbx-chat__box {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        margin-top: 0;
        border-radius: 16px 16px 0 0;
        border: none;
        max-height: none;
    }

    /* Vis header med X-knapp */
    .lgbx-chat__box-header {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        padding: 12px 16px 4px;
        flex-shrink: 0;
    }

    /* Meldingshistorikk fyller tilgjengelig plass */
    .lgbx-chat__messages {
        max-height: none;
    }

    /* Inputfelt sticky i bunn over tastaturet */
    .lgbx-chat__input-bar {
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }
}
