/* ============================================================
   Logiciel de Gestion Immobilière – Maroc
   Feuille de styles principale v8 — COMPLETE REWRITE
   Trilingue : FR / EN / AR (RTL)
   Conforme Décret 2.23.700 & Loi 18-00
   ============================================================ */

/* ---------- Variables CSS ---------- */
:root {
    --primary: #1565c0;
    --primary-light: #5e92f3;
    --primary-dark: #003c8f;
    --primary-gradient: linear-gradient(180deg, #0d47a1 0%, #1565c0 50%, #1976d2 100%);
    --secondary: #78909c;
    --success: #2e7d32;
    --success-light: #66bb6a;
    --danger: #c62828;
    --danger-light: #ef5350;
    --warning: #f57f17;
    --warning-light: #ffb300;
    --info: #0277bd;
    --info-light: #29b6f6;
    --dark: #263238;
    --light: #eceff1;
    --body-bg: #f5f7fa;
    --card-bg: #ffffff;
    --text-color: #212121;
    --text-muted: #78909c;
    --border-color: #e0e0e0;
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --header-height: 58px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 3px 10px rgba(0,0,0,.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
    --radius: 8px;
    --radius-sm: 5px;
    --radius-lg: 12px;
    --transition: all .25s cubic-bezier(.4,0,.2,1);
    --font-ar: 'Cairo', 'Noto Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
    --font-fr: 'Inter', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ---------- Dark Mode ---------- */
[data-theme="dark"] {
    --body-bg: #1a1a2e;
    --card-bg: #16213e;
    --text-color: #e0e0e0;
    --text-muted: #90a4ae;
    --border-color: #2a3a4a;
    --primary: #5e92f3;
    --primary-light: #82b1ff;
    --primary-dark: #1565c0;
    --light: #1a1a2e;
    --dark: #e0e0e0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
    --shadow-md: 0 3px 10px rgba(0,0,0,.35);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.4);
}

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

body {
    font-family: var(--font-fr);
    background: var(--body-bg);
    color: var(--text-color);
    line-height: 1.55;
    font-size: 14px;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ---------- RTL ---------- */
[dir="rtl"] body,
[dir="rtl"] * {
    font-family: var(--font-ar);
    direction: rtl;
    text-align: right;
}
[dir="rtl"] .text-left { text-align: right !important; }
[dir="rtl"] .text-right { text-align: left !important; }
[dir="rtl"] .float-right { float: left !important; }
[dir="rtl"] .float-left { float: right !important; }

/* ============================================================
   SIDEBAR — matches .sidebar, .sidebar-header, .sidebar-logo,
              .sidebar-brand, .sidebar-nav, .nav-item, .nav-section
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--primary-gradient);
    color: #fff;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width .3s ease, transform .3s ease;
    box-shadow: 3px 0 16px rgba(0,0,0,.2);
    display: flex;
    flex-direction: column;
}
[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    box-shadow: -3px 0 16px rgba(0,0,0,.2);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,.12);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo > i {
    font-size: 1.6rem;
    color: #ffc107;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.3));
}

.sidebar-brand {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: .3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar .sidebar-toggle {
    background: rgba(255,255,255,.1);
    border: none;
    color: rgba(255,255,255,.7);
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}
.sidebar .sidebar-toggle:hover {
    background: rgba(255,255,255,.2);
    color: #fff;
}

/* ---------- Sidebar Navigation ---------- */
.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    color: rgba(255,255,255,.8);
    text-decoration: none;
    font-size: .88rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: var(--transition);
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}
[dir="rtl"] .nav-item {
    border-left: none;
    border-right: 3px solid transparent;
}

.nav-item i {
    font-size: 1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
    opacity: .85;
}

.nav-item span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item:hover {
    background: rgba(255,255,255,.12);
    color: #fff;
    border-left-color: rgba(255,255,255,.3);
}
[dir="rtl"] .nav-item:hover {
    border-right-color: rgba(255,255,255,.3);
}

.nav-item.active {
    background: rgba(255,255,255,.18);
    color: #fff;
    border-left-color: #ffc107;
    font-weight: 600;
}
[dir="rtl"] .nav-item.active {
    border-right-color: #ffc107;
}

.nav-item.active i {
    color: #ffc107;
    opacity: 1;
}

.nav-section {
    padding: 14px 18px 4px;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,.4);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
}

/* ---------- Sidebar scrollbar ---------- */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 4px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.4); }

