/*
 * SUPPORT CHAT WIDGET — Luxury Minimalist
 * ========================================
 * sup- prefix isolates from global dashboard CSS.
 * Tokens: admin.css/main.css/base.css (--bg-*, --text-*, --border-color).
 */

#sup-chat-root {
    --sup-brand: #10b981;
    --sup-brand-fg: #ffffff;
    --sup-brand-ring: rgba(16, 185, 129, 0.18);
}

/* FAB — Dark Slate + Emerald indicator */
#sup-fab {
    position: fixed;
    right: max(20px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
    z-index: 9500;
    width: 48px; height: 48px;
    border: none; border-radius: 50%;
    background: #151821;
    color: rgba(255, 255, 255, 0.55);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
}
#sup-fab::after {
    content: '';
    position: absolute;
    top: 5px; right: 5px;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--sup-brand);
    transition: box-shadow 0.3s ease;
}
#sup-fab:hover {
    color: rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
#sup-fab:hover::after { animation: sup-pulse 1.5s ease-in-out infinite; }
#sup-fab:active { transform: translateY(0); }
#sup-fab svg { width: 20px; height: 20px; }
@keyframes sup-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
    50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

/* Panel */
#sup-panel {
    position: fixed;
    right: max(20px, env(safe-area-inset-right));
    bottom: 84px;
    width: 360px; max-height: 560px;
    z-index: 9499;
    display: flex; flex-direction: column;
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    opacity: 0; transform: translateY(8px) scale(0.98);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
    visibility: hidden;
}
#sup-panel[aria-hidden="false"] {
    opacity: 1; transform: none; visibility: visible;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Head */
#sup-panel .sup-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color, rgba(0, 0, 0, 0.06));
    background: var(--bg-secondary, transparent);
}
#sup-panel .sup-title {
    font-size: 0.9375rem; font-weight: 700;
    color: var(--text-primary, #111);
}
#sup-panel #sup-close {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted, #64748b);
    padding: 4px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
}
#sup-panel #sup-close:hover { color: var(--text-primary, #111); background: rgba(0, 0, 0, 0.05); }

/* History */
#sup-panel .sup-history {
    flex: 1; min-height: 60px; max-height: 260px;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex; flex-direction: column; gap: 8px;
}
#sup-panel .sup-item {
    padding: 10px 12px; border-radius: 10px;
    background: var(--bg-secondary, rgba(15, 23, 42, 0.04));
}
#sup-panel .sup-item-body {
    font-size: 0.8125rem; color: var(--text-primary, #111);
    line-height: 1.55; white-space: pre-wrap;
    overflow-wrap: anywhere; word-break: break-word;
}
#sup-panel .sup-item-when {
    font-size: 0.6875rem; color: var(--text-muted, #64748b); margin-top: 4px;
}

/* Form */
#sup-panel .sup-form {
    padding: 12px 16px 14px;
    border-top: 1px solid var(--border-color, rgba(0, 0, 0, 0.06));
}
#sup-panel .sup-input-wrap {
    position: relative;
}
#sup-panel textarea {
    width: 100%; box-sizing: border-box;
    resize: none;
    padding: 10px 44px 10px 12px; border-radius: 10px;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.06));
    background: var(--bg-secondary, rgba(15, 23, 42, 0.06));
    color: var(--text-primary, #111);
    font-family: inherit; font-size: 0.875rem; line-height: 1.5;
    outline: none;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#sup-panel textarea::placeholder { color: var(--text-muted, #64748b); }
#sup-panel textarea:focus {
    border-color: var(--sup-brand);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.04), 0 0 0 3px var(--sup-brand-ring);
}

/* Send — arrow icon inside input wrap */
#sup-panel .sup-btn-send {
    position: absolute; right: 6px; bottom: 6px;
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; color: var(--text-muted, #64748b);
    border: none; border-radius: 8px;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}
#sup-panel .sup-btn-send:disabled { opacity: 0.2; cursor: not-allowed; }
#sup-panel .sup-btn-send:not(:disabled) { color: var(--sup-brand); }
#sup-panel .sup-btn-send:not(:disabled):hover { background: var(--sup-brand-ring); }

/* Status */
#sup-panel .sup-msg {
    font-size: 0.75rem; margin-top: 6px; min-height: 16px;
    color: var(--text-muted, #64748b);
}
#sup-panel .sup-msg.is-ok  { color: #059669; }
#sup-panel .sup-msg.is-err { color: #dc2626; }
#sup-panel .sup-msg.is-info { color: var(--text-muted, #64748b); }

/* Mobile */
@media (max-width: 520px) {
    #sup-panel {
        left: 12px; right: 12px; bottom: 80px;
        width: auto; max-height: 70vh;
    }
    #sup-panel .sup-history { max-height: 40vh; }
    #sup-fab { right: 16px; bottom: 16px; }
}
