/**
 * Marca Coroma HR — Design System
 * Core styles for the entire application
 */

/* ============================================================
   CSS CUSTOM PROPERTIES (DESIGN TOKENS)
   ============================================================ */

:root {
    /* Primary palette */
    --primary-50:  #eff6ff;
    --primary-100: #dbeafe;
    --primary-200: #bfdbfe;
    --primary-300: #93c5fd;
    --primary-400: #60a5fa;
    --primary-500: #3b82f6;
    --primary-600: #2563eb;
    --primary-700: #1d4ed8;
    --primary-800: #1e40af;
    --primary-900: #1e3a8a;

    /* Neutrals */
    --gray-50:  #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --gray-950: #020617;

    /* Semantic colors */
    --success-50:  #f0fdf4;
    --success-500: #22c55e;
    --success-600: #16a34a;
    --danger-50:  #fef2f2;
    --danger-500: #ef4444;
    --danger-600: #dc2626;
    --warning-50:  #fffbeb;
    --warning-500: #f59e0b;
    --warning-600: #d97706;
    --info-50:  #eff6ff;
    --info-500: #3b82f6;
    --info-600: #2563eb;
    --purple-500: #8b5cf6;
    --pink-500:   #ec4899;
    --teal-500:   #14b8a6;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-xs:   0.75rem;
    --font-sm:   0.8125rem;
    --font-base: 0.9375rem;
    --font-lg:   1.125rem;
    --font-xl:   1.25rem;
    --font-2xl:  1.5rem;
    --font-3xl:  1.875rem;
    --font-4xl:  2.25rem;

    /* Radius */
    --radius-sm:  0.375rem;
    --radius-md:  0.5rem;
    --radius-lg:  0.75rem;
    --radius-xl:  1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md:  0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg:  0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl:  0 20px 25px -5px rgba(0, 0, 0, 0.1);

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --header-height: 64px;
    --content-max-width: 1280px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;

    /* LIGHT THEME (default) */
    --bg-body: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f8fafc;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: rgba(255, 255, 255, 0.08);
    --bg-sidebar-active: rgba(59, 130, 246, 0.15);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-sidebar: #cbd5e1;
    --text-sidebar-active: #60a5fa;
    --border-color: #e2e8f0;
    --border-color-light: #f1f5f9;
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
}

/* DARK THEME */
[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --border-color-light: #1e293b;
    --input-bg: #0f172a;
    --input-border: #475569;
}

/* ============================================================
   RESET & BASE
   ============================================================ */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-base);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-body);
}

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

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

img {
    max-width: 100%;
    height: auto;
}

/* ============================================================
   LAYOUT — SIDEBAR + CONTENT
   ============================================================ */

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: width var(--transition-slow);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: var(--space-5) var(--space-6);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    min-height: var(--header-height);
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-500), var(--purple-500));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: var(--font-sm);
    color: white;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
}

.sidebar-brand-name {
    font-size: var(--font-base);
    font-weight: 700;
    color: #f1f5f9;
    line-height: 1.2;
}

.sidebar-brand-sub {
    font-size: var(--font-xs);
    color: var(--gray-500);
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-3) 0;
    overflow-y: auto;
}

.sidebar-section-title {
    padding: var(--space-4) var(--space-6) var(--space-2);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-6);
    margin: 1px var(--space-2);
    color: var(--text-sidebar);
    font-size: var(--font-sm);
    font-weight: 450;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    text-decoration: none;
    position: relative;
}

.sidebar-link:hover {
    background: var(--bg-sidebar-hover);
    color: #f1f5f9;
}

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

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--primary-500);
    border-radius: 0 2px 2px 0;
}

.sidebar-link-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-link.active .sidebar-link-icon {
    opacity: 1;
}

.sidebar-badge {
    margin-left: auto;
    background: var(--danger-500);
    color: white;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full);
    min-width: 1.25rem;
    text-align: center;
}

/* Content area */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-slow);
}

/* Top header */
.top-header {
    height: var(--header-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.top-header-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.page-title {
    font-size: var(--font-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-xs);
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--text-muted);
}

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

/* Page content */
.page-content {
    padding: var(--space-6);
    max-width: var(--content-max-width);
}

/* ============================================================
   COMPONENTS
   ============================================================ */

/* Cards */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transition: box-shadow var(--transition-base);
}

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

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

.card-title {
    font-size: var(--font-base);
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: var(--space-6);
}

.card-footer {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border-color);
    background: var(--bg-surface-hover);
}

