/**
 * LeadFlow CRM — Obsidian Design System
 * 
 * High-fidelity, mobile-first tokens for the Obsidian Observatory experience.
 * Focus: Tonal depth, glassmorphism, and 48px touch targets.
 */

:root {
    /* Shared Brand & Accents (Consistency across themes) */
    --indigo-primary: 239 84% 67%;     /* #818cf8 - Primary */
    --indigo-glow: 239 84% 67% / 0.15;
    --emerald-success: 158 64% 52%;    /* #22c55e - Active/WA Live */
    --rose-danger: 1 89% 63%;          /* #f43f5e - Hot Leads */
    
    /* Functional Tokens */
    --glass-blur: blur(30px);
    --transition-smooth: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Dark Theme (Obsidian) */
[data-theme="dark"] {
    --obsidian-bg: 220 20% 6%;           /* #0c0e12 */
    --obsidian-surface: 220 18% 10%;      /* #161a22 */
    --obsidian-surface-high: 220 16% 15%; /* #202631 */
    --obsidian-surface-highest: 217 14% 20%; /* #2c333e */
    --obsidian-border: rgba(255, 255, 255, 0.08);
    --glass-background: rgba(255, 255, 255, 0.04);
    --subtle-bg: rgba(255, 255, 255, 0.02);
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --text-dim: #475569;
}

/* Light Theme (Crystal) */
[data-theme="light"] {
    --obsidian-bg: 220 20% 98%;          /* #f8fafc */
    --obsidian-surface: 220 20% 100%;     /* #ffffff */
    --obsidian-surface-high: 220 20% 94%; /* #f1f5f9 */
    --obsidian-surface-highest: 220 20% 88%; /* #e2e8f0 */
    --obsidian-border: rgba(15, 23, 42, 0.12);
    --glass-background: rgba(255, 255, 255, 0.85);
    --subtle-bg: rgba(15, 23, 42, 0.04);
    --text-main: #0f172a;                /* Deep Slate (Slate-900) */
    --text-muted: #1e293b;               /* Slate-800 - DARKER for visibility */
    --text-dim: #475569;                 /* Slate-600 - DARKER for visibility */
}

/* Base Body Styles */
.obsidian-theme {
    background-color: hsl(var(--obsidian-bg));
    color: var(--text-main);
    font-family: 'Inter', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Universal Text Visibility Overrides */
[data-theme="light"] .obsidian-theme,
[data-theme="light"] body {
    color: var(--text-main) !important;
    background-color: hsl(var(--obsidian-bg)) !important;
}

[data-theme="light"] p, 
[data-theme="light"] span:not(.text-brand), 
[data-theme="light"] h1, 
[data-theme="light"] h2, 
[data-theme="light"] h3, 
[data-theme="light"] h4, 
[data-theme="light"] li {
    color: var(--text-main);
}

[data-theme="light"] .text-ce-muted { color: var(--text-muted) !important; }
[data-theme="light"] .text-ce-dim { color: var(--text-dim) !important; }

[data-theme="light"] * {
    border-color: var(--obsidian-border);
}

/* Editorial Typography */
.obsidian-title {
    color: var(--text-main);
    font-weight: 800;
    letter-spacing: -0.025em;
}

.obsidian-metric {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--text-main);
}

/* Surface Cards & Glassmorphism */
.obsidian-card {
    background-color: hsl(var(--obsidian-surface-high));
    border: 1px solid var(--obsidian-border);
    border-radius: 16px;
    padding: 20px;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.obsidian-card:active {
    transform: scale(0.98);
}

.glass-card {
    background: var(--glass-background);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--obsidian-border);
}

/* Touch-First Optimization (48px+ targets) */
.obsidian-touch {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
}

.btn-primary-glow {
    background-color: hsl(var(--indigo-primary));
    color: #ffffff !important;
    box-shadow: 0 4px 14px 0 var(--indigo-glow);
}

/* Bottom Navigation (Mobile Only) */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background: hsl(var(--obsidian-bg) / 0.8);
    backdrop-filter: blur(25px);
    border-top: 1px solid var(--obsidian-border);
    display: flex;
    justify-content: space-around;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-decoration: none !important;
    min-width: 64px;
    min-height: 48px; /* Touch-First Standard */
    position: relative;
    transition: color 0.2s ease;
}

