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

:root {
    /* 8px Spacing System */
    --space-1: 8px;
    --space-2: 16px;
    --space-3: 24px;
    --space-4: 32px;
    --space-5: 40px;
    
    /* Brand & Semantic Colors */
    --brand: #6366f1; /* Indigo - Industry standard for Enterprise */
    --brand-hover: #4f46e5;
    --brand-soft: rgba(99, 102, 241, 0.1);
    
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    
    /* Light Theme - High Depth Refined */
    --bg-app: #f8fafc; /* Slate 50 - Provides depth foundation */
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    
    --text-heading: #0f172a;
    --text-body: #334155;
    --text-muted: #64748b;
    
    --border-subtle: rgba(0, 0, 0, 0.03);
    --border-strong: rgba(0, 0, 0, 0.06);
    
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.04), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 20px 50px -12px rgba(0, 0, 0, 0.08), 0 0 1px 0 rgba(0, 0, 0, 0.04);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 80px;
    --header-height: 72px;
}

:root.dark-theme {
    /* Deep Space Black - Depth focused */
    --bg-app: #030303;
    --bg-sidebar: #0a0a0a;
    --bg-card: #111111;
    --bg-input: #1a1a1a;
    
    --text-heading: #ffffff;
    --text-body: #a1a1aa;
    --text-muted: #52525b;
    
    --border-subtle: rgba(255, 255, 255, 0.05);
    --border-strong: rgba(255, 255, 255, 0.08);
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --shadow-md: 0 15px 40px -10px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 30px 60px -12px rgba(0, 0, 0, 0.8);
    
    --brand-soft: rgba(99, 102, 241, 0.2);
}

/* Global Reset */
* { box-sizing: border-box; margin: 0; padding: 0; outline: none; }
body {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-body);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    transition: background 0.2s, color 0.2s;
}

/* Layout Architecture */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 50;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.04);
}

.dark-theme .sidebar {
    box-shadow: none;
}

/* Theme Switch Styling */
.theme-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-sidebar);
    padding: 2px 4px;
    border-radius: 20px;
    border: 1px solid var(--border-strong);
    cursor: pointer;
    position: relative;
    width: 62px;
    height: 32px;
    transition: all 0.2s;
}

.theme-switch .switch-toggle {
    width: 24px;
    height: 24px;
    background: var(--brand);
    border-radius: 50%;
    position: absolute;
    left: 4px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.dark-theme .theme-switch .switch-toggle {
    transform: translateX(30px);
    background: var(--text-heading);
}

.theme-switch i { width: 14px; height: 14px; }

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 var(--space-2);
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--brand);
    color: white;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.logo-text {
    margin-left: 12px;
    font-weight: 700;
    font-size: 16px;
    color: var(--text-heading);
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.2s;
}
.sidebar.collapsed .logo-text { opacity: 0; pointer-events: none; }

.nav-group {
    padding: var(--space-2) var(--space-2);
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: var(--text-body);
    text-decoration: none;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    transition: all 0.15s;
    white-space: nowrap;
}

.nav-item:hover { background: var(--brand-soft); color: var(--brand); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.nav-item svg { width: 18px; height: 18px; margin-right: 12px; flex-shrink: 0; }
.sidebar.collapsed .nav-item span { display: none; }
.sidebar.collapsed .nav-item svg { margin-right: 0; }

/* Top Navigation Bar */
.top-nav {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-4);
    z-index: 40;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark-theme .top-nav {
    background: rgba(3, 3, 3, 0.82);
}

.sidebar.collapsed + .content-wrapper .top-nav { left: var(--sidebar-collapsed-width); }

.top-nav-left { display: flex; align-items: center; gap: var(--space-3); }
.top-nav-right { display: flex; align-items: center; gap: var(--space-3); }

/* Main Content Area */
.content-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding-top: var(--header-height);
    transition: margin-left 0.3s;
}
.sidebar.collapsed + .content-wrapper { margin-left: var(--sidebar-collapsed-width); }

.main-content {
    padding: var(--space-4) var(--space-5);
    max-width: 1600px;
    margin: 0 auto;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: var(--space-5);
}
.page-header h1 { font-size: 28px; font-weight: 800; color: var(--text-heading); letter-spacing: -0.02em; }
.page-header p { color: var(--text-muted); margin-top: 6px; font-size: 15px; }

