/* ---------------------------------------------------------------- */
/* Seanos AI floating support chat widget.                          */
/* Lives in /views/chat/widget.php; controller is /chat/send.       */
/* ---------------------------------------------------------------- */

.sai-chat {
    --sai-bg: #ffffff;
    --sai-fg: #0f172a;
    --sai-muted: #64748b;
    --sai-border: #e2e8f0;
    --sai-soft: #f1f5f9;
    --sai-accent: #4f46e5;
    --sai-accent-soft: #eef2ff;
    --sai-success: #15803d;
    --sai-success-soft: #dcfce7;
    --sai-pro-soft: #fef3c7;
    --sai-pro-fg: #92400e;
    --sai-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);

    bottom: 24px;
    color: var(--sai-fg);
    font: 400 0.95rem/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    position: fixed;
    right: 24px;
    z-index: 9999;
}

/* ---- Bubble ---------------------------------------------------- */

.sai-chat__bubble {
    align-items: center;
    background: var(--sai-accent);
    border: none;
    border-radius: 999px;
    box-shadow: var(--sai-shadow);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 600;
    gap: 10px;
    padding: 14px 20px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.sai-chat__bubble:hover {
    box-shadow: 0 22px 56px rgba(15, 23, 42, 0.24);
    transform: translateY(-1px);
}
.sai-chat__bubble:focus-visible {
    outline: 3px solid #c7d2fe;
    outline-offset: 2px;
}
.sai-chat__bubble-icon {
    flex: 0 0 auto;
    height: 22px;
    width: 22px;
}
.sai-chat__bubble-label { white-space: nowrap; }

.sai-chat.is-open .sai-chat__bubble { display: none; }

/* ---- Panel ---------------------------------------------------- */

.sai-chat__panel {
    background: var(--sai-bg);
    border: 1px solid var(--sai-border);
    border-radius: 16px;
    bottom: 0;
    box-shadow: var(--sai-shadow);
    display: none;
    flex-direction: column;
    height: min(620px, calc(100vh - 48px));
    overflow: hidden;
    position: absolute;
    right: 0;
    width: min(380px, calc(100vw - 48px));
}
.sai-chat.is-open .sai-chat__panel { display: flex; }

.sai-chat__header {
    align-items: flex-start;
    background: linear-gradient(135deg, var(--sai-accent) 0%, #6366f1 100%);
    color: #fff;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 16px 18px 14px;
}
.sai-chat__title {
    color: #fff;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.005em;
    line-height: 1.25;
    margin: 0 0 4px;
}
.sai-chat__subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.45;
    margin: 0;
}
.sai-chat__close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    font-size: 1.2rem;
    height: 28px;
    line-height: 1;
    width: 28px;
}
.sai-chat__close:hover { background: rgba(255, 255, 255, 0.28); }

.sai-chat__capabilities {
    background: var(--sai-accent-soft);
    border-bottom: 1px solid var(--sai-border);
    color: #4338ca;
    display: flex;
    flex-wrap: wrap;
    font-size: 0.72rem;
    font-weight: 600;
    gap: 6px 14px;
    letter-spacing: 0.02em;
    padding: 10px 18px;
    text-transform: uppercase;
}
.sai-chat__cap { align-items: center; display: inline-flex; gap: 5px; }
.sai-chat__cap-dot {
    background: #4f46e5;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
    display: inline-block;
    height: 6px;
    width: 6px;
}

/* ---- Messages ------------------------------------------------- */

.sai-chat__messages {
    background: var(--sai-soft);
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding: 16px;
}

