/* ============================================
   PITECH SCAN — MILLION DOLLAR MD3 SYSTEM
   ============================================ */

:root {
    /* Core Palette - MD3 Baseline Purple */
    --md-sys-color-primary: #6750A4;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #EADDFF;
    --md-sys-color-on-primary-container: #21005D;
    
    --md-sys-color-secondary: #625B71;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #E8DEF8;
    
    --md-sys-color-error: #B3261E;
    --md-sys-color-on-error: #FFFFFF;
    
    /* Surface Palette - Premium Minimalist */
    --md-sys-color-surface: #F8F9FF;
    --md-sys-color-surface-variant: #E7E0EC;
    --md-sys-color-on-surface: #1C1B1F;
    --md-sys-color-on-surface-variant: #49454F;
    
    --md-sys-color-outline: #79747E;
    --md-sys-color-outline-variant: #CAC4D0;

    /* High-End Typography */
    --font-brand: 'Google Sans', 'Outfit', sans-serif;
    --font-plain: 'Google Sans', 'Inter', sans-serif;

    /* Standard MD3 Tokens */
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 32px;
    --radius-pill: 100px;

    /* Elevation System */
    --premium-shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --premium-shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --premium-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-snappy: all 0.15s cubic-bezier(0, 0, 0.2, 1);
}

/* Base Styles */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    font-family: var(--font-plain);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Layout System */
.sidebar {
    width: 280px;
    height: 100vh;
    position: fixed;
    top: 0; left: 0;
    background: #FFF;
    border-right: 1px solid rgba(0,0,0,0.05);
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: var(--transition-smooth);
}

.sidebar.collapsed { width: 88px; }

.main-content {
    margin-left: 280px;
    padding: 48px 64px;
    transition: var(--transition-smooth);
    min-height: 100vh;
}

body:has(.sidebar.collapsed) .main-content { margin-left: 88px; }

/* Responsive Sidebar */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); width: 280px; }
    .sidebar.open { transform: translateX(0); box-shadow: 20px 0 60px rgba(0,0,0,0.1); }
    .main-content { margin-left: 0 !important; padding: 24px 16px; margin-top: 64px; }
}

/* Sidebar Components */
.sidebar-header {
    padding: 0 24px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-text {
    font-family: var(--font-brand);
    font-weight: 800;
    font-size: 20px;
    color: var(--md-sys-color-primary);
    letter-spacing: -1px;
    white-space: nowrap;
    transition: var(--transition-smooth);
}

.sidebar.collapsed .logo-text { opacity: 0; width: 0; pointer-events: none; }

.nav-item-m3 {
    margin: 4px 12px;
    padding: 12px 16px;
    border-radius: 100px;
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    transition: var(--transition-snappy);
    font-size: 14px;
    height: 56px;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item-m3:hover { background: #F4F0F7; color: var(--md-sys-color-primary); }

.nav-item-m3.active {
    background: var(--md-sys-color-primary-container) !important;
    color: var(--md-sys-color-on-primary-container) !important;
    font-weight: 800;
}

.nav-item-m3 .material-symbols-rounded { font-size: 24px; min-width: 24px; }
.nav-item-m3.active .material-symbols-rounded { font-variation-settings: 'FILL' 1; }

.sidebar.collapsed .nav-item-m3 { justify-content: center; padding: 12px; margin: 4px 16px; }
.sidebar.collapsed .nav-item-m3 span:not(.material-symbols-rounded) { display: none; }

/* Mobile Navigation */
.mobile-header {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 64px;
    background: #FFF;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding: 0 24px;
    align-items: center;
    justify-content: space-between;
    z-index: 900;
}

.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 80px;
    background: #FFF;
    border-top: 1px solid rgba(0,0,0,0.05);
    padding: 12px 0;
    justify-content: space-around;
    z-index: 1000;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
}

@media (max-width: 1024px) {
    .mobile-header, .mobile-nav { display: flex; }
    .mobile-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        color: var(--md-sys-color-on-surface-variant);
        text-decoration: none;
        font-size: 11px;
        font-weight: 700;
        flex: 1;
    }
    .mobile-nav a.active { color: var(--md-sys-color-primary); }
    .mobile-nav a .material-symbols-rounded { font-size: 24px; }
    .mobile-nav a.active .material-symbols-rounded { font-variation-settings: 'FILL' 1; }
}

/* Card System */
.premium-card, .card, .lead-card, .doc-card, .analytics-card {
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.02);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--premium-shadow-md);
    transition: var(--transition-smooth);
}