/* Card Component */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 24px;
    margin-bottom: var(--space-3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.card:hover { 
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg); 
}
.card-title { font-size: 16px; font-weight: 600; color: var(--text-heading); margin-bottom: var(--space-2); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.1s;
    border: 1px solid transparent;
    gap: 8px;
}
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-secondary { background: var(--bg-app); border-color: var(--border-strong); color: var(--text-heading); }
.btn-secondary:hover { background: var(--bg-sidebar); }
.btn-ghost { background: transparent; color: var(--text-body); border: none; }
.btn-ghost:hover { background: var(--brand-soft); color: var(--brand); }

/* Tables */
.table-container { 
    overflow-x: auto; 
    border-radius: var(--radius-md); 
    border: 1px solid var(--border-strong);
}
table { width: 100%; border-collapse: collapse; background: var(--bg-card); }
th { 
    position: sticky; top: 0; background: var(--bg-sidebar); 
    padding: 12px 16px; text-align: left; font-size: 11px; 
    font-weight: 700; color: var(--text-muted); 
    text-transform: uppercase; letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-strong);
    z-index: 10;
    vertical-align: middle;
}
td { 
    padding: 16px; 
    border-bottom: 1px solid var(--border-subtle); 
    color: var(--text-body); 
    font-size: 13px; 
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-app); }

/* Form Elements */
.form-group { margin-bottom: var(--space-2); }
label { display: block; font-size: 13px; font-weight: 600; color: var(--text-heading); margin-bottom: 6px; }
input, select, textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-heading);
    transition: border-color 0.2s;
}
input:focus { border-color: var(--brand); }

/* Theme Persistence & Toggle UI */
.theme-toggle { size: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-muted); transition: color 0.2s; }
.theme-toggle:hover { color: var(--brand); background: var(--brand-soft); }

/* Badges */
.badge {
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
}
.badge-success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-error { background: rgba(239, 68, 68, 0.1); color: var(--error); }

/* Dashboard Grid Utilities */
.grid-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-2);
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
}

/* Auth Screens */
.login-centered {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--bg-app);
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(99, 102, 241, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(99, 102, 241, 0.03) 0%, transparent 50%);
    position: relative;
    overflow: hidden;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    padding: 48px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-subtle);
    z-index: 10;
}

.login-card .logo-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 32px;
    text-align: center;
}

.login-card .logo-icon-lg {
    width: 56px;
    height: 56px;
    background: var(--brand);
    color: white;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 16px;
    box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.4);
}

.login-card h2 { font-size: 24px; font-weight: 800; color: var(--text-heading); margin-bottom: 8px; }
.login-card p { color: var(--text-muted); font-size: 14px; margin-bottom: 0; }

/* Mobile Adaptations */
/* Lead Sentiment Tokens */
.badge-hot { background: rgba(239, 68, 68, 0.1); color: var(--error); border: 1px solid rgba(239, 68, 68, 0.2); }
.badge-warm { background: rgba(245, 158, 11, 0.1); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-cold { background: rgba(100, 116, 139, 0.1); color: var(--text-muted); border: 1px solid rgba(100, 116, 139, 0.2); }

/* Modal System */
.modal-overlay {
    backdrop-filter: blur(8px);
    background: rgba(0, 0, 0, 0.4);
    transition: opacity 0.3s;
}

@media (max-width: 1024px) {
    .grid-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: 240px; }
    .sidebar.open { transform: translateX(0); }
    .content-wrapper { margin-left: 0 !important; }
    .top-nav { left: 0 !important; }
    .main-content { padding: var(--space-2); }
    .search-bar { display: none; }
    .grid-stats { grid-template-columns: 1fr; }
}

/* Color Picker & Branded Inputs */
.color-picker-input {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    border: 2px solid var(--border-strong) !important;
    cursor: pointer;
    padding: 0 !important;
    overflow: hidden;
    background: white !important;
    vertical-align: middle;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}

.color-picker-input:hover {
    transform: scale(1.1);
    border-color: var(--brand) !important;
    box-shadow: var(--shadow-md);
}

.color-picker-input::-webkit-color-swatch-wrapper {
    padding: 0;
    border-radius: 50%;
}

.color-picker-input::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}

.color-picker-input::-moz-color-swatch {
    border: none;
    border-radius: 50%;
}

.form-group-color {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    padding: 10px 16px;
    border-radius: 14px;
    border: 1px solid var(--border-subtle);
    margin-bottom: 12px;
    transition: all 0.2s;
}

.form-group-color:hover {
    border-color: var(--border-strong);
    background: var(--bg-app);
}

.form-group-color label {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-body);
}