/* Stat Cards */
.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    transition: all var(--transition-base);
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-icon.blue    { background: var(--primary-50); color: var(--primary-600); }
.stat-icon.green   { background: var(--success-50); color: var(--success-600); }
.stat-icon.red     { background: var(--danger-50); color: var(--danger-600); }
.stat-icon.yellow  { background: var(--warning-50); color: var(--warning-600); }
.stat-icon.purple  { background: #f5f3ff; color: var(--purple-500); }

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: var(--font-2xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-label {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    margin-top: var(--space-1);
}

.stat-change {
    font-size: var(--font-xs);
    font-weight: 500;
    margin-top: var(--space-1);
}

.stat-change.up { color: var(--success-500); }
.stat-change.down { color: var(--danger-500); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0.5625rem 1rem;
    font-family: var(--font-family);
    font-size: var(--font-sm);
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
}

.btn:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--primary-600);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-700);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-success {
    background: var(--success-600);
    color: white;
}
.btn-success:hover { background: #15803d; }

.btn-danger {
    background: var(--danger-600);
    color: white;
}
.btn-danger:hover { background: #b91c1c; }

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

.btn-outline {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-secondary);
}
.btn-outline:hover {
    background: var(--bg-surface-hover);
    border-color: var(--gray-400);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover {
    background: var(--bg-surface-hover);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: var(--font-xs);
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: var(--font-base);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-md);
}

/* Forms */
.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    font-size: var(--font-sm);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.form-label .required {
    color: var(--danger-500);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.5625rem 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-base);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input.error {
    border-color: var(--danger-500);
}

.form-hint {
    font-size: var(--font-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

.form-error {
    font-size: var(--font-xs);
    color: var(--danger-500);
    margin-top: var(--space-1);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-sm);
}

.data-table thead {
    background: var(--bg-surface-hover);
}

.data-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: var(--font-xs);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

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

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

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

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.625rem;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-success { background: var(--success-50); color: var(--success-600); }
.badge-danger  { background: var(--danger-50); color: var(--danger-600); }
.badge-warning { background: var(--warning-50); color: var(--warning-600); }
.badge-info    { background: var(--info-50); color: var(--info-600); }
.badge-purple  { background: #f5f3ff; color: var(--purple-500); }
.badge-gray    { background: var(--gray-100); color: var(--gray-600); }

/* Avatar */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    object-fit: cover;
    background: var(--primary-100);
    color: var(--primary-700);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--font-sm);
    flex-shrink: 0;
}

.avatar-sm { width: 28px; height: 28px; font-size: var(--font-xs); }
.avatar-lg { width: 48px; height: 48px; font-size: var(--font-lg); }
.avatar-xl { width: 64px; height: 64px; font-size: var(--font-2xl); }

/* Grid */
.grid {
    display: grid;
    gap: var(--space-6);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* Flex utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

/* Spacing utilities */
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

/* Text utilities */
.text-sm { font-size: var(--font-sm); }
.text-xs { font-size: var(--font-xs); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success-500); }
.text-danger { color: var(--danger-500); }
.text-warning { color: var(--warning-500); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-6);
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

.empty-state-title {
    font-size: var(--font-lg);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

/* Notification bell */
.notification-bell {
    position: relative;
    cursor: pointer;
}

.notification-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger-500);
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-surface);
}

/* Mobile sidebar toggle */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: var(--space-2);
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 200;
    }

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

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

    .sidebar-toggle {
        display: block;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 150;
    }

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

    .page-content {
        padding: var(--space-4);
    }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-fade-in { animation: fadeIn 0.3s ease-out; }
.animate-slide-up { animation: slideUp 0.3s ease-out; }

/* Skeleton loader */
.skeleton {
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

.modal-header {
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: var(--font-lg);
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
}

.modal-close:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 200px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    padding: var(--space-1) 0;
    display: none;
    animation: slideUp 0.15s ease-out;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition-fast);
    text-decoration: none;
}

.dropdown-item:hover {
    background: var(--bg-surface-hover);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--space-1) 0;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    gap: 0;
    margin-bottom: var(--space-6);
}

.tab {
    padding: var(--space-3) var(--space-5);
    font-size: var(--font-sm);
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition-fast);
    text-decoration: none;
}

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

.tab.active {
    color: var(--primary-600);
    border-bottom-color: var(--primary-600);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    justify-content: center;
    margin-top: var(--space-6);
}