/* ============================================================
   MAIN CONTENT — matches .main-content, .topbar, .content-area
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin .3s ease;
}
[dir="rtl"] .main-content {
    margin-left: 0;
    margin-right: var(--sidebar-width);
}

/* ---------- Topbar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 999;
    height: var(--header-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-toggle-mobile {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-color);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: none;
}
.sidebar-toggle-mobile:hover { background: var(--light); }

.page-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-color);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ---------- Language Switch ---------- */
.lang-switch {
    display: flex;
    gap: 3px;
    background: var(--light);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.lang-btn {
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
}
.lang-btn:hover {
    background: rgba(21,101,192,.08);
    color: var(--primary);
}
.lang-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 1px 3px rgba(21,101,192,.3);
}

/* ---------- Notification Dropdown ---------- */
.notif-dropdown {
    position: relative;
}

.notif-btn {
    background: none;
    border: none;
    font-size: 1.15rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    position: relative;
}
.notif-btn:hover {
    color: var(--primary);
    background: rgba(21,101,192,.05);
}

.notif-badge {
    position: absolute;
    top: 1px;
    right: 1px;
    background: var(--danger);
    color: #fff;
    border-radius: 50%;
    font-size: .6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(198,40,40,.4);
}
[dir="rtl"] .notif-badge {
    right: auto;
    left: 1px;
}

.notif-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    width: 320px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1100;
    overflow: hidden;
}
[dir="rtl"] .notif-menu {
    right: auto;
    left: 0;
}
.notif-dropdown.open .notif-menu {
    display: block;
}

.notif-header {
    padding: 12px 16px;
    font-weight: 700;
    font-size: .88rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

.notif-list {
    max-height: 240px;
    overflow-y: auto;
}

.notif-footer {
    display: block;
    padding: 10px 16px;
    text-align: center;
    font-size: .82rem;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    border-top: 1px solid var(--border-color);
    transition: var(--transition);
}
.notif-footer:hover {
    background: var(--light);
}

/* ---------- User Dropdown ---------- */
.user-dropdown {
    position: relative;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 5px 12px;
    cursor: pointer;
    color: var(--text-color);
    font-size: .85rem;
    font-weight: 500;
    transition: var(--transition);
}
.user-btn:hover {
    background: var(--light);
    border-color: var(--primary);
}
.user-btn i {
    font-size: 1.1rem;
    color: var(--primary);
}

.user-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 180px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1100;
    padding: 6px 0;
    margin-top: 4px;
}
[dir="rtl"] .user-menu {
    right: auto;
    left: 0;
}
.user-dropdown.open .user-menu {
    display: block;
}

.user-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: var(--text-color);
    text-decoration: none;
    font-size: .85rem;
    transition: var(--transition);
}
.user-menu a:hover {
    background: rgba(21,101,192,.06);
    color: var(--primary);
}
.user-menu a i {
    width: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: .92rem;
}
.user-menu a:hover i {
    color: var(--primary);
}

/* ============================================================
   CONTENT AREA & FLASH
   ============================================================ */
.content-area {
    flex: 1;
    padding: 24px;
}

