/* === Global Variables & Reset === */
:root {
    --primary: #1a3c5e;
    --primary-light: #2a5580;
    --primary-dark: #0f2a42;
    --secondary: #4a6fa5;
    --surface: #f0f4f8;
    --background: #ffffff;
    --text: #1a1a2e;
    --text-light: #555;
    --text-muted: #888;
    --success: #2ecc71;
    --success-dark: #27ae60;
    --error: #e74c3c;
    --error-dark: #c0392b;
    --warning: #f39c12;
    --info: #3498db;
    --border: #e0e6ed;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--surface);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-light);
}

button {
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.9rem;
}

img {
    max-width: 100%;
    height: auto;
}

/* === Typography === */
h1 { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
h2 { font-size: 1.5rem; font-weight: 600; color: var(--primary); }
h3 { font-size: 1.25rem; font-weight: 600; color: var(--text); }
h4 { font-size: 1.1rem; font-weight: 500; color: var(--text); }

/* === Layout === */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--primary);
    color: white;
    padding: 24px 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    padding: 0 24px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 16px;
}

.sidebar-header h2 {
    color: white;
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.sidebar-header p {
    color: rgba(255,255,255,0.6);
    font-size: 0.8rem;
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background: rgba(255,255,255,0.1);
    color: white;
    border-left-color: var(--success);
}

.sidebar-nav li a .icon {
    width: 20px;
    text-align: center;
}

.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 32px;
    min-height: 100vh;
}

/* === Header === */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.page-header h1 {
    margin: 0;
}

/* === Cards === */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--background);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    border: 1px solid var(--border);
}

.stat-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.stat-card .card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-bottom: 12px;
}

.stat-card .card-icon.blue { background: rgba(52,152,219,0.1); color: #3498db; }
.stat-card .card-icon.green { background: rgba(46,204,113,0.1); color: #2ecc71; }
.stat-card .card-icon.orange { background: rgba(243,156,18,0.1); color: #f39c12; }
.stat-card .card-icon.purple { background: rgba(155,89,182,0.1); color: #9b59b6; }

.stat-card .card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.stat-card .card-label {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* === Tables === */
.table-container {
    background: var(--background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border);
}

.table-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-header h3 {
    margin: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    background: var(--surface);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    border-bottom: 1px solid var(--border);
}

table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

table tr:last-child td {
    border-bottom: none;
}

table tr:hover {
    background: rgba(240, 244, 248, 0.5);
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-light);
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: var(--success-dark);
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    background: var(--error-dark);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn .spinner {
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === Badge === */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success { background: rgba(46,204,113,0.1); color: var(--success-dark); }
.badge-warning { background: rgba(243,156,18,0.1); color: var(--warning); }
.badge-danger { background: rgba(231,76,60,0.1); color: var(--error); }
.badge-info { background: rgba(52,152,219,0.1); color: var(--info); }

/* === Pagination === */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 20px;
}

.pagination button {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    background: var(--background);
    border-radius: var(--radius);
    font-size: 0.85rem;
    transition: var(--transition);
}

.pagination button:hover,
.pagination button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* === Toast === */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius);
    color: white;
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--error); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--info); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* === Modal === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--background);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--surface);
    border-radius: 50%;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.empty-state h3 {
    color: var(--text-light);
    margin-bottom: 8px;
}

/* === Loading Skeleton === */
.skeleton {
    background: linear-gradient(90deg, var(--surface) 25%, #e8edf2 50%, var(--surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

.skeleton-row {
    height: 48px;
    margin-bottom: 8px;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* === Filter Bar === */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
    padding: 20px;
    background: var(--background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

/* === Responsive === */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }
    .main-content {
        margin-left: 220px;
        padding: 24px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
        padding: 16px;
    }
    .cards-grid {
        grid-template-columns: 1fr;
    }
    .filter-bar {
        flex-direction: column;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

/* === Logout Button === */
.btn-logout {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    color: rgba(255,255,255,0.7);
    width: 100%;
    border: none;
    background: none;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

/* === Confirmation Dialog === */
.confirm-dialog {
    text-align: center;
}

.confirm-dialog p {
    margin-bottom: 24px;
    color: var(--text-light);
}

.confirm-dialog .btn-group {
    display: flex;
    gap: 12px;
    justify-content: center;
}
