/* ==========================================
   MODERN CSS FRAMEWORK FOR FASTAPI SITE
   ========================================== */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette */
    --primary-color: #5e72e4;
    --primary-dark: #4c63d2;
    --primary-light: #8896ff;
    --secondary-color: #f4f5f7;
    --accent-color: #11cdef;
    --success-color: #2dce89;
    --warning-color: #fb6340;
    --danger-color: #f5365c;
    
    /* Text Colors */
    --text-primary: #32325d;
    --text-secondary: #8898aa;
    --text-light: #adb5bd;
    --text-white: #ffffff;
    
    /* Background Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --bg-dark: #172b4d;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(50, 50, 93, 0.15), 0 1px 0 rgba(0, 0, 0, 0.02);
    --shadow-md: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 15px 35px rgba(50, 50, 93, 0.1), 0 5px 15px rgba(0, 0, 0, 0.07);
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-xxl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 1rem;
    
    /* Transitions */
    --transition-base: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

h1 { 
    font-size: 2.5rem; 
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition-base);
}

a:hover {
    color: var(--primary-dark);
}

/* Layout Components */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

.container-fluid {
    width: 100%;
    padding: 0 var(--spacing-lg);
}

/* Top Bar */
.topbar {
    background: var(--bg-primary);
    box-shadow: var(--shadow-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    height: 70px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.topbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    /* Removed margin-left: 260px; */
}

.topbar-brand:hover {
    color: var(--primary-color);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.user-info {
    color: var(--text-secondary);
    font-size: 0.875rem;
    padding: var(--spacing-xs) var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

/* Sidebar Navigation */
.sidebar {
    position: fixed;
    left: 0;
    top: 70px; /* Below topbar */
    bottom: 0;
    width: 250px;
    background: var(--bg-primary);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    overflow-y: auto;
    border-right: 1px solid var(--bg-secondary);
}

.sidebar-content {
    padding: var(--spacing-lg);
}

.sidebar-section {
    margin-bottom: var(--spacing-xl);
}

.sidebar-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-light);
    margin-bottom: var(--spacing-md);
    padding-left: var(--spacing-sm);
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-item {
    margin-bottom: var(--spacing-xs);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-weight: 500;
    transition: var(--transition-base);
    position: relative;
    overflow: hidden;
}

.sidebar-link:hover {
    background: var(--bg-secondary);
    color: var(--primary-color);
    transform: translateX(5px);
}

.sidebar-link.active {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: var(--text-white);
}

.sidebar-link.active:hover {
    transform: translateX(0);
}

.sidebar-icon {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

/* Premium/Locked items styling */
.sidebar-link.locked {
    opacity: 0.5;
    cursor: not-allowed;
    position: relative;
}

.sidebar-link.locked:hover {
    background: transparent;
    transform: translateX(0);
    color: var(--text-secondary);
}

.sidebar-link.locked::after {
    content: '🔒';
    position: absolute;
    right: var(--spacing-md);
    font-size: 0.875rem;
}

.sidebar-badge {
    margin-left: auto;
    font-size: 0.625rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    color: var(--text-white);
    font-weight: 600;
    text-transform: uppercase;
}

/* Main Content Area */
.main-layout {
    display: flex;
    min-height: 100vh;
    padding-top: 70px; /* Space for topbar */
}

.main-content {
    flex: 1;
    margin-left: 250px; /* Space for sidebar */
    background: var(--bg-secondary);
    min-height: calc(100vh - 70px);
}

/* Hero Section */
.hero {
    padding: var(--spacing-xxl) 0;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, var(--primary-light) 0%, transparent 70%);
    opacity: 0.1;
    animation: rotate 30s linear infinite;
}

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

.hero-content {
    position: relative;
    z-index: 1;
}

.hero h1 {
    margin-bottom: var(--spacing-lg);
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xl);
}

/* Cards */
.card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-lg);
    transition: var(--transition-base);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card:hover::before {
    transform: scaleX(1);
}

.card-header {
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 2px solid var(--bg-secondary);
}

.card-title {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-sm);
}

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

.card-body {
    color: var(--text-secondary);
}

.card-footer {
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--bg-secondary);
}

/* Grid System */
.grid {
    display: grid;
    gap: var(--spacing-lg);
}

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

/* Sections */
.section {
    padding: var(--spacing-xxl) 0;
}

.section-header {
    text-align: center;
    margin-bottom: var(--spacing-xxl);
}

.section-title {
    font-size: 2rem;
    margin-bottom: var(--spacing-md);
}

.section-subtitle {
    color: var(--text-secondary);
    font-size: 1.125rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-md);
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-base);
    border: none;
    font-size: 1rem;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: var(--text-white);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-primary);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: var(--text-white);
}

.btn-lg {
    padding: var(--spacing-md) var(--spacing-xl);
    font-size: 1.125rem;
}

.btn-sm {
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: 0.875rem;
}

