/* ============================================================
   SUPPORT CARE AI — Premium Glassmorphic CSS
   v4.0.0 — Final Polish (5 Refinements)
   ============================================================ */

/* ---- CSS VARIABLES ---- */
:root {
    --sca-theme: #4285F4;
    --sca-chat-bg: #131314;
    --sca-radius: 24px;
    --sca-surface: #1e1f20;
    --sca-surface-hover: #2a2b2d;
    --sca-text: #e3e3e3;
    --sca-text-dim: #9aa0a6;
    --sca-border: rgba(255,255,255,0.08);
    --sca-glass: rgba(255,255,255,0.05);
    --sca-glass-strong: rgba(255,255,255,0.1);
    --sca-shadow: 0 8px 32px rgba(0,0,0,0.4);
    --sca-font: 'Segoe UI', system-ui, -apple-system, sans-serif;
    /* Premium dark gradient palette */
    --sca-grad-1: #08090d;
    --sca-grad-2: #0a1225;
    --sca-grad-3: #0d1630;
    --sca-grad-4: #0a0f1c;
    --sca-grad-5: #07080c;
}

/* ============================================================
   ADMIN STYLES
   ============================================================ */
.sca-admin-wrap { max-width: 860px; }
.sca-admin-header {
    background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
    color: #fff; padding: 30px 36px; border-radius: 16px;
    margin-bottom: 24px; box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.sca-admin-header h1 { margin: 0 0 6px; font-size: 28px; color: #fff; }
.sca-admin-header p { margin: 0; opacity: 0.8; font-size: 15px; color: #cbd5e1; }
.sca-tabs {
    display: flex; gap: 6px; margin-bottom: 0;
    background: #f0f0f1; padding: 6px; border-radius: 12px; flex-wrap: wrap;
}
.sca-tab-btn {
    background: transparent; border: none; padding: 12px 20px;
    font-size: 14px; font-weight: 600; cursor: pointer;
    border-radius: 8px; transition: all 0.2s; color: #50575e;
}
.sca-tab-btn:hover { background: #fff; color: #1d2327; }
.sca-tab-btn.active {
    background: #fff; color: #2271b1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.sca-tab-panel {
    display: none; background: #fff; padding: 24px 30px;
    border: 1px solid #ddd; border-radius: 0 0 12px 12px; margin-top: -1px;
}
.sca-tab-panel.active { display: block; }
.sca-tab-panel h2 {
    font-size: 20px; margin-top: 0; padding-bottom: 12px;
    border-bottom: 2px solid #f0f0f1;
}
.sca-admin-form .form-table th {
    padding-top: 20px; padding-bottom: 20px; width: 220px;
    vertical-align: top; font-weight: 600;
}
.sca-admin-form .form-table td { padding-top: 16px; padding-bottom: 16px; }
.sca-admin-form .form-table input[type="text"],
.sca-admin-form .form-table input[type="email"],
.sca-admin-form .form-table input[type="password"],
.sca-admin-form .form-table textarea,
.sca-admin-form .form-table select { border-radius: 8px; }
.sca-admin-form .button-hero {
    background: linear-gradient(135deg, #2271b1, #135e96) !important;
    border: none !important; border-radius: 12px !important;
    font-size: 16px !important; padding: 12px 40px !important;
    text-shadow: none !important;
    box-shadow: 0 4px 15px rgba(34,113,177,0.3) !important;
    transition: transform 0.2s, box-shadow 0.2s !important;
}
.sca-admin-form .button-hero:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(34,113,177,0.4) !important;
}

/* ============================================================
   FRONTEND — LAUNCHER
   ============================================================ */
.sca-launcher {
    position: fixed; bottom: 24px; right: 24px;
    width: 60px; height: 60px; border-radius: 50%;
    background: var(--sca-theme);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 24px rgba(66,133,244,0.4), 0 0 0 0 rgba(66,133,244,0.3);
    z-index: 999998;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: sca-launcher-pulse 2s infinite;
    -webkit-tap-highlight-color: transparent;
    user-select: none; -webkit-user-select: none;
}
.sca-launcher:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(66,133,244,0.55);
}
.sca-launcher.sca-hidden {
    opacity: 0; transform: scale(0.5); pointer-events: none;
}
.sca-launcher-img { width: 32px; height: 32px; object-fit: contain; pointer-events: none; }
.sca-launcher-svg { width: 28px; height: 28px; color: #fff; pointer-events: none; }

@keyframes sca-launcher-pulse {
    0%   { box-shadow: 0 4px 24px rgba(66,133,244,0.4), 0 0 0 0 rgba(66,133,244,0.35); }
    70%  { box-shadow: 0 4px 24px rgba(66,133,244,0.4), 0 0 0 16px rgba(66,133,244,0); }
    100% { box-shadow: 0 4px 24px rgba(66,133,244,0.4), 0 0 0 0 rgba(66,133,244,0); }
}

/* ============================================================
   FRONTEND — CHAT WINDOW (Desktop: floating widget)
   ============================================================ */
.sca-chat-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 600px;
    max-height: 80vh;
    background: linear-gradient(
        170deg,
        var(--sca-grad-1) 0%,
        var(--sca-grad-2) 20%,
        var(--sca-grad-3) 45%,
        var(--sca-grad-4) 70%,
        var(--sca-grad-5) 100%
    );
    border: 1px solid rgba(255,255,255,0.06);
    box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 0 80px rgba(66,133,244,0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
    font-family: var(--sca-font);
    transform-origin: bottom right;
    border-radius: var(--sca-radius);

    /* Hidden state */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: scale(0.5) translateY(20px);
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.sca-chat-window.sca-active {
    opacity: 1; visibility: visible; pointer-events: all;
    transform: scale(1) translateY(0);
}

/* Animation variants */
.sca-anim-zoom { transform: scale(0.5); }
.sca-anim-zoom.sca-active { transform: scale(1); }
.sca-anim-slide { transform: translateY(40px); }
.sca-anim-slide.sca-active { transform: translateY(0); }
.sca-anim-fade { transform: none; }
.sca-anim-fade.sca-active { transform: none; }

/* ============================================================
   HEADER — Transparent over unified gradient
   ============================================================ */
.sca-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    flex-shrink: 0;
    border-radius: var(--sca-radius) var(--sca-radius) 0 0;
}
.sca-header-left { display: flex; align-items: center; gap: 12px; }
.sca-header-logo {
    width: 38px; height: 38px; border-radius: 50%;
    object-fit: cover; border: 2px solid var(--sca-border);
}
.sca-header-logo-default {
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(255,255,255,0.06);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
}
.sca-header-info { display: flex; flex-direction: column; }
.sca-header-title {
    color: var(--sca-text); font-size: 15px; font-weight: 600; line-height: 1.2;
}
.sca-header-status {
    color: #34a853; font-size: 11px; font-weight: 500; letter-spacing: 0.3px;
}

/* ============================================================
   GLASS ARROW BUTTON — Circular + Click Shrink
   ============================================================ */
.sca-minimize-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    cursor: pointer;
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease, transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.sca-minimize-btn:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.18);
}
.sca-minimize-btn:active {
    transform: scale(0.8);
    background: rgba(255,255,255,0.14);
}
.sca-minimize-btn svg {
    width: 20px; height: 20px; color: var(--sca-text-dim); pointer-events: none;
}
.sca-minimize-btn img {
    width: 20px; height: 20px; object-fit: contain;
    filter: brightness(0.7); pointer-events: none;
}

/* ============================================================
   CHAT BODY — Transparent background
   ============================================================ */
.sca-chat-body {
    flex: 1;
    overflow-y: auto; overflow-x: hidden;
    padding: 20px 16px;
    display: flex; flex-direction: column; gap: 16px;
    scroll-behavior: smooth;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    background: transparent;
    transition: padding-bottom 0.2s ease;
}
.sca-chat-body::-webkit-scrollbar { width: 4px; }
.sca-chat-body::-webkit-scrollbar-track { background: transparent; }
.sca-chat-body::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1); border-radius: 10px;
}

