/* ============================================
   Transport Scolaire - Application Styles
   Design: Clean dashboard with Moroccan-inspired accents
   ============================================ */

:root {
    --primary: #1B6B4A;
    --primary-light: #2A9D6E;
    --primary-dark: #0F4A32;
    --secondary: #C4302B;
    --accent: #E8A838;
    --accent-light: #F5D89A;
    --bg-body: #F0F2F5;
    --bg-card: #FFFFFF;
    --bg-sidebar: #0F1F17;
    --bg-sidebar-hover: #1B3528;
    --text-primary: #1A1D21;
    --text-secondary: #5A6068;
    --text-sidebar: #B8C5BE;
    --text-sidebar-active: #FFFFFF;
    --border: #DEE2E6;
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.1);
    --radius: 10px;
    --radius-sm: 6px;
    --sidebar-w: 260px;
    --topbar-h: 60px;
    --font-fr: 'Noto Sans', sans-serif;
    --font-ar: 'Cairo', sans-serif;
}

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

body {
    font-family: var(--font-fr);
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
}
body.lang-ar {
    font-family: var(--font-ar);
    font-size: 15px;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow-y: auto;
}
.lang-ar .sidebar { left: auto; right: 0; }

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
}
.logo-icon {
    font-size: 28px;
    color: var(--primary-light);
}
.logo-text {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
}

.sidebar-user {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.user-avatar i { font-size: 32px; color: var(--primary-light); }
.user-info {
    display: flex;
    flex-direction: column;
}
.user-name { color: #fff; font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; text-transform: uppercase; opacity: 0.6; letter-spacing: 0.5px; }

.sidebar-menu {
    list-style: none;
    padding: 10px 0;
    flex: 1;
}
.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.2s;
    position: relative;
}
.sidebar-menu li a:hover {
    background: var(--bg-sidebar-hover);
    color: #fff;
}
.sidebar-menu li.active a {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}
.sidebar-menu li.active a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
}
.lang-ar .sidebar-menu li.active a::before {
    left: auto;
    right: 0;
}
.sidebar-menu li a i {
    font-size: 17px;
    width: 22px;
    text-align: center;
}
.badge-alarm {
    margin-left: auto;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
}
.lang-ar .badge-alarm { margin-left: 0; margin-right: auto; }

.menu-divider {
    padding: 14px 20px 6px;
}
.menu-divider span {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.4;
    font-weight: 600;
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.lang-switch {
    display: flex;
    gap: 8px;
    justify-content: center;
}
.lang-switch a {
    padding: 4px 14px;
    border-radius: 20px;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid rgba(255,255,255,0.15);
    transition: all 0.2s;
}
.lang-switch a.active,
.lang-switch a:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
}
.lang-ar .main-content { margin-left: 0; margin-right: var(--sidebar-w); }