.sai-chat__msg {
    border-radius: 12px;
    line-height: 1.45;
    max-width: 92%;
    padding: 10px 12px;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.sai-chat__msg--user {
    align-self: flex-end;
    background: var(--sai-accent);
    border-bottom-right-radius: 4px;
    color: #fff;
}
.sai-chat__msg--assistant {
    align-self: flex-start;
    background: var(--sai-bg);
    border: 1px solid var(--sai-border);
    border-bottom-left-radius: 4px;
}
.sai-chat__msg--error {
    align-self: stretch;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    font-size: 0.88rem;
    max-width: 100%;
}

.sai-chat__msg--system {
    align-self: center;
    background: transparent;
    color: var(--sai-muted);
    font-size: 0.82rem;
    max-width: 100%;
    text-align: center;
}

/* The "we recorded this" cards — the marquee feature of the      */
/* widget. These are intentionally bigger, framed, and obviously   */
/* distinct from regular chat bubbles so visitors see the agent is */
/* doing more than chatting.                                       */
.sai-chat__recorded {
    align-self: stretch;
    background: var(--sai-bg);
    border: 1px solid var(--sai-success);
    border-left-width: 4px;
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(21, 128, 61, 0.08);
    display: flex;
    gap: 12px;
    max-width: 100%;
    padding: 12px 14px;
}
.sai-chat__recorded--feature  { border-color: #2563eb; box-shadow: 0 4px 14px rgba(37, 99, 235, 0.1); }
.sai-chat__recorded--complaint { border-color: #b91c1c; box-shadow: 0 4px 14px rgba(185, 28, 28, 0.1); }
.sai-chat__recorded--feedback { border-color: #d97706; box-shadow: 0 4px 14px rgba(217, 119, 6, 0.1); }

.sai-chat__recorded-icon {
    align-items: center;
    background: var(--sai-success-soft);
    border-radius: 50%;
    color: var(--sai-success);
    display: flex;
    flex: 0 0 auto;
    height: 32px;
    justify-content: center;
    width: 32px;
}
.sai-chat__recorded--feature  .sai-chat__recorded-icon { background: #dbeafe; color: #1d4ed8; }
.sai-chat__recorded--complaint .sai-chat__recorded-icon { background: #fee2e2; color: #b91c1c; }
.sai-chat__recorded--feedback .sai-chat__recorded-icon { background: #fef3c7; color: #b45309; }
.sai-chat__recorded-icon svg { height: 18px; width: 18px; }

.sai-chat__recorded-body { flex: 1 1 auto; min-width: 0; }
.sai-chat__recorded-kind {
    color: var(--sai-success);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.sai-chat__recorded--feature  .sai-chat__recorded-kind { color: #1d4ed8; }
.sai-chat__recorded--complaint .sai-chat__recorded-kind { color: #b91c1c; }
.sai-chat__recorded--feedback .sai-chat__recorded-kind { color: #b45309; }
.sai-chat__recorded-title { font-weight: 600; margin: 2px 0 0; }
.sai-chat__recorded-meta {
    color: var(--sai-muted);
    font-size: 0.78rem;
    margin: 4px 0 0;
}

.sai-chat__typing {
    align-self: flex-start;
    color: var(--sai-muted);
    font-size: 0.85rem;
    font-style: italic;
}
.sai-chat__typing::after {
    animation: sai-chat-dots 1.4s steps(4, end) infinite;
    content: '';
}
@keyframes sai-chat-dots {
    0%, 20% { content: ''; }
    40%     { content: '.'; }
    60%     { content: '..'; }
    80%, 100% { content: '...'; }
}

/* ---- Form ----------------------------------------------------- */

.sai-chat__form {
    align-items: flex-end;
    border-top: 1px solid var(--sai-border);
    display: flex;
    gap: 8px;
    padding: 10px 12px;
}
.sai-chat__hp {
    height: 0;
    left: -9999px;
    overflow: hidden;
    position: absolute;
    width: 0;
}
.sai-chat__input {
    background: var(--sai-bg);
    border: 1px solid var(--sai-border);
    border-radius: 10px;
    color: var(--sai-fg);
    flex: 1 1 auto;
    font: inherit;
    padding: 8px 10px;
    resize: none;
}
.sai-chat__input:focus {
    border-color: var(--sai-accent);
    outline: 2px solid var(--sai-accent-soft);
    outline-offset: 0;
}
.sai-chat__send {
    background: var(--sai-accent);
    border: none;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    padding: 9px 14px;
}
.sai-chat__send:disabled { background: #c7d2fe; cursor: not-allowed; }
.sai-chat__send:hover:not(:disabled) { background: #4338ca; }

.sai-chat__footer {
    background: var(--sai-bg);
    border-top: 1px solid var(--sai-border);
    color: var(--sai-muted);
    font-size: 0.72rem;
    padding: 8px 14px 10px;
    text-align: center;
}

/* ---- Mobile --------------------------------------------------- */

@media (max-width: 480px) {
    .sai-chat { bottom: 12px; right: 12px; }
    .sai-chat__bubble-label { display: none; }
    .sai-chat__bubble { padding: 14px; }
    .sai-chat__panel {
        bottom: 12px;
        height: calc(100vh - 24px);
        right: 12px;
        width: calc(100vw - 24px);
    }
}
