/* ================================================================
   Chatbot widget - interviews.dk
   Floating hjælpeassistent, bottom-right
   ================================================================ */

/* -- Lokale tokens (matchar app.css) ----------------------------- */
.cb-widget {
    --cb-ink:       #2B475C;
    --cb-ink-2:     #4A6577;
    --cb-ink-3:     #7A8E9A;
    --cb-bg:        #E9E6E1;
    --cb-paper:     #F4F1EC;
    --cb-white:     #ffffff;
    --cb-orange:    #D28640;
    --cb-teal:      #3B6562;
    --cb-line:      rgba(43,71,92,0.13);
    --cb-shadow:    0 8px 32px rgba(43,71,92,0.18), 0 2px 8px rgba(43,71,92,0.10);
    --cb-radius:    16px;
    --cb-font:      "Montserrat", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --cb-w:         360px;
    --cb-h:         520px;
}

/* -- Trigger-knap (pill når lukket, cirkel når åben) ------------- */
.cb-trigger {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9990;
    height: 52px;
    border-radius: 26px;
    background: var(--cb-ink);
    color: var(--cb-white);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(43,71,92,0.30);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px 0 16px;
    transition: background 0.18s, transform 0.18s, box-shadow 0.18s, border-radius 0.18s, padding 0.18s, width 0.18s;
}
.cb-trigger:hover {
    background: var(--cb-teal);
    transform: scale(1.04);
    box-shadow: 0 6px 20px rgba(43,71,92,0.38);
}
.cb-trigger svg { display: block; flex-shrink: 0; }
.cb-trigger-label {
    font-family: var(--cb-font);
    font-size: 13.5px;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: -0.01em;
}
/* Åben tilstand: rund cirkel, ingen label */
.cb-widget--open .cb-trigger {
    border-radius: 50%;
    width: 52px;
    padding: 0;
    justify-content: center;
}
.cb-trigger .cb-trigger-close { display: none; }
.cb-trigger .cb-trigger-open  { display: block; }
.cb-widget--open .cb-trigger .cb-trigger-open  { display: none; }
.cb-widget--open .cb-trigger .cb-trigger-close { display: block; }
.cb-widget--open .cb-trigger-label { display: none; }

/* Badge med ulæst indikator */
.cb-trigger__badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: var(--cb-orange);
    border-radius: 50%;
    border: 2px solid var(--cb-white);
    display: none;
}
.cb-widget--unread .cb-trigger__badge { display: block; }