.nav-item.active {
    color: hsl(var(--indigo-primary));
}

.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    width: 4px;
    height: 4px;
    background: currentColor;
    border-radius: 50%;
    box-shadow: 0 0 8px currentColor;
}

.nav-item i {
    font-size: 1.25rem;
}

/* Pulse Animation for Status Indicators */
@keyframes status-pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

.pulse-success {
    background: hsl(var(--emerald-success));
    width: 10px;
    height: 10px;
    border-radius: 50%;
    position: relative;
}

.pulse-success::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 50%;
    background: inherit;
    animation: status-pulse 2s infinite ease-in-out;
}

/* ── HIGH-FIDELITY NAVIGATION EXTENSIONS ────────── */

/* Sidebar Rail Mode (Desktop Only) */
.sidebar-collapsed {
    width: 80px !important;
}
.sidebar-collapsed .sidebar-label,
.sidebar-collapsed .sidebar-group-title,
.sidebar-collapsed .workspace-metadata,
.sidebar-collapsed .plan-card {
    display: none !important;
}
.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 0.75rem !important;
    gap: 0;
}
.sidebar-collapsed .sidebar-link i {
    font-size: 1.1rem;
}

/* Bottom Sheet (Mobile Adaptive Overlay) */
#mobileMoreMenu {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: auto;
    max-height: 85vh;
    background: hsl(var(--obsidian-bg) / 0.98);
    backdrop-filter: blur(50px);
    border-top: 1px solid var(--obsidian-border);
    border-radius: 40px 40px 0 0;
    z-index: 2000;
    transform: translateY(100%);
    transition: transform 0.5s cubic-bezier(0.32, 0.72, 0, 1);
    padding: 40px 24px;
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
    box-shadow: 0 -20px 40px rgba(0, 0, 0, 0.4);
}

#mobileMoreMenu.active {
    transform: translateY(0);
}

.bottom-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.bottom-sheet-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* Prime Action FAB (Mobile Nav) */
.fab-prime {
    width: 56px;
    height: 56px;
    background: hsl(var(--indigo-primary));
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
    transform: translateY(-20px);
    border: 4px solid hsl(var(--obsidian-bg));
    transition: var(--transition-bounce);
}
.fab-prime:active {
    transform: translateY(-20px) scale(0.9);
}

/* Enhanced Sidebar Links */
.sidebar-link.active {
    box-shadow: inset 0 0 20px rgba(99, 102, 241, 0.05);
}
.sidebar-link.active i {
    filter: drop-shadow(0 0 8px rgba(129, 140, 248, 0.6));
}

/* Category Grouping Labels */
.sidebar-group-title {
    font-size: 9px;
    font-weight: 900;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    padding: 24px 16px 8px;
}

/* Operational Inputs */
.obsidian-input {
    background: hsl(var(--obsidian-bg) / 0.4) !important;
    border: 1px solid var(--obsidian-border) !important;
    border-radius: 12px;
    color: var(--text-main);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none !important;
}

.obsidian-input:focus {
    border-color: hsl(var(--indigo-primary) / 0.5) !important;
    background: rgba(99, 102, 241, 0.05) !important;
    box-shadow: 0 0 20px hsl(var(--indigo-primary) / 0.1);
}

/* Table Refinements */
table { border-collapse: separate; border-spacing: 0; }
th { border-bottom: 1px solid var(--obsidian-border); color: var(--text-muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; }
td { color: var(--text-main); }
tr:last-child td { border-bottom: none; }

/* Dashboard Pulse */
.animate-pulse-slow { animation: pulse 4s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }

