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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

/* Login */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    color: #667eea;
    margin-bottom: 5px;
    font-size: 28px;
}

.login-box h2 {
    color: #666;
    font-size: 16px;
    font-weight: normal;
    margin-bottom: 30px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e5eb;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s;
}

.btn-primary {
    background: #667eea;
    color: white;
    width: 100%;
    padding: 14px;
    font-size: 16px;
}

.btn-primary:hover {
    background: #5a6fd6;
}

.btn-save {
    background: #28a745;
    color: white;
    padding: 6px 12px;
}

.btn-save:hover {
    background: #218838;
}

.btn-delete {
    background: #dc3545;
    color: white;
    padding: 6px 12px;
}

.btn-delete:hover {
    background: #c82333;
}

.btn-logout {
    background: #6c757d;
    color: white;
}

.btn-logout:hover {
    background: #5a6268;
}

.btn-export {
    background: #17a2b8;
    color: white;
    margin-right: 10px;
}

.btn-export:hover {
    background: #138496;
}

/* Messages */
.error {
    background: #f8d7da;
    color: #721c24;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.success {
    background: #d4edda;
    color: #155724;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.info {
    background: #e7f3ff;
    color: #004085;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 20px;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e1e5eb;
}

header h1 {
    color: #667eea;
    font-size: 24px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
}

.tab {
    padding: 12px 24px;
    background: #e1e5eb;
    color: #555;
    text-decoration: none;
    border-radius: 6px 6px 0 0;
    font-weight: 500;
}

.tab:hover {
    background: #d1d5db;
}

.tab.active {
    background: #667eea;
    color: white;
}

/* Filters */
.filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filters select,
.filters input[type="text"] {
    padding: 10px 15px;
    border: 2px solid #e1e5eb;
    border-radius: 6px;
    font-size: 14px;
}

.filters select {
    min-width: 250px;
}

.filters input[type="text"] {
    min-width: 200px;
}

/* Table */
.table-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto; /* Laisser le navigateur calculer les largeurs */
}

th, td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid #e1e5eb;
    vertical-align: top;
}

/* Colonnes spécifiques - largeurs optimisées */
td:nth-child(1),  /* Colonne Élève */
th:nth-child(1) {
    min-width: 150px;
}

td:nth-child(2),  /* Colonne Établissement */
th:nth-child(2) {
    min-width: 180px;
}

td:nth-child(3),  /* Colonne Classe */
th:nth-child(3) {
    min-width: 70px;
}

td:nth-child(4),  /* Colonne Notif I */
th:nth-child(4) {
    min-width: 90px;
}

td:nth-child(5),  /* Colonne Notif M */
th:nth-child(5) {
    min-width: 90px;
}

td:nth-child(6),  /* Colonne Plan B */
th:nth-child(6) {
    min-width: 60px;
    text-align: center;
}

td:nth-child(7),  /* Colonne AESH */
th:nth-child(7) {
    min-width: 150px;
}

td:nth-child(8),  /* Colonne Heures */
th:nth-child(8) {
    min-width: 80px;
    text-align: center;
}

td:nth-child(9),  /* Colonne Remarques */
th:nth-child(9) {
    min-width: 120px;
}

td:nth-child(10),  /* Colonne Actions */
th:nth-child(10) {
    min-width: 90px;
}

th {
    background: #667eea;
    color: white;
    font-weight: 500;
    font-size: 13px;
    white-space: nowrap;
    padding: 12px 10px;
}

th small {
    font-weight: normal;
    opacity: 0.9;
}

tr:hover {
    background: #f8f9fa;
}

td.readonly {
    background: #f8f9fa;
    color: #555;
}

td.center {
    text-align: center;
}

td.actions {
    white-space: nowrap;
}

