/* ========================================
   PLACILO — Organisez vos classes en un clic
   Thème : Orange #E85A24 / Bleu #1B4B7A
   ======================================== */

:root {
    /* Couleurs principales Placilo */
    --primary-orange: #E85A24;
    --primary-orange-dark: #C94A1A;
    --primary-orange-light: #FFF4F0;
    
    --primary-blue: #1B4B7A;
    --primary-blue-dark: #143A5E;
    --primary-blue-light: #EDF4FA;
    
    --accent-green: #2EAC66;
    --accent-green-light: #E8F8EF;
    
    --accent-yellow: #F5A623;
    --accent-yellow-light: #FEF7E8;

    /* Neutres */
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #5A6B7A;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;

    /* Cartes élèves - Garçons/Filles */
    --boy-bg: #EDF4FA;
    --boy-border: #1B4B7A;
    --girl-bg: #FFF4F0;
    --girl-border: #E85A24;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.05);
}

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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 13px;
    color: var(--slate-800);
    background: var(--slate-100);
}

/* ===== TOPBAR ===== */
.topbar {
    height: 54px;
    background: var(--primary-blue);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    gap: 12px;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
    letter-spacing: -0.01em;
}

.topbar-brand img {
    height: 36px;
    width: auto;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-name {
    font-size: 18px;
    font-weight: 700;
}

.brand-name .highlight {
    color: var(--primary-orange);
}

.brand-tagline {
    font-size: 10px;
    font-weight: 400;
    opacity: 0.8;
    letter-spacing: 0.02em;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.tb-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, opacity 0.15s, transform 0.1s;
    line-height: 1;
}

.tb-ghost {
    background: transparent;
    color: rgba(255,255,255,0.8);
}
.tb-ghost:hover { 
    background: rgba(255,255,255,0.1); 
    color: white; 
}

.tb-accent {
    background: var(--primary-orange);
    color: white;
}
.tb-accent:hover { 
    background: var(--primary-orange-dark); 
    transform: translateY(-1px);
}

.tb-secondary {
    background: rgba(255,255,255,0.15);
    color: white;
}
.tb-secondary:hover { 
    background: rgba(255,255,255,0.25); 
}

.tb-danger {
    background: transparent;
    color: #ff8a80;
}
.tb-danger:hover { 
    background: rgba(255,138,128,0.15); 
}

.tb-divider {
    width: 1px;
    height: 24px;
    background: rgba(255,255,255,0.2);
    margin: 0 6px;
    flex-shrink: 0;
}

/* ===== LAYOUT ===== */
.main-container {
    display: flex;
    height: calc(100vh - 54px);
    overflow: hidden;
}

/* ===== PANNEAU GAUCHE ===== */
.panel-eleves {
    width: 190px;
    min-width: 190px;
    background: white;
    border-right: 1px solid var(--slate-200);
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--slate-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--slate-50);
}

.panel-title {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--slate-600);
}

.panel-count {
    background: var(--primary-orange);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 22px;
    text-align: center;
}

.eleves-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

.empty-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 8px;
    color: var(--slate-400);
    text-align: center;
    padding: 16px;
}
.empty-hint p { font-size: 12px; margin: 0; }

/* ===== CARTES PANNEAU ===== */
.panel-eleve-card {
    padding: 6px 8px;
    margin-bottom: 4px;
    border-radius: var(--radius-sm);
    cursor: grab;
    user-select: none;
    transition: transform 0.1s, box-shadow 0.1s;
    display: flex;
    flex-direction: column;
    gap: 1px;
    border-left: 3px solid transparent;
}
.panel-eleve-card:active { cursor: grabbing; }
.panel-eleve-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.panel-eleve-card.dragging { opacity: 0.35; }

.panel-eleve-card.garcon {
    background: var(--boy-bg);
    border-left-color: var(--boy-border);
}
.panel-eleve-card.fille {
    background: var(--girl-bg);
    border-left-color: var(--girl-border);
}

.panel-card-prenom {
    font-weight: 600;
    font-size: 11px;
    line-height: 1.2;
}
.panel-card-nom {
    font-size: 10px;
    color: var(--slate-500);
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.panel-card-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}
.panel-card-note {
    font-size: 10px;
    color: var(--slate-400);
    font-weight: 500;
}