/* ============================================================
   WELCOME SECTION — Vanishing Act Container
   ============================================================ */
.sca-welcome-section {
    /* Wrapper for welcome + chips — vanishes together */
}
.sca-welcome-section.sca-vanish-up {
    animation: sca-welcome-vanish 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes sca-welcome-vanish {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
        max-height: 600px;
    }
    100% {
        opacity: 0;
        transform: translateY(-30px) scale(0.96);
        max-height: 0;
        padding: 0;
        margin: 0;
        overflow: hidden;
    }
}

/* ============================================================
   WELCOME — Glass Pill Badge + Gradient Headline (Compact)
   ============================================================ */
.sca-welcome {
    text-align: center;
    padding: 10px 4px 6px;
}
/* Hide any old icon completely */
.sca-welcome-icon { display: none !important; }

/* [REFINED] Glass Pill Badge — premium translucent */
.sca-brand-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
    margin-bottom: 10px;
    display: inline-block;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 6px 16px;
    border-radius: 20px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* [REFINED] Gradient headline — compact line-height 1.1 */
.sca-welcome-headline {
    font-size: 30px;
    font-weight: 900;
    line-height: 1.1;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #4285F4 0%, #F5A623 35%, #EA4335 60%, #E040FB 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

/* Subtitle below headline */
.sca-welcome-sub {
    color: var(--sca-text-dim);
    font-size: 13.5px;
    line-height: 1.5;
    opacity: 0.85;
    max-width: 300px;
    margin: 0 auto;
}
/* Keep old class hidden just in case */
.sca-welcome-text { display: none; }

/* ============================================================
   QUICK CHIPS — 2x2 Grid + Simple Colored Bullets
   ============================================================ */
.sca-chips {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px 0 10px;
}
.sca-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--sca-text);
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 12.5px;
    cursor: pointer;
    transition: all 0.25s;
    font-family: var(--sca-font);
    text-align: left;
    white-space: normal;
    line-height: 1.4;
    -webkit-tap-highlight-color: transparent;
}
.sca-chip:hover {
    background: rgba(66,133,244,0.12);
    border-color: rgba(66,133,244,0.3);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(66,133,244,0.15);
}

/* Simple colored bullet dot */
.sca-chip-dot {
    font-size: 22px;
    font-weight: 900;
    line-height: 1;
    flex-shrink: 0;
    color: #4285F4;
}
/* Alternating bullet colors */
.sca-chip:nth-child(2) .sca-chip-dot { color: #EA4335; }
.sca-chip:nth-child(3) .sca-chip-dot { color: #34A853; }
.sca-chip:nth-child(4) .sca-chip-dot { color: #F5A623; }

/* Legacy chip vanish */
.sca-chips.sca-vanish {
    animation: sca-chips-vanish 0.35s ease-in forwards;
}
@keyframes sca-chips-vanish {
    to {
        opacity: 0; transform: scale(0.95) translateY(-6px);
        max-height: 0; padding: 0; margin: 0; overflow: hidden;
    }
}

/* ============================================================
   MESSAGE BUBBLES — Premium Glass Styling
   ============================================================ */
.sca-msg {
    max-width: 85%;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.65;
    color: var(--sca-text);
    animation: sca-msg-in 0.3s ease-out;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
@keyframes sca-msg-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* USER bubble */
.sca-msg-user {
    align-self: flex-end;
    background: rgba(66, 133, 244, 0.12);
    border: 1px solid rgba(66, 133, 244, 0.25);
    color: #d4e2f9;
    border-radius: 18px 18px 4px 18px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* AI bubble */
.sca-msg-ai {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 4px 18px 18px 18px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.sca-msg-ai p { margin: 0 0 8px; }
.sca-msg-ai p:last-child { margin-bottom: 0; }
.sca-msg-ai strong { color: #fff; }
.sca-msg-ai code {
    background: rgba(255,255,255,0.08);
    padding: 2px 6px; border-radius: 4px; font-size: 13px;
}
.sca-msg-ai a {
    color: var(--sca-theme); text-decoration: underline;
}

/* Error message */
.sca-msg-error {
    align-self: flex-start;
    background: rgba(234,67,53,0.08);
    border: 1px solid rgba(234,67,53,0.2);
    color: #f28b82;
    border-radius: 4px 18px 18px 18px;
    font-size: 13px;
}

/* ============================================================
   CONTACT BUTTONS
   ============================================================ */
.sca-contact-grid {
    display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px;
}
.sca-contact-btn {
    flex: 1; min-width: 90px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 14px; border-radius: 14px;
    font-size: 13px; font-weight: 600; font-family: var(--sca-font);
    cursor: pointer; text-decoration: none;
    transition: all 0.3s;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.04);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.sca-contact-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.sca-contact-btn.sca-btn-call {
    color: #34a853; border-color: rgba(52,168,83,0.25);
}
.sca-contact-btn.sca-btn-call:hover { background: rgba(52,168,83,0.12); }
.sca-contact-btn.sca-btn-email {
    color: #ea4335; border-color: rgba(234,67,53,0.25);
}
.sca-contact-btn.sca-btn-email:hover { background: rgba(234,67,53,0.12); }
.sca-contact-btn.sca-btn-wa {
    color: #25d366; border-color: rgba(37,211,102,0.25);
}
.sca-contact-btn.sca-btn-wa:hover { background: rgba(37,211,102,0.12); }
.sca-contact-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ============================================================
   INPUT BAR
   ============================================================ */
.sca-input-bar {
    padding: 12px 14px 10px;
    background: transparent;
    flex-shrink: 0;
    transition: bottom 0.15s ease-out;
}
.sca-input-container {
    display: flex; align-items: center; gap: 4px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    padding: 4px 6px 4px 16px;
    border-radius: 22px;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.sca-input-container:focus-within {
    border-color: rgba(66,133,244,0.4);
    box-shadow: 0 0 0 2px rgba(66,133,244,0.1);
}
.sca-input {
    flex: 1; background: transparent; border: none; outline: none;
    color: var(--sca-text); font-size: 14px; font-family: var(--sca-font);
    padding: 10px 0; min-width: 0;
}
.sca-input::placeholder { color: var(--sca-text-dim); opacity: 0.6; }

.sca-icon-btn {
    width: 38px; height: 38px; border-radius: 50%; border: none;
    background: transparent; display: flex; align-items: center;
    justify-content: center; cursor: pointer;
    transition: all 0.25s; flex-shrink: 0; padding: 0;
    -webkit-tap-highlight-color: transparent;
}
.sca-icon-btn svg { width: 20px; height: 20px; pointer-events: none; }
.sca-icon-btn img { width: 20px; height: 20px; object-fit: contain; pointer-events: none; }
.sca-mic-btn { color: var(--sca-text-dim); }
.sca-mic-btn:hover { background: rgba(255,255,255,0.08); color: var(--sca-text); }

/* Send Button — Dim by default, active when text exists */
.sca-send-btn {
    color: var(--sca-theme);
    opacity: 0.3;
    filter: grayscale(80%);
    transition: all 0.2s ease;
    cursor: default;
}
.sca-send-btn.sca-send-active {
    opacity: 1;
    filter: grayscale(0%);
    cursor: pointer;
}
.sca-send-btn.sca-send-active:hover {
    background: rgba(66,133,244,0.12);
}

/* ============================================================
   MIC — Premium Blue/Multi-color Ripple Animation
   ============================================================ */
.sca-mic-btn.sca-listening {
    color: #4285F4;
    background: rgba(66, 133, 244, 0.1);
    animation: sca-mic-ripple 2s ease-out infinite;
    position: relative;
}
.sca-mic-btn.sca-listening::before,
.sca-mic-btn.sca-listening::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
}
.sca-mic-btn.sca-listening::before {
    animation: sca-ripple-ring1 2s ease-out infinite;
}
.sca-mic-btn.sca-listening::after {
    animation: sca-ripple-ring2 2s ease-out infinite 0.4s;
}

@keyframes sca-mic-ripple {
    0%   { box-shadow: 0 0 0 0 rgba(66,133,244,0.3); }
    50%  { box-shadow: 0 0 12px 2px rgba(66,133,244,0.15); }
    100% { box-shadow: 0 0 0 0 rgba(66,133,244,0.05); }
}
@keyframes sca-ripple-ring1 {
    0%   { box-shadow: 0 0 0 0 rgba(66,133,244,0.35); }
    100% { box-shadow: 0 0 0 14px rgba(66,133,244,0); }
}
@keyframes sca-ripple-ring2 {
    0%   { box-shadow: 0 0 0 0 rgba(224,64,251,0.25); }
    100% { box-shadow: 0 0 0 22px rgba(224,64,251,0); }
}

/* ============================================================
   THINKING — Static (Legacy, kept for PHP HTML compat)
   ============================================================ */
.sca-thinking {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 24px 14px 12px; gap: 12px; flex-shrink: 0;
}

/* ============================================================
   THINKING — Premium Conic Gradient Ring + Pulsing Glow
   ============================================================ */
.sca-thinking-ring {
    width: 56px; height: 56px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    position: relative;
    /* [REFINED] Pulsing glow animation on the ring container */
    animation: sca-ring-glow 2.5s ease-in-out infinite;
}
/* Premium multi-color conic gradient spinning ring */
.sca-thinking-ring::before {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        #4285F4 0%,
        #E040FB 25%,
        #F5A623 50%,
        #EA4335 75%,
        #4285F4 100%
    );
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3.5px), #000 calc(100% - 3px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 3.5px), #000 calc(100% - 3px));
    animation: sca-spin 1.5s linear infinite;
}
/* Subtle glow behind the ring */
.sca-thinking-ring::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        rgba(66,133,244,0.15),
        rgba(224,64,251,0.1),
        rgba(245,166,35,0.1),
        rgba(234,67,53,0.1),
        rgba(66,133,244,0.15)
    );
    filter: blur(8px);
    animation: sca-spin 1.5s linear infinite reverse;
    z-index: -1;
}
@keyframes sca-spin { to { transform: rotate(360deg); } }

/* [REFINED] Pulsing glow keyframes — alive & modern */
@keyframes sca-ring-glow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(66,133,244,0.12), 0 0 20px rgba(66,133,244,0.05);
    }
    50% {
        box-shadow: 0 0 20px rgba(66,133,244,0.35), 0 0 40px rgba(224,64,251,0.15), 0 0 60px rgba(245,166,35,0.08);
    }
}

.sca-thinking-img {
    width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
    position: relative; z-index: 1;
}
.sca-thinking-default {
    font-size: 28px;
    position: relative; z-index: 1;
}
.sca-thinking-text {
    color: var(--sca-text-dim); font-size: 13px; font-weight: 500;
    letter-spacing: 0.5px;
    animation: sca-thinking-dots 1.5s infinite;
}
@keyframes sca-thinking-dots {
    0%, 100% { opacity: 0.4; }
    50%      { opacity: 1; }
}

/* ============================================================
   [REFINED] INLINE THINKING BUBBLE — Gemini-style in chat body
   ============================================================ */
.sca-thinking-inline {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    max-width: 85%;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 4px 18px 18px 18px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: sca-msg-in 0.3s ease-out;
}
.sca-thinking-inline .sca-thinking-ring {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}
.sca-thinking-inline .sca-thinking-ring::before {
    inset: -4px;
}
.sca-thinking-inline .sca-thinking-ring::after {
    inset: -6px;
}
.sca-thinking-inline .sca-thinking-img {
    width: 32px;
    height: 32px;
}
.sca-thinking-inline .sca-thinking-default {
    font-size: 22px;
}
.sca-thinking-inline .sca-thinking-text {
    font-size: 13px;
}

/* ============================================================
   FOOTER — Transparent
   ============================================================ */
.sca-footer {
    text-align: center; padding: 8px 14px 12px;
    font-size: 11px; color: var(--sca-text-dim); opacity: 0.5;
    flex-shrink: 0; letter-spacing: 0.3px;
    background: transparent;
}
.sca-footer a {
    color: var(--sca-theme); text-decoration: none; font-weight: 600;
}
.sca-footer a:hover { text-decoration: underline; }

/* ============================================================
   TYPEWRITER CURSOR
   ============================================================ */
.sca-typewriter-cursor {
    display: inline-block; width: 2px; height: 1em;
    background: var(--sca-theme); margin-left: 2px;
    animation: sca-blink 0.7s step-end infinite;
    vertical-align: text-bottom;
}
@keyframes sca-blink { 50% { opacity: 0; } }

/* ============================================================
   VOICE LANGUAGE INDICATOR
   ============================================================ */
.sca-voice-lang {
    position: absolute;
    top: -6px; right: -6px;
    font-size: 8px;
    background: var(--sca-theme);
    color: #fff;
    padding: 1px 4px;
    border-radius: 6px;
    font-weight: 700;
    letter-spacing: 0.3px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}
.sca-mic-btn.sca-listening .sca-voice-lang {
    opacity: 1;
}

/* ============================================================
   MOBILE — OVERLAY KEYBOARD APPROACH
   Uses position:fixed inset:0 (NOT vh units) to avoid iOS
   URL-bar and keyboard resize issues. The background, header,
   and gradient stay 100% FIXED. Only the input bar moves.
   ============================================================ */
@media (max-width: 480px) {
    /* 
     * CRITICAL: Use inset:0 + position:fixed — NOT height:100vh.
     * 100vh on iOS includes the URL bar area and causes jumps.
     * position:fixed with inset:0 = true full screen, always.
     */
    .sca-chat-window {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        max-height: none !important;
        border-radius: 0 !important;
        /* CRITICAL: overflow:hidden prevents the background from scrolling */
        overflow: hidden !important;
    }
    /* Slide-up entry on mobile */
    .sca-chat-window {
        transform: translateY(100%);
    }
    .sca-chat-window.sca-active {
        transform: translateY(0);
    }

    /* Header: stays fixed at top, NEVER moves */
    .sca-header {
        border-radius: 0 !important;
        flex-shrink: 0;
        position: relative;
        z-index: 2;
    }

    .sca-launcher {
        bottom: 16px; right: 16px;
        width: 54px; height: 54px;
    }

    /* ---- KEYBOARD OPEN STATE ---- */
    /* 
     * When .sca-kb-active is added (by JS via visualViewport):
     * - Input bar becomes position:fixed, sitting above keyboard
     * - Footer hides to save space
     * - Chat body gets extra bottom padding (set by JS)
     */
    .sca-chat-window.sca-kb-active .sca-input-bar {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        /* bottom is set dynamically by JS: offset from keyboard */
        z-index: 1000000 !important;
        background: linear-gradient(180deg, var(--sca-grad-4), var(--sca-grad-5)) !important;
        border-top: 1px solid rgba(255,255,255,0.08);
        padding: 10px 14px !important;
    }

    .sca-chat-window.sca-kb-active .sca-footer {
        display: none !important;
    }

    /* Chips go single column on small screens */
    .sca-chips {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   SAFE AREA (Notch support)
   ============================================================ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .sca-input-bar {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
    .sca-footer {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
}

/* ============================================================
   WORDPRESS THEME OVERRIDE — NUCLEAR SPECIFICITY
   ============================================================
   WordPress themes (Astra, GeneratePress, Divi, Elementor,
   OceanWP, Kadence, etc.) use selectors like:
     body input[type="text"]
     .entry-content input
     #content input
     .site-content input[type="text"]
   These override our .sca-input background to white.
   
   Fix: Use stacked ID selectors (#id#id) for specificity 200+,
   plus !important on EVERY visual property.
   ============================================================ */

/* --- INPUT FIELD — The main text input --- */
#sca-chat-window #sca-input-bar #sca-input,
#sca-chat-window #sca-input-bar input[type="text"],
#sca-chat-window .sca-input-bar .sca-input-container input,
#sca-chat-window .sca-input-container input.sca-input,
.sca-chat-window .sca-input-container input,
div#sca-chat-window input#sca-input,
body #sca-chat-window input#sca-input,
html body #sca-chat-window input#sca-input {
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    color: #e3e3e3 !important;
    color: var(--sca-text) !important;
    border: none !important;
    border-color: transparent !important;
    outline: none !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    font-size: 14px !important;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif !important;
    font-family: var(--sca-font) !important;
    padding: 10px 0 !important;
    margin: 0 !important;
    height: auto !important;
    min-height: unset !important;
    max-height: unset !important;
    line-height: normal !important;
    width: auto !important;
    min-width: 0 !important;
    flex: 1 !important;
    border-radius: 0 !important;
    text-indent: 0 !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    transition: none !important;
}

/* --- INPUT PLACEHOLDER --- */
#sca-chat-window #sca-input::placeholder,
#sca-chat-window .sca-input-container input::placeholder,
body #sca-chat-window input#sca-input::placeholder {
    color: #9aa0a6 !important;
    color: var(--sca-text-dim) !important;
    opacity: 0.6 !important;
    font-style: normal !important;
    font-weight: 400 !important;
}

/* --- INPUT FOCUS STATE --- */
#sca-chat-window #sca-input:focus,
#sca-chat-window .sca-input-container input:focus,
body #sca-chat-window input#sca-input:focus {
    background: transparent !important;
    background-color: transparent !important;
    color: #e3e3e3 !important;
    color: var(--sca-text) !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
}

/* --- INPUT CONTAINER — The rounded glass wrapper --- */
#sca-chat-window .sca-input-container,
#sca-chat-window #sca-input-bar .sca-input-container,
body #sca-chat-window .sca-input-container,
div#sca-chat-window div.sca-input-container {
    background: rgba(255, 255, 255, 0.05) !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 22px !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    padding: 4px 6px 4px 16px !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    margin: 0 !important;
    overflow: visible !important;
}

