/* === CONSOLIDATED DASHBOARD CSS === */

/* --- CSS VARIABLES --- */
:root {
    /* Modern Color Palette */
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --text: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --bg: #ffffff;
    --bg-card: #f9fafb;
    --bg-secondary: #f3f4f6;
    --sidebar-bg: #f8fafc;
    --sidebar-border: #e2e8f0;
    --border-color: #e5e7eb;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Hard Corners */
    --radius: 2px;
    --radius-lg: 4px;
    --radius-xl: 6px;
    --border: 1px solid var(--border-color);
    --border-light: 1px solid #f1f5f9;
    
    /* Clean Shadows */
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-xl: 0 10px 15px rgba(0, 0, 0, 0.1);
    
    /* Subtle Magic */
    --magic-gradient: linear-gradient(135deg, rgba(59, 130, 246, 0.015), rgba(147, 51, 234, 0.015), rgba(236, 72, 153, 0.015));
    
    /* Layout */
    --sidebar-width: 280px;
    --header-height: 60px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    position: relative;
    overflow-x: hidden;
}

/* Subtle Magic Background Element */
.magic-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 5%;
    height: 100vh;
    background: var(--magic-gradient);
    z-index: -1;
    opacity: 0.6;
    animation: magicShift 15s ease-in-out infinite;
}

@keyframes magicShift {
    0%, 100% { 
        background: linear-gradient(180deg, rgba(147, 51, 234, 0.03), rgba(59, 130, 246, 0.03));
    }
    33% { 
        background: linear-gradient(180deg, rgba(59, 130, 246, 0.03), rgba(236, 72, 153, 0.03));
    }
    66% { 
        background: linear-gradient(180deg, rgba(236, 72, 153, 0.03), rgba(147, 51, 234, 0.03));
    }
}

/* Dashboard Layout */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
    margin-top: var(--header-height);
}

/* Sidebar */
.dashboard-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    padding: var(--space-lg);
    position: fixed;
    top: var(--header-height);
    left: 0;
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    z-index: 10;
}

.sidebar-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.nav-item:hover {
    background: rgba(0, 122, 255, 0.08);
    color: var(--primary);
}

.nav-item.active {
    background: rgba(37, 99, 235, 0.15);
    color: var(--primary-dark);
    font-weight: 600;
    box-shadow: var(--shadow);
    border: 1px solid var(--primary);
}

.nav-item.active .nav-item-icon {
    color: var(--primary-dark);
}

.nav-item.active svg {
    stroke: var(--primary-dark);
    stroke-width: 2.5;
}

.nav-item.active span {
    color: var(--primary-dark);
}

.nav-item-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Main Content */
.dashboard-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--space-xl);
    min-height: calc(100vh - var(--header-height));
}

.main-content-area {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    min-height: 600px;
}


/* Documentation Styles */
.documentation-view {
    max-width: 900px;
    margin: 0 auto;
}

.documentation-content {
    font-size: 0.95rem;
    line-height: 1.8;
}

.documentation-content h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--space-lg);
    color: var(--primary);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: var(--space-md);
}

.documentation-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: var(--space-2xl);
    margin-bottom: var(--space-md);
    color: var(--text);
}

.documentation-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: var(--space-xl);
    margin-bottom: var(--space-md);
    color: var(--text);
}

.documentation-content p {
    margin-bottom: var(--space-md);
    color: var(--text-secondary);
}

.documentation-content ul {
    margin-bottom: var(--space-md);
    padding-left: var(--space-xl);
}

.documentation-content li {
    margin-bottom: var(--space-sm);
    color: var(--text-secondary);
}

.documentation-content strong {
    font-weight: 600;
    color: var(--text);
}

.documentation-content code {
    background: var(--bg-secondary);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius);
    font-family: monospace;
    font-size: 0.875em;
    color: var(--primary);
}

.documentation-content hr {
    margin: var(--space-2xl) 0;
    border: none;
    border-top: 1px solid var(--border-color);
}

/* --- COMPONENT CLASSES --- */

/* Cards */
.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    border: var(--border);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.card-magic {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    border: var(--border);
    box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    position: relative;
    overflow: hidden;
}

