﻿/* =============================================
   CSS Variables & Reset
============================================= */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --header-h: 64px;
    --bg: #f0f2f7;
    --surface: #ffffff;
    --sidebar-bg: #0f1623;
    --sidebar-hover: #1a2437;
    --sidebar-active: #1e3a5f;
    --accent: #3b82f6;
    --accent-soft: rgba(59,130,246,0.12);
    --text-primary: #1a202c;
    --text-secondary: #64748b;
    --text-sidebar: #94a3b8;
    --text-sidebar-active: #ffffff;
    --border: #e2e8f0;
    --shadow: 0 4px 24px rgba(0,0,0,0.07);
    --shadow-md: 0 8px 32px rgba(0,0,0,0.12);
    --radius: 10px;
    --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
    --font-body: 'DM Sans', sans-serif;
    --font-display: 'Syne', sans-serif;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

/* =============================================
   Layout Shell
============================================= */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* =============================================
   Sidebar Overlay (mobile)
============================================= */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    backdrop-filter: blur(2px);
}

    .sidebar-overlay.active {
        display: block;
    }

/* =============================================
   Sidebar
============================================= */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 300;
    transition: width var(--transition), transform var(--transition);
    overflow: hidden;
}

    .sidebar.collapsed {
        width: var(--sidebar-collapsed);
    }

        .sidebar.collapsed .nav-label,
        .sidebar.collapsed .submenu-arrow,
        .sidebar.collapsed .sidebar-brand-text,
        .sidebar.collapsed .nav-section-label {
            opacity: 0;
            pointer-events: none;
        }

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }

        .sidebar.mobile-open {
            transform: translateX(0);
        }
}

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 18px;
    height: var(--header-h);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    transition: opacity var(--transition);
}

/* Scrollable nav area */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 0;
}

    .sidebar-nav::-webkit-scrollbar {
        width: 4px;
    }

    .sidebar-nav::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,0.1);
        border-radius: 4px;
    }

/* Section labels */
.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.25);
    padding: 16px 20px 6px;
    transition: opacity var(--transition);
    white-space: nowrap;
}

/* Nav items */
.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 11px 18px;
    color: var(--text-sidebar);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
    user-select: none;
}

    .nav-link:hover {
        background: var(--sidebar-hover);
        color: #fff;
    }

    .nav-link.active {
        background: var(--sidebar-active);
        color: var(--text-sidebar-active);
        position: relative;
    }

        .nav-link.active::before {
            content: '';
            position: absolute;
            left: 0;
            top: 4px;
            bottom: 4px;
            width: 3px;
            background: var(--accent);
            border-radius: 0 3px 3px 0;
        }

.nav-icon {
    font-size: 16px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.nav-label {
    font-size: 14px;
    font-weight: 500;
    flex: 1;
    transition: opacity var(--transition);
}

.submenu-arrow {
    font-size: 11px;
    transition: transform var(--transition), opacity var(--transition);
}

.nav-item.open > .nav-link .submenu-arrow {
    transform: rotate(90deg);
}

/* Sub-menu */
.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4,0,0.2,1);
    background: rgba(0,0,0,0.15);
}

.nav-item.open > .submenu {
    max-height: 500px;
}

.submenu .nav-link {
    padding-left: 50px;
    font-size: 13.5px;
}

    .submenu .nav-link .nav-icon {
        font-size: 13px;
    }

/* Tooltip in collapsed mode */
.sidebar.collapsed .nav-link:hover::after {
    content: attr(data-label);
    position: absolute;
    left: calc(var(--sidebar-collapsed) + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: #1e293b;
    color: #fff;
    font-size: 13px;
    padding: 5px 12px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: var(--shadow-md);
    z-index: 400;
}

/* Sidebar footer */
.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.06);
    padding: 14px 18px;
    flex-shrink: 0;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 11px;
    cursor: pointer;
    border-radius: 8px;
    padding: 8px;
    transition: background var(--transition);
}

    .user-card:hover {
        background: var(--sidebar-hover);
    }

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    font-size: 13px;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
    transition: opacity var(--transition);
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 11px;
    color: var(--text-sidebar);
}

