@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --sidebar-hover: #1e293b;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #f8fafc;
    --border-color: #e2e8f0;
    --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: 1rem;
    --transition: all 0.2s ease-in-out;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

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

/* Layout */
.wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    z-index: 10;
}

.sidebar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: var(--transition);
}

.nav-item:hover, .nav-item.active {
    background-color: var(--sidebar-hover);
    color: white;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: calc(100% - 260px);
}

.topbar {
    background-color: var(--bg-card);
    padding: 1rem 2rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    box-shadow: var(--shadow-sm);
    z-index: 5;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-weight: 500;
}

.content {
    padding: 2rem;
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Components */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

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

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

.btn-outline {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background-color: var(--bg-main);
    border-color: var(--text-muted);
}

.btn-danger {
    background-color: #ef4444;
    color: white;
}
.btn-danger:hover {
    background-color: #dc2626;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

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

.input-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-main);
    color: var(--text-main);
    transition: var(--transition);
}

.input-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    background-color: var(--bg-card);
}

/* Tables */
.table-responsive {
    width: 100%;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th {
    padding: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-main);
}

.table td {
    padding: 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

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

/* KPIs */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background-color: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.kpi-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Auth Layout */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-main);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

/* Segmented Control / Nav Tabs */
.nav-tabs {
    display: inline-flex;
    background-color: var(--bg-main);
    padding: 0.375rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
    gap: 0.25rem;
    align-items: center;
}

.nav-tab {
    padding: 0.5rem 1.25rem;
    border-radius: calc(var(--radius-md) - 0.125rem);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
}

.nav-tab:hover {
    color: var(--text-main);
}

.nav-tab.active {
    background-color: var(--bg-card);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-danger { color: #ef4444; }
.text-main { color: var(--text-main); }
.font-bold { font-weight: 700; }
.m-0 { margin: 0; }
.p-0 { padding: 0; }
.mt-4 { margin-top: 1rem; }
.mt-8 { margin-top: 2rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-8 { margin-bottom: 2rem; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.w-full { width: 100%; }
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
}
.badge-active { background-color: #dcfce7; color: #166534; }
.badge-inactive { background-color: #f1f5f9; color: #475569; }

.alert {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}
.alert-error {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}
.alert-success {
    background-color: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* Mobile Responsive */
.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }
    
    .topbar {
        justify-content: space-between;
        padding: 1rem;
    }

    .wrapper {
        position: relative;
        overflow-x: hidden;
    }

    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        transition: left 0.3s ease;
        z-index: 1000;
    }
    
    .sidebar.open {
        left: 0;
    }

    .main-content {
        width: 100%;
        transition: margin-left 0.3s ease;
    }
    
    .content {
        padding: 1rem;
    }
    
    /* Ensure grids stack on small screens */
    .kpi-grid, .grid-2, .breakdowns {
        grid-template-columns: 1fr;
    }
    
    /* Make tables scrollable horizontally */
    .table-responsive, .card {
        overflow-x: auto;
    }

    .table th, .table td {
        white-space: nowrap;
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    
    .sidebar-overlay.open {
        display: block;
    }
}
