/* ============================================
   Invoice App — Design System 2.0
   Premium Dark Theme with Glassmorphism
   ============================================ */

/* --- Fonts --- */
/* Inter for body, Outfit for headings */

/* --- Reset & Variables --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Colors - Zinc/Midnight Base */
    --bg-base: #09090b;
    --bg-surface: rgba(24, 24, 27, 0.65);
    --bg-surface-hover: rgba(39, 39, 42, 0.8);
    --bg-elevated: rgba(39, 39, 42, 0.9);
    
    /* Borders */
    --border-light: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(255, 255, 255, 0.15);
    
    /* Text */
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    /* Accents (Indigo/Violet) */
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.4);
    --accent-bg: rgba(99, 102, 241, 0.1);
    
    /* Status Colors */
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.15);
    
    /* Effects & Geometry */
    --radius-lg: 16px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-soft: 0 4px 24px -4px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--accent-glow);
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --transition-fast: all 0.15s ease;
    
    /* Layout */
    --sidebar-width: 280px;
    
    /* Typography */
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-heading: 'Outfit', 'Inter', sans-serif;
}

html { font-size: 15px; scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    background-color: var(--bg-base);
    /* Subtle radial gradient background */
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.08), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.08), transparent 25%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: -0.02em;
}

a { color: var(--accent); text-decoration: none; transition: var(--transition-fast); }
a:hover { color: var(--accent-hover); }

/* --- Glass Card 2.0 --- */
.glass-card {
    background: var(--bg-surface);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
}
.glass-card:hover { 
    border-color: var(--border-glow); 
    transform: translateY(-2px);
    box-shadow: 0 8px 32px -4px rgba(0, 0, 0, 0.6);
}

