/* 1. DESIGN TOKENS & RESET */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Palette: Indigo & Slate */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    
    --bg-body: #f1f5f9; /* Slate 100 */
    --surface: #ffffff;
    
    --text-main: #0f172a; /* Slate 900 */
    --text-muted: #64748b; /* Slate 500 */
    --border: #e2e8f0;
    
    /* Status Colors */
    --success-bg: #dcfce7; --success-text: #166534;
    --danger-bg: #fee2e2; --danger-text: #991b1b;
    --warning-bg: #fef3c7; --warning-text: #92400e;
    
    /* Elevation (Shadows) */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

/* Dark Mode Overrides */
[data-theme="dark"] {
    --bg-body: #0f172a;
    --surface: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --primary-light: rgba(79, 70, 229, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; outline: none; }

body { 
    font-family: 'Inter', sans-serif; 
    background: var(--bg-body); 
    color: var(--text-main); 
    margin: 0; 
    height: 100vh; 
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* 2. LAYOUT ENGINE */
.app-container { display: flex; width: 100%; height: 100%; }

/* Sidebar */
.sidebar { 
    width: 280px; 
    background: var(--surface); 
    border-right: 1px solid var(--border); 
    display: flex; 
    flex-direction: column; 
    padding: 1.5rem; 
    flex-shrink: 0;
    transition: transform 0.3s ease;
    z-index: 50;
}

.sidebar h3 {
    font-size: 1.25rem;
    margin-top: 0;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.sidebar hr { border-color: var(--border); margin: 1rem 0; opacity: 0.5; }

/* Main Content Area */
.main-content { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
    position: relative; 
    background: var(--bg-body);
}

.top-header { 
    height: 70px; 
    background: rgba(255, 255, 255, 0.8); /* Glassmorphism base */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border); 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 0 2.5rem; 
    z-index: 40;
}
[data-theme="dark"] .top-header { background: rgba(30, 41, 59, 0.8); }

.content-scroll { 
    flex: 1; 
    overflow-y: auto; 
    padding: 2.5rem; 
    /* Smooth scrolling */
    scroll-behavior: smooth;
}

/* 3. COMPONENTS & UI KITS */

/* Buttons */
.btn { 
    padding: 0.6rem 1rem; 
    border-radius: var(--radius-md); 
    border: 1px solid transparent; 
    cursor: pointer; 
    font-weight: 500; 
    font-size: 0.95rem;
    display: inline-flex; 
    align-items: center; 
    gap: 0.6rem; 
    text-decoration: none; 
    transition: all 0.2s ease;
}

/* Sidebar Nav Links */
.sidebar .btn {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    justify-content: flex-start;
    padding: 0.85rem 1rem;
    margin-bottom: 0.25rem;
    border-radius: var(--radius-lg);
}
.sidebar .btn:hover { background: var(--bg-body); color: var(--primary); transform: translateX(4px); }
.sidebar .btn.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }

.btn-primary { 
    background: var(--primary); 
    color: white; 
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3); 
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 6px rgba(79, 70, 229, 0.4); }

.btn-danger { background: var(--danger-text); color: white; }
.btn-danger:hover { background: #7f1d1d; }

/* 4. FORMS (Soft Inputs) */
.form-group { margin-bottom: 1.5rem; }
.form-group label { 
    display: block; 
    margin-bottom: 0.5rem; 
    font-weight: 500; 
    color: var(--text-muted); 
    font-size: 0.875rem; 
}
.soft-input {
    width: 100%;
    background: var(--bg-body);
    border: 1px solid transparent;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.95rem;
    transition: all 0.2s ease;
}
.soft-input:focus { 
    background: var(--surface); 
    border-color: var(--primary); 
    box-shadow: 0 0 0 4px var(--primary-light); 
}
[data-theme="dark"] .soft-input { background: #0f172a; }

/* 5. DATA VISUALIZATION (Tables & Cards) */

/* Filter Bar Container */
.filter-bar {
    background: var(--surface);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-xl);
    display: flex;
    gap: 1rem;
    align-items: center;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
    flex-wrap: wrap;
    border: 1px solid var(--border);
}
.filter-bar select, .filter-bar input {
    background: var(--bg-body);
    border: 1px solid var(--border);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-main);
    outline: none;
    font-size: 0.9rem;
}

/* Table Card */
.table-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    overflow: hidden;
    animation: fadeIn 0.4s ease-out;
}

table { width: 100%; border-collapse: collapse; }
th { 
    background: #f8fafc; 
    text-transform: uppercase; 
    font-size: 0.75rem; 
    letter-spacing: 0.05em; 
    color: var(--text-muted); 
    padding: 1.25rem 1.5rem; 
    text-align: left;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}
[data-theme="dark"] th { background: #1e293b; }

td { 
    padding: 1.25rem 1.5rem; 
    vertical-align: middle; 
    font-size: 0.9rem; 
    border-bottom: 1px solid var(--border); 
    color: var(--text-main);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-body); transition: background 0.15s; }

/* Status Pills */
.badge {
    padding: 0.35rem 0.85rem;
    border-radius: 2rem;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: capitalize;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    letter-spacing: 0.02em;
}
.badge-active { background: var(--success-bg); color: var(--success-text); }
.badge-inactive { background: var(--danger-bg); color: var(--danger-text); }

/* Action Buttons (Icon only) */
.action-btn {
    width: 34px; height: 34px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    display: inline-flex; align-items: center; justify-content: center;
    margin-right: 0.25rem;
    cursor: pointer;
    transition: all 0.2s;
}
.action-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.action-btn.delete:hover { border-color: var(--danger-text); color: white; background: var(--danger-text); }

/* 6. TOAST NOTIFICATIONS */
.toast {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    display: flex; align-items: center;
    animation: slideIn 0.3s ease-out;
}
.toast.error { border-left-color: var(--danger-text); }

/* 7. RESPONSIVENESS */
@media (max-width: 1024px) {
    .sidebar { position: fixed; left: -280px; height: 100%; box-shadow: var(--shadow-lg); }
    .sidebar.active { left: 0; }
    .top-header { padding: 0 1.5rem; }
    .content-scroll { padding: 1.5rem; }
    /* Toggle Button needed for mobile */
    .mobile-toggle { display: block !important; font-size: 1.5rem; cursor: pointer; margin-right: 1rem; }
}
@media (min-width: 1025px) {
    .mobile-toggle { display: none; }
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* Scrollbar Polish */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }