/* ============================================================
   KIWI: the assistant's avatar, the call card's kiwi dress, the
   notification bell with its history, and the banners.
   Built by kiwi.js. Dark is the base, body.light-mode the override,
   like the rest of the app.
   ============================================================ */
body {
    --kw-surface:     #171C17;
    --kw-surface-2:   #1E251D;
    --kw-hover:       #243023;
    --kw-border:      rgba(255, 255, 255, 0.12);
    --kw-text:        #EEF3EA;
    --kw-muted:       #AEB9AB;
    --kw-green:       #8FD14F;
    --kw-green-deep:  #6DB22E;
    --kw-wash:        rgba(124, 198, 58, 0.14);
    --kw-unread:      rgba(124, 198, 58, 0.09);
    --kw-shadow:      0 18px 50px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
    --kw-scrim:       rgba(6, 10, 6, 0.55);
}
body.light-mode {
    --kw-surface:     #FFFFFF;
    --kw-surface-2:   #F5FAEE;
    --kw-hover:       #EEF6E4;
    --kw-border:      #DCE6D2;
    --kw-text:        #1D2419;
    --kw-muted:       #55604F;
    --kw-green:       #3F7A1A;
    --kw-green-deep:  #4E8A22;
    --kw-wash:        #EAF5DD;
    --kw-unread:      #F4FAEC;
    --kw-shadow:      0 18px 50px rgba(33, 37, 49, 0.16), 0 2px 8px rgba(33, 37, 49, 0.07);
    --kw-scrim:       rgba(40, 48, 36, 0.28);
}

.kiwi-ava {
    display: inline-block; flex: 0 0 auto;
    width: 20px; height: 20px;
    object-fit: contain;   /* Kiwi's picture is transparent: no disc behind him */
    user-select: none; -webkit-user-drag: none;
}

/* ── the call card, Kiwi's ─────────────────────────────────────
   Same card as before (.outcome-queue .call-queue from styles.css):
   plain white so the name, the time and the buttons stay what the eye
   reads first; Kiwi's face and a pale green header are the only touch. */
