/* HistoriquePage.css - VERSION OPTIMISÉE RESPONSIVE */

/* ═══════════════════════════════════════════════════════
   VARIABLES
   ═══════════════════════════════════════════════════════ */
:root {
    --primary-color: #0ea5e9;
    --primary-dark: #0284c7;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --dark-color: #1e293b;
    --gray-color: #64748b;
    --light-gray: #f1f5f9;
    --border-radius: 12px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

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

html {
    font-size: 16px;
}

/* Réduction automatique pour les petits écrans */
@media (max-width: 1600px) {
    html {
        font-size: 15px;
    }
}

@media (max-width: 1400px) {
    html {
        font-size: 14px;
    }
}

@media (max-width: 1200px) {
    html {
        font-size: 13px;
    }
}

@media (max-width: 992px) {
    html {
        font-size: 12px;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

.page-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 100vw;
    overflow-x: hidden;
}

/* ═══════════════════════════════════════════════════════
   NAVBAR - COMPACT
   ═══════════════════════════════════════════════════════ */
.navbar {
    background: white;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 1rem;
    flex-wrap: nowrap;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.nav-logo {
    font-size: 1.5rem;
}

.nav-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.nav-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--dark-color);
    white-space: nowrap;
}

.nav-subtitle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--gray-color);
}

.role-badge {
    background: var(--primary-color);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.user-name {
    font-weight: 600;
    color: var(--dark-color);
    font-size: 0.9rem;
    white-space: nowrap;
}

.logout-button {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: var(--transition);
    font-size: 0.85rem;
    white-space: nowrap;
}

    .logout-button:hover {
        background: #dc2626;
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }

/* ═══════════════════════════════════════════════════════
   MAIN CONTENT - ADAPTATIF
   ═══════════════════════════════════════════════════════ */
.main-content {
    flex: 1;
    padding: 1.25rem;
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
}

.content-header {
    margin-bottom: 1.5rem;
}

    .content-header h1 {
        font-size: 1.75rem;
        font-weight: 700;
        color: white;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

/* ═══════════════════════════════════════════════════════
   SEARCH - COMPACT
   ═══════════════════════════════════════════════════════ */
.search-section {
    background: white;
    padding: 1.25rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-md);
}

.search-wrapper {
    position: relative;
    max-width: 100%;
}

.search-icon {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    color: var(--gray-color);
}

.search-input {
    width: 100%;
    padding: 0.7rem 2.5rem;
    border: 2px solid var(--light-gray);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    transition: var(--transition);
}

    .search-input:focus {
        outline: none;
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
    }

.search-clear {
    position: absolute;
    right: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--light-gray);
    border: none;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--gray-color);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

    .search-clear:hover {
        background: var(--danger-color);
        color: white;
    }

/* ═══════════════════════════════════════════════════════
   FILTERS - OPTIMISÉ
   ═══════════════════════════════════════════════════════ */
.filters-container {
    background: white;
    padding: 1.25rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-md);
}

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

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

