/* ============================================
   VARIABLES ET RESET
   ============================================ */
:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --bg-light: #f8fafc;
    --bg-white: #ffffff;
    --text-dark: #1e293b;
    --text-gray: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
}

/* ============================================
   MESSAGES FLASH
   ============================================ */
.flash-messages {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    min-width: 300px;
}

.alert {
    padding: 15px 40px 15px 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-lg);
    position: relative;
    transition: opacity 0.3s;
}

.alert-success {
    background: var(--success);
    color: white;
}

.alert-error {
    background: var(--error);
    color: white;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

/* ============================================
   AUTHENTIFICATION (LOGIN/SIGNUP)
   ============================================ */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.70) 0%, rgba(30, 58, 138, 0.60) 100%),
                url('https://images.unsplash.com/photo-1486406146926-c627a92ad1ab?w=1600&h=900&fit=crop&q=80') center/cover no-repeat fixed;
}

.auth-box {
    background: rgba(255, 255, 255, 0.97);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 48px 40px;
    width: 100%;
    max-width: 450px;
    backdrop-filter: blur(10px);
}

.auth-box h1 {
    color: var(--primary);
    font-size: 34px;
    margin-bottom: 5px;
    text-align: center;
    font-weight: 800;
}

/* Logo sur les pages d'authentification */
.auth-logo {
    display: block;
    margin: 0 auto 8px;
    height: 120px;
    width: auto;
}

.auth-box h2 {
    color: var(--text-gray);
    font-size: 18px;
    font-weight: normal;
    margin-bottom: 30px;
    text-align: center;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-dark);
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--text-gray);
    font-size: 13px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    background: var(--text-gray);
    cursor: not-allowed;
}

/* Bouton "Étape suivante" bien visible */
.btn-next-step {
    display: block;
    width: 100%;
    padding: 16px 32px;
    background: linear-gradient(135deg, #1a73e8, #0d47a1);
    color: white;
    font-size: 1.15rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(26, 115, 232, 0.35);
    transition: all 0.3s ease;
    margin-top: 10px;
}

.btn-next-step:hover {
    background: linear-gradient(135deg, #1565c0, #0a3d91);
    box-shadow: 0 6px 20px rgba(26, 115, 232, 0.5);
    transform: translateY(-2px);
    color: white;
    text-decoration: none;
}

.btn-next-step:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(26, 115, 232, 0.3);
}

.btn-secondary {
    background: var(--text-gray);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.auth-link {
    text-align: center;
    color: var(--text-gray);
}

.auth-link a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-link a:hover {
    text-decoration: underline;
}

/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
    margin-bottom: 30px;
}

.page-header h2 {
    color: var(--text-dark);
    font-size: 28px;
    margin-bottom: 10px;
}

.page-header p {
    color: var(--text-gray);
    font-size: 16px;
}

/* ============================================
   TABLEAUX DE DONNEES
   ============================================ */
.table-container {
    overflow-x: auto;
    margin: 20px 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--bg-light);
    font-weight: 600;
    color: var(--text-dark);
    white-space: nowrap;
}

.data-table tr:hover {
    background: var(--bg-light);
}

.data-table td:first-child,
.data-table th:first-child {
    width: 50px;
    text-align: center;
    color: var(--text-gray);
}

/* ============================================
   CARTES ET SECTIONS
   ============================================ */
.preview-card,
.students-list-card,
.help-card {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.preview-header,
.students-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.preview-header h3,
.students-list-header h3 {
    color: var(--text-dark);
    font-size: 20px;
}

.preview-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.help-card {
    background: #fffbeb;
    border: 1px solid #fcd34d;
}

.help-card h4 {
    color: #92400e;
    margin-bottom: 10px;
}

.help-card p {
    color: #78350f;
    margin-bottom: 10px;
}

.help-card ul {
    list-style: none;
    padding: 0;
}

.help-card li {
    padding: 5px 0;
    color: #78350f;
    font-size: 14px;
}

/* ============================================
   BOUTONS ICON ET ACTIONS
   ============================================ */
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 5px 10px;
    border-radius: 5px;
    transition: all 0.2s;
}

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

