@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-50: #eef2ff;
    --primary-100: #e0e7ff;
    --primary-900: #312e81;
    --accent: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --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;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --gradient: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    --card-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
    --card-shadow-hover: 0 10px 25px rgba(0,0,0,0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    font-size: 0.9rem;
    -webkit-font-smoothing: antialiased;
}

/* ========== SIDEBAR ========== */
#sidebar-wrapper {
    background: var(--sidebar-bg) !important;
    min-height: 100vh;
    transition: var(--transition);
    border-right: 1px solid rgba(255,255,255,0.05);
    position: fixed;
    top: 0; left: 0; z-index: 1000;
    overflow-y: auto;
}

.sidebar-heading {
    padding: 24px 20px !important;
    border-bottom: 1px solid rgba(255,255,255,0.06) !important;
}

.sidebar-heading h5 {
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.02em;
}

.sidebar-heading .bi-building {
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.3rem;
}

#sidebar-wrapper .list-group { padding: 12px 10px; }

#sidebar-wrapper .list-group-item {
    background: transparent !important;
    border: none !important;
    padding: 10px 14px;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--radius-sm) !important;
    margin-bottom: 2px;
    transition: var(--transition);
    color: var(--gray-400) !important;
}

#sidebar-wrapper .list-group-item:hover {
    background: var(--sidebar-hover) !important;
    color: white !important;
}

#sidebar-wrapper .list-group-item.active {
    background: var(--gradient) !important;
    color: white !important;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

/* ========== MAIN CONTENT ========== */
#page-content-wrapper { margin-left: 250px; min-height: 100vh; width: calc(100% - 250px); }

/* ========== NAVBAR ========== */
.navbar {
    background: rgba(255,255,255,0.8) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--gray-200) !important;
    padding: 12px 24px !important;
    position: sticky; top: 0; z-index: 999;
    box-shadow: none;
    display: flex; justify-content: space-between; width: 100%;
}

.navbar .btn-outline-secondary {
    border: 1px solid var(--gray-200);
    color: var(--gray-500);
    border-radius: var(--radius-sm);
}

.navbar .btn-outline-secondary:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.navbar .badge {
    font-size: 0.7rem; padding: 4px 8px;
    font-weight: 600; border-radius: 20px;
}

.navbar .btn-outline-danger {
    border-radius: 50%;
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    border: 1px solid var(--gray-200);
    color: var(--gray-400);
    transition: var(--transition);
}

.navbar .btn-outline-danger:hover {
    background: var(--danger); border-color: var(--danger); color: white;
}

/* ========== CARDS ========== */
.card {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    background: white;
    overflow: hidden;
}

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

.card-header {
    background: white;
    border-bottom: 1px solid var(--gray-100);
    border-radius: var(--radius) var(--radius) 0 0 !important;
    padding: 16px 20px;
    font-weight: 600; font-size: 0.9rem;
}

.card-body { padding: 20px; }

/* ========== STAT CARDS ========== */
.stat-card {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    border-left: none;
    padding: 24px !important;
    background: white;
    position: relative; overflow: hidden;
    transition: var(--transition);
}

.stat-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: var(--primary);
}

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

.stat-card .stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; margin-bottom: 16px;
}

.stat-card .stat-number {
    font-size: 2rem; font-weight: 800;
    letter-spacing: -0.03em; line-height: 1;
    margin-bottom: 4px; color: var(--gray-900);
}

.stat-card .stat-label {
    color: var(--gray-500); font-size: 0.8rem;
    font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em;
}

