/* ========================================
   DESIGN TOKENS
   ======================================== */
:root {
    /* Core Surfaces */
    --surface-base: #0c0c0c;
    --surface-elevated: rgba(18, 18, 18, 0.65);
    
    /* Glass Material */
    --glass-blur: 24px;
    --glass-saturation: 1.4;
    --glass-contrast: 1.05;
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-radius-container: 32px;
    --glass-radius-element: 30px;
    --glass-radius-pill: 999px;
    
    /* Typography */
    --text-primary: #f5f5f7;
    --text-secondary: rgba(245, 245, 247, 0.7);
    --text-tertiary: rgba(245, 245, 247, 0.4);
    
    /* Type Scale */
    --text-xs: 12px;
    --text-sm: 13px;
    --text-base: 14px;
    --text-md: 15px;
    --text-lg: 16px;
    --text-xl: 18px;
    
    /* Accent Colors */
    --accent-blue-start: #3b82f6;
    --accent-blue-end: #1d4ed8;
    --accent-emerald: #10b981;
    --accent-emerald-bg: rgba(16, 185, 129, 0.2);
    --accent-amber: #f59e0b;
    --accent-amber-bg: rgba(245, 158, 11, 0.2);
    --accent-red: #ef4444;
    --accent-red-bg: rgba(239, 68, 68, 0.2);
    
    /* Motion */
    --ease-out-expo: cubic-bezier(0.2, 0.8, 0.2, 1);
    --transition-fast: 150ms var(--ease-out-expo);
    --transition-base: 250ms var(--ease-out-expo);
    --transition-slow: 400ms var(--ease-out-expo);
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.6);
    --shadow-glow-blue: 0 0 30px rgba(59, 130, 246, 0.3);
    --shadow-glow-emerald: 0 0 20px rgba(16, 185, 129, 0.25);
}

/* Light Mode Variables */
[data-theme="light"] {
    /* Core Surfaces */
    --surface-base: #fafbfc;
    --surface-elevated: rgba(255, 255, 255, 0.95);
    
    /* Glass Material */
    --glass-border: rgba(0, 0, 0, 0.08);
    
    /* Typography */
    --text-primary: #0f172a;
    --text-secondary: rgba(15, 23, 42, 0.75);
    --text-tertiary: rgba(15, 23, 42, 0.55);
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-glow-blue: 0 0 20px rgba(99, 102, 241, 0.15);
    --shadow-glow-emerald: 0 0 20px rgba(16, 185, 129, 0.12);
}

[data-theme="light"] body::before {
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.04) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(236, 72, 153, 0.03) 0%, transparent 50%),
        linear-gradient(rgba(99, 102, 241, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 102, 241, 0.02) 1px, transparent 1px);
}

[data-theme="light"] .glass::before {
    background: radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255, 255, 255, 0.6) 0%, transparent 100%);
    mix-blend-mode: overlay;
}

[data-theme="light"] .glass::after {
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.1), transparent);
}

/* ========================================
   RESET & BASE
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--surface-base);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.5;
    position: relative;
    overflow-x: hidden;
}

/* Fixed Background Grid */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 50%),
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 60px 60px, 60px 60px;
    pointer-events: none;
    z-index: 0;
}

/* ========================================
   GLASS MATERIAL MIXIN
   ======================================== */
.glass {
    background: var(--surface-elevated);
    backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation)) contrast(var(--glass-contrast));
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation)) contrast(var(--glass-contrast));
    border: 1px solid var(--glass-border);
    border-radius: var(--glass-radius-element);
    position: relative;
    overflow: hidden;
}

/* Internal lighting effect */
.glass::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255, 255, 255, 0.08) 0%, transparent 100%);
    mix-blend-mode: screen;
    pointer-events: none;
}

/* Top edge highlight */
.glass::after {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    pointer-events: none;
}

/* ========================================
   LAYOUT
   ======================================== */
.container {
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* ========================================
   HEADER
   ======================================== */
.header {
    background: var(--surface-elevated);
    backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation)) contrast(var(--glass-contrast));
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation)) contrast(var(--glass-contrast));
    border: 1px solid var(--glass-border);
    border-radius: var(--glass-radius-container);
    padding: 32px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.6s var(--ease-out-expo) forwards;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60%;
    background: radial-gradient(ellipse 100% 70% at 50% 0%, rgba(255, 255, 255, 0.06) 0%, transparent 100%);
    mix-blend-mode: screen;
    pointer-events: none;
}

.header::after {
    content: '';
    position: absolute;
    top: 0;
    left: 5%;
    right: 5%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
    pointer-events: none;
}

h1 {
    color: var(--text-primary);
    font-size: var(--text-xl);
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: -0.02em;
    position: relative;
}

.subtitle {
    color: var(--text-tertiary);
    font-size: var(--text-sm);
    font-weight: 400;
}

/* ========================================
   STAT CARDS
   ======================================== */
