/* =====================
   Variables & Base
   ===================== */
:root {
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 72px;
    --sidebar-bg: #1e2130;
    --sidebar-text: #a0aec0;
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: rgba(255,255,255,0.08);
    --sidebar-active-text: #ffffff;
    --sidebar-border: rgba(255,255,255,0.06);
    --topbar-height: 64px;
    --topbar-bg: #ffffff;
    --body-bg: #f4f6f9;
    --card-bg: #ffffff;
    --card-border: #e8ecf0;
    --text-primary: #1a202c;
    --text-secondary: #718096;
    --accent: #4f6ef7;
    --accent-light: #eef0fe;
    --success: #38a169;
    --warning: #d69e2e;
    --danger: #e53e3e;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --radius: 10px;
    --transition: all 0.25s ease;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--body-bg);
    color: var(--text-primary);
    margin: 0;
    font-size: 0.9rem;
}

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

/* =====================
   Sidebar
   ===================== */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    transition: var(--transition);
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    overflow: hidden;
    white-space: nowrap;
}

.brand-title {
    font-weight: 700;
    font-size: 1rem;
    color: #ffffff;
    letter-spacing: 0.5px;
}

.brand-sub {
    font-size: 0.72rem;
    color: var(--sidebar-text);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-section-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(160,174,192,0.5);
    padding: 16px 20px 6px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 0;
    transition: var(--transition);
    white-space: nowrap;
    font-size: 0.875rem;
    position: relative;
}

.sidebar-nav .nav-link i {
    font-size: 1.1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.sidebar-nav .nav-link:hover {
    color: var(--sidebar-text-hover);
    background: var(--sidebar-active-bg);
}

.sidebar-nav .nav-link.active {
    color: var(--sidebar-active-text);
    background: var(--sidebar-active-bg);
}

.sidebar-nav .nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--sidebar-border);
    white-space: nowrap;
    overflow: hidden;
}

/* =====================
   Main Content
   ===================== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: var(--transition);
}

/* =====================
   Topbar
   ===================== */
.topbar {
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: var(--transition);
    line-height: 1;
}

.sidebar-toggle:hover {
    background: var(--body-bg);
    color: var(--text-primary);
}

.topbar-left { flex: 1; }

.topbar-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.badge-date {
    background: var(--body-bg);
    border: 1px solid var(--card-border);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* =====================
   Page Content
   ===================== */
.page-content {
    padding: 24px;
    flex: 1;
}

/* =====================
   Cards
   ===================== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--card-border);
    padding: 16px 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body { padding: 20px; }

/* Stat Cards */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon.blue   { background: #eef0fe; color: var(--accent); }
.stat-icon.green  { background: #f0fff4; color: var(--success); }
.stat-icon.orange { background: #fffaf0; color: #dd6b20; }
.stat-icon.red    { background: #fff5f5; color: #e53e3e; }
.stat-icon.purple { background: #faf5ff; color: #805ad5; }
.stat-icon.gray   { background: #f7fafc; color: #4a5568; }

.stat-info {}
.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-primary);
}
.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* =====================
   Tables
   ===================== */
.table {
    font-size: 0.875rem;
    margin-bottom: 0;
}

.table thead th {
    background: var(--body-bg);
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    border-bottom: 1px solid var(--card-border);
    padding: 10px 14px;
    white-space: nowrap;
}

.table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid #f0f2f5;
    vertical-align: middle;
    color: var(--text-primary);
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover td { background: #fafbfc; }

/* =====================
   Buttons
   ===================== */
.btn {
    border-radius: 7px;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 7px 16px;
    transition: var(--transition);
}

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

.btn-primary:hover {
    background: #3d5ae3;
    border-color: #3d5ae3;
}

.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

/* =====================
   Badges
   ===================== */
.badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 5px;
}

/* =====================
   Sidebar Collapsed
   ===================== */
body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .sidebar-brand-text,
body.sidebar-collapsed .sidebar-section-label,
body.sidebar-collapsed .nav-link span,
body.sidebar-collapsed .sidebar-footer span {
    display: none;
}

body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 20px 12px 16px;
}

body.sidebar-collapsed .sidebar-nav .nav-link {
    justify-content: center;
    padding: 10px;
}

body.sidebar-collapsed .sidebar-nav .nav-link i {
    margin: 0;
    width: auto;
}

/* =====================
   Form controls
   ===================== */
.form-control, .form-select {
    border-color: var(--card-border);
    border-radius: 7px;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79,110,247,0.12);
}

.form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* =====================
   Page header
   ===================== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.page-header-sub {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* =====================
   Upload zone
   ===================== */
.upload-zone {
    border: 2px dashed var(--card-border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--body-bg);
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.upload-zone i {
    font-size: 2.5rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 8px;
}

/* =====================
   Responsive
   ===================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    body.sidebar-open .sidebar {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .page-content {
        padding: 16px;
    }
}