/* ============================================
   ETAT VIDE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 60px 30px;
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.empty-state h3 {
    color: var(--text-dark);
    margin-bottom: 10px;
}

.empty-state p {
    color: var(--text-gray);
}

/* ============================================
   MESSAGES FLASH - Info
   ============================================ */
.alert-info {
    background: var(--primary);
    color: white;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        gap: 12px;
        padding: 14px 16px;
        text-align: center;
    }

    .header-left {
        margin-right: 0;
    }

    .header-nav {
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
    }

    .header-user {
        border-left: none;
        padding-left: 0;
        margin-left: 0;
        padding-top: 8px;
        border-top: 1px solid var(--border);
    }

    .workflow-steps {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .drop-zone {
        padding: 40px 20px;
    }

    .format-list {
        justify-content: center;
    }

    .preview-actions {
        flex-direction: column;
    }

    .students-list-header {
        flex-direction: column;
        gap: 15px;
    }

    .modal-content {
        width: 95%;
        margin: 10px;
    }
}

/* ============================================
   MODAL DE MODIFICATION
   ============================================ */
.modal-overlay {
    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: var(--bg-white);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    color: var(--text-dark);
    font-size: 20px;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-gray);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--error);
}

.modal-body {
    padding: 25px;
}

.modal-body .form-group {
    margin-bottom: 20px;
}

.modal-body .form-group:last-child {
    margin-bottom: 0;
}

.modal-body .form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-dark);
    font-weight: 500;
    font-size: 14px;
}

.modal-body .form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.3s;
}

.modal-body .form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px 25px;
    border-top: 1px solid var(--border);
    background: var(--bg-light);
    border-radius: 0 0 12px 12px;
}

.modal-footer .btn {
    width: auto;
    min-width: 100px;
}

/* ============================================
   BOUTONS D'ACTION (EDIT + DELETE)
   ============================================ */
.actions-cell {
    white-space: nowrap;
}

.btn-edit {
    margin-right: 5px;
}

.btn-edit:hover {
    background: #dbeafe;
}

/* ============================================
   NOTIFICATIONS : modal etudiant + envoi prof
   ============================================ */

/* Overlay du modal (plein ecran, semi-transparent) */
.notif-modal-overlay {
    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: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}
.notif-modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* Carte modale */
.notif-modal {
    background: white;
    border-radius: 16px;
    padding: 32px;
    max-width: 460px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s;
    text-align: center;
}
.notif-modal-overlay.visible .notif-modal {
    transform: scale(1);
}

/* Header du modal */
.notif-modal-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 16px;
}
.notif-modal-icon {
    font-size: 1.8rem;
}
.notif-modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
}
.notif-modal-counter {
    background: #e2e8f0;
    color: #64748b;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Corps du message */
.notif-modal-body {
    font-size: 1rem;
    line-height: 1.6;
    color: #334155;
    margin-bottom: 20px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 10px;
}

/* Footer (heure + bouton) */
.notif-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.notif-modal-time {
    font-size: 0.8rem;
    color: #94a3b8;
}
.notif-modal-btn {
    background: #2563eb;
    color: white;
    border: none;
    padding: 10px 28px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
}
.notif-modal-btn:hover {
    background: #1d4ed8;
}

/* Badge dans la sidebar */
.notif-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    padding: 0 5px;
    margin-left: 6px;
    vertical-align: super;
}

/* Formulaire d'envoi prof (dans le monitoring) */
.notif-send-section {
    margin-bottom: 20px;
}
.notif-send-form {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.notif-send-form h3 {
    font-size: 0.95rem;
    color: #334155;
    margin-bottom: 12px;
}
.notif-send-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.notif-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #334155;
}
.notif-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.notif-select {
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #334155;
    background: white;
    cursor: pointer;
}
.notif-send-feedback {
    margin-top: 8px;
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 6px;
}
.notif-feedback-success {
    background: #d1fae5;
    color: #065f46;
}
.notif-feedback-error {
    background: #fef2f2;
    color: #991b1b;
}