/* Editable inputs in table */
input.editable,
select.editable {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

textarea.editable {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
}

textarea.textarea-aesh {
    min-height: 50px;
    max-height: 60px;
    min-width: 110px;
}

textarea.textarea-remarques {
    min-height: 50px;
    max-height: 60px;
    min-width: 90px;
}

/* Style global pour tous les textareas dans les tableaux */
.table-container textarea.editable {
    min-height: 50px;
    max-height: 60px;
    resize: vertical;
}

/* ========================================
   TABLE ÉTABLISSEMENT - Styles
   ======================================== */

table.table-etab th,
table.table-etab td {
    padding: 10px 8px;
}

table.table-etab th:nth-child(1),
table.table-etab td:nth-child(1) {
    min-width: 140px;
}

table.table-etab th:nth-child(2),
table.table-etab td:nth-child(2) {
    min-width: 60px;
}

table.table-etab th:nth-child(3),
table.table-etab td:nth-child(3) {
    min-width: 80px;
}

table.table-etab th:nth-child(4),
table.table-etab td:nth-child(4) {
    min-width: 80px;
}

table.table-etab th:nth-child(5),
table.table-etab td:nth-child(5) {
    min-width: 50px;
    text-align: center;
}

table.table-etab th:nth-child(6),
table.table-etab td:nth-child(6) {
    min-width: 150px;
}

table.table-etab th:nth-child(7),
table.table-etab td:nth-child(7) {
    min-width: 70px;
    text-align: center;
}

table.table-etab th:nth-child(8),
table.table-etab td:nth-child(8) {
    min-width: 120px;
}

table.table-etab th:nth-child(9),
table.table-etab td:nth-child(9) {
    min-width: 60px;
    text-align: center;
}

input.editable:focus,
select.editable:focus,
textarea.editable:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

input.editable.small,
select.editable.small {
    width: 100px;
}

input.editable.large {
    width: 280px;
}

input.editable.tiny {
    width: 80px; /* Augmenté de 60px à 80px pour le champ Heures */
    text-align: center;
}

/* Larger fields for AESH and Remarques columns */
input.editable.xlarge {
    width: 250px;
}

input.editable.xxlarge {
    width: 300px;
}

/* Établissement title */
.etab-title {
    background: #667eea;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    margin: 30px 0 15px 0;
    font-size: 18px;
}

.etab-title:first-of-type {
    margin-top: 0;
}

/* Form add */
.form-add {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    max-width: 600px;
}

.form-row {
    margin-bottom: 20px;
}

.form-row label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-row input[type="text"],
.form-row select {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #e1e5eb;
    border-radius: 6px;
    font-size: 14px;
}

.form-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
}

code {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}

/* ========================================
   SÉLECTION GLOBALE - Admin
   ======================================== */

.global-actions {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.select-all-container {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    font-weight: 500;
    cursor: pointer;
}

.select-all-container input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.selected-count {
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.btn-save-global {
    margin-left: auto;
    padding: 10px 20px;
    font-size: 14px;
    background: #28a745;
    border: 2px solid rgba(255,255,255,0.3);
}

.btn-save-global:hover {
    background: #218838;
    border-color: rgba(255,255,255,0.5);
}

.col-checkbox {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    text-align: center;
}

.row-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Ajustement des colonnes pour le tableau admin avec checkbox */
table.table-admin th:nth-child(1),
table.table-admin td:nth-child(1) {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
}

table.table-admin th:nth-child(2),
table.table-admin td:nth-child(2) {
    min-width: 140px;
}

table.table-admin th:nth-child(3),
table.table-admin td:nth-child(3) {
    min-width: 150px;
}

table.table-admin th:nth-child(4),
table.table-admin td:nth-child(4) {
    min-width: 60px;
}

table.table-admin th:nth-child(5),
table.table-admin td:nth-child(5) {
    min-width: 80px;
}

table.table-admin th:nth-child(6),
table.table-admin td:nth-child(6) {
    min-width: 80px;
}

table.table-admin th:nth-child(7),
table.table-admin td:nth-child(7) {
    min-width: 50px;
    text-align: center;
}

table.table-admin th:nth-child(8),
table.table-admin td:nth-child(8) {
    min-width: 120px;
}

table.table-admin th:nth-child(9),
table.table-admin td:nth-child(9) {
    min-width: 70px;
}

table.table-admin th:nth-child(10),
table.table-admin td:nth-child(10) {
    min-width: 100px;
}

table.table-admin th:nth-child(11),
table.table-admin td:nth-child(11) {
    min-width: 50px;
    text-align: center;
}

/* ========================================
   STATISTIQUES - Styles
   ======================================== */

.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-card .stat-number {
    font-size: 36px;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-card .stat-label {
    font-size: 14px;
    color: #666;
}

.stat-total .stat-number {
    color: #667eea;
}

.stat-ok .stat-number {
    color: #28a745;
}

.stat-warning .stat-number {
    color: #ffc107;
}

.stat-pct .stat-number {
    color: #17a2b8;
}

/* Progress bar global */
.progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    margin-top: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #20c997);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Mini progress dans le tableau */
.mini-progress {
    position: relative;
    width: 100%;
    height: 20px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.mini-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.mini-progress span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: bold;
    color: #333;
    text-shadow: 0 0 2px white;
}

/* Couleurs des lignes selon statut */
.stat-row-complet {
    background: #d4edda;
}

.stat-row-partiel {
    background: #fff3cd;
}

.stat-row-debut {
    background: #ffe5d0;
}

.stat-row-vide {
    background: #f8f9fa;
}

/* ========================================
   MAILING - Styles
   ======================================== */

.mailing-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 30px;
}

.mailing-form .form-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e1e5eb;
}

.mailing-form .form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.mailing-form h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 16px;
}