/* -- Chatvindue -------------------------------------------------- */
.cb-window {
    position: fixed;
    bottom: 96px;
    right: 28px;
    z-index: 9991;
    width: var(--cb-w);
    height: var(--cb-h);
    background: var(--cb-white);
    border-radius: var(--cb-radius);
    box-shadow: var(--cb-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.96);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1), opacity 0.18s ease;
}
.cb-widget--open .cb-window {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* -- Header ------------------------------------------------------ */
.cb-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--cb-ink);
    color: var(--cb-white);
    flex-shrink: 0;
}
.cb-header__avatar {
    width: 34px;
    height: 34px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.cb-header__text { flex: 1; min-width: 0; }
.cb-header__title {
    font-family: var(--cb-font);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0;
    line-height: 1.2;
}
.cb-header__sub {
    font-family: var(--cb-font);
    font-size: 11px;
    color: rgba(255,255,255,0.65);
    margin: 0;
    line-height: 1.3;
}
.cb-header__actions {
    display: flex;
    gap: 4px;
    align-items: center;
}
.cb-header__btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.70);
    cursor: pointer;
    padding: 5px 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background 0.15s, color 0.15s;
}
.cb-header__btn:hover {
    background: rgba(255,255,255,0.12);
    color: var(--cb-white);
}
.cb-header__btn-label {
    font-family: var(--cb-font);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
/* Luk-knap kun paa mobil - paa desktop lukker man via trigger-krydset */
.cb-header__btn--close { display: none; }

/* -- Paneler (welcome / chat / feedback) ------------------------- */
.cb-panel {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.cb-panel--active { display: flex; }

/* -- Velkomstskærm ----------------------------------------------- */
.cb-welcome {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px 8px;
    scrollbar-width: thin;
}
.cb-welcome__greeting {
    font-family: var(--cb-font);
    font-size: 16px;
    font-weight: 700;
    color: var(--cb-ink);
    margin: 0 0 6px;
    line-height: 1.3;
}
.cb-welcome__sub {
    font-family: var(--cb-font);
    font-size: 13px;
    color: var(--cb-ink-2);
    margin: 0 0 18px;
    line-height: 1.5;
}
.cb-chips {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}
.cb-chip {
    background: var(--cb-paper);
    border: 1px solid var(--cb-line);
    border-radius: 10px;
    padding: 10px 13px;
    font-family: var(--cb-font);
    font-size: 12.5px;
    color: var(--cb-ink);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1.4;
}
.cb-chip:hover {
    background: var(--cb-bg);
    border-color: rgba(43,71,92,0.25);
}

/* -- Chatvisning ------------------------------------------------- */
.cb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 4px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(43,71,92,0.15) transparent;
}
.cb-messages::-webkit-scrollbar { width: 4px; }
.cb-messages::-webkit-scrollbar-track { background: transparent; }
.cb-messages::-webkit-scrollbar-thumb { background: rgba(43,71,92,0.15); border-radius: 2px; }

.cb-msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
}
.cb-msg--user {
    align-self: flex-end;
    align-items: flex-end;
}
.cb-msg--assistant {
    align-self: flex-start;
    align-items: flex-start;
}
.cb-msg__bubble {
    padding: 9px 13px;
    border-radius: 14px;
    font-family: var(--cb-font);
    font-size: 13px;
    line-height: 1.55;
    word-break: break-word;
}
.cb-msg--user .cb-msg__bubble {
    background: var(--cb-ink);
    color: var(--cb-white);
    border-bottom-right-radius: 4px;
}
.cb-msg--assistant .cb-msg__bubble {
    background: var(--cb-paper);
    color: var(--cb-ink);
    border-bottom-left-radius: 4px;
}

/* Skrive-indikator */
.cb-msg--typing .cb-msg__bubble {
    padding: 12px 16px;
}
.cb-typing-dots {
    display: flex;
    gap: 5px;
    align-items: center;
}
.cb-typing-dots span {
    width: 7px;
    height: 7px;
    background: var(--cb-ink-3);
    border-radius: 50%;
    animation: cb-bounce 1.2s infinite ease-in-out;
}
.cb-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.cb-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes cb-bounce {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1.1); opacity: 1; }
}

/* Eskaleringslinje */
.cb-escalate-bar {
    padding: 8px 14px;
    border-top: 1px solid var(--cb-line);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.cb-escalate-btn {
    background: none;
    border: none;
    font-family: var(--cb-font);
    font-size: 11.5px;
    color: var(--cb-ink-3);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color 0.15s, background 0.15s;
}
.cb-escalate-btn:hover {
    color: var(--cb-ink);
    background: var(--cb-paper);
}

/* -- Input-felt -------------------------------------------------- */
.cb-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px 12px;
    border-top: 1px solid var(--cb-line);
    background: var(--cb-white);
    flex-shrink: 0;
}
.cb-input {
    flex: 1;
    min-height: 38px;
    max-height: 100px;
    padding: 9px 12px;
    background: var(--cb-paper);
    border: 1.5px solid transparent;
    border-radius: 10px;
    font-family: var(--cb-font);
    font-size: 13px;
    color: var(--cb-ink);
    resize: none;
    outline: none;
    overflow-y: auto;
    line-height: 1.45;
    transition: border-color 0.15s;
}
.cb-input:focus { border-color: rgba(43,71,92,0.30); }
.cb-input::placeholder { color: var(--cb-ink-3); }
.cb-send-btn {
    width: 38px;
    height: 38px;
    background: var(--cb-ink);
    color: var(--cb-white);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
}
.cb-send-btn:hover { background: var(--cb-teal); }
.cb-send-btn:active { transform: scale(0.94); }
.cb-send-btn:disabled { background: var(--cb-line); cursor: not-allowed; }

