/* FILE: assets/chatbot.css
 * SMC India Membership Assistant - widget styles. Everything is scoped under #smc-chatbot
 * so it will not clash with the host website's styles.
 */
#smc-chatbot {
    --smc-primary: #0b3160;       /* deep scientific navy */
    --smc-primary-2: #144a8a;
    --smc-accent: #c8841a;        /* muted saffron/amber */
    --smc-bg: #f4f6fa;
    --smc-bot-bubble: #ffffff;
    --smc-user-bubble: #0b3160;
    --smc-text: #1d2733;
    --smc-muted: #6b7686;
    --smc-border: #dfe4ec;
    --smc-ok: #1f7a4d;
    --smc-warn: #9a6400;
    --smc-err: #b42318;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    color: var(--smc-text);
}

/* ---------- Launcher ---------- */
#smc-chatbot .smc-launcher {
    position: fixed; right: 22px; bottom: 22px; z-index: 2147483000;
    display: flex; align-items: center; gap: .55rem;
    border: 0; border-radius: 999px; padding: .7rem 1.1rem .7rem .8rem;
    background: var(--smc-primary); color: #fff; font-weight: 600; font-size: 15px;
    box-shadow: 0 10px 28px rgba(11, 49, 96, .35);
    cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, background .15s;
}
#smc-chatbot .smc-launcher:hover { transform: translateY(-2px); background: var(--smc-primary-2); }
#smc-chatbot .smc-launcher:focus-visible { outline: 3px solid var(--smc-accent); outline-offset: 3px; }
#smc-chatbot .smc-launcher .smc-launcher-icon {
    width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.14);
    display: grid; place-items: center; font-size: 18px;
}
#smc-chatbot.smc-open .smc-launcher { display: none; }

/* ---------- Panel ---------- */
#smc-chatbot .smc-panel {
    position: fixed; right: 22px; bottom: 22px; z-index: 2147483001;
    width: 390px; height: min(640px, calc(100vh - 44px));
    display: none; flex-direction: column;
    background: var(--smc-bg); border-radius: 16px; overflow: hidden;
    box-shadow: 0 24px 60px rgba(9, 30, 66, .28); border: 1px solid rgba(11,49,96,.08);
}
#smc-chatbot.smc-open .smc-panel { display: flex; animation: smcPop .18s ease-out; }
@keyframes smcPop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

/* Header */
#smc-chatbot .smc-header {
    display: flex; align-items: center; gap: .7rem; padding: .8rem .9rem;
    background: linear-gradient(135deg, var(--smc-primary), var(--smc-primary-2)); color: #fff;
    border-bottom: 3px solid var(--smc-accent); flex: 0 0 auto;
}
#smc-chatbot .smc-logo {
    width: 42px; height: 42px; border-radius: 50%; background: #fff; padding: 3px; object-fit: contain; flex: 0 0 auto;
}
#smc-chatbot .smc-title { font-weight: 700; font-size: 15.5px; margin: 0; line-height: 1.2; }
#smc-chatbot .smc-status { font-size: 12.5px; opacity: .9; display: flex; align-items: center; gap: .35rem; }
#smc-chatbot .smc-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 3px rgba(61,220,132,.25); }
#smc-chatbot .smc-header-actions { margin-left: auto; display: flex; gap: .25rem; }
#smc-chatbot .smc-icon-btn {
    border: 0; background: transparent; color: #fff; width: 34px; height: 34px; border-radius: 8px;
    display: grid; place-items: center; font-size: 17px; cursor: pointer;
}
#smc-chatbot .smc-icon-btn:hover { background: rgba(255,255,255,.14); }
#smc-chatbot .smc-icon-btn:focus-visible { outline: 2px solid #fff; }

/* Messages */
#smc-chatbot .smc-messages {
    flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 1rem .85rem 1.25rem; position: relative;
    overscroll-behavior: contain;
}
#smc-chatbot .smc-row { display: flex; margin-bottom: .7rem; gap: .5rem; align-items: flex-end; }
#smc-chatbot .smc-row.smc-user { justify-content: flex-end; }
#smc-chatbot .smc-avatar {
    width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 1px solid var(--smc-border);
    flex: 0 0 auto; object-fit: contain; padding: 2px;
}
#smc-chatbot .smc-bubble {
    max-width: 82%; padding: .6rem .8rem; border-radius: 14px; word-wrap: break-word; overflow-wrap: anywhere;
}
#smc-chatbot .smc-bot .smc-bubble {
    background: var(--smc-bot-bubble); border: 1px solid var(--smc-border); border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
#smc-chatbot .smc-user .smc-bubble {
    background: var(--smc-user-bubble); color: #fff; border-bottom-right-radius: 4px;
}
#smc-chatbot .smc-bubble a { color: var(--smc-primary-2); text-decoration: underline; word-break: break-all; }
#smc-chatbot .smc-bubble ul { margin: .3rem 0 0; padding-left: 1.1rem; }
#smc-chatbot .smc-bubble strong { font-weight: 700; }
#smc-chatbot .smc-time { font-size: 11px; color: var(--smc-muted); margin-top: .2rem; }
#smc-chatbot .smc-user .smc-time { text-align: right; }