.stats {
    display: flex;
    gap: 16px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.stat-card {
    background: linear-gradient(135deg, var(--accent-blue-start) 0%, var(--accent-blue-end) 100%);
    padding: 20px 24px;
    border-radius: var(--glass-radius-element);
    flex: 1;
    min-width: 200px;
    box-shadow: var(--shadow-md), var(--shadow-glow-blue);
    position: relative;
    overflow: hidden;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
    animation: slideUp 0.6s var(--ease-out-expo) forwards;
    animation-delay: 0.1s;
    opacity: 0;
}

.stat-card:nth-child(2) {
    animation-delay: 0.15s;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.15) 0%, transparent 100%);
    pointer-events: none;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 40px rgba(59, 130, 246, 0.4);
}

.stat-label {
    font-size: var(--text-xs);
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
}

.stat-value.time-ago {
    font-size: 24px;
}

/* ========================================
   CLIENTS CONTAINER
   ======================================== */
.clients-container {
    background: var(--surface-elevated);
    backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation)) contrast(var(--glass-contrast));
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation)) contrast(var(--glass-contrast));
    border: 1px solid var(--glass-border);
    border-radius: var(--glass-radius-container);
    padding: 32px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
    animation: slideUp 0.6s var(--ease-out-expo) forwards;
    animation-delay: 0.2s;
    opacity: 0;
}

.clients-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: radial-gradient(ellipse 100% 60% at 50% 0%, rgba(255, 255, 255, 0.04) 0%, transparent 100%);
    mix-blend-mode: screen;
    pointer-events: none;
}

.clients-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 5%;
    right: 5%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    pointer-events: none;
}

.clients-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    position: relative;
}

h2 {
    color: var(--text-primary);
    font-size: var(--text-lg);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.last-updated {
    color: var(--text-tertiary);
    font-size: var(--text-xs);
}

/* ========================================
   CLIENTS GRID
   ======================================== */
.clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    position: relative;
}

/* ========================================
   CLIENT CARD
   ======================================== */
.client-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--glass-radius-element);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: 
        transform var(--transition-base),
        box-shadow var(--transition-base),
        background var(--transition-base),
        border-color var(--transition-base);
    animation: fadeInUp 0.4s var(--ease-out-expo) forwards;
    opacity: 0;
}

.client-card:nth-child(1) { animation-delay: 0.05s; }
.client-card:nth-child(2) { animation-delay: 0.1s; }
.client-card:nth-child(3) { animation-delay: 0.15s; }
.client-card:nth-child(4) { animation-delay: 0.2s; }
.client-card:nth-child(5) { animation-delay: 0.25s; }
.client-card:nth-child(6) { animation-delay: 0.3s; }
.client-card:nth-child(n+7) { animation-delay: 0.35s; }

.client-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255, 255, 255, 0.04) 0%, transparent 100%);
    mix-blend-mode: screen;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.client-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.12);
}

.client-card:hover::before {
    opacity: 1;
}

.client-id {
    font-weight: 600;
    color: var(--text-primary);
    font-size: var(--text-md);
    margin-bottom: 12px;
    word-break: break-all;
    letter-spacing: -0.01em;
}

.client-info {
    color: var(--text-tertiary);
    font-size: var(--text-sm);
    margin: 6px 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.client-info strong {
    color: var(--text-secondary);
    font-weight: 500;
}

/* ========================================
   STATUS BADGES
   ======================================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--glass-radius-pill);
    font-size: var(--text-xs);
    font-weight: 600;
    margin-top: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-online {
    background: var(--accent-emerald-bg);
    color: var(--accent-emerald);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.15);
}

.status-online::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--accent-emerald);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
    box-shadow: 0 0 8px var(--accent-emerald);
}

.status-warning {
    background: var(--accent-amber-bg);
    color: var(--accent-amber);
}

.status-warning::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--accent-amber);
    border-radius: 50%;
}

/* ========================================
   EMPTY STATE
   ======================================== */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-tertiary);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
    filter: grayscale(0.5);
}

.empty-state h3 {
    color: var(--text-secondary);
    font-size: var(--text-lg);
    font-weight: 500;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: var(--text-sm);
    max-width: 300px;
    margin: 0 auto;
}

/* ========================================
   ERROR MESSAGE
   ======================================== */
.error-message {
    background: var(--accent-red-bg);
    color: var(--accent-red);
    padding: 16px 20px;
    border-radius: var(--glass-radius-pill);
    margin-bottom: 20px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    font-size: var(--text-sm);
    display: flex;
    align-items: center;
    gap: 8px;
}

.error-message strong {
    font-weight: 600;
}

/* ========================================
   LOADING STATE
   ======================================== */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
}

.loading p {
    font-size: var(--text-sm);
    margin-top: 16px;
}

/* Rotary Spinner */
.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    position: relative;
}

.spinner::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.spinner::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: var(--accent-blue-start);
    animation: spin 0.8s linear infinite;
}

/* Shimmer Loading Effect */
.shimmer {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.03) 0%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0.03) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--glass-radius-element);
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    body {
        padding: 16px;
    }
    
    .header,
    .clients-container {
        padding: 24px;
        border-radius: 24px;
    }
    
    .stat-card {
        min-width: 100%;
    }
    
    .clients-grid {
        grid-template-columns: 1fr;
    }
    
    .client-card {
        border-radius: 24px;
    }
}

/* ========================================
   FONT IMPORT
   ======================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