/* ===== ZONE PLAN ===== */
.plan-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 10px 14px;
    overflow: hidden;
    gap: 8px;
}

/* ===== SALLE ===== */
.salle {
    flex: 1;
    display: grid;
    gap: 10px;
    align-content: stretch;
    overflow: hidden;
}

.placeholder-salle {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--slate-400);
}
.placeholder-salle p { font-size: 13px; margin: 0; }

/* ===== ÎLOTS ===== */
.ilot {
    background: white;
    border: 2px dashed var(--slate-300);
    border-radius: var(--radius);
    padding: 8px;
    display: flex;
    flex-direction: column;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    overflow-y: auto;
}

.ilot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    flex-shrink: 0;
}

.ilot-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--slate-400);
}

.ilot-badge {
    font-size: 9px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
    background: var(--slate-100);
    color: var(--slate-500);
}

.ilot-content {
    flex: 1;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 4px;
    align-items: stretch;
    overflow-x: auto;
    min-height: 0;
}

.ilot-stats {
    font-size: 9px;
    color: var(--slate-400);
    text-align: center;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid var(--slate-100);
    flex-shrink: 0;
    font-weight: 500;
}

.ilot.drag-over {
    border-color: var(--primary-orange);
    border-style: solid;
    background: var(--primary-orange-light);
    box-shadow: 0 0 0 3px rgba(232,90,36,0.15);
}

.ilot.full .ilot-badge {
    background: var(--accent-yellow-light);
    color: var(--accent-yellow);
}

/* ===== CARTES ÉLÈVES DANS ÎLOTS ===== */
.eleve-card {
    flex: 1 1 0;
    min-width: 0;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    cursor: grab;
    user-select: none;
    transition: transform 0.1s, box-shadow 0.1s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 1px;
    border-top: 3px solid transparent;
}
.eleve-card:active { cursor: grabbing; }
.eleve-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); z-index: 2; }
.eleve-card.dragging { opacity: 0.35; }
.eleve-card.swap-target {
    outline: 2px solid var(--accent-yellow);
    outline-offset: -2px;
    background: var(--accent-yellow-light) !important;
    box-shadow: 0 0 0 4px rgba(245,166,35,0.2);
    transform: scale(1.04);
    z-index: 3;
}

.eleve-card.garcon {
    background: var(--boy-bg);
    border-top-color: var(--boy-border);
}
.eleve-card.fille {
    background: var(--girl-bg);
    border-top-color: var(--girl-border);
}

.card-prenom {
    font-weight: 600;
    font-size: 11px;
    line-height: 1.2;
    color: var(--slate-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.card-nom {
    font-size: 9px;
    line-height: 1.2;
    color: var(--slate-500);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.card-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    margin-top: 1px;
}
.card-note {
    font-size: 9px;
    color: var(--slate-400);
    font-weight: 600;
}
.card-pr {
    font-size: 8px;
    font-weight: 700;
    background: var(--accent-yellow);
    color: var(--slate-800);
    padding: 0 4px;
    border-radius: 3px;
    line-height: 1.5;
}

/* ===== BUREAU PROF ===== */
.bureau-prof {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    padding: 6px 0;
}

.bureau-inner {
    background: var(--primary-blue);
    color: white;
    padding: 10px 48px;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-md);
    position: relative;
}
.bureau-inner::before,
.bureau-inner::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 2px;
    background: rgba(255,255,255,0.3);
}
.bureau-inner::before { left: 12px; }
.bureau-inner::after { right: 12px; }

/* ===== STATS BAR ===== */
.stats-bar {
    padding: 7px 12px;
    background: white;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    font-size: 12px;
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.stats-empty { color: var(--slate-400); }

.stat-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.stat-label { font-weight: 600; color: var(--slate-600); }
.stat-value { color: var(--primary-blue); font-weight: 500; }
.stat-sep { color: var(--slate-300); margin: 0 2px; }

/* ===== CONFIG SUMMARY ===== */
.config-summary {
    padding: 10px;
    background: var(--primary-blue-light);
    border-radius: var(--radius-sm);
    text-align: center;
    color: var(--primary-blue);
    font-size: 13px;
}

/* ===== MODAL ===== */
.modal-modern { border: none; border-radius: var(--radius); box-shadow: var(--shadow-md); }
.modal-modern .modal-header { 
    border-bottom: 1px solid var(--slate-200); 
    padding: 14px 20px; 
    background: var(--primary-blue);
    color: white;
    border-radius: var(--radius) var(--radius) 0 0;
}
.modal-modern .modal-header .btn-close {
    filter: brightness(0) invert(1);
}
.modal-modern .modal-title { font-size: 16px; font-weight: 600; }
.modal-modern .modal-footer { border-top: 1px solid var(--slate-200); padding: 12px 20px; }

.eleves-table thead { background: var(--slate-50); }
.eleves-table th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--slate-500); border-bottom-width: 1px; }
.eleves-table td { font-size: 12px; vertical-align: middle; padding: 5px 8px; }