.btn-group {
    display: flex;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

/* Features List */
.features-list {
    list-style: none;
    padding: 0;
}

.feature-item {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    padding: var(--spacing-md) 0;
    border-bottom: 1px solid var(--bg-secondary);
    transition: var(--transition-base);
}

.feature-item:hover {
    transform: translateX(5px);
}

.feature-item:last-child {
    border-bottom: none;
}

.feature-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-white);
    flex-shrink: 0;
}

.feature-content h3 {
    font-size: 1.125rem;
    margin-bottom: var(--spacing-xs);
}

.feature-content p {
    color: var(--text-secondary);
    margin: 0;
}

/* Badges */
.badge {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-primary {
    background: var(--primary-color);
    color: var(--text-white);
}

.badge-success {
    background: var(--success-color);
    color: var(--text-white);
}

.badge-warning {
    background: var(--warning-color);
    color: var(--text-white);
}

/* Footer */
.footer {
    background: var(--bg-dark);
    color: var(--text-light);
    padding: var(--spacing-xl) 0;
    margin-top: auto;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-lg);
}

.footer-section h4 {
    color: var(--text-white);
    margin-bottom: var(--spacing-md);
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: var(--spacing-sm);
}

.footer-links a {
    color: var(--text-light);
}

.footer-links a:hover {
    color: var(--text-white);
}

.footer-bottom {
    text-align: center;
    padding-top: var(--spacing-lg);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-light);
}

/* Authentication State Classes */
.authenticated-only { 
    display: none !important; 
}

.public-only { 
    display: block; 
}

.auth-content .authenticated-only { 
    display: block !important; 
}

.auth-content .public-only { 
    display: none !important; 
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

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

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

.p-sm { padding: var(--spacing-sm); }
.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }
.p-xl { padding: var(--spacing-xl); }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.6s ease-out;
}

/* Mobile Menu Toggle (hidden on desktop, shown via media query below) */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-primary);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-md);
    line-height: 1;
}
.mobile-menu-toggle:hover {
    background: var(--bg-secondary);
}

/* Sidebar backdrop (mobile only — tap outside to close) */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.sidebar-backdrop.active {
    display: block;
    opacity: 1;
}

/* ==========================================
   RESPONSIVE — Tablet + Mobile (≤ 900px)
   Sidebar collapses into an overlay drawer.
   ========================================== */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .mobile-menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* ==========================================
   RESPONSIVE — Phones (≤ 768px)
   ========================================== */
@media (max-width: 768px) {
    h1 { font-size: 1.875rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.125rem; }

    /* Slimmer topbar — reclaim vertical space */
    .topbar {
        padding: var(--spacing-sm) var(--spacing-md);
        height: 60px;
    }
    .main-layout { padding-top: 60px; }
    .sidebar { top: 60px; }

    .topbar-brand { font-size: 1.1rem; }
    .topbar-left  { gap: var(--spacing-sm); }
    .topbar-right { gap: var(--spacing-sm); }

    /* Email + role indicator clutters the bar — drop on phones */
    .user-info { display: none; }

    .btn-sm {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 0.8rem;
    }

    /* Hero */
    .hero { padding: var(--spacing-xl) 0; }
    .hero-subtitle { font-size: 1rem; }

    /* Cards & layout */
    .card { padding: var(--spacing-lg); }
    .section { padding: var(--spacing-xl) 0; }
    .container,
    .container-fluid { padding: 0 var(--spacing-md); }

    /* Generic grids */
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .footer-content { grid-template-columns: 1fr; }

    /* Buttons */
    .btn-lg {
        padding: var(--spacing-sm) var(--spacing-lg);
        font-size: 1rem;
    }
    .btn-group { width: 100%; }
    .btn-group .btn { flex: 1 1 auto; }

    /* Card header layouts wrap nicely (used by profile, dashboards) */
    .card-header { flex-wrap: wrap; gap: var(--spacing-sm); }

    /* Reduce horizontal-shift effect on touch (looks weird without hover) */
    .sidebar-link:hover { transform: none; }
    .feature-item:hover { transform: none; }

    /* Prevent iOS auto-zoom on focus — inputs must be ≥ 16px.
       !important is needed because page-level class selectors (e.g. .modern-input,
       .filter-bar select, .promo-input) have higher specificity than element/attr ones. */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="url"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* ==========================================
   RESPONSIVE — Small phones (≤ 480px)
   ========================================== */
@media (max-width: 480px) {
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }

    .topbar { padding: var(--spacing-sm); }
    .topbar-brand { font-size: 1rem; }

    .container,
    .container-fluid { padding: 0 var(--spacing-sm); }

    .card { padding: var(--spacing-md); }
    .card-header { padding-bottom: var(--spacing-sm); }
    .card-footer { padding-top: var(--spacing-sm); }

    .sidebar { width: 84vw; max-width: 280px; }
}