/* Historique des notifications envoyées */
.notif-history {
    margin-top: 16px;
    border-top: 1px solid #e5e7eb;
    padding-top: 12px;
}
.notif-history-title {
    font-size: 0.85rem;
    color: #6b7280;
    font-weight: 600;
    margin-bottom: 8px;
}
.notif-history-count {
    font-weight: 400;
    color: #9ca3af;
}
.notif-history-list {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.notif-history-item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 6px;
    background: #f8fafc;
    font-size: 0.82rem;
}
.notif-history-item.notif-system {
    background: #fffbeb;
}
.notif-history-date {
    color: #9ca3af;
    white-space: nowrap;
    min-width: 110px;
}
.notif-history-target {
    color: #6366f1;
    font-weight: 500;
    white-space: nowrap;
}
.notif-history-message {
    color: #334155;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.notif-history-empty {
    color: #9ca3af;
    font-size: 0.82rem;
    font-style: italic;
    padding: 8px 0;
}

/* Responsive notification modal */
@media (max-width: 768px) {
    .notif-modal {
        padding: 24px;
        max-width: 95%;
    }
    .notif-send-row {
        flex-direction: column;
    }
    .notif-input {
        min-width: 100%;
    }
}


/* ========================================
   BOUTON REMONTER EN HAUT
   ======================================== */
.scroll-top-fab {
    position: fixed;
    bottom: 88px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #d1d5db;
    color: #4b5563;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
    z-index: 9998;
    transition: opacity 0.3s, transform 0.3s, background 0.2s, box-shadow 0.2s;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.scroll-top-fab.visible {
    opacity: 0.85;
    transform: translateY(0);
    pointer-events: auto;
}
.scroll-top-fab:hover {
    opacity: 1;
    background: #c0c5cc;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    transform: scale(1.05);
}
@media (max-width: 480px) {
    .scroll-top-fab {
        bottom: 76px;
        right: 16px;
    }
}

/* ========================================
   WIDGET D'AIDE CONTEXTUELLE
   ======================================== */

/* Bouton flottant (FAB) */
.help-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    border: none;
    font-size: 22px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
    z-index: 9999;
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-fab:hover {
    background: #1d4ed8;
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(37, 99, 235, 0.45);
}

.help-fab.active {
    background: #64748b;
    transform: rotate(45deg) scale(1.05);
}

/* Panneau de chat */
.help-panel {
    position: fixed;
    bottom: 88px;
    right: 24px;
    width: 380px;
    height: 480px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
}

.help-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Header du panneau */
.help-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #2563eb;
    color: #fff;
    border-radius: 16px 16px 0 0;
    font-weight: 600;
    font-size: 15px;
}

.help-panel-header div {
    display: flex;
    gap: 4px;
}

.help-header-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.help-header-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.help-close-btn {
    font-size: 22px;
}

/* Zone des messages */
.help-panel-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Message de bienvenue */
.help-welcome {
    text-align: center;
    color: #64748b;
    font-size: 14px;
    padding: 40px 16px;
    line-height: 1.5;
}

/* Bulles de messages */
.help-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
}

.help-msg-user {
    align-self: flex-end;
    background: #2563eb;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.help-msg-ai {
    align-self: flex-start;
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 4px;
}

.help-msg-ai strong {
    font-weight: 600;
}

.help-msg-ai code {
    background: #e2e8f0;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12.5px;
}

.help-msg-ai ul {
    margin: 6px 0;
    padding-left: 18px;
}

.help-msg-ai li {
    margin-bottom: 3px;
}

/* Indicateur de chargement (3 points animés) */
.help-loading {
    opacity: 0.7;
}

.help-dots span {
    animation: helpDotPulse 1.2s infinite;
    font-size: 18px;
    font-weight: bold;
}

.help-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.help-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes helpDotPulse {
    0%, 60%, 100% { opacity: 0.3; }
    30% { opacity: 1; }
}

/* Zone de saisie */
.help-panel-input {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e2e8f0;
    background: #fafbfc;
    border-radius: 0 0 16px 16px;
}

.help-panel-input textarea {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13.5px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 100px;
    line-height: 1.4;
    transition: border-color 0.15s;
}

.help-panel-input textarea:focus {
    border-color: #2563eb;
}

.help-panel-input button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    border: none;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}

.help-panel-input button:hover {
    background: #1d4ed8;
}

.help-panel-input button:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 480px) {
    .help-panel {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 76px;
        height: 60vh;
    }
    .help-fab {
        bottom: 16px;
        right: 16px;
    }
}