/* Filtres de saisie */
.filter-saisie {
    margin-bottom: 15px;
}

.filter-saisie > label {
    display: block;
    margin-bottom: 10px;
}

.filter-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-filter {
    background: #e9ecef;
    color: #495057;
    border: 2px solid transparent;
    padding: 8px 16px;
    font-size: 13px;
}

.btn-filter:hover {
    background: #dee2e6;
}

.btn-filter.active {
    background: #667eea;
    color: white;
    border-color: #5a6fd6;
}

.destinataires-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.selection-count {
    background: #667eea;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.destinataires-list {
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid #e1e5eb;
    border-radius: 6px;
}

.destinataire-item {
    display: grid;
    grid-template-columns: 30px 1.5fr 1fr 1.5fr 70px 70px;
    gap: 10px;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
}

.destinataire-item:hover {
    background: #f8f9fa;
}

.destinataire-item:last-child {
    border-bottom: none;
}

.destinataire-item.no-email {
    background: #fff3cd;
    opacity: 0.7;
    cursor: not-allowed;
}

.destinataire-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.etab-name {
    font-weight: 500;
    color: #333;
}

.etab-contact {
    color: #666;
    font-size: 13px;
}

.etab-email {
    color: #667eea;
    font-size: 13px;
}

.etab-stats {
    color: #666;
    font-size: 12px;
    text-align: center;
}

.etab-progress {
    text-align: right;
}

.mini-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
}

.badge-ok {
    background: #d4edda;
    color: #155724;
}

.badge-partial {
    background: #fff3cd;
    color: #856404;
}

.badge-empty {
    background: #e9ecef;
    color: #6c757d;
}

.badge-none {
    background: #f8d7da;
    color: #721c24;
}

/* Options d'inclusion */
.include-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.include-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: #f8f9fa;
    border: 2px solid #e1e5eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.include-option:hover {
    background: #e9ecef;
    border-color: #667eea;
}

.include-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.include-option input[type="checkbox"]:checked + .option-icon + .option-text {
    color: #667eea;
    font-weight: 500;
}

.option-icon {
    font-size: 20px;
}

.option-text {
    font-size: 14px;
    color: #555;
}

/* Modèles de messages */
.message-templates {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px dashed #e1e5eb;
}

.message-templates > label {
    display: block;
    margin-bottom: 10px;
}

.template-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-template {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #495057;
}

.btn-template:hover {
    background: #e9ecef;
    border-color: #667eea;
}

.message-textarea {
    min-height: 200px;
    font-family: inherit;
    line-height: 1.5;
}

.help-text {
    display: block;
    margin-top: 8px;
    color: #666;
    font-size: 13px;
}

.help-text code {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: #667eea;
}

/* Actions d'envoi */
.send-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.send-actions .btn-primary {
    width: auto;
    padding: 14px 30px;
}

/* Modal aperçu */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: #999;
}

.modal-close:hover {
    color: #333;
}

.modal-content h3 {
    margin-bottom: 20px;
    color: #667eea;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .filters select,
    .filters input[type="text"] {
        width: 100%;
        min-width: auto;
    }
    
    .tabs {
        flex-wrap: wrap;
    }
    
    /* Le tableau garde sa taille minimale et scroll horizontalement */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    th, td {
        padding: 8px 5px;
        font-size: 12px;
    }
    
    /* Message d'indication du scroll */
    .table-container::after {
        content: "← Faites défiler horizontalement →";
        display: block;
        text-align: center;
        padding: 10px;
        background: #f0f0f0;
        font-size: 12px;
        color: #666;
    }
    
    .stats-summary {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-card .stat-number {
        font-size: 28px;
    }
}