/* --- Auth Layout --- */
.auth-layout {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 100vh; padding: 2rem;
    background: radial-gradient(circle at top center, rgba(99,102,241,0.15) 0%, var(--bg-base) 60%);
}
.auth-container { width: 100%; max-width: 440px; }
.auth-card { text-align: center; border-radius: var(--radius-lg); padding: 2.5rem; }
.auth-card-wide { max-width: 560px; }
.auth-header { margin-bottom: 2.5rem; }
.auth-logo { 
    font-size: 3.5rem; 
    display: inline-block; 
    margin-bottom: 1rem;
    color: var(--accent);
    filter: drop-shadow(0 0 12px var(--accent-glow));
}
.auth-header h1 { font-size: 1.8rem; font-weight: 700; color: #fff; }
.auth-subtitle { color: var(--text-secondary); font-size: 0.95rem; margin-top: 0.5rem; }
.auth-footer { margin-top: 2rem; }
.auth-security-note { color: var(--text-muted); font-size: 0.85rem; display: flex; align-items: center; justify-content: center; gap: 0.5rem; }

/* --- Sidebar --- */
.sidebar {
    position: fixed; top: 0; left: 0;
    width: var(--sidebar-width); height: 100vh;
    background: rgba(9, 9, 11, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-light);
    display: flex; flex-direction: column;
    z-index: 100;
    transition: var(--transition);
}
.sidebar-header {
    padding: 1.5rem;
    display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 0.75rem; color: #fff; }
.logo-icon { font-size: 1.75rem; color: var(--accent); filter: drop-shadow(0 0 8px var(--accent-glow)); }
.logo-text { font-size: 1.25rem; font-weight: 700; font-family: var(--font-heading); letter-spacing: -0.03em; }
.sidebar-toggle { display: none; background: none; border: none; color: var(--text-primary); cursor: pointer; padding: 0.5rem; font-size: 1.5rem; }

.nav-menu { list-style: none; padding: 1rem; flex: 1; display: flex; flex-direction: column; gap: 0.25rem; }
.nav-link {
    display: flex; align-items: center; gap: 1rem;
    padding: 0.85rem 1rem; color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    font-weight: 500;
}
.nav-link:hover { 
    color: var(--text-primary); 
    background: rgba(255,255,255,0.05); 
}
.nav-link.active { 
    color: var(--accent); 
    background: var(--accent-bg); 
    font-weight: 600;
}
.nav-icon { font-size: 1.25rem; display: flex; align-items: center; justify-content: center; }
.nav-text { font-size: 0.95rem; }

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-light);
}
.user-info { margin-bottom: 1rem; }
.user-email { font-size: 0.8rem; color: var(--text-secondary); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout {
    width: 100%; display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1rem; background: rgba(239, 68, 68, 0.05); border: 1px solid transparent;
    color: var(--danger); cursor: pointer; font-size: 0.9rem; font-weight: 500;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}
.btn-logout:hover { background: var(--danger-bg); border-color: rgba(239, 68, 68, 0.2); }

/* --- Main Content --- */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 2.5rem 3rem;
    min-height: 100vh;
}
.content-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 2.5rem;
}
.content-header h1 { font-size: 2rem; font-weight: 700; color: #fff; }

/* --- Flash Messages --- */
.flash-messages { margin-bottom: 2rem; display: flex; flex-direction: column; gap: 0.75rem; }
.alert {
    padding: 1rem 1.25rem; border-radius: var(--radius-sm);
    display: flex; justify-content: space-between; align-items: center;
    font-size: 0.95rem; font-weight: 500;
    animation: slideDown 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(10px);
}
.alert-success { background: var(--success-bg); border: 1px solid rgba(16,185,129,0.3); color: #34d399; }
.alert-error { background: var(--danger-bg); border: 1px solid rgba(239,68,68,0.3); color: #f87171; }
.alert-warning { background: var(--warning-bg); border: 1px solid rgba(245,158,11,0.3); color: #fbbf24; }
.alert-info { background: var(--info-bg); border: 1px solid rgba(59,130,246,0.3); color: #60a5fa; }
.alert-close { background: none; border: none; color: inherit; cursor: pointer; font-size: 1.2rem; padding: 0 0.25rem; opacity: 0.7; transition: var(--transition-fast); }
.alert-close:hover { opacity: 1; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-15px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- Buttons --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.75rem 1.5rem; border-radius: var(--radius-sm);
    font-size: 0.9rem; font-weight: 600; font-family: var(--font-body);
    cursor: pointer; transition: var(--transition);
    border: 1px solid transparent; text-decoration: none;
    line-height: 1.2;
}
.btn i { font-size: 1.1em; }
.btn-primary {
    background: var(--accent);
    color: #fff; border-color: transparent;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}
.btn-primary:hover { 
    background: var(--accent-hover); 
    box-shadow: 0 6px 20px var(--accent-glow); 
    transform: translateY(-2px); 
}
.btn-primary:active { transform: translateY(0); }

.btn-ghost { background: rgba(255,255,255,0.03); color: var(--text-primary); border: 1px solid var(--border-light); }
.btn-ghost:hover { background: rgba(255,255,255,0.08); border-color: var(--border-glow); transform: translateY(-1px); }

.btn-danger { background: var(--danger-bg); color: #f87171; border-color: rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.25); border-color: rgba(239,68,68,0.4); transform: translateY(-1px); }

.btn-full { width: 100%; }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.85rem; }

/* --- Forms --- */
.form-container { max-width: 680px; }
.form-group { margin-bottom: 1.5rem; }
.form-label { display: block; font-size: 0.9rem; font-weight: 500; color: var(--text-primary); margin-bottom: 0.5rem; }
.form-input {
    width: 100%; padding: 0.85rem 1.25rem; border-radius: var(--radius-sm);
    background: rgba(0,0,0,0.2); border: 1px solid var(--border-light);
    color: #fff; font-size: 0.95rem; font-family: var(--font-body);
    transition: var(--transition-fast);
}
.form-input:hover { border-color: rgba(255,255,255,0.15); }
.form-input:focus { outline: none; border-color: var(--accent); background: rgba(0,0,0,0.4); box-shadow: 0 0 0 4px var(--accent-bg); }
.form-input::placeholder { color: var(--text-muted); }

select.form-input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23a1a1aa' viewBox='0 0 256 256'%3E%3Cpath d='M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z'%3E%3C/path%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 1rem center; padding-right: 2.5rem; }
select.form-input option { background: var(--bg-elevated); color: #fff; }

.form-hint { display: block; color: var(--text-muted); font-size: 0.85rem; margin-top: 0.4rem; }
.form-error { display: block; color: #f87171; font-size: 0.85rem; margin-top: 0.4rem; font-weight: 500; }
.form-row { display: flex; gap: 1.5rem; }
.form-row .form-group { flex: 1; }
.form-actions { display: flex; justify-content: flex-end; gap: 1rem; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border-light); }

.checkbox-card {
    padding: 0.85rem 1.25rem; border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.02); border: 1px solid var(--border-light);
    transition: var(--transition-fast); width: 100%; cursor: pointer;
    display: flex; align-items: center; gap: 0.75rem;
}
.checkbox-card:hover { background: rgba(255,255,255,0.04); border-color: var(--border-glow); }
.checkbox-card:has(input:checked) { background: var(--accent-bg); border-color: var(--accent); }
.checkbox-card input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); cursor: pointer; }

/* --- Stats Grid --- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.5rem; margin-bottom: 3rem; }
.stat-card { display: flex; align-items: center; gap: 1.25rem; padding: 1.75rem; }
.stat-icon { font-size: 2.5rem; width: 4.5rem; height: 4.5rem; display: flex; align-items: center; justify-content: center; border-radius: var(--radius); }
.stat-icon-blue { background: var(--info-bg); color: #60a5fa; }
.stat-icon-green { background: var(--success-bg); color: #34d399; }
.stat-icon-yellow { background: var(--warning-bg); color: #fbbf24; }
.stat-icon-red { background: var(--danger-bg); color: #f87171; }
.stat-info { display: flex; flex-direction: column; gap: 0.25rem; }
.stat-value { font-size: 2.25rem; font-weight: 700; font-family: var(--font-heading); color: #fff; line-height: 1; }
.stat-label { font-size: 0.9rem; color: var(--text-secondary); font-weight: 500; }

/* --- Sections --- */
.section { margin-bottom: 3rem; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.section-header h2 { font-size: 1.35rem; font-weight: 600; color: #fff; }

/* --- Tables --- */
.table-container { overflow-x: auto; padding: 0.5rem; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.95rem; }
.table th { text-align: left; padding: 1rem 1.25rem; color: var(--text-secondary); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border-light); }
.table td { padding: 1.25rem; border-bottom: 1px solid rgba(255,255,255,0.03); vertical-align: middle; }
.table tbody tr { transition: var(--transition-fast); }
.table tbody tr:hover { background: rgba(255,255,255,0.02); }
.table tbody tr:last-child td { border-bottom: none; }

/* --- Badges --- */
.badge { display: inline-flex; align-items: center; justify-content: center; padding: 0.35rem 0.75rem; border-radius: 99px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.03em; }
.badge-green { background: var(--success-bg); color: #10b981; border: 1px solid rgba(16,185,129,0.2); }
.badge-yellow { background: var(--warning-bg); color: #f59e0b; border: 1px solid rgba(245,158,11,0.2); }
.badge-red { background: var(--danger-bg); color: #ef4444; border: 1px solid rgba(239,68,68,0.2); }
.badge-neutral { background: rgba(255,255,255,0.05); color: var(--text-secondary); border: 1px solid var(--border-light); }

/* --- Store Cards --- */
.stores-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1.5rem; }
.store-card { display: flex; flex-direction: column; gap: 1rem; padding: 1.75rem; }
.store-header { display: flex; justify-content: space-between; align-items: flex-start; }
.store-header h3 { font-size: 1.15rem; font-weight: 600; color: #fff; margin-bottom: 0.25rem; }
.store-url { color: var(--text-secondary); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 0.4rem; }
.store-config { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.config-tag { padding: 0.25rem 0.6rem; border-radius: 6px; font-size: 0.75rem; font-weight: 500; background: rgba(255,255,255,0.05); color: var(--text-secondary); border: 1px solid var(--border-light); display: flex; align-items: center; gap: 0.3rem; }
.store-actions { display: flex; gap: 0.75rem; border-top: 1px solid var(--border-light); padding-top: 1.25rem; margin-top: 0.5rem; }
.inline-form { display: inline; }

/* --- Empty State --- */
.empty-state { text-align: center; padding: 4rem 2rem; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.empty-icon { font-size: 4rem; display: block; margin-bottom: 1.5rem; color: var(--text-muted); opacity: 0.5; }
.empty-state h3 { font-size: 1.35rem; margin-bottom: 0.75rem; color: #fff; }
.empty-state p { color: var(--text-secondary); margin-bottom: 2rem; font-size: 0.95rem; max-width: 400px; }

/* --- Detail Grid --- */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.detail-card h3 { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 1.25rem; text-transform: uppercase; letter-spacing: 0.05em; display: flex; align-items: center; gap: 0.5rem; }
.detail-list { display: grid; grid-template-columns: auto 1fr; gap: 0.75rem 1.25rem; font-size: 0.95rem; }
.detail-list dt { color: var(--text-muted); font-weight: 500; }
.detail-list dd { color: #fff; font-weight: 500; }

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .main-content { margin-left: 0; padding: 1.5rem; }
    .content-header { flex-direction: column; gap: 1rem; align-items: flex-start; }
    .form-row { flex-direction: column; gap: 0; }
    .stats-grid { grid-template-columns: 1fr; }
    .stores-grid { grid-template-columns: 1fr; }
    .auth-card { padding: 1.5rem; }
}