.card-magic::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    background: var(--magic-border);
    background-size: 300% 300%;
    border-radius: var(--radius-lg);
    z-index: -1;
    animation: borderShift 15s ease-in-out infinite;
    opacity: 0.6;
}

@keyframes borderShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Buttons */
.btn {
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    padding: var(--space-sm) var(--space-lg);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.btn-secondary {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text);
    border: var(--border-light);
    padding: var(--space-sm) var(--space-lg);
}

.btn-secondary:hover {
    background: rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: var(--space-sm) var(--space-md);
}

.btn-ghost:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text);
}

.btn-ghost.active {
    background: var(--primary);
    color: white;
}

/* Status Elements */
.status {
    padding: var(--space-xs) var(--space-sm);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-success { background: var(--success); color: white; }
.status-warning { background: var(--warning); color: white; }
.status-error { background: var(--error); color: white; }

/* Text Styles */
.text-primary { color: var(--text); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }

/* Spacing */
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.p-xl { padding: var(--space-xl); }

.m-sm { margin: var(--space-sm); }
.m-md { margin: var(--space-md); }
.m-lg { margin: var(--space-lg); }
.m-xl { margin: var(--space-xl); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

.pt-xl { padding-top: var(--space-xl); }

.text-center { text-align: center; }

/* Layout */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* --- SPECIFIC COMPONENTS --- */

/* Header */
.header {
    background: rgba(248, 249, 250, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: var(--border);
    padding: var(--space-sm) var(--space-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

/* Logo styles now come from /.public/styles/components/navigation.css */

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: rgba(0, 0, 0, 0.04);
    padding: var(--space-sm) var(--space-md);
    border-radius: 20px;
    border: var(--border-light);
}

.user-email {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-right: var(--space-xs);
}

.logout-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.375rem 0.875rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.logout-btn:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

.logout-btn:active {
    transform: translateY(1px);
}

/* Layout */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-xl);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: calc(100vh - 100px);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: var(--space-xl);
    width: 100%;
    max-width: 1200px;
    align-items: start;
}

.main-card {
    min-height: 600px;
    display: flex;
    flex-direction: column;
}

/* Sidebar */
.module-sidebar {
    position: sticky;
    top: var(--space-xl);
    height: fit-content;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.sidebar-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: var(--border);
}

.module-navigation {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.module-btn {
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.module-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

/* Hero */
.hero-section {
    text-align: center;
    padding: var(--space-sm) 0;
    margin-bottom: var(--space-md);
}

.hero-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--space-xs);
    letter-spacing: -0.02em;
}

.hero-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto var(--space-md);
}


/* Loading */
.loading {
    text-align: center;
    padding: 6rem var(--space-xl);
    color: white;
}

.loading h2 {
    font-size: clamp(2rem, 4vw, 3rem);
    margin-bottom: var(--space-lg);
    background: linear-gradient(135deg, var(--primary), var(--success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
}

.spinner {
    width: 60px !important;
    height: 60px !important;
    border: 4px solid rgba(255,255,255,0.1);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: var(--space-xl) auto;
    display: block;
    flex-shrink: 0;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Forms */
.input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.15);
}

/* === RESPONSIVE DESIGN === */

/* Mobile First Approach - Base styles for mobile, then scale up */

/* Extra Small Devices (320px and up) */
@media (max-width: 480px) {
    :root {
        --space-xs: 0.25rem;
        --space-sm: 0.5rem;
        --space-md: 0.75rem;
        --space-lg: 1rem;
        --space-xl: 1.25rem;
        --space-2xl: 1.5rem;
        --sidebar-width: 100%;
        --header-height: 60px;
    }
    
    /* Mobile Login Optimizations */
    .login-container {
        padding: var(--space-md);
        min-height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .login-card, .card-magic {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: var(--space-xl);
        box-shadow: none;
        border: none;
        background: rgba(255, 255, 255, 0.95);
    }
    
    .modal-content {
        width: 95%;
        max-width: 350px;
        padding: var(--space-xl);
        margin: var(--space-md);
    }
    
    /* Mobile Form Elements */
    .input, .modal-input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: var(--space-md);
        min-height: 44px; /* Touch target minimum */
        border-radius: var(--radius-lg);
    }
    
    .btn {
        min-height: 44px; /* Touch target minimum */
        padding: var(--space-md) var(--space-lg);
        font-size: 1rem;
    }
    
    .btn-primary, .modal-button {
        width: 100%;
        margin-top: var(--space-md);
    }
    
    /* Typography scaling */
    .hero-title {
        font-size: 1.75rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.125rem; }
}

/* Small Devices (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .login-card, .card-magic {
        max-width: 400px;
        margin: var(--space-xl) auto;
    }
}

/* Tablet and Mobile Responsive (768px and below) */
@media (max-width: 768px) {
    /* Dashboard Layout Mobile Fixes */
    .dashboard-layout {
        margin-top: 60px;
    }
    
    /* Mobile Sidebar - Transform to Overlay */
    .dashboard-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 280px;
        height: 100vh;
        z-index: 200;
        background: var(--sidebar-bg);
        transition: left 0.3s ease;
        padding-top: 60px;
        box-shadow: var(--shadow-xl);
    }
    
    .dashboard-sidebar.open {
        left: 0;
    }
    
    /* Mobile Sidebar Backdrop */
    .sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 150;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .sidebar-backdrop.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Main Content Mobile Adjustments */
    .dashboard-main {
        margin-left: 0;
        padding: var(--space-md);
        width: 100%;
    }
    
    .main-content-area {
        padding: var(--space-lg);
        margin: 0;
    }
    
    /* === MOBILE HEADER REDESIGN === */
    .mobile-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: var(--bg);
        border-bottom: 1px solid var(--border-color);
        padding: 0 var(--space-md);
        z-index: 1000;
        display: flex;
        flex-direction: column;
    }
    
    .mobile-header-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 60px;
        width: 100%;
    }
    
    /* Mobile Menu Button */
    .mobile-menu-btn {
        background: none;
        border: none;
        padding: 8px;
        cursor: pointer;
        color: var(--text);
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: var(--radius);
        transition: background 0.2s ease;
    }
    
    .mobile-menu-btn:active {
        background: var(--bg-secondary);
    }
    
    /* Mobile Logo */
    .mobile-logo {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        align-items: center;
    }
    
    /* Mobile User Section */
    .mobile-user-section {
        display: flex;
        align-items: center;
        gap: var(--space-sm);
    }
    
    /* Mobile Status Dot */
    .mobile-status-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        display: inline-block;
    }
    
    .mobile-status-dot.status-active {
        background: var(--success);
    }
    
    .mobile-status-dot.status-inactive {
        background: var(--error);
    }
    
    /* Mobile User Button */
    .mobile-user-btn {
        background: none;
        border: none;
        padding: 8px;
        cursor: pointer;
        color: var(--text);
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: var(--radius);
        transition: background 0.2s ease;
    }
    
    .mobile-user-btn:active {
        background: var(--bg-secondary);
    }
    
    /* Mobile User Dropdown */
    .mobile-user-dropdown {
        position: absolute;
        top: 100%;
        right: var(--space-md);
        background: var(--bg);
        border: 1px solid var(--border-color);
        border-radius: var(--radius);
        box-shadow: var(--shadow-xl);
        min-width: 280px;
        z-index: 1001;
        animation: slideDown 0.2s ease;
    }
    
    .dropdown-header {
        padding: var(--space-md);
        border-bottom: 1px solid var(--border-color);
    }
    
    .dropdown-header #user-email-full {
        display: block;
        font-size: 0.875rem;
        color: var(--text-secondary);
        margin-bottom: var(--space-sm);
        word-break: break-all;
    }
    
    .logout-btn-mobile {
        display: flex;
        align-items: center;
        gap: var(--space-sm);
        width: 100%;
        padding: var(--space-sm) var(--space-md);
        background: none;
        border: 1px solid var(--border-color);
        border-radius: var(--radius);
        color: var(--text);
        font-size: 0.875rem;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    
    .logout-btn-mobile:hover {
        background: var(--error);
        color: white;
        border-color: var(--error);
    }
    
    .dropdown-site-info {
        padding: var(--space-md);
    }
    
    .dropdown-site-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: var(--space-sm);
        font-size: 0.875rem;
    }
    
    .site-label {
        color: var(--text-secondary);
        font-weight: 500;
    }
    
    .site-link {
        color: var(--primary);
        text-decoration: none;
        font-weight: 500;
    }
    
    .site-link:hover {
        text-decoration: underline;
    }
    
    .site-status {
        font-weight: 600;
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .site-status.status-active {
        color: var(--success);
    }
    
    .site-status.status-inactive {
        color: var(--error);
    }
    
    .no-site-selected {
        color: var(--text-muted);
        font-style: italic;
        font-size: 0.875rem;
    }
    
    .mobile-unfocus-btn {
        display: flex;
        align-items: center;
        gap: var(--space-sm);
        width: 100%;
        padding: var(--space-sm) var(--space-md);
        margin-top: var(--space-md);
        background: none;
        border: 1px solid var(--border-color);
        border-radius: var(--radius);
        color: var(--text-secondary);
        font-size: 0.875rem;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    
    .mobile-unfocus-btn:hover {
        background: var(--bg-secondary);
        color: var(--text);
        border-color: var(--primary);
    }
    
    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    /* Navigation Mobile Optimizations */
    .sidebar-nav {
        padding-top: var(--space-md);
    }
    
    .nav-item {
        padding: var(--space-lg) var(--space-md);
        margin-bottom: var(--space-xs);
        font-size: 1rem;
        min-height: 44px; /* Touch target */
    }
    
    .nav-item-icon {
        width: 24px;
        height: 24px;
    }
    
    /* Grid and Layout Mobile */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }
    
    .module-sidebar {
        position: relative;
        top: 0;
        order: -1;
        max-height: none;
    }
    
    .module-navigation {
        flex-direction: row;
        overflow-x: auto;
        gap: var(--space-xs);
        padding-bottom: var(--space-sm);
        -webkit-overflow-scrolling: touch;
    }
    
    .module-btn {
        flex-shrink: 0;
        white-space: nowrap;
        min-width: 120px;
        justify-content: center;
        min-height: 44px;
    }
    
    .container {
        padding: var(--space-md);
    }
    
    .grid-2, .grid-3, .grid-auto {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }
    
    
    /* Documentation Mobile */
    .documentation-view {
        max-width: 100%;
        padding: 0;
    }
    
    .documentation-content {
        font-size: 0.9rem;
        line-height: 1.6;
    }
    
    .documentation-content h1 {
        font-size: 1.5rem;
    }
    
    .documentation-content h2 {
        font-size: 1.25rem;
    }
    
    .documentation-content h3 {
        font-size: 1.125rem;
    }
    
    /* Form Elements Mobile */
    .modal-form {
        margin-bottom: var(--space-lg);
    }
    
    .modal-input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: var(--space-md);
        margin-bottom: var(--space-md);
    }
    
    .modal-button {
        padding: var(--space-md) var(--space-lg);
        font-size: 1rem;
        min-height: 44px;
    }
    
    /* Loading Mobile */
    .loading {
        padding: 3rem var(--space-md);
    }
    
    .loading h2 {
        font-size: clamp(1.5rem, 6vw, 2.5rem);
        margin-bottom: var(--space-md);
    }
    
    .spinner {
        width: 50px;
        height: 50px;
        margin: var(--space-lg) auto;
    }
    
    /* Cards Mobile */
    .card, .card-magic {
        margin: var(--space-sm) 0;
        border-radius: var(--radius);
    }
    
    /* Utilities Mobile */
    .p-xl { padding: var(--space-lg); }
    .m-xl { margin: var(--space-lg); }
    .mb-xl { margin-bottom: var(--space-lg); }
    .mt-xl { margin-top: var(--space-lg); }
}

