/* ================================================================
   SupportAI — Enterprise Design System
   v4.0 — Blue + White, Professional Light Theme
   Single source of truth for all design tokens and components.
   ================================================================ */

/* ─── Google Fonts ───────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&family=Space+Grotesk:wght@500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── Design Tokens ──────────────────────────────────────────── */
:root {
    /* ── Page & Surface ── */
    --bg-page:          #f8fafc;
    --bg-surface:       #ffffff;
    --bg-surface-2:     #f1f5f9;
    --bg-surface-3:     #e8edf5;
    --bg-overlay:       rgba(15, 23, 42, 0.5);

    /* ── Borders ── */
    --border:           #e2e8f0;
    --border-strong:    #cbd5e1;
    --border-focus:     #2563eb;

    /* ── Brand / Primary (Blue) ── */
    --primary:          #2563eb;
    --primary-hover:    #1d4ed8;
    --primary-active:   #1e40af;
    --primary-subtle:   #eff6ff;
    --primary-border:   #bfdbfe;
    --primary-text:     #1e40af;

    /* ── Accent (used sparingly) ── */
    --accent-teal:          #0d9488;
    --accent-teal-subtle:   #f0fdfa;
    --accent-teal-border:   #99f6e4;
    --accent-amber:         #d97706;
    --accent-amber-subtle:  #fffbeb;
    --accent-amber-border:  #fde68a;
    --accent-purple:        #7c3aed;
    --accent-purple-subtle: #f5f3ff;
    --accent-purple-border: #ddd6fe;

    /* ── Semantic ── */
    --success:          #059669;
    --success-subtle:   #ecfdf5;
    --success-border:   #a7f3d0;
    --warning:          #d97706;
    --warning-subtle:   #fffbeb;
    --warning-border:   #fde68a;
    --danger:           #dc2626;
    --danger-subtle:    #fef2f2;
    --danger-border:    #fecaca;
    --info:             #0284c7;
    --info-subtle:      #f0f9ff;
    --info-border:      #bae6fd;

    /* ── Text ── */
    --text-primary:     #0f172a;
    --text-secondary:   #334155;
    --text-muted:       #64748b;
    --text-dim:         #94a3b8;
    --text-inverse:     #ffffff;
    --text-on-primary:  #ffffff;

    /* ── Shadows ── */
    --shadow-xs:        0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-sm:        0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md:        0 4px 12px rgba(15, 23, 42, 0.1), 0 2px 4px rgba(15, 23, 42, 0.06);
    --shadow-lg:        0 10px 24px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.06);
    --shadow-xl:        0 20px 40px rgba(15, 23, 42, 0.14), 0 8px 16px rgba(15, 23, 42, 0.08);
    --shadow-primary:   0 4px 14px rgba(37, 99, 235, 0.25);
    --shadow-inner:     inset 0 1px 3px rgba(15, 23, 42, 0.08);

    /* ── Border Radius ── */
    --radius-xs:        3px;
    --radius-sm:        6px;
    --radius-md:        8px;
    --radius-lg:        12px;
    --radius-xl:        16px;
    --radius-2xl:       24px;
    --radius-full:      9999px;

    /* ── Spacing Scale ── */
    --space-1:  4px;
    --space-2:  8px;
    --space-3:  12px;
    --space-4:  16px;
    --space-5:  20px;
    --space-6:  24px;
    --space-7:  28px;
    --space-8:  32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

    /* ── Typography ── */
    --font-sans:    'Inter', system-ui, -apple-system, sans-serif;
    --font-display: 'Space Grotesk', 'Inter', sans-serif;
    --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

    /* ── Transitions ── */
    --transition-fast:  all 0.12s ease;
    --transition-base:  all 0.18s ease;
    --transition-slow:  all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ─── Base Reset ─────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    color: var(--text-primary);
    line-height: 1.25;
    font-weight: 700;
}

p { color: var(--text-secondary); line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--primary-hover); }
img { max-width: 100%; display: block; }

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ================================================================
   COMPONENT LIBRARY
   ================================================================ */

/* ─── Buttons ────────────────────────────────────────────────── */
button { font-family: var(--font-sans); cursor: pointer; }

.btn, button[type="submit"], form button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 10px 18px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition-base);
    white-space: nowrap;
    outline: none;
    text-decoration: none;
    background: var(--primary);
    color: var(--text-on-primary);
    box-shadow: var(--shadow-primary);
}
.btn:hover, button[type="submit"]:hover, form button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.3);
}
.btn:active, button[type="submit"]:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-secondary);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
    background: var(--bg-surface-2);
    color: var(--text-primary);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.25);
}
.btn-danger:hover { background: #b91c1c; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
    box-shadow: none;
}
.btn-ghost:hover {
    background: var(--bg-surface-2);
    color: var(--text-primary);
    border-color: var(--border);
    box-shadow: none;
    transform: none;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12.5px;
    border-radius: var(--radius-sm);
}
.btn-lg {
    padding: 12px 24px;
    font-size: 15px;
    border-radius: var(--radius-md);
}

/* ─── Inputs ─────────────────────────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="search"],
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    outline: none;
    transition: var(--transition-base);
    appearance: none;
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }
input:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, textarea:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle);
    background: var(--bg-surface);
}

/* Input with icon wrapper */
.input-icon-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.input-icon-wrap i {
    position: absolute;
    left: 12px;
    color: var(--text-dim);
    font-size: 13px;
    pointer-events: none;
    z-index: 1;
}
.input-icon-wrap input { padding-left: 36px; }