.pagination-btn {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: var(--font-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pagination-btn:hover {
    background: var(--bg-surface-hover);
    border-color: var(--primary-300);
}

.pagination-btn.active {
    background: var(--primary-600);
    color: white;
    border-color: var(--primary-600);
}

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

/* Toggle switch */
.toggle {
    position: relative;
    display: inline-flex;
    cursor: pointer;
}

.toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    width: 44px;
    height: 24px;
    background: var(--gray-300);
    border-radius: var(--radius-full);
    transition: background var(--transition-fast);
    position: relative;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.toggle input:checked + .toggle-slider {
    background: var(--primary-500);
}

.toggle input:checked + .toggle-slider::after {
    transform: translateX(20px);
}

/* Search */
.search-box {
    position: relative;
    max-width: 320px;
}

.search-box input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.5rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    font-size: var(--font-sm);
    color: var(--text-primary);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

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

/* ============================================================
   SIDEBAR FOOTER & USER
   ============================================================ */

.sidebar-footer {
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin-top: auto;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.sidebar-user:hover {
    background: var(--bg-sidebar-hover);
}

.sidebar-user .avatar {
    border: 2px solid rgba(255, 255, 255, 0.15);
}

.sidebar-user .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-full);
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    display: block;
    font-size: var(--font-sm);
    font-weight: 500;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    display: block;
    font-size: var(--font-xs);
    color: var(--gray-500);
}

.sidebar-logout {
    color: var(--gray-500);
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.sidebar-logout:hover {
    color: var(--danger-500);
    background: rgba(239, 68, 68, 0.1);
}

.sidebar-close-btn {
    display: none;
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: var(--space-1);
    margin-left: auto;
}

@media (max-width: 768px) {
    .sidebar-close-btn {
        display: block;
    }
}

/* ============================================================
   USER DROPDOWN (HEADER)
   ============================================================ */

.user-dropdown {
    position: relative;
}

.user-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-2);
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font-family);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.user-dropdown-trigger:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-color);
}

.user-dropdown-trigger .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-full);
}

.user-dropdown-name {
    font-size: var(--font-sm);
    font-weight: 500;
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    width: 240px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 200;
    display: none;
    animation: slideUp 0.15s ease-out;
    overflow: hidden;
}

.user-dropdown-menu.show {
    display: block;
}

.user-dropdown-header {
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--border-color);
}

.user-dropdown-header strong {
    font-size: var(--font-sm);
    color: var(--text-primary);
}

.user-dropdown-header small {
    font-size: var(--font-xs);
    color: var(--text-muted);
    word-break: break-all;
}

.user-dropdown-divider {
    height: 1px;
    background: var(--border-color);
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-sm);
    color: var(--text-primary);
    text-decoration: none;
    transition: background var(--transition-fast);
}

.user-dropdown-item:hover {
    background: var(--bg-surface-hover);
}

/* ============================================================
   TOAST ENHANCEMENTS
   ============================================================ */

.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    font-size: var(--font-sm);
    font-weight: 500;
    backdrop-filter: blur(10px);
    animation: slideIn 0.3s ease-out;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    box-shadow: var(--shadow-lg);
}

.toast.success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--success-600);
}

.toast.error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger-600);
}

.toast.warning {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--warning-600);
}

.toast.info {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--info-600);
}

.toast-message {
    flex: 1;
}

.toast-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.6;
    padding: 2px;
    flex-shrink: 0;
}