/* Large Mobile/Small Tablet (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .dashboard-sidebar {
        width: 240px;
    }
    
    .dashboard-main {
        margin-left: 240px;
    }
    
    .user-info .user-email {
        display: inline; /* Show email on larger screens */
    }
}

/* Desktop Responsive Utilities */
@media (min-width: 1025px) {
    .mobile-menu-toggle,
    .mobile-header,
    .mobile-user-dropdown,
    .mobile-menu-btn,
    .mobile-user-btn,
    .mobile-status-dot {
        display: none !important;
    }
    
    .sidebar-backdrop {
        display: none;
    }
    
    .dashboard-sidebar {
        position: fixed;
        left: 0;
        transition: none;
    }
}

/* === MOBILE TOUCH OPTIMIZATIONS === */

/* Improve touch targets across the board */
@media (max-width: 768px) {
    /* Ensure all clickable elements meet 44px minimum */
    button, .btn, .nav-item, .module-btn, 
    input[type="submit"], input[type="button"], 
    a.btn, .logout-btn {
        min-height: 44px;
        min-width: 44px;
        padding: var(--space-sm) var(--space-md);
    }
    
    /* Improve form field usability */
    input, textarea, select {
        font-size: 16px; /* Prevents iOS zoom */
        padding: var(--space-md);
        border-radius: var(--radius-lg);
        border: 2px solid var(--border-color);
        background: white;
        transition: border-color 0.2s ease;
    }
    
    input:focus, textarea:focus, select:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
        outline: none;
    }
    
    /* Improve mobile scrolling */
    .dashboard-main, .main-content-area, .sidebar-nav {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Better tap highlighting */
    .nav-item, .btn, button, .module-btn {
        -webkit-tap-highlight-color: rgba(37, 99, 235, 0.1);
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Improve modal mobile experience */
    .modal-overlay {
        padding: var(--space-md);
        align-items: flex-start;
        padding-top: 20vh;
    }
    
    .modal-content {
        width: 100%;
        max-width: none;
        margin: 0;
        max-height: 70vh;
        overflow-y: auto;
    }
    
    /* Better mobile loading experience */
    .loading {
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }
    
    /* Improve login mobile experience */
    .login-container .card-magic {
        border-radius: var(--radius-lg);
        backdrop-filter: none;
        background: white;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    }
    
    /* Better mobile typography */
    .documentation-content p,
    .documentation-content li {
        line-height: 1.7;
        font-size: 0.95rem;
    }
    
    /* Smooth mobile animations */
    .nav-item, .btn, .module-btn {
        transition: all 0.2s ease;
    }
    
    /* Improve mobile cards */
    .card, .card-magic {
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        border: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    /* Mobile-specific utilities */
    .text-mobile-center { text-align: center; }
    .hide-on-mobile { display: none !important; }
    .show-on-mobile { display: block !important; }
}

/* === TABLE STYLES === */

/* Base table styling */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem;
    padding: 0 1rem;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table thead {
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border-color);
}

.table th {
    text-align: left;
    padding: var(--space-md) var(--space-lg);
    font-weight: 600;
    color: var(--text);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background-color 0.2s ease;
}

.table tbody tr:hover {
    background-color: var(--bg-secondary);
}

.table td {
    padding: var(--space-md) var(--space-lg);
    color: var(--text);
    vertical-align: middle;
}

/* Payment table specific styles */
.payment-history-section .table {
    min-width: 800px;
}

.payment-history-section .table th:first-child,
.payment-history-section .table td:first-child {
    width: 120px;
}

.payment-history-section .table th:nth-child(2),
.payment-history-section .table td:nth-child(2) {
    width: 160px;
}

.payment-history-section .table th:nth-child(3),
.payment-history-section .table td:nth-child(3) {
    width: auto;
    min-width: 180px;
}

.payment-history-section .table th:nth-child(4),
.payment-history-section .table td:nth-child(4) {
    width: 100px;
    text-align: right;
}

.payment-history-section .table th:nth-child(5),
.payment-history-section .table td:nth-child(5) {
    width: 90px;
    text-align: center;
}

.payment-history-section .table th:nth-child(6),
.payment-history-section .table td:nth-child(6) {
    width: 120px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Amount styling */
.amount {
    font-weight: 600;
    font-size: 0.95rem;
}

.amount.refunded {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* Enhanced badge styles */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    border-radius: var(--radius);
    white-space: nowrap;
}

.badge-success {
    background-color: rgba(16, 185, 129, 0.1);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-secondary {
    background-color: rgba(107, 114, 128, 0.1);
    color: #6b7280;
    border: 1px solid rgba(107, 114, 128, 0.2);
}

/* Table controls */
.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    gap: var(--space-md);
    flex-wrap: wrap;
}

.table-filter {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    flex: 1;
    min-width: 200px;
}

.table-filter input {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.table-sort {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.table-sort select {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background-color: white;
    cursor: pointer;
}

/* Empty state */
.table-empty {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-muted);
}

.table-empty i {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

/* Additional utility classes for tables */
.text-sm {
    font-size: 0.875rem;
}

.font-medium {
    font-weight: 500;
}

/* Responsive table */
@media (max-width: 768px) {
    .table-container {
        margin: 0 -0.5rem;
        padding: 0 0.5rem;
    }
    
    .table {
        font-size: 0.8rem;
    }
    
    .table th,
    .table td {
        padding: var(--space-sm) var(--space-md);
    }
    
    .payment-history-section .table {
        min-width: 700px;
    }
    
    .table-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .table-filter,
    .table-sort {
        width: 100%;
    }
}

/* === SPINNER AND GENERATION INDICATORS === */

/* Large spinner for generation status card */
.spinner-wrapper {
    width: 48px;
    height: 48px;
    position: relative;
}

.spinner {
    width: 100%;
    height: 100%;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Small spinner for inline indicators */
.spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Generation indicator styles */
.generation-indicator {
    padding: var(--space-sm) var(--space-md);
    background-color: rgba(37, 99, 235, 0.05);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: var(--radius);
}

/* Highlighted card for active generation */
.card-highlight {
    border: 2px solid var(--primary);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.02), rgba(37, 99, 235, 0.05));
}

/* Additional utility classes for generation display */
.d-flex {
    display: flex;
}

.align-items-center {
    align-items: center;
}

.gap-md {
    gap: var(--space-md);
}

.flex-grow-1 {
    flex-grow: 1;
}

.mb-0 {
    margin-bottom: 0;
}

.mt-sm {
    margin-top: var(--space-sm);
}

/* === ACCESSIBILITY IMPROVEMENTS === */

/* Focus management for keyboard navigation */
.nav-item:focus,
.btn:focus,
button:focus,
.mobile-menu-toggle:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .dashboard-sidebar {
        border-right: 2px solid var(--text);
    }
    
    .nav-item {
        border: 1px solid var(--text);
    }
    
    .btn-primary {
        border: 2px solid var(--primary-dark);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .dashboard-sidebar,
    .sidebar-backdrop,
    .hamburger span,
    .nav-item,
    .btn,
    .magic-hover {
        transition: none !important;
        animation: none !important;
    }
    
    .magic-background {
        display: none;
    }
}

/* Dark mode preparation (for future implementation) */
@media (prefers-color-scheme: dark) {
    /* Dark mode styles would go here if implemented */
}

/* === MOBILE LANDSCAPE OPTIMIZATIONS === */
@media (max-width: 768px) and (orientation: landscape) {
    .dashboard-layout {
        margin-top: calc(var(--header-height) - 10px);
    }
    
    .header {
        height: calc(var(--header-height) - 10px);
        padding: var(--space-xs) var(--space-md);
    }
    
    
    .loading {
        padding: 2rem var(--space-md);
    }
    
    .modal-overlay {
        padding-top: 10vh;
    }
}

/* === ULTRA SMALL SCREENS (320px and below) === */
@media (max-width: 320px) {
    .logo {
        font-size: 0.9rem;
    }
    
    .mobile-menu-toggle span {
        font-size: 0.875rem;
    }
    
    .nav-item {
        padding: var(--space-md) var(--space-sm);
        font-size: 0.9rem;
    }
    
}

/* === SAFE AREA INSETS (for devices with notches) === */
@supports (padding: max(0px)) {
    .dashboard-layout {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    .header {
        padding-left: max(var(--space-md), env(safe-area-inset-left));
        padding-right: max(var(--space-md), env(safe-area-inset-right));
        padding-top: max(var(--space-sm), env(safe-area-inset-top));
    }
    
    .dashboard-sidebar {
        padding-left: max(var(--space-lg), env(safe-area-inset-left));
    }
}

/* Utilities */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Magic Hover Effects */
.magic-hover {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.magic-hover::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.6s;
}

.magic-hover:hover::before {
    left: 100%;
}

.magic-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

/* --- MODAL STYLES --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.modal-title {
    margin-bottom: 15px;
    color: #1f2937;
    font-size: 1.5rem;
    font-weight: 600;
}

.modal-title.error-title {
    color: #ef4444;
}

.modal-description {
    color: #6b7280;
    margin-bottom: 25px;
    line-height: 1.6;
}

.modal-form {
    margin-bottom: 20px;
}

.modal-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 16px;
    margin-bottom: 15px;
    transition: border-color 0.2s ease;
}

.modal-input:focus {
    outline: none;
    border-color: var(--primary);
}

.modal-button {
    width: 100%;
    font-size: 16px;
    padding: 12px 24px;
}

/* Login Form Specific Styles */
.login-card {
    max-width: 400px;
    margin: 80px auto;
}

.login-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1.5rem;
}

.login-icon .icon-large {
    width: 48px;
    height: 48px;
}

/* Login Container for fallback */
.login-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a2e;
    z-index: 9999;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

/* Email Messages */
.email-sent-success {
    color: #10b981;
    text-align: center;
    font-size: 14px;
    line-height: 1.5;
}

/* === CHECKOUT DIALOG STYLES === */

/* Enhanced modal styles for checkout dialogs */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}

.modal {
    background: var(--background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.btn-close {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    color: var(--text-primary);
}

/* Form styles for checkout dialogs */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--background);
    color: var(--text-primary);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-text {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Alert styles for payment info */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    gap: 0.75rem;
}

.alert-info {
    background: rgba(37, 99, 235, 0.05);
    border: 1px solid rgba(37, 99, 235, 0.2);
    color: var(--primary);
}

.alert-warning {
    background: rgba(251, 191, 36, 0.05);
    border: 1px solid rgba(251, 191, 36, 0.2);
    color: #d97706;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #dc2626;
}

.alert-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

/* Price display styles */
.text-strike {
    text-decoration: line-through;
    opacity: 0.6;
}

/* Loader animation for buttons */
.animate-spin {
    animation: spin 1s linear infinite;
}

/* Dialog-specific error styling */
.dialog-error {
    animation: shake 0.3s ease-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Checkout Dialog Styles */
.checkout-content {
    padding: 0;
}

.operation-details {
    margin-bottom: 1.5rem;
}

.plan-comparison {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

.current-plan, .new-plan {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    text-align: center;
}

.new-plan {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

.plan-name {
    font-weight: 600;
    color: var(--text-primary);
    margin: 0.5rem 0;
}

.plan-cost {
    font-size: 1.25rem;
    color: var(--primary);
    margin: 0.25rem 0;
}

.plan-total {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.plan-savings {
    color: var(--success);
    font-weight: 600;
}

.arrow {
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.info-message, .warning-message {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius);
    margin-top: 1rem;
}

.info-message {
    background: rgba(37, 99, 235, 0.1);
    border: 1px solid rgba(37, 99, 235, 0.2);
    color: var(--primary);
}

.warning-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.takeout-info ul {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.takeout-info li {
    margin: 0.5rem 0;
    color: var(--text-secondary);
}

.free-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius);
    color: var(--success);
    margin-top: 1rem;
}

.pricing {
    text-align: center;
    margin-top: 1rem;
}

.price {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

.price-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.credits-info .current-balance {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--background-secondary);
    border-radius: var(--radius);
    margin: 1rem 0;
}

.credit-pricing {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
}

.credit-option {
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    text-align: center;
    transition: all 0.2s;
}

.credit-option:hover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

.credit-amount {
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.credit-price {
    font-size: 1.5rem;
    color: var(--primary);
    font-weight: 700;
    margin: 0.5rem 0;
}

.credit-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.payment-info {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.stripe-notice, .saved-payment {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Spinner for loading state */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.6s linear infinite;
}

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