/* Search input */
.ds-search {
    position: relative;
    display: flex;
    align-items: center;
}
.ds-search i {
    position: absolute;
    left: 11px;
    color: var(--text-dim);
    font-size: 12.5px;
    pointer-events: none;
}
.ds-search input {
    padding: 8px 12px 8px 32px;
    font-size: 13.5px;
    background: var(--bg-surface-2);
    border-color: var(--border);
}
.ds-search input:focus {
    background: var(--bg-surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

/* ─── Cards ──────────────────────────────────────────────────── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
}
.card:hover {
    box-shadow: var(--shadow-md);
}

/* ─── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 11.5px;
    font-weight: 600;
    border-radius: var(--radius-full);
    border: 1px solid transparent;
    white-space: nowrap;
}
.badge-blue   { background: var(--primary-subtle);        color: var(--primary-text);   border-color: var(--primary-border); }
.badge-green  { background: var(--success-subtle);        color: var(--success);        border-color: var(--success-border); }
.badge-red    { background: var(--danger-subtle);         color: var(--danger);         border-color: var(--danger-border); }
.badge-amber  { background: var(--accent-amber-subtle);   color: var(--accent-amber);   border-color: var(--accent-amber-border); }
.badge-purple { background: var(--accent-purple-subtle);  color: var(--accent-purple);  border-color: var(--accent-purple-border); }
.badge-teal   { background: var(--accent-teal-subtle);    color: var(--accent-teal);    border-color: var(--accent-teal-border); }
.badge-gray   { background: var(--bg-surface-2);          color: var(--text-muted);     border-color: var(--border); }

/* ─── Status Dot ─────────────────────────────────────────────── */
.status-dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.online  { background: var(--success); box-shadow: 0 0 0 2px var(--success-subtle); }
.status-dot.offline { background: var(--text-dim); }
.status-dot.busy    { background: var(--warning); }

/* ─── Skeleton Loader ────────────────────────────────────────── */
.skeleton {
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg,
        var(--bg-surface-2) 25%,
        var(--border) 50%,
        var(--bg-surface-2) 75%);
    background-size: 800px 100%;
    animation: ds-shimmer 1.4s infinite linear;
}

@keyframes ds-shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

/* ─── Spinner ────────────────────────────────────────────────── */
.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: ds-spin 0.7s linear infinite;
}
@keyframes ds-spin { to { transform: rotate(360deg); } }

/* ─── Animations ─────────────────────────────────────────────── */
@keyframes ds-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes ds-fade-in-fast {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes ds-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}
@keyframes ds-ping {
    75%, 100% { transform: scale(1.6); opacity: 0; }
}

/* ─── Empty State ─────────────────────────────────────────────── */
.ds-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-12) var(--space-6);
    text-align: center;
}
.ds-empty-icon {
    font-size: 32px;
    color: var(--text-dim);
    margin-bottom: var(--space-1);
}
.ds-empty h3 { font-size: 15px; color: var(--text-secondary); }
.ds-empty p  { font-size: 13.5px; color: var(--text-muted); max-width: 260px; line-height: 1.5; }

/* ─── Divider ─────────────────────────────────────────────────── */
.ds-divider {
    height: 1px;
    background: var(--border);
    margin: var(--space-5) 0;
}

/* ─── Avatar Circle ──────────────────────────────────────────── */
.ds-avatar {
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-family: var(--font-display);
    color: #fff;
    flex-shrink: 0;
    font-size: 13px;
}
.ds-avatar-sm  { width: 30px; height: 30px; font-size: 11px; }
.ds-avatar-md  { width: 38px; height: 38px; font-size: 14px; }
.ds-avatar-lg  { width: 48px; height: 48px; font-size: 17px; }

/* ─── Toast ──────────────────────────────────────────────────── */
.toast-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text-primary);
    color: var(--text-inverse);
    padding: 12px 18px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}
.toast-notification.show { opacity: 1; transform: translateY(0); }

/* ─── Tags / Pills ───────────────────────────────────────────── */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    font-size: 11.5px;
    font-weight: 600;
    border-radius: var(--radius-full);
    background: var(--bg-surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    white-space: nowrap;
}

/* ─── Table ──────────────────────────────────────────────────── */
.ds-table-wrap {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.ds-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.ds-table thead tr { border-bottom: 1px solid var(--border); background: var(--bg-surface-2); }
.ds-table thead th {
    padding: 11px 16px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
}
.ds-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: var(--transition-fast);
}
.ds-table tbody tr:last-child { border-bottom: none; }
.ds-table tbody tr:hover { background: var(--bg-surface-2); }
.ds-table td {
    padding: 13px 16px;
    color: var(--text-secondary);
    vertical-align: middle;
}

/* ─── Form Field Group ───────────────────────────────────────── */
.field {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg-surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    transition: var(--transition-base);
    overflow: hidden;
}
.field:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}
.field i {
    padding: 0 12px;
    color: var(--text-dim);
    font-size: 13.5px;
    flex-shrink: 0;
}
.field input {
    flex: 1;
    border: none;
    background: transparent;
    box-shadow: none;
    padding: 11px 14px 11px 0;
}
.field input:focus { box-shadow: none; border-color: transparent; }
.field button {
    margin: 4px;
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 13px;
    box-shadow: none;
}
.field button:hover { transform: none; }