.premium-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--premium-shadow-lg);
}

/* Stat Cards */
.stat-card-mini {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
    background: #FFFFFF;
    border-radius: 28px;
    border: 1px solid rgba(0, 0, 0, 0.02);
    box-shadow: var(--premium-shadow-sm);
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.5s ease forwards; }

.mesh-gradient {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at 10% 20%, rgba(103, 80, 164, 0.05) 0%, transparent 40%),
                radial-gradient(circle at 90% 80%, rgba(103, 80, 164, 0.05) 0%, transparent 40%);
    pointer-events: none;
    z-index: -1;
}

/* Navigation Pills */
.nav-pill-group {
    display: flex;
    gap: 12px;
    margin-bottom: 32px;
    overflow-x: auto;
    padding: 4px;
    scrollbar-width: none;
}
.nav-pill-group::-webkit-scrollbar { display: none; }

.nav-pill {
    padding: 10px 24px;
    background: #FFF;
    border-radius: 100px;
    border: 1px solid var(--md-sys-color-outline-variant);
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 700;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
    transition: var(--transition-snappy);
}

.nav-pill.active {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border-color: var(--md-sys-color-primary);
}

/* Modern Inputs */
.m3-field { margin-bottom: 24px; }
.m3-field label { 
    display: block; 
    font-size: 11px; 
    font-weight: 800; 
    color: var(--md-sys-color-primary); 
    margin-bottom: 8px; 
    text-transform: uppercase;
    letter-spacing: 1px;
}

.m3-input-wrapper {
    background: #FFF;
    border: 1.5px solid rgba(0,0,0,0.05);
    border-radius: 20px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    transition: var(--transition-snappy);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.m3-input-wrapper:focus-within {
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 4px rgba(103, 80, 164, 0.1);
}

.m3-input-wrapper input, .m3-input-wrapper textarea {
    width: 100%;
    padding: 16px 0;
    border: none;
    background: transparent;
    font-family: var(--font-plain);
    font-size: 15px;
    font-weight: 600;
    outline: none;
}

/* Dark Mode Overrides */
body.dark-mode {
    --md-sys-color-surface: #141218;
    --md-sys-color-surface-variant: #211F26;
    --md-sys-color-on-surface: #E6E0E9;
    --md-sys-color-on-surface-variant: #CAC4D0;
    --md-sys-color-outline: #938F99;
    --md-sys-color-outline-variant: #49454F;
    --md-sys-color-primary-container: #4F378B;
    --md-sys-color-on-primary-container: #EADDFF;
    color-scheme: dark;
}

body.dark-mode .sidebar, 
body.dark-mode .mobile-header, 
body.dark-mode .mobile-nav,
body.dark-mode .premium-card, 
body.dark-mode .card, 
body.dark-mode .lead-card, 
body.dark-mode .doc-card, 
body.dark-mode .analytics-card,
body.dark-mode .stat-card-mini,
body.dark-mode .limit-meter,
body.dark-mode .upload-section {
    background: var(--md-sys-color-surface-variant);
    border-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

body.dark-mode .m3-input-wrapper,
body.dark-mode .photo-identity-wrap,
body.dark-mode .layout-option {
    background: #2B2930;
    border-color: rgba(255,255,255,0.05);
    color: var(--md-sys-color-on-surface);
}

body.dark-mode .m3-input-wrapper input, 
body.dark-mode .m3-input-wrapper textarea {
    color: var(--md-sys-color-on-surface);
}

body.dark-mode .nav-item-m3:hover {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-mode .nav-item-m3.active {
    background: var(--md-sys-color-primary-container) !important;
    color: var(--md-sys-color-on-primary-container) !important;
}

body.dark-mode .mesh-gradient {
    opacity: 0.1;
}