.filter-label {
    font-weight: 600;
    color: var(--dark-color);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.filter-icon {
    font-size: 0.9rem;
}

.filter-select {
    padding: 0.55rem 0.75rem;
    border: 2px solid var(--light-gray);
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    background: white;
    cursor: pointer;
    transition: var(--transition);
}

    .filter-select:focus {
        outline: none;
        border-color: var(--primary-color);
    }

    .filter-select:disabled {
        background: var(--light-gray);
        cursor: not-allowed;
        opacity: 0.6;
    }

.filter-hint {
    color: var(--gray-color);
    font-size: 0.7rem;
    font-style: italic;
}

.reset-filters-button {
    background: var(--gray-color);
    color: white;
    border: none;
    padding: 0.55rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    width: 100%;
    font-size: 0.85rem;
}

    .reset-filters-button:hover {
        background: var(--dark-color);
    }

/* ═══════════════════════════════════════════════════════
   TABLE - ULTRA COMPACT
   ═══════════════════════════════════════════════════════ */
.table-container {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    overflow-x: auto;
    max-width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1000px;
}

    .data-table thead {
        background: var(--primary-color);
        color: white;
        position: sticky;
        top: 0;
        z-index: 10;
    }

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

        .data-table th.sortable {
            cursor: pointer;
            user-select: none;
            transition: var(--transition);
        }

            .data-table th.sortable:hover {
                background: var(--primary-dark);
            }

.sort-icon {
    margin-left: 0.3rem;
    opacity: 0.5;
    font-size: 0.75rem;
}

    .sort-icon.active {
        opacity: 1;
    }

.data-table td {
    padding: 0.75rem 0.6rem;
    border-bottom: 1px solid var(--light-gray);
    font-size: 0.8rem;
}

.table-row {
    transition: var(--transition);
}

    .table-row:hover {
        background: var(--light-gray);
    }

.text-center {
    text-align: center;
}

/* ═══════════════════════════════════════════════════════
   CELLS - COMPACT
   ═══════════════════════════════════════════════════════ */
.student-cell {
    min-width: 160px;
}

.student-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.student-name {
    color: var(--dark-color);
    font-weight: 600;
    font-size: 0.85rem;
}

.student-id {
    color: var(--gray-color);
    font-size: 0.7rem;
}

.promo-text {
    color: var(--dark-color);
    font-weight: 500;
}

.status-badge {
    display: inline-block;
    padding: 0.3rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-align: center;
}

.status-success {
    background: #dcfce7;
    color: #166534;
}

.status-progress {
    background: #fef3c7;
    color: #92400e;
}

.status-pending {
    background: #fee2e2;
    color: #991b1b;
}

.date-cell {
    min-width: 100px;
}

.date-text {
    color: var(--dark-color);
    font-weight: 500;
    font-size: 0.8rem;
}

.no-date {
    color: var(--gray-color);
}

.commentaire-formateur-cell,
.commentaire-rre-cell {
    max-width: 250px;
}

.commentaire-content,
.commentaire-rre-content {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.commentaire-icon {
    font-size: 0.9rem;
    flex-shrink: 0;
}

.commentaire-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.8rem;
}

.no-comment {
    color: var(--gray-color);
    text-align: center;
}

.history-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: white;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    font-weight: 600;
    font-size: 0.8rem;
}

.actions-cell {
    min-width: 100px;
}

.action-buttons {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
}

.action-btn {
    padding: 0.4rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition);
    background: var(--light-gray);
}

    .action-btn:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }

.action-view:hover {
    background: var(--primary-color);
}

.action-export:hover {
    background: var(--success-color);
}

/* ═══════════════════════════════════════════════════════
   LOADING & EMPTY
   ═══════════════════════════════════════════════════════ */
.loading-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid var(--light-gray);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--gray-color);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* ═══════════════════════════════════════════════════════
   MODAL - RESPONSIVE
   ═══════════════════════════════════════════════════════ */
.modal-header {
    padding: 1.2rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 20px 20px 0 0;
}

    .modal-header h2 {
        font-size: 1.3rem;
        font-weight: 700;
    }

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.8rem;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

    .modal-close:hover {
        background: rgba(255, 255, 255, 0.3);
        transform: rotate(90deg);
    }

.modal-student-info {
    padding: 1.2rem 1.5rem;
    background: var(--light-gray);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.9rem;
    border-bottom: 2px solid #e2e8f0;
}

.info-row {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.info-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gray-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--dark-color);
}

.column-section-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--dark-color);
    margin-bottom: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding-bottom: 0.6rem;
    border-bottom: 2px solid var(--light-gray);
}

    .column-section-title span:first-child {
        font-size: 1.3rem;
    }

.history-badge {
    background: var(--primary-color);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.no-history-message {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--gray-color);
}

.no-history-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
}

/* ═══════════════════════════════════════════════════════
   STATUS & FORM
   ═══════════════════════════════════════════════════════ */
.current-status {
    background: white;
    padding: 1.2rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.2rem;
    border: 2px solid var(--light-gray);
}

    .current-status h3 {
        font-size: 1rem;
        font-weight: 700;
        color: var(--dark-color);
        margin-bottom: 0.9rem;
    }

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.9rem;
}

