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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* Barre de navigation */
.navbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.nav-container h1 {
    font-size: 1.5rem;
    white-space: nowrap;
}

.nav-menu {
    list-style: none;
    display: flex;
    gap: 2rem;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s ease;
    cursor: pointer;
}

.nav-link:hover,
.nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
}

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.3);
    font-weight: bold;
}

/* Sections */
.section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Conteneur principal */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.container h2 {
    color: #667eea;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

/* Zone de upload */
.upload-area {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.upload-box {
    background: white;
    border: 2px dashed #667eea;
    border-radius: 8px;
    padding: 2rem;
    transition: all 0.3s ease;
}

.upload-box:hover {
    border-color: #764ba2;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.upload-box h3 {
    color: #667eea;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.file-input-label {
    display: block;
    cursor: pointer;
}

.file-input {
    display: none;
}

.file-label-text {
    display: block;
    padding: 2rem;
    text-align: center;
    color: #666;
    background-color: #f9f9f9;
    border-radius: 4px;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.file-input-label:hover .file-label-text {
    background-color: #f0f0f0;
    color: #333;
}

.file-status {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    padding: 0.5rem;
    border-radius: 4px;
}

.file-status.success {
    background-color: #d4edda;
    color: #155724;
}

.file-status.error {
    background-color: #f8d7da;
    color: #721c24;
}

/* Boutons */
.button-group {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background-color: #e9ecef;
    color: #333;
}

.btn-secondary:hover {
    background-color: #dee2e6;
}

/* Tableau */
.data-container {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.data-container h3 {
    color: #667eea;
    margin-bottom: 1rem;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    position: sticky;
    top: 0;
}

.data-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e9ecef;
}

.data-table tbody tr:hover {
    background-color: #f8f9fa;
}

.data-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

/* Messages */
.info-message {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 4px;
    background-color: #e7f3ff;
    color: #0066cc;
    border-left: 4px solid #0066cc;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-menu {
        width: 100%;
        justify-content: space-around;
        gap: 0;
    }

    .container {
        padding: 1rem;
    }

    .upload-area {
        grid-template-columns: 1fr;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .data-table {
        font-size: 0.8rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem;
    }
}

/* Section Display (Partie 2) */
.display-controls {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-weight: 600;
    color: #667eea;
    font-size: 0.9rem;
}

.control-group select,
.control-group input {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.weight-inputs {
    display: flex;
    gap: 0.5rem;
}

.weight-inputs > div {
    flex: 1;
}

.weight-inputs label {
    font-size: 0.8rem;
    font-weight: normal;
}

.weight-inputs input {
    width: 100%;
}

.filters-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.filters-section h3 {
    color: #667eea;
    margin-bottom: 1rem;
}

.filter-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-item label {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

.filter-item input {
    flex: 1;
    padding: 0.4rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
}

.filter-item span {
    min-width: 30px;
    text-align: right;
    font-weight: 600;
    color: #667eea;
}

/* Classes et élèves - Organisés par niveau */
#classes-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

.level-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.level-title {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    padding-bottom: 1rem;
    border-bottom: 3px solid rgba(255, 255, 255, 0.3);
    text-align: center;
    text-transform: capitalize;
    margin: 0;
    flex-shrink: 0;
}

.level-classes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(var(--column-width), 1fr));
    gap: 1rem;
    width: 100%;
}

.class-group {
    background: white;
    border-radius: 6px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.class-label {
    font-weight: 600;
    color: #667eea;
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    text-transform: capitalize;
}

.level-group {
    margin-bottom: 1.5rem;
}

.level-label {
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

:root {
    --badge-width: 100px;
    --badge-height: 60px;
    --column-width: calc(var(--badge-width) + 40px);
}

.students-grid {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.student-badge {
    display: flex;
    flex-direction: column;
    width: var(--badge-width);
    min-height: calc(var(--badge-height) - 8px);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
    cursor: pointer;
}

.student-badge:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.badge-indicators {
    display: flex;
    height: 4px;
    gap: 0;
}

.behavior-indicator {
    flex: 1;
    height: 4px;
    flex-shrink: 0;
}

.student-name {
    flex: 1;
    padding: 0.4rem 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #333;
    text-align: center;
    word-wrap: break-word;
    line-height: 1.1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.absence-indicator {
    flex: 1;
    height: 4px;
    flex-shrink: 0;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #667eea;
}

.modal-header h2 {
    color: #667eea;
    margin: 0;
    font-size: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #667eea;
}

.modal-body {
    display: grid;
    gap: 1rem;
}

.info-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.info-field {
    display: flex;
    flex-direction: column;
}

.info-field label {
    font-weight: 600;
    color: #667eea;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-field value {
    color: #333;
    font-size: 1rem;
    padding: 0.5rem;
    background-color: #f9f9f9;
    border-radius: 4px;
    border-left: 3px solid #667eea;
    padding-left: 0.75rem;
}

.info-field.full {
    grid-column: 1 / -1;
}

.modal-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
    text-align: center;
    font-size: 0.85rem;
    color: #999;
}

.legend {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.legend h3 {
    color: #667eea;
    margin-bottom: 1rem;
}

.legend-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.legend-sample {
    width: 60px;
    height: 40px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.legend-label {
    font-size: 0.8rem;
    color: #666;
}

@media (max-width: 768px) {
    .display-controls {
        grid-template-columns: 1fr;
    }

    .weight-inputs {
        flex-direction: column;
    }

    .filter-group {
        grid-template-columns: 1fr;
    }

    .student-name {
        font-size: 0.7rem;
    }
}

/* Section Statistiques */
.stats-filters {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    align-items: flex-end;
}

.filter-group-stats {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group-stats label {
    font-weight: 600;
    color: #667eea;
    font-size: 0.9rem;
}

.filter-group-stats select {
    padding: 0.6rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    background-color: white;
    cursor: pointer;
}

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

.summary-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1.5rem;
    border-radius: 8px;
    color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: center;
}

.summary-label {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.summary-value {
    font-size: 2rem;
    font-weight: 700;
}

.stats-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 2rem;
}

.chart-container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.chart-container h3 {
    color: #667eea;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

.chart-container canvas {
    max-height: 400px;
}

@media (max-width: 1200px) {
    .stats-charts {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .stats-filters {
        grid-template-columns: 1fr;
    }

    .stats-summary {
        grid-template-columns: repeat(2, 1fr);
    }

    .summary-value {
        font-size: 1.5rem;
    }

    .chart-container {
        padding: 1rem;
    }
}

/* Section Profils */
.profiles-config {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.profiles-config h3 {
    color: #667eea;
    margin-bottom: 1.5rem;
}

.profiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.profile-card {
    background: #f9f9f9;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.3s ease;
}

.profile-card:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.profile-card h4 {
    color: #667eea;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.profile-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.input-group label {
    font-weight: 600;
    color: #333;
    font-size: 0.85rem;
}

.range-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.range-inputs input {
    flex: 1;
    padding: 0.4rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.8rem;
}

.range-inputs span {
    color: #666;
    font-weight: 600;
}

.profile-input {
    width: 100%;
}

#profiles-results {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

.profile-results-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-left: 5px solid #667eea;
}

.profile-results-card h4 {
    color: #667eea;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.profile-count {
    display: inline-block;
    background: #667eea;
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    font-weight: 600;
    margin-left: 0.5rem;
}

.profile-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.profile-table thead {
    background: #667eea;
    color: white;
}

.profile-table th {
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
}

.profile-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #e9ecef;
}

.profile-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.profile-table tbody tr:hover {
    background-color: #f0f0f0;
}