.flash-container {
    margin-bottom: 16px;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 10px;
    font-size: .88rem;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeIn .3s ease;
}
.alert i { font-size: 1rem; }
.alert-success { background: #e8f5e9; color: #1b5e20; border: 1px solid #a5d6a7; }
.alert-danger { background: #ffebee; color: #b71c1c; border: 1px solid #ef9a9a; }
.alert-warning { background: #fff8e1; color: #e65100; border: 1px solid #ffcc80; }
.alert-info { background: #e1f5fe; color: #01579b; border: 1px solid #81d4fa; }
.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: inherit;
    opacity: .5;
    transition: var(--transition);
}
.alert-close:hover { opacity: 1; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Footer ---------- */
.footer {
    padding: 14px 24px;
    text-align: center;
    font-size: .78rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* ---------- Sidebar Overlay ---------- */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.4);
    z-index: 999;
    transition: var(--transition);
}
.sidebar-overlay.active {
    display: block;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 10px;
}
.page-header h1 i {
    color: var(--primary);
}
.header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 18px;
    transition: var(--transition);
    overflow: hidden;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
    padding: 13px 18px;
    font-weight: 600;
    font-size: .92rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-body { padding: 18px; }
.card-footer { padding: 10px 18px; border-top: 1px solid var(--border-color); }

/* Header color variants */
.card-header.bg-primary   { background: var(--primary); color: #fff; }
.card-header.bg-success   { background: var(--success); color: #fff; }
.card-header.bg-warning   { background: var(--warning); color: #212121; }
.card-header.bg-info      { background: var(--info); color: #fff; }
.card-header.bg-secondary { background: var(--secondary); color: #fff; }
.card-header.bg-danger    { background: var(--danger); color: #fff; }

/* ============================================================
   STAT CARDS (Dashboard)
   ============================================================ */
.stat-card {
    border-radius: var(--radius-lg);
    padding: 18px;
    color: #fff;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}
.stat-card .stat-icon {
    font-size: 2.2rem;
    opacity: .25;
    position: absolute;
    top: 14px;
    right: 14px;
}
[dir="rtl"] .stat-card .stat-icon {
    right: auto;
    left: 14px;
}
.stat-card .stat-value {
    font-size: 1.85rem;
    font-weight: 800;
    line-height: 1.2;
}
.stat-card .stat-label {
    font-size: .82rem;
    opacity: .9;
    margin-top: 2px;
}
.stat-card::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: -20px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,.08);
}

.bg-primary-gradient   { background: linear-gradient(135deg, #0d47a1 0%, #1e88e5 100%); }
.bg-success-gradient   { background: linear-gradient(135deg, #1b5e20 0%, #43a047 100%); }
.bg-warning-gradient   { background: linear-gradient(135deg, #e65100 0%, #ff9800 100%); }
.bg-danger-gradient    { background: linear-gradient(135deg, #b71c1c 0%, #e53935 100%); }
.bg-info-gradient      { background: linear-gradient(135deg, #01579b 0%, #039be5 100%); }
.bg-secondary-gradient { background: linear-gradient(135deg, #37474f 0%, #78909c 100%); }

/* ============================================================
   TABLES
   ============================================================ */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: .86rem;
}
[dir="rtl"] .table th, [dir="rtl"] .table td { text-align: right; }
.table thead th {
    background: var(--light);
    font-weight: 600;
    color: var(--text-color);
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1;
}
.table-striped tbody tr:nth-child(even) { background: rgba(0,0,0,.015); }
.table-hover tbody tr:hover { background: rgba(21,101,192,.04); }
.table .actions { white-space: nowrap; width: 1%; }
.table .table-total td { font-weight: 700; border-top: 2px solid var(--border-color); background: var(--light); }

.table-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.table-responsive { overflow-x: auto; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: .86rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary        { background: var(--primary); color: #fff; }
.btn-primary:hover   { background: var(--primary-dark); }
.btn-secondary      { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: #546e7a; }
.btn-success        { background: var(--success); color: #fff; }
.btn-success:hover   { background: #1b5e20; }
.btn-danger          { background: var(--danger); color: #fff; }
.btn-danger:hover    { background: #8e0000; }
.btn-warning         { background: var(--warning); color: #212121; }
.btn-info            { background: var(--info); color: #fff; }

.btn-outline-primary   { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn-outline-primary:hover   { background: var(--primary); color: #fff; }
.btn-outline-secondary { background: transparent; border-color: var(--secondary); color: var(--secondary); }
.btn-outline-danger    { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-outline-danger:hover    { background: var(--danger); color: #fff; }
.btn-outline-warning   { background: transparent; border-color: var(--warning); color: var(--warning); }
.btn-outline-success   { background: transparent; border-color: var(--success); color: var(--success); }
.btn-outline-info      { background: transparent; border-color: var(--info); color: var(--info); }

.btn-sm { padding: 4px 10px; font-size: .78rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }

.btn-group {
    display: inline-flex;
    gap: 0;
}
.btn-group .btn {
    border-radius: 0;
}
.btn-group .btn:first-child {
    border-radius: var(--radius) 0 0 var(--radius);
}
.btn-group .btn:last-child {
    border-radius: 0 var(--radius) var(--radius) 0;
}
[dir="rtl"] .btn-group .btn:first-child {
    border-radius: 0 var(--radius) var(--radius) 0;
}
[dir="rtl"] .btn-group .btn:last-child {
    border-radius: var(--radius) 0 0 var(--radius);
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 4px;
    font-size: .73rem;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: .2px;
}
.badge-primary   { background: #e3f2fd; color: #0d47a1; }
.badge-success   { background: #e8f5e9; color: #1b5e20; }
.badge-danger    { background: #ffebee; color: #b71c1c; }
.badge-warning   { background: #fff8e1; color: #e65100; }
.badge-info      { background: #e1f5fe; color: #01579b; }
.badge-secondary { background: #eceff1; color: #37474f; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    font-size: .86rem;
    color: var(--text-color);
}
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: .86rem;
    color: var(--text-color);
    background: var(--card-bg);
    transition: var(--transition);
    font-family: inherit;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21,101,192,.12);
}
.form-control.is-invalid { border-color: var(--danger); }
select.form-control { appearance: auto; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}
.form-check-input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }
.form-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}
.form-row .form-group { flex: 1; min-width: 200px; }
.form-control-file { font-size: .82rem; }

/* ============================================================
   MODALS (Bootstrap-style compat)
   ============================================================ */
.modal { display: none; }
.modal.show { display: block; }
.modal.fade .modal-dialog { transform: translateY(-20px); transition: var(--transition); }
.modal.show .modal-dialog { transform: translateY(0); }
.modal-backdrop {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.45); z-index: 2000;
}
.modal-dialog {
    position: relative;
    max-width: 500px;
    margin: 60px auto;
}
.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}
.modal-header .close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
}
.modal-header .close:hover { color: var(--danger); }
.modal-body { padding: 18px; }
.modal-footer {
    padding: 10px 18px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ============================================================
   CHART AREA
   ============================================================ */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* ============================================================
   COMPTE CLASS BADGES
   ============================================================ */
.compte-class-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    font-size: .82rem;
}
.classe-1 { background: #e53935; }
.classe-2 { background: #f57c00; }
.classe-3 { background: #fdd835; color: #333; }
.classe-4 { background: #43a047; }
.classe-5 { background: #1e88e5; }
.classe-6 { background: #8e24aa; }
.classe-7 { background: #546e7a; }

/* ============================================================
   AUTH / LOGIN
   ============================================================ */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    padding: 20px;
}
.auth-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: 100%;
    padding: 32px;
}
.auth-card h2 {
    text-align: center;
    color: var(--primary);
    font-weight: 800;
    font-size: 1.3rem;
}
.auth-card .auth-logo {
    text-align: center;
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 10px;
}
.auth-footer {
    text-align: center;
    margin-top: 16px;
    font-size: .82rem;
    color: var(--text-muted);
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
    .sidebar, .topbar, .header-actions, .btn, .table-filters,
    .sidebar-toggle, .sidebar-toggle-mobile, .sidebar-overlay { display: none !important; }
    .main-content { margin-left: 0 !important; margin-right: 0 !important; padding: 10px !important; }
    .card { box-shadow: none !important; border: 1px solid #ccc !important; }
    body { background: #fff !important; color: #000 !important; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    [dir="rtl"] .sidebar {
        transform: translateX(100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar.open ~ .sidebar-overlay {
        display: block;
    }
    .main-content {
        margin-left: 0 !important;
    }
    [dir="rtl"] .main-content {
        margin-right: 0 !important;
    }
    .sidebar-toggle-mobile {
        display: flex;
    }
}

@media (max-width: 576px) {
    .page-header { flex-direction: column; align-items: flex-start; }
    .stat-card { padding: 14px; }
    .stat-card .stat-value { font-size: 1.4rem; }
    .form-row { flex-direction: column; }
    .form-row .form-group { min-width: 100%; }
    .table th, .table td { padding: 7px 9px; font-size: .78rem; }
    .header-actions { width: 100%; }
    .btn { font-size: .8rem; padding: 6px 12px; }
    .topbar-right { gap: 6px; }
    .lang-switch { display: none; }
    .content-area { padding: 14px; }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--body-bg); }
::-webkit-scrollbar-thumb { background: var(--secondary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.spinner {
    display: inline-block;
    width: 22px; height: 22px;
    border: 3px solid rgba(21,101,192,.15);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
    position: fixed;
    top: 72px;
    right: 18px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
[dir="rtl"] .toast-container {
    right: auto;
    left: 18px;
}
.toast-container .toast { pointer-events: auto; }

.toast {
    padding: 10px 16px;
    border-radius: var(--radius);
    background: var(--card-bg);
    box-shadow: var(--shadow-md);
    border-left: 4px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn .3s ease;
    min-width: 260px;
    max-width: 380px;
    font-size: .86rem;
}
[dir="rtl"] .toast {
    border-left: none;
    border-right: 4px solid var(--primary);
}

.toast-success { border-color: var(--success); }
.toast-danger  { border-color: var(--danger); }
.toast-warning { border-color: var(--warning); }
.toast-info    { border-color: var(--info); }

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

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-left   { text-align: left; }
.text-primary  { color: var(--primary) !important; }
.text-success  { color: var(--success) !important; }
.text-danger   { color: var(--danger) !important; }
.text-warning  { color: var(--warning) !important; }
.text-muted    { color: var(--text-muted) !important; }
.font-weight-bold { font-weight: 700; }

.mt-1 { margin-top: .5rem; }   .mt-2 { margin-top: 1rem; }   .mt-3 { margin-top: 1.5rem; }   .mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; } .mb-4 { margin-bottom: 2rem; }
.mr-1 { margin-right: .5rem; } .mr-2 { margin-right: 1rem; } .ml-1 { margin-left: .5rem; }   .ml-2 { margin-left: 1rem; }
.p-2 { padding: 1rem; } .p-3 { padding: 1.5rem; }

.d-flex { display: flex; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.gap-2 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }

.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
}
.col-6, .col-md-6, .col-lg-6 {
    flex: 0 0 50%;
    max-width: 50%;
    padding: 0 10px;
}
.col-12 {
    flex: 0 0 100%;
    max-width: 100%;
    padding: 0 10px;
}
.col-lg-4 {
    flex: 0 0 33.333%;
    max-width: 33.333%;
    padding: 0 10px;
}
.col-lg-8 {
    flex: 0 0 66.666%;
    max-width: 66.666%;
    padding: 0 10px;
}
.col-lg-3 {
    flex: 0 0 25%;
    max-width: 25%;
    padding: 0 10px;
}
.col-lg-9 {
    flex: 0 0 75%;
    max-width: 75%;
    padding: 0 10px;
}

/* ---------- Misc helpers ---------- */
.text-small { font-size: .78rem; }
.text-uppercase { text-transform: uppercase; }
.letter-spacing { letter-spacing: 1px; }
.border-bottom { border-bottom: 1px solid var(--border-color); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.rounded { border-radius: var(--radius); }
.rounded-lg { border-radius: var(--radius-lg); }
.overflow-hidden { overflow: hidden; }
.position-relative { position: relative; }
.cursor-pointer { cursor: pointer; }
.list-unstyled { list-style: none; padding: 0; }
.h-100 { height: 100%; }
.min-vh-100 { min-height: 100vh; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 18px;
    flex-wrap: wrap;
}
.pagination {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 3px;
}
.page-item {
    display: inline-block;
}
.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: .84rem;
    font-weight: 500;
    color: var(--text-color);
    background: var(--card-bg);
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
}
.page-link:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.page-item.active .page-link {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(21,101,192,.3);
}
.page-item.disabled .page-link {
    color: var(--text-muted);
    pointer-events: none;
    opacity: .5;
    background: var(--light);
}
.page-item.disabled .page-link:hover {
    background: var(--light);
    color: var(--text-muted);
    border-color: var(--border-color);
}
.pagination-info {
    font-size: .82rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 6px;
}
.page-link i {
    font-size: .75rem;
}

/* RTL pagination */
[dir="rtl"] .page-link i.fa-chevron-left::before { content: "\f054"; }
[dir="rtl"] .page-link i.fa-chevron-right::before { content: "\f053"; }