/* --- INPUT CONTAINER FOCUS-WITHIN STATE --- */
#sca-chat-window .sca-input-container:focus-within,
body #sca-chat-window .sca-input-container:focus-within {
    border-color: rgba(66, 133, 244, 0.4) !important;
    box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.1) !important;
    background: rgba(255, 255, 255, 0.05) !important;
}

/* --- INPUT BAR WRAPPER --- */
#sca-chat-window .sca-input-bar,
#sca-chat-window #sca-input-bar,
body #sca-chat-window #sca-input-bar {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 12px 14px 10px !important;
    margin: 0 !important;
}

/* --- ICON BUTTONS (Mic + Send) inside input --- */
#sca-chat-window .sca-input-container .sca-icon-btn,
#sca-chat-window .sca-icon-btn.sca-mic-btn,
#sca-chat-window .sca-icon-btn.sca-send-btn,
body #sca-chat-window button.sca-icon-btn {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 38px !important;
    height: 38px !important;
    min-width: unset !important;
    min-height: unset !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    line-height: normal !important;
    font-size: inherit !important;
}

/* --- Mic button hover (keep override for themes that add bg on hover) --- */
#sca-chat-window .sca-mic-btn:hover,
body #sca-chat-window button.sca-mic-btn:hover {
    background: rgba(255, 255, 255, 0.08) !important;
}