.stat-card.primary::before { background: var(--primary); }
.stat-card.primary .stat-icon { background: var(--primary-50); color: var(--primary); }
.stat-card.success::before { background: var(--success); }
.stat-card.success .stat-icon { background: #ecfdf5; color: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.warning .stat-icon { background: #fffbeb; color: var(--warning); }
.stat-card.info::before { background: var(--info); }
.stat-card.info .stat-icon { background: #eff6ff; color: var(--info); }

/* ========== TABLES ========== */
.table { font-size: 0.85rem; }

.table thead th {
    font-weight: 600; font-size: 0.75rem;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--gray-500); border-bottom: 2px solid var(--gray-200);
    padding: 12px 16px; white-space: nowrap;
}

.table tbody td {
    padding: 14px 16px; vertical-align: middle;
    border-bottom: 1px solid var(--gray-100); color: var(--gray-700);
}

.table-hover tbody tr:hover { background: var(--gray-50); }
.table tbody td strong { color: var(--gray-900); font-weight: 600; }
.table a { color: var(--primary); text-decoration: none; font-weight: 500; }
.table a:hover { color: var(--primary-dark); }

/* ========== BADGES ========== */
.badge {
    font-weight: 600; padding: 5px 10px;
    font-size: 0.72rem; border-radius: 20px;
}

.bg-success { background: #dcfce7 !important; color: #166534 !important; }
.bg-warning { background: #fef3c7 !important; color: #92400e !important; }
.bg-danger { background: #fef2f2 !important; color: #991b1b !important; }
.bg-primary { background: var(--primary-100) !important; color: var(--primary-900) !important; }
.bg-secondary { background: var(--gray-100) !important; color: var(--gray-600) !important; }
.bg-info { background: #dbeafe !important; color: #1e40af !important; }

/* ========== BUTTONS ========== */
.btn {
    font-weight: 500; font-size: 0.85rem;
    border-radius: var(--radius-sm);
    padding: 8px 16px; transition: var(--transition);
}

.btn-primary {
    background: var(--primary); border-color: var(--primary);
    box-shadow: 0 1px 3px rgba(99,102,241,0.3);
}

.btn-primary:hover {
    background: var(--primary-dark); border-color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(99,102,241,0.4);
    transform: translateY(-1px);
}

.btn-outline-primary { border-color: var(--gray-200); color: var(--primary); }
.btn-outline-primary:hover {
    background: var(--primary); border-color: var(--primary); color: white;
}

.btn-outline-success { border-color: var(--gray-200); color: var(--success); }
.btn-outline-success:hover { background: var(--success); border-color: var(--success); color: white; }

.btn-outline-info { border-color: var(--gray-200); color: var(--accent); }
.btn-outline-info:hover { background: var(--accent); border-color: var(--accent); color: white; }

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

.btn-lg {
    padding: 12px 32px; font-size: 0.95rem;
    font-weight: 600; border-radius: var(--radius);
}

/* ========== FORMS ========== */
.form-control, .form-select {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 10px 14px; font-size: 0.85rem;
    color: var(--gray-800); transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.form-control::placeholder { color: var(--gray-400); }

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

.input-group-text {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    color: var(--gray-400);
}

/* ========== SECTION DIVIDERS ========== */
.section-divider {
    padding: 10px 16px; margin: 28px 0 16px;
    background: var(--gray-50);
    border-left: 3px solid var(--primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-weight: 600; font-size: 0.85rem; color: var(--gray-700);
}

.section-divider i { color: var(--primary); }

/* ========== ALERTS ========== */
.alert { border-radius: var(--radius); border: none; font-size: 0.85rem; font-weight: 500; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ========== LOGIN PAGE ========== */
.login-wrapper {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: var(--gray-900);
    position: relative; overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute; width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(99,102,241,0.15) 0%, transparent 70%);
    top: -200px; right: -100px; border-radius: 50%;
}

.login-wrapper::after {
    content: '';
    position: absolute; width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(6,182,212,0.1) 0%, transparent 70%);
    bottom: -100px; left: -50px; border-radius: 50%;
}

.login-card {
    width: 100%; max-width: 420px;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.03);
    backdrop-filter: blur(20px);
    box-shadow: 0 25px 50px rgba(0,0,0,0.4);
    position: relative; z-index: 1;
}

.login-card .card-body { padding: 40px; }

.login-logo {
    width: 56px; height: 56px;
    border-radius: var(--radius);
    background: var(--gradient);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 20px;
    font-size: 1.6rem; color: white;
    box-shadow: 0 8px 24px rgba(99,102,241,0.3);
}

.login-logo-svg {
    margin: 0 auto 10px;
    display: flex; align-items: center; justify-content: center;
}

.login-card h3 {
    font-weight: 800; font-size: 1.5rem;
    letter-spacing: -0.03em; color: white;
}

.login-card p { color: var(--gray-400); }

.login-card .form-label { color: var(--gray-400); }

.login-card .form-control {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: white; padding: 12px 14px;
}

.login-card .form-control:focus {
    background: rgba(255,255,255,0.08);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}

.login-card .form-control::placeholder { color: var(--gray-500); }

.login-card .input-group-text {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--gray-400);
}

.login-card .btn-primary {
    padding: 12px; font-weight: 600; font-size: 0.95rem;
    background: var(--gradient); border: none;
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(99,102,241,0.4);
}

.login-card .btn-primary:hover {
    box-shadow: 0 8px 24px rgba(99,102,241,0.5);
    transform: translateY(-1px);
}

/* ========== DATATABLE ========== */
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
    padding: 6px 12px; font-size: 0.85rem;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12); outline: none;
}

.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: var(--radius-sm) !important;
    border: 1px solid var(--gray-200) !important;
    margin: 0 2px; font-size: 0.85rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: white !important;
}

.dataTables_wrapper .dataTables_info { font-size: 0.8rem; color: var(--gray-500); }

/* ========== TELEGESTION ========== */
.telegestion-row {
    border: 1px solid var(--gray-200) !important;
    border-radius: var(--radius-sm) !important;
    background: var(--gray-50);
}

.telegestion-row:hover { border-color: var(--primary-light) !important; }

/* ========== COLOR PICKER ========== */
.minicolors .minicolors-swatch { top: 5px; border-radius: 4px; }

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    #sidebar-wrapper { margin-left: -250px; position: fixed; z-index: 1000; }
    #sidebar-wrapper.toggled { margin-left: 0; }
    #page-content-wrapper { margin-left: 0; width: 100%; }
    .container-fluid { padding: 16px !important; }
}

/* ========== LOADING ========== */
.loading-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.85); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center; z-index: 9999;
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