/* -- Feedback-panel ---------------------------------------------- */
.cb-feedback {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.cb-feedback__title {
    font-family: var(--cb-font);
    font-size: 14px;
    font-weight: 700;
    color: var(--cb-ink);
    margin: 0 0 2px;
}
.cb-feedback__sub {
    font-family: var(--cb-font);
    font-size: 12.5px;
    color: var(--cb-ink-2);
    margin: 0 0 4px;
    line-height: 1.5;
}
.cb-feedback__field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.cb-feedback__label {
    font-family: var(--cb-font);
    font-size: 11.5px;
    font-weight: 600;
    color: var(--cb-ink-2);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.cb-feedback__textarea,
.cb-feedback__emailinput {
    padding: 9px 12px;
    background: var(--cb-paper);
    border: 1.5px solid var(--cb-line);
    border-radius: 10px;
    font-family: var(--cb-font);
    font-size: 13px;
    color: var(--cb-ink);
    outline: none;
    transition: border-color 0.15s;
}
.cb-feedback__textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.cb-feedback__textarea:focus,
.cb-feedback__emailinput:focus { border-color: rgba(43,71,92,0.35); }
.cb-feedback__submit {
    background: var(--cb-ink);
    color: var(--cb-white);
    border: none;
    border-radius: 10px;
    padding: 11px 16px;
    font-family: var(--cb-font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    text-align: center;
}
.cb-feedback__submit:hover { background: var(--cb-teal); }
.cb-feedback__submit:disabled { background: var(--cb-ink-3); cursor: not-allowed; }
.cb-feedback__back {
    background: none;
    border: none;
    font-family: var(--cb-font);
    font-size: 12.5px;
    color: var(--cb-ink-3);
    cursor: pointer;
    text-align: center;
    padding: 4px;
    transition: color 0.15s;
}
.cb-feedback__back:hover { color: var(--cb-ink); }

/* Bekræftelse efter afsendelse */
.cb-confirm {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px 20px;
    text-align: center;
}
.cb-confirm__icon {
    width: 48px;
    height: 48px;
    background: rgba(59,101,98,0.10);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cb-teal);
}
.cb-confirm__title {
    font-family: var(--cb-font);
    font-size: 15px;
    font-weight: 700;
    color: var(--cb-ink);
    margin: 0;
}
.cb-confirm__sub {
    font-family: var(--cb-font);
    font-size: 13px;
    color: var(--cb-ink-2);
    margin: 0;
    line-height: 1.5;
}
.cb-confirm__back {
    background: none;
    border: 1.5px solid var(--cb-line);
    border-radius: 10px;
    padding: 9px 20px;
    font-family: var(--cb-font);
    font-size: 13px;
    color: var(--cb-ink);
    cursor: pointer;
    margin-top: 6px;
    transition: background 0.15s;
}
.cb-confirm__back:hover { background: var(--cb-paper); }

/* -- Fejlbesked -------------------------------------------------- */
.cb-error-bar {
    font-family: var(--cb-font);
    font-size: 12px;
    color: #b91c1c;
    padding: 6px 14px;
    text-align: center;
    display: none;
}
.cb-error-bar--visible { display: block; }

/* -- Mobil ------------------------------------------------------- */
@media (max-width: 480px) {
    .cb-widget {
        --cb-w: 100vw;
    }
    .cb-window {
        right: 0;
        left: 0;
        bottom: 0;
        width: 100vw;
        height: 85dvh;
        border-radius: var(--cb-radius) var(--cb-radius) 0 0;
    }
    .cb-trigger {
        bottom: 18px;
        right: 18px;
        padding: 0 16px 0 13px;
        height: 48px;
    }
    .cb-trigger-label { font-size: 12.5px; }
    .cb-header__btn--close { display: inline-flex; }
}