/* --- Send button active hover --- */
#sca-chat-window .sca-send-btn.sca-send-active:hover,
body #sca-chat-window button.sca-send-btn.sca-send-active:hover {
    background: rgba(66, 133, 244, 0.12) !important;
}

/* --- HEADER MINIMIZE BUTTON (WP themes override all buttons) --- */
#sca-chat-window .sca-minimize-btn,
#sca-chat-window button.sca-minimize-btn,
body #sca-chat-window button#sca-minimize {
    background: rgba(255, 255, 255, 0.06) !important;
    background-color: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: none !important;
    text-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 36px !important;
    height: 36px !important;
    min-width: unset !important;
    min-height: unset !important;
    border-radius: 50% !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    line-height: normal !important;
    font-size: inherit !important;
}

/* --- CHAT WINDOW ITSELF (override theme's max-width, padding, etc.) --- */
body div#sca-chat-window,
html body div#sca-chat-window.sca-chat-window {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif !important;
    font-family: var(--sca-font) !important;
    box-sizing: border-box !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
    text-align: left !important;
    direction: ltr !important;
    word-spacing: normal !important;
}

/* --- CHAT BODY override (themes might set padding/bg on divs) --- */
#sca-chat-window .sca-chat-body,
#sca-chat-window #sca-chat-body,
body #sca-chat-window #sca-chat-body {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* --- MESSAGE BUBBLES (protect from theme's p/a/div styles) --- */
#sca-chat-window .sca-msg {
    text-align: left !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    word-spacing: normal !important;
    text-indent: 0 !important;
}

