/* PRISMES v2 — app.css (no Bootstrap) */

/* ===========================================
   Variables grille interventions
   Ordre: Classe, Date, Début, Fin, Durée, Inter1, Inter2, Salle, Prof, Dispo
   =========================================== */
:root {
    --grid-cols: 7% 8% 5% 5% 4% 10% 10% 6% 12% 1fr;
    --grid-cols-seance: 7% 5% 8% 5% 5% 4% 10% 10% 6% 12% 1fr;
    --grid-cols-nonscolaire: 10% 7% 7% 5% 12% 12% 8% 1fr;
}

*, *::before, *::after { box-sizing: border-box; }
body { font-family: Arial, sans-serif; font-size: 14px; line-height: 1.4; margin: 0; padding: 0; color: #333; background-color: #f0f0f0; }
body.etablissement { padding: 20px; }
a { color: #2563eb; }
a:hover { color: #1d4ed8; }
img { max-width: 100%; }
hr { border: none; border-top: 1px solid #dee2e6; margin: 8px 0; }

/* ==========================================
   Navbar
   ========================================== */
.navbar { display: flex; align-items: center; padding: 8px 16px; background: #212529; color: #fff; }
.navbar-brand { font-weight: bold; letter-spacing: 1px; color: #fff; text-decoration: none; margin-right: 24px; font-size: 1.1rem; }
.navbar-brand:hover { color: #fff; }
.navbar-nav { display: flex; list-style: none; margin: 0; padding: 0; gap: 4px; }
.nav-item { display: inline; }
.nav-link { color: rgba(255,255,255,0.7); text-decoration: none; padding: 6px 10px; border-radius: 4px; font-size: 0.9rem; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,0.1); }
.navbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

/* ==========================================
   Buttons
   ========================================== */
.btn { display: inline-block; padding: 6px 14px; font-size: 0.9rem; border-radius: 4px; border: 1px solid transparent; cursor: pointer; text-decoration: none; text-align: center; line-height: 1.5; transition: background 0.15s; }
.btn-sm { padding: 3px 10px; font-size: 0.8rem; }
.btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #6b7280; color: #fff; border-color: #6b7280; }
.btn-secondary:hover { background: #4b5563; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-warning { background: #f59e0b; color: #333; }
.btn-warning:hover { background: #d97706; }
.btn-info { background: #06b6d4; color: #fff; }
.btn-info:hover { background: #0891b2; }
.btn-outline-light { background: transparent; color: #fff; border-color: rgba(255,255,255,0.5); }
.btn-outline-light:hover { background: rgba(255,255,255,0.15); color: #fff; }
.btn-outline-secondary { background: transparent; color: #6b7280; border-color: #6b7280; }
.btn-outline-secondary:hover { background: #f3f4f6; }
.btn-outline-primary { background: transparent; color: #2563eb; border-color: #2563eb; }
.btn-outline-primary:hover { background: #eff6ff; }
.btn-outline-warning { background: transparent; color: #d97706; border-color: #d97706; }
.btn-outline-warning:hover { background: #fffbeb; }
.btn-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; padding: 4px; opacity: 0.5; }
.btn-close:hover { opacity: 1; }
.btn-close::after { content: "×"; }

/* ==========================================
   Cards
   ========================================== */
.card { border: 1px solid #dee2e6; border-radius: 6px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 12px; }
.card-header { padding: 10px 16px; background: #f8f9fa; border-bottom: 1px solid #dee2e6; font-weight: 600; border-radius: 6px 6px 0 0; }
.card-body { padding: 16px; }

/* ==========================================
   Tables
   ========================================== */
table.table { width: 100%; border-collapse: collapse; }
table.table th, table.table td { padding: 6px 10px; border-bottom: 1px solid #dee2e6; text-align: left; vertical-align: middle; }
table.table thead th { background: #f8f9fa; font-weight: 600; border-bottom: 2px solid #dee2e6; }
table.table-sm th, table.table-sm td { padding: 4px 8px; font-size: 0.85rem; }
table.table-striped tbody tr:nth-child(odd) { background: #f9fafb; }
table.table-bordered th, table.table-bordered td { border: 1px solid #dee2e6; }
table.table-hover tbody tr:hover { background: #e8f4fd; }

/* ==========================================
   Forms
   ========================================== */
.form-label { display: block; font-weight: 500; margin-bottom: 4px; font-size: 0.9rem; }
.form-control, .form-select { display: block; width: 100%; padding: 6px 10px; font-size: 0.9rem; border: 1px solid #d1d5db; border-radius: 4px; background: #fff; line-height: 1.5; }
.form-control:focus, .form-select:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }
.form-control-sm, .form-select-sm { padding: 3px 8px; font-size: 0.8rem; }
select.form-select { appearance: auto; }

/* ==========================================
   Modals
   ========================================== */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; }
.modal.show { display: flex; }
.modal-dialog { background: #fff; border-radius: 8px; max-width: 500px; width: 90%; max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.3); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid #dee2e6; }
.modal-title { font-weight: 600; font-size: 1.1rem; margin: 0; }
.modal-body { padding: 16px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid #dee2e6; }

/* ==========================================
   Badges
   ========================================== */
.badge { display: inline-block; padding: 2px 8px; font-size: 0.75rem; font-weight: 600; border-radius: 10px; color: #fff; }
.bg-secondary { background: #6b7280; }
.bg-success { background: #16a34a; }
.bg-warning { background: #f59e0b; color: #333; }
.bg-danger { background: #e53935; }
.bg-info { background: #06b6d4; }

/* ==========================================
   Alerts
   ========================================== */
.alert { padding: 10px 16px; border-radius: 4px; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ==========================================
   Dropdown
   ========================================== */
.dropdown { position: relative; display: inline-block; }
.dropdown-toggle::after { content: " ▾"; }
.dropdown-menu { display: none; position: absolute; right: 0; top: 100%; background: #fff; border: 1px solid #dee2e6; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); min-width: 160px; z-index: 100; padding: 4px 0; list-style: none; margin: 2px 0 0; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item { display: block; padding: 6px 14px; color: #333; text-decoration: none; font-size: 0.9rem; }
.dropdown-item:hover { background: #f3f4f6; }
.dropdown-item.active { background: #2563eb; color: #fff; }
.dropdown-divider { border-top: 1px solid #dee2e6; margin: 4px 0; }

/* ==========================================
   Utility classes
   ========================================== */
.d-flex { display: flex; }
.d-none { display: none; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.align-items-center { align-items: center; }
.gap-3 { gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.text-center { text-align: center; }
.text-decoration-none { text-decoration: none; }
.text-nowrap { white-space: nowrap; }
.text-light { color: rgba(255,255,255,0.9); }
.text-muted { color: #6b7280; }
.text-success { color: #16a34a; }
.small { font-size: 0.8rem; }
.text-danger { color: #dc2626; }
.text-warning { color: #d97706; }
.text-primary { color: #2563eb; }
.fw-bold { font-weight: 700; }
.me-1 { margin-right: 4px; }
.shadow { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 24px; }
.mt-3 { margin-top: 12px; }
.me-2 { margin-right: 8px; }
.me-auto { margin-right: auto; }
.p-5 { padding: 32px; }
.container-fluid { width: 100%; padding: 0 16px; }
.row { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.col, [class*="col-"] { padding: 0 8px; }
.col-md-6 { width: 50%; }

/* ==========================================
   Établissement bandeau
   ========================================== */
.etab-info {
    border-radius: 6px;
    margin-bottom: 12px;
    padding: 10px;
    border-left: 4px solid #4299e1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    background: linear-gradient(to right, #cce4ff 0%, #cce4ff 50%, #fff 85%);
}
.etab-info.etab-lycee { border-left-color: #48bb78; background: linear-gradient(to right, #d4eddf 0%, #d4eddf 50%, #fff 85%); }
.etab-info.etab-college { border-left-color: #9f7aea; background: linear-gradient(to right, #e0d5ff 0%, #e0d5ff 50%, #fff 85%); }
.etab-info.etab-media { border-left-color: #ed8936; background: linear-gradient(to right, #ffe4cc 0%, #ffe4cc 50%, #fff 85%); }

.etab-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    font-size: 0.9em;
}
.etab-grid .label { font-weight: bold; margin-right: 4px; }
.etab-comment { margin-top: 6px; padding-top: 6px; border-top: 1px solid #ddd; }

/* ==========================================
   Session Container (V1-style)
   ========================================== */
.session-block {
    width: 100%;
    max-width: 100vw;
    background: #ffffff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

/* ==========================================
   Session Info Header (V1-style)
   ========================================== */
.session-info {
    display: grid;
    grid-template-columns: 65px 430px 1fr;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    align-items: center;
    gap: 5px;
    padding: 15px 50px 15px 15px;
    border-radius: 10px !important;
    background: linear-gradient(to right, #f0f0f0, #dcdcdc);
    transition: background 0.3s;
    /* border: 1px blue dotted; */
    position: relative;
}

.session-info button[type=reset] {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
}

/* Toggle button on session header */
.toggle-table {
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #c00;
    padding: 0;
    min-width: 28px;
    z-index: 20;
}
.toggle-table .material-symbols-outlined { font-size: 28px; }
.session-block.collapsed .session-info { opacity: 0.8; }

.session-name { font-size: 1.1em; font-weight: bold; }
.session-meta { font-size: 0.9em; margin-top: 4px; }
.session-meta .label { font-weight: bold; margin-right: 4px; }

.session-selects { display: flex; gap: 6px; flex-wrap: wrap; }
.session-selects .form-select-sm { width: auto; min-width: 100px; font-size: 0.85em; }

.session-dates-extra { font-size: 0.85em; display: flex; gap: 8px; flex-wrap: wrap; }
.session-dates-extra .label { font-weight: 600; }

/* Remove debug blue dotted border from session-info icon */
.session-info::before { border: none !important; }

/* État colors on session-info (V1-style) */
.session-info.etat_nouveau {
    background: linear-gradient(90deg, #f0f0f0 0%, #f8d7da 62%);
    padding: 5px 10px;
    border-radius: 6px;
    font-weight: bold;
}
.session-info.etat_attentedispo {
    background: linear-gradient(90deg, #f0f0f0 0%, #ffeeba 62%);
    padding: 5px 10px;
    border-radius: 6px;
    font-weight: bold;
}
.session-info.etat_envoye {
    background: linear-gradient(90deg, #f0f0f0 0%, #c3e6cb 62%);
    padding: 5px 10px;
    border-radius: 6px;
    font-weight: bold;
}
.session-info.etat_attentecertification {
    background: linear-gradient(90deg, #f0f0f0 0%, #bee5eb 62%);
    padding: 5px 10px;
    border-radius: 6px;
    font-weight: bold;
}
.session-info.etat_certifrecue {
    background: linear-gradient(90deg, #f0f0f0 0%, #d6d8db 62%);
    padding: 5px 10px;
    border-radius: 6px;
    font-weight: bold;
}

/* ==========================================
   Intervention GRID (V1-style)
   ========================================== */
.inter-grid-wrap {
    padding: 0;
    overflow-x: auto;
    width: 100%;
    max-width: 100vw;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #ddd;
    margin-top: 15px;
}

/* Grille interventions — utilise les variables définies en haut */
.inter-row {
    display: grid;
    grid-template-columns: var(--grid-cols);
    align-items: center;
    min-height: 38px;
}
.inter-row > div {
    padding: 8px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    border: 1px solid #dee2e6;
    font-size: 14px;
}
/* Séance column hidden by default (like V1) */
.col-seance { display: none !important; }
/* Show séance when needed (add class has-seance to inter-grid-wrap) */
.inter-grid-wrap.has-seance .col-seance { display: block !important; }
.inter-grid-wrap.has-seance .inter-row {
    grid-template-columns: var(--grid-cols-seance);
}

/* Header V1-style — VIOLET #8904f8 comme V1 */
.inter-grid-wrap .inter-header {
    font-weight: bold;
    font-size: 14px;
}
.inter-grid-wrap .inter-header > div {
    padding: 12px !important;
    background: #8904f8 !important;
    color: white !important;
    border: 1px solid #6b03c4 !important;
    text-align: left;
}

/* Alternating groups (V1-style) */
.inter-row.grp-even { background: #fff; }
.inter-row.grp-odd { background: #f8f9fa; }
.inter-row:hover:not(.inter-header) { background: #e1f5fe; transition: 0.3s; }

/* Inter cells empty highlight (V1-style) */
.inter-row .col-inter1:has(.inter_empty),
.inter-row .col-inter2:has(.inter_empty) {
    background-color: #c8ede3;
}

/* Hide classe + prof for non-scolaire */
.inter-grid-wrap:not(.kind_scolaire) .inter-row {
    grid-template-columns: var(--grid-cols-nonscolaire);
}
.inter-grid-wrap:not(.kind_scolaire) .col-classe,
.inter-grid-wrap:not(.kind_scolaire) .col-prof {
    display: none;
}

/* ==========================================
   Editable cells (for intervention grid only)
   ========================================== */
.inter-row .editable {
    cursor: pointer;
    min-width: 30px;
    min-height: 1.2em;
    padding: 2px 4px;
    border: 1px solid transparent;
    border-radius: 3px;
    transition: all 0.15s ease;
    display: inline-block;
}
.inter-row .editable:hover {
    background-color: #f0f4ff;
    border-color: #b0c4ff;
}
.inter-row .editable.editing {
    padding: 0;
    background: #fff;
    border-color: transparent;
}
.inter-row .editable.editing input,
.inter-row .editable.editing select,
.inter-row .editable.editing textarea {
    width: 100%;
    border: 2px solid #0d6efd;
    padding: 2px 4px;
    font-size: inherit;
    border-radius: 3px;
    box-sizing: border-box;
}
.inter-row .editable.editing input:focus,
.inter-row .editable.editing textarea:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(13,110,253,0.15);
}

.ph { color: #aaa; font-style: italic; }

/* ==========================================
   Actor cells & menus
   ========================================== */
.actor-cell {
    cursor: pointer;
    font-weight: 500;
    transition: background 0.15s;
}
.actor-cell:hover { background: #d1ecf1; }

.actor-menu { position: relative; }
.actor-menu select.actorMenu {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    z-index: 10;
}
select.actorMenu option.dispo { color: #198754; }
select.actorMenu option.indispo { color: #dc3545; }
select.actorMenu option.inconnu { color: #6c757d; }
select.actorMenu option:disabled { color: #ccc; text-decoration: line-through; }

.forced { background: red !important; color: #fff !important; border-radius: 10px; }

/* ==========================================
   Disponibilités inline (style v1)
   ========================================== */
.col-dispo {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    white-space: normal !important;
    overflow: hidden;
    align-items: center;
    justify-content: flex-start;
    font-size: 0.85em;
}
.dispo-item {
    display: inline;
    margin: 0 3px;
    white-space: nowrap;
}
.dispo-ok { color: #155724; }
.dispo-no { color: #dc3545; font-weight: 700; }
.dispo-unknown { color: #0d6efd; }
.dispo-forced { color: #ff8c00; font-weight: 700; }

/* ==========================================
   Table container (v1 style)
   ========================================== */
.table_container {
    width: 100%;
    display: flex;
    align-items: flex-end;
    column-gap: .5em;
}
.table_container .buttons { display: flex; flex-direction: column; }
.action-button {
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    transition: background 0.15s;
}
.action-button:hover { background: #e8f0fe; }
.action-button .material-symbols-outlined { color: #3c09f3; font-size: 24px; }

/* ==========================================
   Session action buttons (v1 style : row-reverse)
   ========================================== */
.session-actions {
    display: flex;
    align-items: center;
    justify-content: right;
    gap: 5rem;
    padding: 2rem 0;
    flex-flow: row-reverse nowrap;
}
.session-actions .btn {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    position: relative;
}
.session-actions .btn-secondary {
    background-color: white;
    border: 1px solid #d1d5db;
    color: #374151;
}
.session-actions .btn-secondary:hover {
    background-color: #e5e7eb;
    border-color: #6b7280;
    color: #111827;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.1);
}
.session-actions .btn-primary {
    background-color: #2563eb;
    border: none;
    color: white;
    padding: 0.5rem 1.5rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    font-weight: 500;
}
.session-actions .btn-primary:hover {
    background-color: #1e40af;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.25);
}
.session-actions .btn:disabled {
    background: radial-gradient(circle at center, #C5D4E3 0%, #A4B7CC 50%, #8299B3 100%);
    color: #FFFFFF;
}
.dejacertif {
    background-color: rgba(193, 226, 232, 0.917) !important;
    border: 2px solid #e1c572 !important;
    color: #374151 !important;
}

/* ==========================================
   Dashboard — Metric bar (v1 style)
   ========================================== */
.dashboard-metrics {
    display: flex;
    max-width: 60%;
    margin: 10px 0;
    border: 1px solid #d3d3d3;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.dashboard-metrics:empty { display: none; }
.metric-button {
    flex: 1;
    padding: 10px 14px;
    text-align: center;
    color: #333;
    background: linear-gradient(to bottom, #f6f6f6, #e9e9e9);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
    border-right: 1px solid #d3d3d3;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.metric-button:last-child { border-right: none; }
.metric-button:hover { background: linear-gradient(to bottom, #dadada, #c9c9c9); color: #212121; text-decoration: none; }
.metric-count { font-size: 18px; font-weight: bold; color: #1c94c4; }
.metric-label { font-size: 13px; }

/* ==========================================
   Dashboard — Table
   ========================================== */
.card { box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.card-header { font-weight: 600; }

/* TDB row colors by état */
tr.etat-row-nouveau { background-color: #e3f2fd !important; }
tr.etat-row-attentedispo { background-color: #fff3e0 !important; }
tr.etat-row-envoye { background-color: #e8f5e9 !important; }
tr.etat-row-attentecertification { background-color: #fff9c4 !important; }
tr.etat-row-certifrecue { background-color: #e8eaf6 !important; }

/* État badges */
.badge-etat { color: #fff; }
.etat-nouveau { background-color: #42a5f5; }
.etat-attentedispo { background-color: #ffa726; }
.etat-envoye { background-color: #66bb6a; }
.etat-attentecertification { background-color: #ffca28; color: #333 !important; }
.etat-certifrecue { background-color: #7e57c2; }

.badge.bg-danger { background-color: #e53935 !important; }

/* TDB column sizing */
#tdb { font-size: 0.85rem; }
#tdb th, #tdb td { vertical-align: middle; }
#tdb a { text-decoration: none; color: inherit; }
.status-pay { text-align: center; }

/* Red arrows (v1 style) */
.tdb-arrow {
    color: #e53935 !important;
    font-size: 1.1em;
    margin-left: 4px;
    text-decoration: none !important;
    opacity: 0.7;
    transition: opacity 0.15s;
}
.tdb-arrow:hover { opacity: 1; }

/* Filter row */
.tdb-filters th { padding: 4px !important; background: #f8f9fa; }
.tdb-filters input, .tdb-filters select { font-size: 0.8rem; }

/* menuOnDouble (v1 inline edit) */
.menuOnDouble {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background 0.15s;
}
.menuOnDouble:hover { background: #e8f0fe; }
select.enum-select {
    font-size: 0.85rem;
    padding: 2px 4px;
    border: 2px solid #4a90e2;
    border-radius: 3px;
    box-shadow: 0 0 5px #4a90e2;
    max-width: 100%;
}

/* Paiement status colors */
.pay-afacturer { background: #e53935; color: #fff; padding: 2px 6px; border-radius: 4px; }
.pay-facture { background: #ffa726; color: #333; padding: 2px 6px; border-radius: 4px; }
.pay-recu { background: #c3f489; color: #333; padding: 2px 6px; border-radius: 4px; }
.pay-gratuit { background: #c3f489; color: #333; padding: 2px 6px; border-radius: 4px; }

/* État text colors in cells (v1 style) */
.status-etat {
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}
.etat-nouveau { color: #1565c0; }
.etat-attentedispo { color: #e65100; }
.etat-envoye { color: #2e7d32; }
.etat-attentecertification { color: #f57f17; background: #fff9c4; }
.etat-certifrecue { color: #4527a0; }

/* ==========================================
   Print
   ========================================== */
@media print {
    .navbar, .btn, .no-print, .session-actions { display: none !important; }
    .card { box-shadow: none; border: 1px solid #ddd; }
    .session-info { border: 1px solid #999; }
    body { font-size: 11px; }
}