/* ===== BOOTSTRAP OVERRIDES ===== */
.btn-primary { 
    background: var(--primary-orange); 
    border-color: var(--primary-orange); 
}
.btn-primary:hover { 
    background: var(--primary-orange-dark); 
    border-color: var(--primary-orange-dark); 
}
.btn-primary:focus {
    background: var(--primary-orange);
    border-color: var(--primary-orange);
    box-shadow: 0 0 0 3px rgba(232,90,36,0.25);
}

.badge.bg-primary { background: var(--primary-blue) !important; }
.badge.bg-danger { background: var(--primary-orange) !important; }

.form-control:focus, .form-select:focus { 
    border-color: var(--primary-orange); 
    box-shadow: 0 0 0 3px rgba(232,90,36,0.15); 
}

.dropdown-menu { border-radius: var(--radius-sm); border: 1px solid var(--slate-200); box-shadow: var(--shadow-md); }
.dropdown-item { font-size: 13px; padding: 6px 14px; }
.dropdown-item:hover { background: var(--slate-50); }

/* ===== EXPORT MODAL ===== */
.export-list {
    display: flex;
    flex-direction: column;
}

.export-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s;
    border-bottom: 1px solid var(--slate-100);
}
.export-option:last-child { border-bottom: none; }
.export-option:hover { background: var(--slate-50); }

.export-option-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.export-option-icon.excel-icon { background: var(--accent-green-light); color: var(--accent-green); }
.export-option-icon.pdf-icon { background: var(--primary-orange-light); color: var(--primary-orange); }
.export-option-icon.print-icon { background: var(--primary-blue-light); color: var(--primary-blue); }

.export-option-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.export-option-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--slate-800);
}
.export-option-desc {
    font-size: 11px;
    color: var(--slate-400);
}

/* ===== EDITION ÉLÈVE ===== */
.eleves-table tr.editing-row {
    background: var(--primary-orange-light) !important;
}
.eleves-table tr.editing-row td {
    border-bottom-color: var(--primary-orange);
}

#formEleveRow.editing-mode {
    background: var(--primary-orange-light);
    border-radius: var(--radius-sm);
    padding: 8px;
    border: 1px solid rgba(232,90,36,0.3);
    margin-bottom: 12px !important;
}

/* ===== PRINT ===== */
.print-only { display: none; }
.print-header { text-align: center; margin-bottom: 10px; }
.print-title { font-size: 18px; font-weight: 700; color: var(--primary-blue); }
.print-date { font-size: 12px; color: var(--slate-500); }

@media print {
    .no-print { display: none !important; }
    .print-only { display: block !important; }

    html, body { overflow: visible; height: auto; font-size: 10px; background: white; }
    @page { size: A4 landscape; margin: 8mm; }

    .main-container { height: auto; overflow: visible; }
    .plan-container { padding: 0; overflow: visible; }
    .salle { overflow: visible; }

    .ilot { border: 1.5px solid var(--slate-400); box-shadow: none; }
    .eleve-card {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        padding: 2px 5px;
    }
    .card-prenom { font-size: 10px; }
    .card-nom { font-size: 8px; }

    .bureau-inner {
        background: var(--primary-blue) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        padding: 6px 32px;
        font-size: 10px;
    }

    .stats-bar { border: 1px solid var(--slate-300); font-size: 10px; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .topbar {
        padding: 0 10px;
    }
    .brand-tagline {
        display: none;
    }
    .tb-btn span:not(.tb-icon) {
        display: none;
    }
    .panel-eleves {
        width: 150px;
        min-width: 150px;
    }
}
