/* ==========================================================================
   Admin Dashboard Theme Variables & Styles
   ========================================================================== */

:root[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --border-color: #e2e8f0;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --accent-primary: #4f46e5;
    --accent-primary-hover: #4338ca;
    --accent-light: #eef2ff;
    
    --color-emerald: #10b981;
    --color-emerald-light: #d1fae5;
    --color-indigo: #6366f1;
    --color-indigo-light: #e0e7ff;
    --color-amber: #f59e0b;
    --color-amber-light: #fef3c7;
    --color-blue: #3b82f6;
    --color-blue-light: #dbeafe;
    --color-rose: #ef4444;
    --color-rose-light: #fee2e2;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

:root[data-theme="dark"] {
    --bg-primary: #0b0f19;
    --bg-secondary: #111827;
    --bg-tertiary: #1f2937;
    --border-color: #1f2937;
    
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --accent-primary: #6366f1;
    --accent-primary-hover: #818cf8;
    --accent-light: #1e1b4b;
    
    --color-emerald: #10b981;
    --color-emerald-light: rgba(16, 185, 129, 0.15);
    --color-indigo: #818cf8;
    --color-indigo-light: rgba(99, 102, 241, 0.15);
    --color-amber: #f59e0b;
    --color-amber-light: rgba(245, 158, 11, 0.15);
    --color-blue: #60a5fa;
    --color-blue-light: rgba(59, 130, 246, 0.15);
    --color-rose: #f87171;
    --color-rose-light: rgba(239, 68, 68, 0.15);

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

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

/* ==========================================================================
   Sidebar Navigation
   ========================================================================== */
.sidebar {
    width: 260px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s ease;
}

.sidebar-header {
    height: 70px;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--accent-primary), #818cf8);
    color: #ffffff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-name {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

.mobile-close-btn {
    display: none;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-title {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0 0.75rem 0.5rem;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    margin-bottom: 0.25rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.925rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.sidebar-nav a:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-nav li.active a {
    background-color: var(--accent-light);
    color: var(--accent-primary);
    font-weight: 600;
}

.sidebar-nav li.active a i {
    color: var(--accent-primary);
}

.sidebar-nav i {
    width: 20px;
    height: 20px;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 10px;
    background-color: var(--bg-tertiary);
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.logout-btn {
    color: var(--text-muted);
}

.logout-btn:hover {
    color: var(--color-rose);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 90;
}

/* ==========================================================================
   Main Content Layout & Top Header
   ========================================================================== */
.main-wrapper {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.3s ease;
}

.top-header {
    height: 70px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 80;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle-btn {
    display: none;
}

.search-box {
    position: relative;
    width: 320px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.4rem;
    background-color: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
    transition: all 0.2s ease;
}

.search-box input:focus {
    border-color: var(--accent-primary);
    background-color: var(--bg-secondary);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.icon-btn-sm {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn-sm:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Theme Toggle Icons */
[data-theme="light"] .sun-icon { display: none; }
[data-theme="light"] .moon-icon { display: block; }
[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }

.dot-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background-color: var(--color-rose);
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
}

.header-divider {
    width: 1px;
    height: 24px;
    background-color: var(--border-color);
}

.header-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.header-profile:hover {
    background-color: var(--bg-tertiary);
}

.avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.profile-name {
    font-size: 0.875rem;
    font-weight: 500;
}

.chevron-icon {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

/* ==========================================================================
   Content Area & Page Elements
   ========================================================================== */
.content {
    padding: 2rem;
    flex: 1;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.625rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn i {
    width: 18px;
    height: 18px;
}

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

.btn-primary:hover {
    background-color: var(--accent-primary-hover);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.btn-secondary {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Badges */
.badge {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    line-height: 1;
    margin-left: auto;
}

.badge-primary {
    background-color: var(--accent-light);
    color: var(--accent-primary);
}

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

.stat-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

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

.stat-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.stat-icon-wrapper {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon-wrapper i {
    width: 22px;
    height: 22px;
}

.bg-emerald { background-color: var(--color-emerald-light); color: var(--color-emerald); }
.bg-indigo { background-color: var(--color-indigo-light); color: var(--color-indigo); }
.bg-amber { background-color: var(--color-amber-light); color: var(--color-amber); }
.bg-blue { background-color: var(--color-blue-light); color: var(--color-blue); }

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 0.5rem;
}

.stat-trend {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8125rem;
    font-weight: 600;
}

.stat-trend i {
    width: 16px;
    height: 16px;
}

.stat-trend.positive {
    color: var(--color-emerald);
}

.stat-trend.negative {
    color: var(--color-rose);
}

.trend-label {
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 0.25rem;
}

/* ==========================================================================
   Charts Section
   ========================================================================== */
.charts-grid {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.chart-card {
    display: flex;
    flex-direction: column;
}

.flex-2 { flex: 2; min-width: 320px; }
.flex-1 { flex: 1; min-width: 280px; }

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
}

.card-subtitle {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.select-input {
    padding: 0.4rem 0.8rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.8125rem;
    outline: none;
    cursor: pointer;
}

.card-body {
    padding: 1.5rem;
    flex: 1;
}

.p-0 { padding: 0 !important; }

.chart-container {
    position: relative;
    width: 100%;
    height: 300px;
}

.doughnut-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================================================
   Data Table Section
   ========================================================================== */
.table-card {
    overflow: hidden;
}

.flex-header {
    flex-wrap: wrap;
    gap: 1rem;
}

.table-search-box {
    position: relative;
    width: 240px;
}

.table-search-box i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.table-search-box input {
    width: 100%;
    padding: 0.45rem 0.75rem 0.45rem 2.1rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.8125rem;
    outline: none;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}

.data-table th {
    background-color: var(--bg-tertiary);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.875rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    vertical-align: middle;
}

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

.data-table tbody tr {
    transition: background-color 0.2s ease;
}

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

.font-medium { font-weight: 500; color: var(--text-primary); }
.font-semibold { font-weight: 600; color: var(--text-primary); }
.text-right { text-align: right; }

.customer-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar-table {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
}

.customer-name {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
}

.customer-email {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-completed {
    background-color: var(--color-emerald-light);
    color: var(--color-emerald);
}

.status-pending {
    background-color: var(--color-amber-light);
    color: var(--color-amber);
}

.status-cancelled {
    background-color: var(--color-rose-light);
    color: var(--color-rose);
}

/* Table Footer & Pagination */
.table-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.table-info {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.pagination {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.page-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.page-btn i {
    width: 16px;
    height: 16px;
}

.page-btn:hover:not(.disabled) {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.page-btn.active {
    background-color: var(--accent-primary);
    color: #ffffff;
    border-color: var(--accent-primary);
}

.page-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-close-btn {
        display: flex;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .sidebar-toggle-btn {
        display: flex;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .charts-grid {
        flex-direction: column;
    }
}

@media (max-width: 640px) {
    .top-header {
        padding: 0 1rem;
    }

    .content {
        padding: 1.25rem 1rem;
    }

    .search-box {
        width: 160px;
    }

    .profile-name {
        display: none;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .table-footer {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
}