/* Result badges */
#smc-chatbot .smc-badge {
    display: inline-flex; align-items: center; gap: .3rem; font-size: 11.5px; font-weight: 600;
    padding: .12rem .5rem; border-radius: 999px; margin-bottom: .35rem;
}
#smc-chatbot .smc-badge-verified { background: #e3f4ea; color: var(--smc-ok); }
#smc-chatbot .smc-badge-multiple, #smc-chatbot .smc-badge-too_many, #smc-chatbot .smc-badge-partial { background: #fdf1dc; color: var(--smc-warn); }
#smc-chatbot .smc-badge-not_found, #smc-chatbot .smc-badge-mismatch, #smc-chatbot .smc-badge-conflict { background: #eef1f6; color: #3d4a5c; }
#smc-chatbot .smc-badge-error { background: #fde8e7; color: var(--smc-err); }

/* Typing indicator */
#smc-chatbot .smc-typing { display: inline-flex; gap: 4px; padding: .75rem .9rem; }
#smc-chatbot .smc-typing span {
    width: 7px; height: 7px; border-radius: 50%; background: #9aa6b8; animation: smcBlink 1.2s infinite ease-in-out;
}
#smc-chatbot .smc-typing span:nth-child(2) { animation-delay: .15s; }
#smc-chatbot .smc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes smcBlink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* Quick actions */
#smc-chatbot .smc-quick {
    display: flex; flex-wrap: wrap; justify-content: center; gap: .35rem; padding: .45rem .6rem .5rem;
    border-top: 1px solid var(--smc-border); background: #fff; flex: 0 0 auto;
}
#smc-chatbot .smc-quick::-webkit-scrollbar { display: none; }
#smc-chatbot .smc-chip {
    flex: 0 0 auto; line-height: 1.3; border: 1px solid #c9d3e3; background: #fff; color: var(--smc-primary);
    border-radius: 999px; padding: .28rem .6rem; font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
#smc-chatbot .smc-chip .bi { display: none; }
@media (min-width: 577px) { #smc-chatbot .smc-chip .bi { display: inline; } }
#smc-chatbot .smc-chip:hover { background: #eef3fa; border-color: var(--smc-primary-2); }
#smc-chatbot .smc-chip:focus-visible { outline: 2px solid var(--smc-accent); }
#smc-chatbot .smc-chip:disabled { opacity: .5; cursor: default; }

/* Composer */
#smc-chatbot .smc-composer {
    display: flex; align-items: flex-end; gap: .5rem; padding: .6rem .7rem; background: #fff;
    border-top: 1px solid var(--smc-border); flex: 0 0 auto;
}
#smc-chatbot .smc-input {
    flex: 1 1 auto; resize: none; border: 1px solid #cfd6e1; border-radius: 12px; padding: .55rem .75rem;
    font: inherit; max-height: 110px; min-height: 42px; outline: none; background: #fbfcfe;
}
#smc-chatbot .smc-input:focus { border-color: var(--smc-primary-2); box-shadow: 0 0 0 3px rgba(20,74,138,.15); background: #fff; }
#smc-chatbot .smc-send {
    flex: 0 0 auto; width: 42px; height: 42px; border-radius: 12px; border: 0; background: var(--smc-accent); color: #fff;
    display: grid; place-items: center; font-size: 18px; cursor: pointer; transition: background .15s;
}
#smc-chatbot .smc-send:hover { background: #ad7012; }
#smc-chatbot .smc-send:disabled { background: #c9cfd8; cursor: default; }
#smc-chatbot .smc-send .spinner-border { width: 1.1rem; height: 1.1rem; border-width: .16em; }
#smc-chatbot .smc-footnote { font-size: 11px; color: var(--smc-muted); text-align: center; padding: 0 .8rem .5rem; background: #fff; flex: 0 0 auto; }

/* ---------- Mobile: near full-screen ---------- */
@media (max-width: 576px) {
    #smc-chatbot .smc-launcher { right: 14px; bottom: 14px; padding: .65rem; }
    #smc-chatbot .smc-launcher .smc-launcher-text { display: none; }
    #smc-chatbot .smc-panel {
        right: 0; bottom: 0; left: 0; top: 0; width: 100%; height: 100%; height: 100dvh; border-radius: 0;
    }
    #smc-chatbot .smc-bubble { max-width: 88%; }
    #smc-chatbot .smc-input { font-size: 16px; } /* prevents iOS zoom on focus */
}

@media (prefers-reduced-motion: reduce) {
    #smc-chatbot * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print { #smc-chatbot { display: none !important; } }

/* ---------- Self-contained fallbacks (work even if the host page has no Bootstrap 5) ---------- */
#smc-chatbot .visually-hidden {
    position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important;
    overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important;
}
#smc-chatbot .me-1 { margin-right: .25rem; }
#smc-chatbot .spinner-border {
    display: inline-block; border-radius: 50%; border: .16em solid currentColor; border-right-color: transparent;
    animation: smcSpin .75s linear infinite;
}
@keyframes smcSpin { to { transform: rotate(360deg); } }
#smc-chatbot *, #smc-chatbot *::before, #smc-chatbot *::after { box-sizing: border-box; }