.call-queue {
    border-color: #DCEBCB;
    background: #FFFFFF;
    overflow: visible;                /* Kiwi looks over the top edge */
}
.call-queue .oq-head {
    position: relative;
    justify-content: center;          /* the title sits centred under Kiwi */
    padding-left: 36px; padding-right: 36px;
    background: #F4FAEE;
    border-bottom-color: #E3EFD6;
    border-radius: 13px 13px 0 0;     /* the card no longer clips its corners */
}
.call-queue .oq-close { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.call-queue .oq-title > i.ph-phone-call { color: #4E8A22; }   /* Kiwi's green, like the count */
/* Kiwi hiding behind the card: his head above the top edge, centred, cut
   where the card begins. 78% of the picture shows: the leaves, the eyes and
   the smile; the chin stays "behind" the card. Never catches a click. */
.call-queue .kiwi-peek {
    position: absolute; left: 50%; bottom: 100%;
    transform: translateX(-50%);
    width: 72px; height: 56px;
    overflow: hidden; pointer-events: none;
}
.call-queue .kiwi-peek img { display: block; width: 72px; height: 72px; max-width: none; }
@media (max-width: 700px) {
    /* A phone has less room above the card: a smaller Kiwi, same cut. */
    .call-queue .kiwi-peek { width: 60px; height: 47px; }
    .call-queue .kiwi-peek img { width: 60px; height: 60px; }
}
.call-queue .oq-count { background: #4E8A22; }
.call-queue .oq-big { background: rgba(255, 255, 255, 0.92); }
.call-queue .cq-call { border-color: #9CCB6E; color: #2F5F12; }
.call-queue .cq-call:hover { border-color: #4E8A22; color: #2F5F12; background: #EAF5DD; }

body:not(.light-mode) .call-queue {
    border-color: rgba(143, 209, 79, 0.28);
    background-color: #161D15;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg transform='translate(16 20)'%3E%3Ccircle r='9' fill='%23B08A5E' fill-opacity='.16'/%3E%3Ccircle r='7.4' fill='%237CC63A' fill-opacity='.18'/%3E%3Ccircle r='2.6' fill='%23F7F4D2' fill-opacity='.22'/%3E%3C/g%3E%3Cg transform='translate(54 54)'%3E%3Ccircle r='7' fill='%23B08A5E' fill-opacity='.14'/%3E%3Ccircle r='5.6' fill='%237CC63A' fill-opacity='.16'/%3E%3Ccircle r='2' fill='%23F7F4D2' fill-opacity='.2'/%3E%3C/g%3E%3Cpath d='M44 18 q7 -9 16 -6 q-5 9 -16 6z' fill='%237CC63A' fill-opacity='.14'/%3E%3Cpath d='M8 58 q7 -9 16 -6 q-5 9 -16 6z' fill='%237CC63A' fill-opacity='.12'/%3E%3C/svg%3E");
    box-shadow: var(--kw-shadow);
}
body:not(.light-mode) .call-queue .oq-head {
    background: linear-gradient(90deg, rgba(143, 209, 79, 0.2), rgba(143, 209, 79, 0.06));
    border-bottom-color: rgba(143, 209, 79, 0.2);
}
body:not(.light-mode) .call-queue .oq-title,
body:not(.light-mode) .call-queue .oq-card-name { color: var(--kw-text); }
body:not(.light-mode) .call-queue .oq-card-what,
body:not(.light-mode) .call-queue .oq-card-when,
body:not(.light-mode) .call-queue .oq-skip,
body:not(.light-mode) .call-queue .oq-close { color: var(--kw-muted); }
body:not(.light-mode) .call-queue .oq-close:hover { background: rgba(255, 255, 255, 0.08); color: var(--kw-text); }
body:not(.light-mode) .call-queue .oq-big {
    background: rgba(30, 37, 29, 0.92); border-color: rgba(255, 255, 255, 0.16); color: var(--kw-text);
}
body:not(.light-mode) .call-queue .cq-call { border-color: rgba(143, 209, 79, 0.5); color: #B6E58A; }
body:not(.light-mode) .call-queue .cq-call:hover { background: rgba(143, 209, 79, 0.14); color: #CFF0AE; }
body:not(.light-mode) .call-queue .cq-when.cq-due    { color: #F5B454; }
body:not(.light-mode) .call-queue .cq-when.cq-missed { color: #F87171; }

/* ── the bell ──────────────────────────────────────────────── */
.kiwi-bell { position: relative; }
.kiwi-bell.has-unread { color: var(--kw-green-deep); }
.kiwi-bell-badge {
    position: absolute; top: -3px; right: -4px;
    min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 999px; box-sizing: border-box;
    background: #E5484D; color: #fff;
    font-family: var(--font-ui, sans-serif); font-size: 10px; font-weight: 700; line-height: 16px;
    text-align: center; pointer-events: none;
    box-shadow: 0 0 0 2px var(--kw-surface);
}
.kiwi-bell-badge[hidden] { display: none; }

/* The phone bar's bell, at its right edge. The bar's spacer only kept the
   logo centred against an empty slot; the bell fills that slot now, and the
   logo is centred absolutely anyway. */
.kiwi-bell-m { display: none; }
@media (max-width: 900px) {
    .kiwi-bell-m {
        display: inline-flex; align-items: center; justify-content: center;
        width: 40px; height: 40px; flex-shrink: 0; padding: 0;
        margin-left: auto;
        border: 0; border-radius: 10px; background: transparent;
        color: #F2F2F7; font-size: 22px; cursor: pointer;
    }
    body.light-mode .kiwi-bell-m { color: #1C1C1E; }
    .kiwi-bell-m.has-unread,
    body.light-mode .kiwi-bell-m.has-unread { color: var(--kw-green-deep); }
    .kiwi-bell-m .kiwi-bell-badge { top: 3px; right: 2px; }
    #mobile-cal-btn + .kiwi-bell-m { margin-left: 0; }
    /* Like the calendar icon: on a phone the bell is in the fixed bar only. */
    .top-header #kiwi-bell-btn { display: none; }
    .mobile-top-bar .mobile-top-spacer { display: none; }
    /* Calendar and bell sit together on the right; the calendar takes the
       auto margin when it is there. */
    .mobile-top-bar .mobile-cal-btn:not([hidden]) { margin-left: auto; }
}

/* ── the history panel ─────────────────────────────────────── */
.kiwi-panel {
    position: fixed; top: 64px; right: 16px;
    z-index: 9999990;                  /* over the header, under the app's dialogs */
    width: 380px; max-width: calc(100vw - 24px);
    max-height: min(560px, calc(100vh - 90px));
    display: flex; flex-direction: column;
    border: 1px solid var(--kw-border);
    border-radius: 14px;
    background: var(--kw-surface);
    color: var(--kw-text);
    box-shadow: var(--kw-shadow);
    font-family: var(--font-ui, sans-serif);
    overflow: hidden;
    animation: kiwi-drop .16s cubic-bezier(.2,.8,.2,1);
}
.kiwi-panel[hidden] { display: none; }
.kiwi-panel.is-phone {
    top: calc(64px + env(safe-area-inset-top)); left: 12px; right: 12px;
    width: auto; max-width: none;
    max-height: calc(100vh - 88px - env(safe-area-inset-top));
}
@keyframes kiwi-drop {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: none; }
}

.kiwi-panel-head {
    display: flex; align-items: center; gap: 8px;
    padding: 11px 10px 10px 14px;
    border-bottom: 1px solid var(--kw-border);
    background: var(--kw-wash);
}
.kiwi-panel-ava { width: 26px; height: 26px; }
.kiwi-panel-title { flex: 1 1 auto; min-width: 0; font-size: 14px; font-weight: 700; }
.kiwi-link {
    flex: 0 0 auto;
    padding: 5px 8px; border: 0; border-radius: 7px; background: none;
    font: inherit; font-size: 12px; font-weight: 600; color: var(--kw-green);
    cursor: pointer; white-space: nowrap;
}
.kiwi-link:hover:not([disabled]) { background: rgba(124, 198, 58, 0.16); }
.kiwi-link[disabled] { color: var(--kw-muted); opacity: .55; cursor: default; }
.kiwi-x {
    flex: 0 0 auto;
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px;
    border: 0; border-radius: 7px; background: none;
    color: var(--kw-muted); font-size: 15px; cursor: pointer;
}
.kiwi-x:hover { background: rgba(127, 127, 127, 0.14); color: var(--kw-text); }

.kiwi-list { overflow-y: auto; overscroll-behavior: contain; }
.kiwi-entry {
    display: flex; align-items: flex-start; gap: 10px;
    width: 100%; box-sizing: border-box;
    padding: 11px 14px;
    border: 0; border-bottom: 1px solid var(--kw-border);
    background: transparent; color: inherit;
    font: inherit; text-align: left;
}
.kiwi-entry:last-child { border-bottom: 0; }
.kiwi-entry.is-unread { background: var(--kw-unread); }
.kiwi-entry.is-link { cursor: pointer; }
.kiwi-entry.is-link:hover { background: var(--kw-hover); }
.kiwi-entry.is-link:focus-visible { outline: 2px solid var(--kw-green-deep); outline-offset: -2px; }
.kiwi-entry-ava { width: 30px; height: 30px; margin-top: 1px; }
.kiwi-entry-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1 1 auto; }
.kiwi-entry-top { display: flex; align-items: center; gap: 6px; }
.kiwi-entry-title { font-size: 13px; font-weight: 700; line-height: 1.3; }
.kiwi-entry-text {
    font-size: 13px; line-height: 1.4; color: var(--kw-text);
    display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
    overflow-wrap: anywhere;
}
.kiwi-entry-meta { font-size: 11.5px; color: var(--kw-muted); }
/* Équipe: has the person read it (in the bell, or "J'ai compris" on a banner) */
.kiwi-read { display: block; margin-top: 2px; font-size: 11px; font-weight: 600; }
.kiwi-read.is-read { color: #3F7A1A; }
.kiwi-read.is-unread { color: #B45309; }
.kiwi-dot { width: 7px; height: 7px; border-radius: 50%; background: #E5484D; }

.kiwi-chip {
    display: inline-block; padding: 1px 8px;
    border-radius: 999px;
    font-size: 10.5px; font-weight: 700; line-height: 1.6; letter-spacing: .01em;
}
.kiwi-chip-notification { background: #E4EDFF; color: #1D4ED8; }
.kiwi-chip-helper       { background: #EAF5DD; color: #3F7A1A; }
.kiwi-chip-banner       { background: #FFF1D6; color: #92400E; }
body:not(.light-mode) .kiwi-chip-notification { background: rgba(96, 140, 255, 0.18); color: #A9C1FF; }
body:not(.light-mode) .kiwi-chip-helper       { background: rgba(143, 209, 79, 0.18); color: #B6E58A; }
body:not(.light-mode) .kiwi-chip-banner       { background: rgba(245, 180, 84, 0.18); color: #F5C98A; }

.kiwi-empty {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    padding: 34px 20px 36px;
    color: var(--kw-muted); font-size: 13px; text-align: center;
}
.kiwi-empty .kiwi-ava { width: 64px; height: 64px; opacity: .9; }

/* ── Me / Team: an admin's two lists (sql/047) ─────────────── */
.kiwi-tabs {
    display: flex; gap: 4px;
    margin: 10px 14px; padding: 3px;
    border: 1px solid var(--kw-border); border-radius: 10px;
    background: var(--kw-surface-2);
}
.kiwi-tab {
    flex: 1 1 0; min-width: 0;
    padding: 6px 10px;
    border: 0; border-radius: 7px; background: none;
    font: inherit; font-size: 12.5px; font-weight: 700; color: var(--kw-muted);
    cursor: pointer; white-space: nowrap;
}
.kiwi-tab:hover:not(.is-on) { color: var(--kw-text); }
.kiwi-tab.is-on { background: var(--kw-surface); color: var(--kw-green); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14); }
.kiwi-tab:focus-visible { outline: 2px solid var(--kw-green-deep); outline-offset: 1px; }
.kiwi-panel[data-tab="me"] .kiwi-tabs + .kiwi-list { border-top: 1px solid var(--kw-border); }
.kiwi-filters {
    display: flex; gap: 8px;
    padding: 0 14px 10px;
    border-bottom: 1px solid var(--kw-border);
}
.kiwi-select {
    flex: 1 1 0; min-width: 0;
    height: 32px; padding: 0 26px 0 10px;
    border: 1px solid var(--kw-border); border-radius: 8px;
    background: var(--kw-surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238A9486' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center;
    color: var(--kw-text);
    font: inherit; font-size: 12.5px; font-weight: 600;
    -webkit-appearance: none; appearance: none;
    text-overflow: ellipsis; cursor: pointer;
}
body:not(.light-mode) .kiwi-select { color-scheme: dark; }
.kiwi-select:focus-visible { outline: 2px solid var(--kw-green-deep); outline-offset: 1px; }
.kiwi-entry-who {
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 12px; font-weight: 700; color: var(--kw-text);
}
.kiwi-note { padding: 28px 20px; color: var(--kw-muted); font-size: 13px; text-align: center; }
.kiwi-more {
    display: block; width: calc(100% - 28px); margin: 10px 14px 14px;
    padding: 8px 12px;
    border: 1px solid var(--kw-border); border-radius: 8px; background: none;
    font: inherit; font-size: 12.5px; font-weight: 700; color: var(--kw-green);
    cursor: pointer;
}
.kiwi-more:hover:not([disabled]) { background: rgba(124, 198, 58, 0.12); }
.kiwi-more[disabled] { color: var(--kw-muted); cursor: default; }

/* ── banners ───────────────────────────────────────────────── */
.kiwi-banner {
    position: fixed; inset: 0;
    z-index: 9999995;
    display: flex; align-items: center; justify-content: center;
    padding: 20px 16px; box-sizing: border-box;
    background: var(--kw-scrim);
    backdrop-filter: blur(10px) saturate(120%);
    -webkit-backdrop-filter: blur(10px) saturate(120%);
    opacity: 0; transition: opacity .25s ease;
    font-family: var(--font-ui, sans-serif);
}
.kiwi-banner.is-in { opacity: 1; }
.kiwi-banner-card {
    position: relative;
    width: 460px; max-width: 100%;
    max-height: calc(100vh - 40px); overflow-y: auto;
    box-sizing: border-box;
    padding: 30px 30px 26px;
    border: 1px solid var(--kw-border);
    border-radius: 22px;
    background-color: var(--kw-surface);
    background-image: radial-gradient(120% 60% at 50% 0%, var(--kw-wash), transparent 70%);
    color: var(--kw-text);
    box-shadow: var(--kw-shadow);
    text-align: center;
    transform: translateY(10px) scale(.98);
    transition: transform .28s cubic-bezier(.2,.8,.2,1);
}
.kiwi-banner.is-in .kiwi-banner-card { transform: none; }
.kiwi-banner-ava { width: 140px; height: 140px; margin: 0 auto 10px; display: block; object-fit: contain; }
.kiwi-banner-title {
    margin: 0 0 12px;
    font-size: 19px; font-weight: 800; line-height: 1.3; letter-spacing: -.01em;
    color: var(--kw-text);
}
.kiwi-banner-text {
    margin: 0 0 22px;
    font-size: 14.5px; line-height: 1.6; color: var(--kw-text);
    text-align: left;
}
.kiwi-banner-ok {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 160px; padding: 11px 22px;
    border: 0; border-radius: 10px;
    background: #4E8A22; color: #fff;
    font: inherit; font-size: 14px; font-weight: 700;
    cursor: pointer;
    transition: background .12s;
}
.kiwi-banner-ok:hover { background: #3F7A1A; }
.kiwi-banner-ok:focus-visible { outline: 3px solid rgba(124, 198, 58, 0.55); outline-offset: 2px; }

@media (max-width: 600px) {
    .kiwi-banner { align-items: flex-end; padding: 12px; }
    .kiwi-banner-card { padding: 24px 20px 20px; border-radius: 20px; }
    .kiwi-banner-ava { width: 110px; height: 110px; }
    .kiwi-banner-title { font-size: 17px; }
    .kiwi-banner-text { font-size: 14px; }
    .kiwi-banner-ok { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .kiwi-panel, .kiwi-banner, .kiwi-banner-card { animation: none; transition: none; }
}

/* The AI tab (Kiwi): his transparent picture in the welcome logo, the thinking
   ring and each answer, in place of the old "S." disc (the rings still turn). */
.sai-core-kiwi { background: none; border-color: transparent; box-shadow: none; overflow: visible; animation: none; }
.sai-msg.assistant .sai-msg-avatar.sai-msg-avatar-kiwi { background: none; border-color: transparent; overflow: visible; padding: 0; }
.sai-kiwi-img { width: 100%; height: 100%; display: block; object-fit: contain; }
