/* SchoolManager - Feuille de style principale */
:root {
    --primary: #2c3e50;
    --primary-light: #34495e;
    --accent: #3498db;
    --accent-hover: #2980b9;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --light: #ecf0f1;
    --bg: #f0f2f5;
    --white: #ffffff;
    --text: #2c3e50;
    --text-muted: #7f8c8d;
    --border: #dde1e7;
    --shadow: 0 2px 12px rgba(0,0,0,.08);
    --radius: 8px;
    --sidebar-w: 240px;
    --topbar-h: 60px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html { font-size: 15px; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Layout principal ── */
.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform .3s;
}
.sidebar-brand {
    padding: 18px 20px;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: .5px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-brand i { color: var(--accent); font-size: 1.4rem; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-section {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,.4);
    padding: 14px 20px 4px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: rgba(255,255,255,.8);
    font-size: .9rem;
    cursor: pointer;
    transition: background .2s, color .2s;
    border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active {
    background: rgba(52,152,219,.2);
    color: #fff;
    border-left-color: var(--accent);
}
.nav-item i { width: 18px; text-align: center; font-size: 1rem; }
.sidebar-user {
    padding: 15px 20px;
    border-top: 1px solid rgba(255,255,255,.1);
    font-size: .85rem;
    color: rgba(255,255,255,.7);
}
.sidebar-user strong { display: block; color: #fff; font-size: .9rem; }

/* Contenu principal */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.topbar {
    height: var(--topbar-h);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
    gap: 16px;
}
.topbar-title { font-size: 1.1rem; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text);
    padding: 4px 8px;
}
.content { padding: 24px; flex: 1; }

/* ── Cards ── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.card-title { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-title i { color: var(--accent); }

/* ── Boutons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all .2s;
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #219a52; color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #c0392b; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #e67e22; color: #fff; }
.btn-secondary { background: var(--light); color: var(--text); }
.btn-secondary:hover { background: #d5dbdb; }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-icon { padding: 7px 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Formulaires ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: 5px; color: var(--text); }
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: .9rem;
    background: var(--white);
    color: var(--text);
    transition: border-color .2s;
}
.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(52,152,219,.15);
}
.form-control:disabled { background: var(--light); }
.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }
.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-check input { width: 16px; height: 16px; cursor: pointer; }

/* ── Tables ── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th {
    background: var(--bg);
    padding: 10px 14px;
    text-align: left;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(52,152,219,.04); }

/* ── Alertes ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: .9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-success { background: #d5f5e3; color: #1e8449; border: 1px solid #a9dfbf; }
.alert-error   { background: #fde8e8; color: #c0392b; border: 1px solid #f5b7b1; }
.alert-warning { background: #fef9e7; color: #b7770d; border: 1px solid #f9e79f; }
.alert-info    { background: #d6eaf8; color: #1a5276; border: 1px solid #aed6f1; }

/* ── Badges ── */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-primary  { background: #d6eaf8; color: #1a5276; }
.badge-success  { background: #d5f5e3; color: #1e8449; }
.badge-warning  { background: #fef9e7; color: #9a7d0a; }
.badge-danger   { background: #fde8e8; color: #922b21; }
.badge-secondary{ background: var(--light); color: var(--text-muted); }

/* ── Modales ── */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: 0 8px 40px rgba(0,0,0,.2);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn .2s ease;
}
.modal-lg { max-width: 900px; }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-close {
    background: none; border: none;
    font-size: 1.2rem; cursor: pointer;
    color: var(--text-muted); padding: 4px 8px;
    border-radius: 4px;
    transition: background .2s;
}
.modal-close:hover { background: var(--light); }
.modal-body { padding: 22px; }
.modal-footer {
    padding: 16px 22px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

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

/* ── Planning grille ── */
.planning-grid {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: .85rem;
}
.planning-header {
    display: grid;
    background: var(--primary);
    color: #fff;
}
.planning-header .ph-cell {
    padding: 10px 8px;
    text-align: center;
    font-weight: 600;
    border-right: 1px solid rgba(255,255,255,.1);
    font-size: .8rem;
}
.planning-row {
    display: grid;
    border-bottom: 1px solid var(--border);
}
.planning-row:last-child { border-bottom: none; }
.planning-period {
    background: var(--bg);
    padding: 8px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-muted);
}
.planning-cell {
    padding: 4px;
    border-right: 1px solid var(--border);
    min-height: 60px;
    cursor: pointer;
    transition: background .2s;
    position: relative;
}
.planning-cell:hover { background: rgba(52,152,219,.06); }
.planning-cell:last-child { border-right: none; }
.slot-card {
    border-radius: 5px;
    padding: 5px 7px;
    font-size: .78rem;
    height: 100%;
    min-height: 52px;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    position: relative;
}
.slot-card .slot-branch { font-weight: 700; }
.slot-card .slot-info { opacity: .9; font-size: .72rem; }
.slot-card.cancelled { opacity: .5; text-decoration: line-through; }
.slot-empty { color: var(--text-muted); font-size: .75rem; text-align: center; padding-top: 14px; }

/* ── Remplacements ── */
.replacement-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.replacement-item {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    cursor: pointer;
    transition: all .2s;
}
.replacement-item:hover { border-color: var(--accent); background: rgba(52,152,219,.04); }
.replacement-item.selected { border-color: var(--accent); background: rgba(52,152,219,.1); }
.replacement-item.available { border-color: var(--success); }
.replacement-item.needed { border-color: var(--warning); }
.match-result {
    background: var(--success);
    color: #fff;
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 16px;
}

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab {
    padding: 9px 18px;
    cursor: pointer;
    font-size: .9rem;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all .2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.tab:hover { color: var(--accent); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Pagination ── */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; margin-top: 16px; }
.page-btn {
    min-width: 34px; height: 34px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: .85rem;
    background: var(--white);
    transition: all .2s;
}
.page-btn:hover, .page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Stats dashboard ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.stat-icon.blue { background: #d6eaf8; color: var(--accent); }
.stat-icon.green { background: #d5f5e3; color: var(--success); }
.stat-icon.orange { background: #fdebd0; color: var(--warning); }
.stat-icon.red { background: #fde8e8; color: var(--danger); }
.stat-info .stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-info .stat-label { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }

/* ── Select2-like ── */
.multi-select { border: 1px solid var(--border); border-radius: 6px; padding: 6px; min-height: 80px; }
.multi-select option { padding: 4px 6px; }

/* ── Color picker ── */
.color-input-wrap { display: flex; align-items: center; gap: 10px; }
.color-input-wrap input[type=color] { width: 44px; height: 34px; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; padding: 2px; }

/* ── Login ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, #1a252f 100%);
}
.login-box {
    background: var(--white);
    border-radius: 12px;
    padding: 40px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo i { font-size: 3rem; color: var(--accent); }
.login-logo h1 { font-size: 1.5rem; font-weight: 700; margin-top: 8px; color: var(--primary); }
.login-logo p { color: var(--text-muted); font-size: .9rem; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay {
        display: none;
        position: fixed; inset: 0;
        background: rgba(0,0,0,.5);
        z-index: 99;
    }
    .sidebar-overlay.active { display: block; }
    .main { margin-left: 0; }
    .hamburger { display: block; }
    .form-row.cols-2,
    .form-row.cols-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .replacement-panel { grid-template-columns: 1fr; }
    .content { padding: 16px; }
}

/* ── Utilitaires ── */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-10 { gap: 10px; }
.gap-16 { gap: 16px; }
.mt-10 { margin-top: 10px; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-center { text-align: center; }
.fw-600 { font-weight: 600; }
.fs-sm { font-size: .85rem; }
.w-100 { width: 100%; }
.hidden { display: none !important; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
