/* SHSAC Knowledge Assistant Widget */

:root {
    --shsac-red:    #b5001e;
    --shsac-red-dk: #8a0016;
    --shsac-bg:     #ffffff;
    --shsac-border: #e0e0e0;
    --shsac-text:   #1a1a1a;
    --shsac-muted:  #666666;
    --shsac-user:   #f5e6e9;
    --shsac-radius: 12px;
    --shsac-shadow: 0 4px 24px rgba(0,0,0,0.15);
    --shsac-z:      9999;
}

#shsac-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: var(--shsac-z);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

/* ── Toggle button ─────────────────────────────────────────────────────────── */

#shsac-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--shsac-red);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shsac-shadow);
    transition: background 0.2s, transform 0.2s;
    color: #fff;
}

#shsac-toggle:hover { background: var(--shsac-red-dk); transform: scale(1.05); }
#shsac-toggle:focus-visible { outline: 3px solid var(--shsac-red); outline-offset: 3px; }
#shsac-toggle svg { width: 26px; height: 26px; }

/* ── Panel ─────────────────────────────────────────────────────────────────── */

#shsac-panel[hidden] { display: none; }

#shsac-panel {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 340px;
    max-height: 520px;
    background: var(--shsac-bg);
    border-radius: var(--shsac-radius);
    box-shadow: var(--shsac-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--shsac-border);
}

/* ── Header ────────────────────────────────────────────────────────────────── */

#shsac-header {
    background: var(--shsac-red);
    color: #fff;
    padding: 14px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
}

#shsac-header span { font-weight: 600; font-size: 15px; }
#shsac-header small { font-size: 12px; opacity: 0.85; }

/* ── Trial banner ──────────────────────────────────────────────────────────── */

#shsac-banner {
    background: #fff8e1;
    border-bottom: 1px solid #ffe082;
    color: #5d4037;
    font-size: 12px;
    padding: 7px 12px;
    line-height: 1.4;
    flex-shrink: 0;
}

#shsac-banner a { color: #5d4037; text-decoration: underline; }

/* ── Messages ──────────────────────────────────────────────────────────────── */

#shsac-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 12px 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
}

.shsac-msg-wrap {
    display: flex;
    flex-direction: column;
}

.shsac-msg-wrap--bot  { align-items: flex-start; }
.shsac-msg-wrap--user { align-items: flex-end; }

.shsac-msg {
    max-width: 88%;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 14px;
    color: var(--shsac-text);
    word-break: break-word;
}

.shsac-msg--bot {
    background: #f4f4f4;
    border-bottom-left-radius: 3px;
}

.shsac-msg--user {
    background: var(--shsac-user);
    border-bottom-right-radius: 3px;
    text-align: right;
}

/* ── Feedback button ───────────────────────────────────────────────────────── */

.shsac-feedback-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    padding: 2px 4px;
    margin-top: 2px;
    opacity: 0.45;
    line-height: 1;
    transition: opacity 0.15s;
}

.shsac-feedback-btn:hover { opacity: 1; }
.shsac-feedback-btn:disabled { opacity: 0.7; cursor: default; }

/* ── Typing indicator ──────────────────────────────────────────────────────── */

.shsac-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 12px;
}

.shsac-typing span {
    width: 7px;
    height: 7px;
    background: var(--shsac-muted);
    border-radius: 50%;
    animation: shsac-bounce 1.2s infinite ease-in-out;
}

.shsac-typing span:nth-child(2) { animation-delay: 0.2s; }
.shsac-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes shsac-bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40%           { transform: scale(1.0); opacity: 1;   }
}

/* ── Suggestions ───────────────────────────────────────────────────────────── */

#shsac-suggestions {
    padding: 6px 12px 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
}

#shsac-suggestions[hidden] { display: none; }

.shsac-suggestion {
    background: #fff;
    border: 1px solid var(--shsac-red);
    color: var(--shsac-red);
    border-radius: 16px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.shsac-suggestion:hover {
    background: var(--shsac-red);
    color: #fff;
}

/* ── Input row ─────────────────────────────────────────────────────────────── */

#shsac-input-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 8px 10px 10px;
    border-top: 1px solid var(--shsac-border);
    flex-shrink: 0;
}

#shsac-input-wrap {
    flex: 1;
    position: relative;
}

#shsac-input {
    width: 100%;
    border: 1px solid var(--shsac-border);
    border-radius: 8px;
    padding: 8px 32px 8px 10px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    line-height: 1.4;
    box-sizing: border-box;
    color: var(--shsac-text);
    transition: border-color 0.15s;
}

#shsac-input:focus {
    outline: none;
    border-color: var(--shsac-red);
}

#shsac-input:disabled { opacity: 0.6; }

#shsac-counter {
    position: absolute;
    bottom: 6px;
    right: 8px;
    font-size: 10px;
    color: var(--shsac-muted);
    pointer-events: none;
}

#shsac-send {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--shsac-red);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    transition: background 0.15s;
}

#shsac-send:hover:not(:disabled) { background: var(--shsac-red-dk); }
#shsac-send:disabled { opacity: 0.5; cursor: not-allowed; }
#shsac-send svg { width: 16px; height: 16px; }

/* ── Mobile ────────────────────────────────────────────────────────────────── */

@media (max-width: 420px) {
    #shsac-widget { bottom: 16px; right: 16px; }

    #shsac-panel {
        position: fixed;
        bottom: 80px;
        right: 12px;
        left: 12px;
        width: auto;
        max-height: calc(100vh - 120px);
    }
}