/* --- FOOTER — protect from theme overrides --- */
#sca-chat-window .sca-footer,
body #sca-chat-window .sca-footer {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* --- LAUNCHER BUTTON — themes often override button backgrounds --- */
body div#sca-launcher,
html body div#sca-launcher.sca-launcher {
    background: var(--sca-theme) !important;
    background-color: var(--sca-theme) !important;
    border: none !important;
    text-shadow: none !important;
    -webkit-appearance: none !important;
}

/* --- QUICK CHIPS — protect button styling --- */
#sca-chat-window .sca-chip,
#sca-chat-window button.sca-chip,
body #sca-chat-window button.sca-chip {
    background: rgba(255, 255, 255, 0.04) !important;
    background-color: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    color: #e3e3e3 !important;
    color: var(--sca-text) !important;
    box-shadow: none !important;
    text-shadow: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}
#sca-chat-window .sca-chip:hover,
body #sca-chat-window button.sca-chip:hover {
    background: rgba(66, 133, 244, 0.12) !important;
    border-color: rgba(66, 133, 244, 0.3) !important;
}

/* --- CONTACT BUTTONS — protect from theme a/link styles --- */
#sca-chat-window .sca-contact-btn,
body #sca-chat-window a.sca-contact-btn {
    background: rgba(255, 255, 255, 0.04) !important;
    background-color: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    text-decoration: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

/* --- Autofill override (Chrome/Safari add white bg on autofill) --- */
#sca-chat-window input:-webkit-autofill,
#sca-chat-window input:-webkit-autofill:hover,
#sca-chat-window input:-webkit-autofill:focus,
#sca-chat-window input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #131314 inset !important;
    -webkit-text-fill-color: #e3e3e3 !important;
    background-color: transparent !important;
    transition: background-color 5000s ease-in-out 0s !important;
    caret-color: #e3e3e3 !important;
}