.sidebar.collapsed .user-info {
    opacity: 0;
    pointer-events: none;
}

/* =============================================
   Main Area
============================================= */
.main-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition);
}

    .main-area.sidebar-collapsed {
        margin-left: var(--sidebar-collapsed);
    }

@media (max-width: 768px) {
    .main-area {
        margin-left: 0 !important;
    }
}

/* =============================================
   Top Bar
============================================= */
.topbar {
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 0 var(--border);
}

.topbar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 18px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}

    .topbar-toggle:hover {
        background: var(--bg);
        color: var(--text-primary);
    }

.topbar-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    color: var(--text-secondary);
    flex: 1;
}

    .topbar-breadcrumb .crumb {
        color: var(--text-primary);
        font-weight: 500;
    }

    .topbar-breadcrumb .sep {
        font-size: 11px;
    }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    font-size: 16px;
    transition: background var(--transition), color var(--transition);
    position: relative;
}

    .topbar-btn:hover {
        background: var(--bg);
        color: var(--text-primary);
    }

.notif-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid var(--surface);
}

.topbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
}

.topbar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
}

/* =============================================
   Page Content Wrapper
============================================= */
.page-content {
    flex: 1;
    padding: 28px;
}

/* =============================================
   Shared UI Components (available to all pages)
============================================= */

/* Page Header */
.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 14px;
    transition: transform var(--transition), box-shadow var(--transition);
}

    .stat-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

    .stat-icon.blue {
        background: rgba(59,130,246,0.12);
        color: #3b82f6;
    }

    .stat-icon.green {
        background: rgba(16,185,129,0.12);
        color: #10b981;
    }

    .stat-icon.amber {
        background: rgba(245,158,11,0.12);
        color: #f59e0b;
    }

    .stat-icon.purple {
        background: rgba(139,92,246,0.12);
        color: #8b5cf6;
    }

.stat-value {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.stat-change {
    font-size: 12px;
    margin-top: 6px;
    font-weight: 500;
}

    .stat-change.up {
        color: #10b981;
    }

    .stat-change.down {
        color: #ef4444;
    }

/* Content Grid */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 960px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

/* Card */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-weight: 600;
    font-size: 15px;
}

.card-body {
    padding: 20px;
}

/* Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

    .data-table th {
        text-align: left;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-secondary);
        padding: 8px 12px;
        border-bottom: 1px solid var(--border);
    }

    .data-table td {
        padding: 10px 12px;
        border-bottom: 1px solid var(--border);
    }

    .data-table tr:last-child td {
        border-bottom: none;
    }

    .data-table tr:hover td {
        background: var(--bg);
    }

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
}

.badge-green {
    background: rgba(16,185,129,0.12);
    color: #059669;
}

.badge-amber {
    background: rgba(245,158,11,0.12);
    color: #d97706;
}

.badge-red {
    background: rgba(239,68,68,0.12);
    color: #dc2626;
}

.badge-blue {
    background: rgba(59,130,246,0.12);
    color: #2563eb;
}

/* Activity List */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.activity-text {
    font-size: 13.5px;
    line-height: 1.5;
}

.activity-time {
    font-size: 11.5px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    font-family: var(--font-body);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

    .btn-primary:hover {
        background: #2563eb;
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(59,130,246,0.3);
    }

.btn-ghost {
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

    .btn-ghost:hover {
        color: var(--text-primary);
        border-color: #cbd5e1;
    }

/* =============================================
   Footer
============================================= */
.app-footer {
    text-align: center;
    padding: 18px 28px;
    font-size: 12.5px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    background: var(--surface);
}

/* =============================================
   Mobile Responsiveness
============================================= */
@media (max-width: 640px) {
    .page-content {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .topbar {
        padding: 0 16px;
    }

    .topbar-breadcrumb {
        display: none;
    }
}

@media (max-width: 400px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}