.toast-close:hover {
    opacity: 1;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   MODAL SIZES
   ============================================================ */

.modal-sm {
    max-width: 380px;
}

.modal-lg {
    max-width: 720px;
}

.modal-xl {
    max-width: 960px;
}

.confirm-icon {
    color: var(--warning-500);
    margin-bottom: var(--space-4);
}

.confirm-title {
    font-size: var(--font-lg);
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================================
   WELCOME CARD (Dashboard)
   ============================================================ */

.welcome-card {
    background: linear-gradient(135deg, var(--primary-600) 0%, #7c3aed 100%);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    color: white;
    position: relative;
    overflow: hidden;
}

.welcome-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 300px;
    height: 300px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
}

.welcome-card::after {
    content: '';
    position: absolute;
    bottom: -30%;
    right: 10%;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
}

.welcome-card h2 {
    font-size: var(--font-2xl);
    font-weight: 700;
    margin-bottom: var(--space-2);
    position: relative;
    z-index: 1;
}

.welcome-card p {
    font-size: var(--font-base);
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

.welcome-card .welcome-date {
    font-size: var(--font-sm);
    opacity: 0.7;
    margin-top: var(--space-4);
    position: relative;
    z-index: 1;
}

/* ============================================================
   ACTIVITY FEED
   ============================================================ */

.activity-item {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border-color-light);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.activity-dot.blue { background: var(--primary-500); }
.activity-dot.green { background: var(--success-500); }
.activity-dot.red { background: var(--danger-500); }
.activity-dot.yellow { background: var(--warning-500); }

.activity-text {
    font-size: var(--font-sm);
    color: var(--text-primary);
    line-height: 1.4;
}

.activity-time {
    font-size: var(--font-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

/* ============================================================
   QUICK ACTION BUTTONS
   ============================================================ */

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-4);
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-5);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    color: var(--text-primary);
    font-family: var(--font-family);
}

.quick-action-btn:hover {
    border-color: var(--primary-300);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.quick-action-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.quick-action-label {
    font-size: var(--font-sm);
    font-weight: 500;
    text-align: center;
}

/* ============================================================
   RESPONSIVE HIDING
   ============================================================ */

@media (max-width: 768px) {
    .user-dropdown-name {
        display: none;
    }
    
    .user-dropdown-trigger svg:last-child {
        display: none;
    }
}

@media (max-width: 480px) {
    .header-search {
        display: none;
    }
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */

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

.form-label {
    display: block;
    font-size: var(--font-sm);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}

.form-label .required { color: var(--danger-500); }

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-sm);
    font-family: var(--font-family);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-textarea { resize: vertical; min-height: 80px; }

.form-hint {
    font-size: var(--font-xs);
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-error {
    font-size: var(--font-xs);
    color: var(--danger-500);
    margin-top: 0.25rem;
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.toggle input[type="checkbox"] {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    width: 44px;
    height: 24px;
    background: var(--gray-300);
    border-radius: 12px;
    transition: background var(--transition-fast);
    position: relative;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform var(--transition-fast);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-slider {
    background: var(--primary-500);
}

.toggle input:checked + .toggle-slider::after {
    transform: translateX(20px);
}

/* ============================================================
   DATA TABLES
   ============================================================ */

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-sm);
}

.data-table thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: var(--font-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-surface);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color-light);
    vertical-align: middle;
}

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

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

/* ============================================================
   TABS
   ============================================================ */

.tabs {
    display: flex;
    gap: var(--space-1);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab {
    padding: 0.625rem 1rem;
    font-size: var(--font-sm);
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
    white-space: nowrap;
    cursor: pointer;
}

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

.tab.active {
    color: var(--primary-600);
    border-bottom-color: var(--primary-600);
}

/* ============================================================
   BADGES
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    font-size: var(--font-xs);
    font-weight: 500;
    border-radius: var(--radius-full);
    line-height: 1.4;
    white-space: nowrap;
}

.badge-success { background: rgba(34, 197, 94, 0.1); color: var(--success-600); }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning-600); }
.badge-danger  { background: rgba(239, 68, 68, 0.1); color: var(--danger-600); }
.badge-info    { background: rgba(59, 130, 246, 0.1); color: var(--info-600); }
.badge-gray    { background: var(--gray-100); color: var(--gray-600); }
.badge-purple  { background: rgba(139, 92, 246, 0.1); color: #7c3aed; }
.badge-primary { background: rgba(59, 130, 246, 0.1); color: var(--primary-600); }

/* ============================================================
   GRID LAYOUT
   ============================================================ */

.grid {
    display: grid;
    gap: var(--space-6);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.text-xs { font-size: var(--font-xs); }
.text-sm { font-size: var(--font-sm); }
.text-base { font-size: var(--font-base); }
.text-lg { font-size: var(--font-lg); }
.text-xl { font-size: var(--font-xl); }
.text-2xl { font-size: var(--font-2xl); }
.text-3xl { font-size: var(--font-3xl); }

.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success-600); }
.text-danger { color: var(--danger-600); }
.text-center { text-align: center; }

/* ============================================================
   STAT CARDS
   ============================================================ */

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    transition: all var(--transition-base);
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue   { background: rgba(59, 130, 246, 0.1); color: var(--primary-600); }
.stat-icon.green  { background: rgba(34, 197, 94, 0.1); color: var(--success-600); }
.stat-icon.yellow { background: rgba(245, 158, 11, 0.1); color: var(--warning-600); }
.stat-icon.red    { background: rgba(239, 68, 68, 0.1); color: var(--danger-600); }
.stat-icon.purple { background: rgba(139, 92, 246, 0.1); color: #7c3aed; }

.stat-info { flex: 1; min-width: 0; }

.stat-value {
    font-size: var(--font-2xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: var(--font-sm);
    color: var(--text-muted);
    margin-top: 2px;
}

.stat-change {
    font-size: var(--font-xs);
    color: var(--text-muted);
    margin-top: 4px;
}

.stat-change.up { color: var(--success-600); }
.stat-change.down { color: var(--danger-500); }

/* ============================================================
   EMPTY STATES
   ============================================================ */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--space-4);
    opacity: 0.6;
}

.empty-state-title {
    font-size: var(--font-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

.animate-slide-up {
    animation: slideUp 0.4s ease-out;
}

/* ============================================================
   CARD FOOTER
   ============================================================ */

.card-footer {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border-color-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   SPINNER
   ============================================================ */

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