.status-item {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.status-item-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gray-color);
    text-transform: uppercase;
}

.status-item-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--dark-color);
}

.action-form {
    background: white;
    padding: 1.2rem;
    border-radius: var(--border-radius);
    border: 2px solid var(--light-gray);
}

.form-grid-2col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.9rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group-full {
    grid-column: 1 / -1;
}

.form-label {
    font-weight: 600;
    color: var(--dark-color);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.label-icon {
    font-size: 0.9rem;
}

.required-star {
    color: var(--danger-color);
    margin-left: 0.2rem;
}

.form-select,
.form-input {
    padding: 0.65rem;
    border: 2px solid var(--light-gray);
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    transition: var(--transition);
}

    .form-select:focus,
    .form-input:focus {
        outline: none;
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
    }

.form-textarea {
    padding: 0.65rem;
    border: 2px solid var(--light-gray);
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    font-family: inherit;
    resize: vertical;
    transition: var(--transition);
    min-height: 80px;
}

    .form-textarea:focus {
        outline: none;
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
    }

.form-textarea-highlight {
    border-color: var(--warning-color);
    background: #fffbeb;
}

.form-info-note {
    grid-column: 1 / -1;
    background: #dbeafe;
    color: #1e40af;
    padding: 0.65rem 0.9rem;
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.rre-readonly-info {
    background: var(--light-gray);
    padding: 0.9rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.2rem;
    border-left: 4px solid var(--primary-color);
}

    .rre-readonly-info h4 {
        font-size: 0.9rem;
        font-weight: 700;
        color: var(--dark-color);
        margin-bottom: 0.6rem;
    }

    .rre-readonly-info p {
        font-size: 0.8rem;
        color: var(--dark-color);
        margin-bottom: 0.4rem;
    }

/* ═══════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════ */
.modal-footer {
    padding: 1.2rem 1.5rem;
    background: var(--light-gray);
    display: flex;
    justify-content: flex-end;
    gap: 0.9rem;
    border-radius: 0 0 20px 20px;
    flex-wrap: wrap;
}

.secondary-button {
    background: var(--gray-color);
    color: white;
    border: none;
    padding: 0.65rem 1.2rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    font-size: 0.85rem;
}

    .secondary-button:hover {
        background: var(--dark-color);
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }

.btn-add-action {
    background: var(--success-color);
    color: white;
    border: none;
    padding: 0.65rem 1.2rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    font-size: 0.85rem;
}

    .btn-add-action:hover:not(:disabled) {
        background: #16a34a;
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }

    .btn-add-action:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

/* ═══════════════════════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════════════════════ */
.table-container::-webkit-scrollbar {
    height: 6px;
}

.table-container::-webkit-scrollbar-track {
    background: var(--light-gray);
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

    .table-container::-webkit-scrollbar-thumb:hover {
        background: var(--primary-dark);
    }

/* ═══════════════════════════════════════════════════════
   RESPONSIVE - MOBILE
   ═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    .navbar {
        flex-direction: column;
        align-items: flex-start;
        padding: 0.9rem;
    }

    .nav-right {
        width: 100%;
        justify-content: space-between;
    }

    .filters-grid {
        grid-template-columns: 1fr;
    }

    .data-table {
        min-width: 800px;
    }

    div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* Ajoutez ceci dans la constante styles */

.table-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    overflow: auto; /* ✅ Changé de overflow-x à overflow */
    max-width: 100%;
}

    /* Scrollbar verticale */
    .table-container::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }

    .table-container::-webkit-scrollbar-track {
        background: #f1f5f9;
        border-radius: 4px;
    }

    .table-container::-webkit-scrollbar-thumb {
        background: #0ea5e9;
        border-radius: 4px;
    }

        .table-container::-webkit-scrollbar-thumb:hover {
            background: #0284c7;
        }

    /* Corner pour les deux scrollbars */
    .table-container::-webkit-scrollbar-corner {
        background: #f1f5f9;
    }