.topbar {
    height: var(--topbar-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.page-title { font-size: 18px; font-weight: 700; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.annee-scolaire-badge {
    background: var(--primary-light);
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.topbar-alarm {
    position: relative;
    color: var(--text-secondary);
    font-size: 20px;
}
.topbar-alarm .badge {
    position: absolute;
    top: -4px;
    right: -6px;
    font-size: 9px;
    padding: 2px 5px;
}
.btn-logout {
    color: var(--text-secondary);
    font-size: 18px;
    text-decoration: none;
}
.btn-logout:hover { color: var(--secondary); }

.content-area {
    padding: 24px;
}

/* ============================================
   CARDS & STATS
   ============================================ */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    margin-bottom: 12px;
}
.stat-card .stat-icon.green { background: var(--primary); }
.stat-card .stat-icon.red { background: var(--secondary); }
.stat-card .stat-icon.orange { background: var(--accent); }
.stat-card .stat-icon.blue { background: #2563EB; }
.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}
.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}
.stat-card .stat-detail {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}
.stat-card .stat-detail span { font-weight: 600; }
.stat-card .stat-detail .male { color: #2563EB; }
.stat-card .stat-detail .female { color: #DB2777; }

.card-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.card-section-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-section-header h3 {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
}
.card-section-body {
    padding: 20px;
}

/* ============================================
   TABLES
   ============================================ */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.table-container .table {
    margin: 0;
    font-size: 13px;
}
.table-container .table thead th {
    background: #F8F9FA;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-secondary);
    padding: 12px 14px;
    white-space: nowrap;
}
.table-container .table td {
    padding: 10px 14px;
    vertical-align: middle;
    border-bottom: 1px solid #F0F0F0;
}
.table-container .table tbody tr:hover {
    background: #F8FBF9;
}
.table-actions {
    display: flex;
    gap: 6px;
}
.table-actions .btn {
    padding: 4px 8px;
    font-size: 12px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}
.btn-add {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-add:hover {
    background: var(--primary-dark);
    color: #fff;
}

/* ============================================
   FORMS
   ============================================ */
.form-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}
.form-label {
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    font-size: 13px;
    padding: 8px 12px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(42, 157, 110, 0.15);
}

/* ============================================
   ALERTS & ALARMS
   ============================================ */
.alarm-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    border-left: 4px solid transparent;
}
.lang-ar .alarm-item {
    border-left: none;
    border-right: 4px solid transparent;
}
.alarm-item.danger {
    background: #FEF2F2;
    border-left-color: #DC2626;
}
.lang-ar .alarm-item.danger {
    border-right-color: #DC2626;
}
.alarm-item.warning {
    background: #FFFBEB;
    border-left-color: #F59E0B;
}
.lang-ar .alarm-item.warning {
    border-right-color: #F59E0B;
}
.alarm-item.info {
    background: #EFF6FF;
    border-left-color: #3B82F6;
}
.lang-ar .alarm-item.info {
    border-right-color: #3B82F6;
}
.alarm-icon {
    font-size: 20px;
    flex-shrink: 0;
}
.alarm-item.danger .alarm-icon { color: #DC2626; }
.alarm-item.warning .alarm-icon { color: #F59E0B; }
.alarm-item.info .alarm-icon { color: #3B82F6; }
.alarm-content { flex: 1; }
.alarm-message { font-weight: 600; font-size: 13px; }
.alarm-etab { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.alarm-type-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

/* ============================================
   MAP
   ============================================ */
#map {
    height: 65vh;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 1;
}
.map-legend {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    box-shadow: var(--shadow);
}
.map-legend h5 {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    margin-bottom: 4px;
}
.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}
.legend-line {
    width: 24px;
    height: 3px;
    flex-shrink: 0;
    border-radius: 2px;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-wrapper {
    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%);
    position: relative;
}
.login-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 0L60 30L30 60L0 30z' fill='%23ffffff' fill-opacity='0.03'/%3E%3C/svg%3E") repeat;
}
.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    position: relative;
    z-index: 1;
}
.login-card .login-logo {
    text-align: center;
    margin-bottom: 28px;
}
.login-card .login-logo i {
    font-size: 52px;
    color: var(--primary);
}
.login-card .login-logo h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 10px;
}
.login-card .login-logo p {
    font-size: 13px;
    color: var(--text-secondary);
}
.login-card .form-control {
    padding: 10px 14px;
    font-size: 14px;
}
.login-card .btn-login {
    width: 100%;
    padding: 10px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 14px;
    transition: background 0.2s;
}
.login-card .btn-login:hover {
    background: var(--primary-dark);
}
.login-lang {
    text-align: center;
    margin-top: 16px;
}
.login-lang a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    margin: 0 8px;
    font-weight: 600;
}
.login-lang a.active {
    color: var(--primary);
}

/* ============================================
   IMPORT/EXPORT
   ============================================ */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    background: #FAFBFC;
    transition: all 0.2s;
    cursor: pointer;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary-light);
    background: #F0FAF5;
}
.upload-zone i {
    font-size: 40px;
    color: var(--primary-light);
    margin-bottom: 12px;
}
.upload-zone p {
    color: var(--text-secondary);
    font-size: 13px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 767.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .lang-ar .sidebar {
        transform: translateX(100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    .content-area {
        padding: 16px;
    }
    .sidebar-toggle {
        background: none;
        border: none;
        font-size: 22px;
        color: var(--text-primary);
        cursor: pointer;
    }
    .stat-card .stat-value { font-size: 22px; }
    #map { height: 50vh; }
}

@media (min-width: 768px) {
    .sidebar-toggle { display: none !important; }
}

/* ============================================
   CHARTS
   ============================================ */
.chart-wrapper {
    position: relative;
    height: 280px;
    width: 100%;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.stat-card, .card-section, .table-container, .form-section {
    animation: fadeInUp 0.4s ease-out;
}

/* ============================================
   PRINT
   ============================================ */
@media print {
    .sidebar, .topbar, .btn-add, .table-actions { display: none !important; }
    .main-content { margin: 0 !important; }
    .content-area { padding: 0; }
}
