/* ==========================================================================
   Reset & Base
   ========================================================================== */

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

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

a {
    color: #0f4c5f;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

header {
    background: #0f4c5f;
    color: white;
    padding: 15px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

header h1 {
    font-size: 1.5rem;
}

.header-top {
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-items: center;
}

.header-buttons a,
.header-top a {
    color: white;
    background: rgba(255,255,255,0.15);
    padding: 6px 12px;
    border-radius: 20px;
    margin-left: 8px;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.header-buttons a:hover,
.header-top a:hover {
    background: rgba(255,255,255,0.3);
    text-decoration: none;
}

.user-info {
    font-size: 0.9rem;
}

/* ==========================================================================
   Conteneurs principaux (type carte)
   ========================================================================== */

main {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 15px;
}

/* ==========================================================================
   Formulaires uniformisés
   ========================================================================== */

input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="email"],
textarea,
select {
    padding: 12px;
    border-radius: 30px;
    border: 1px solid #ccc;
    font-size: 1rem;
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color 0.2s;
    outline: none;
    background: #fff;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="url"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
    border-color: #e67e22;
    box-shadow: 0 0 0 2px rgba(230, 126, 34, 0.2);
}

textarea {
    border-radius: 20px;
    resize: vertical;
}

/* Boutons principaux */
button[type="submit"],
button.btn-admin,
button.btn-valider,
button.btn-rejeter,
button.envoyer,
button.btn-pdf {
    background-color: #e67e22;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 40px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s, transform 0.1s;
}

button[type="submit"]:hover,
button.btn-admin:hover,
button.btn-valider:hover,
button.envoyer:hover,
button.btn-pdf:hover {
    background-color: #b45f1b;
}

button.btn-danger {
    background-color: #c0392b;
}
button.btn-danger:hover {
    background-color: #a93226;
}

button.btn-success {
    background-color: #27ae60;
}
button.btn-success:hover {
    background-color: #219a52;
}

button.delete-btn {
    background: #c0392b;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
}

/* ==========================================================================
   Champs dans les tableaux (padding réduit)
   ========================================================================== */

table input[type="text"],
table input[type="password"],
table input[type="number"],
table textarea,
table select {
    padding: 6px 10px;
    border-radius: 15px;
    font-size: 0.9rem;
}

table textarea {
    border-radius: 10px;
}

/* ==========================================================================
   Formulaires en ligne (ajout élève, etc.)
   ========================================================================== */

.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.form-inline input,
.form-inline select {
    flex: 1 1 auto;
    min-width: 150px;
}

/* ==========================================================================
   Conteneurs de formulaire type "auth"
   ========================================================================== */

.auth-container {
    max-width: 400px;
    margin: 50px auto;
    background: white;
    border-radius: 30px;
    padding: 30px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    text-align: center;
}

.auth-container h1 {
    color: #0f4c5f;
    margin-bottom: 20px;
}

.auth-form .form-group {
    margin-bottom: 15px;
    text-align: left;
}

.auth-form label {
    display: block;
    color: #0f4c5f;
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.auth-form input {
    width: 100%;
}

/* ==========================================================================
   Messages (inline, conservés pour certaines pages)
   ========================================================================== */

.message {
    background: #e0f2e9;
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 15px;
}

.message-error {
    background: #ffe6e6;
    color: #c0392b;
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 15px;
}

.message-success {
    background: #e0f2e9;
    color: #27ae60;
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 15px;
}

/* ==========================================================================
   Tableaux
   ========================================================================== */

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.table th,
.table td {
    padding: 10px;
    border-bottom: 1px solid #eee;
    text-align: left;
}

.table th {
    background: #f0f4f8;
    color: #0f4c5f;
    font-weight: bold;
}

/* ==========================================================================
   Cartes & Séquences (accueil / cahier)
   ========================================================================== */

.sequence {
    margin-bottom: 15px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.sequence-header {
    background: #f0f4f8;
    padding: 12px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sequence-header:hover {
    background: #e0e9f0;
}

.sequence-content {
    padding: 15px;
    display: block;
}

.sequence-content.collapsed {
    display: none;
}

.sequence-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.toggle-icon,
.toggle-icon-sub {
    font-size: 1.2rem;
    transition: transform 0.2s;
}

.ressources {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.carte-ressource {
    background: #f9fafb;
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #eee;
    transition: box-shadow 0.2s;
}

.carte-ressource:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ==========================================================================
   Sous-accordéons
   ========================================================================== */

.sub-header {
    background: #f5f7fa;
    padding: 8px 15px;
    border-radius: 8px;
    margin-top: 5px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sub-content {
    padding: 10px 0 10px 15px;
}

.sub-content.collapsed {
    display: none;
}

/* ==========================================================================
   Quiz
   ========================================================================== */

.quiz-container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.quiz-question {
    margin-bottom: 20px;
    padding: 15px;
    background: #fafafa;
    border-radius: 10px;
}

.quiz-question.correct {
    border-left: 4px solid #27ae60;
}

.quiz-question.incorrect {
    border-left: 4px solid #e74c3c;
}

.options label {
    display: block;
    margin: 5px 0;
}

.chrono {
    font-size: 1.5rem;
    font-weight: bold;
    color: #e67e22;
    margin-bottom: 20px;
}

.correct-badge { color: #27ae60; }
.incorrect-badge { color: #e74c3c; }

.btn-pdf.disabled {
    background: #ccc;
    cursor: not-allowed;
    color: #666;
}

/* ==========================================================================
   Chat
   ========================================================================== */

.chat-container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    padding: 16px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.chat-messages {
    height: 50vh;
    min-height: 300px;
    overflow-y: auto;
    background: #fef9e8;
    border-radius: 15px;
    padding: 12px;
    margin-bottom: 20px;
}

/* ==========================================================================
   Dashboard / Stats
   ========================================================================== */

.admin-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.stat-item {
    background: white;
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #0f4c5f;
}

.stat-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

/* ==========================================================================
   Utilitaires
   ========================================================================== */

.btn-admin {
    display: inline-block;
    background: #0f4c5f;
    color: white;
    padding: 8px 16px;
    border-radius: 25px;
    font-size: 0.9rem;
}

.btn-admin:hover {
    background: #0a3a4a;
    text-decoration: none;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 600px) {
    .form-inline {
        flex-direction: column;
    }
    .stat-grid {
        grid-template-columns: 1fr 1fr;
    }
}


/* ==========================================================================
   Mise en relief du Top 5 (élève)
   ========================================================================== */
.top5 {
    background: #f0f4f8;
    border: 1px solid #d0d9e0;
    border-radius: 12px;
    padding: 12px 15px;
    margin-top: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.top5 strong {
    display: block;
    margin-bottom: 8px;
    font-size: 1rem;
    color: #0f4c5f;
}

.top5 ul {
    list-style: none;
    padding: 0;
    margin: 0 0 10px 0;
}

.top5 ul li {
    padding: 4px 0;
    border-bottom: 1px dotted #ccc;
    font-size: 0.95rem;
}

.top5 .info {
    color: #888;
    font-style: italic;
}

.top5 .historique-link {
    display: inline-block;
    font-size: 0.85rem;
    margin-top: 5px;
    color: #0f4c5f;
    text-decoration: underline;
}




/* ==========================================================================
   Toast notifications
   ========================================================================== */
#toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    padding: 14px 20px;
    border-radius: 30px;
    color: #fff;
    font-weight: 500;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
    opacity: 0;
    transform: translateY(20px);
    animation: slideIn 0.3s forwards;
    transition: opacity 0.3s, transform 0.3s;
    max-width: 400px;
    word-wrap: break-word;
    cursor: default;
}
.toast.success { background: #27ae60; }
.toast.error   { background: #c0392b; }
.toast.info    { background: #0f4c5f; }
.toast:hover { opacity: 1; }
.toast.removing { animation: slideOut 0.3s forwards; }
@keyframes slideIn {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideOut {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(20px); }
}



/* ==========================================================================
   Styles pour la gestion professeur (compléments)
   ========================================================================== */

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

.resource-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 10px;
    margin-bottom: 5px;
    transition: box-shadow 0.2s;
}

.resource-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.resource-title {
    font-weight: bold;
    margin-right: 10px;
}

.resource-url {
    color: #888;
    font-size: 0.9rem;
    word-break: break-all;
}

.quiz-info {
    flex: 1;
}

.quiz-desc {
    color: #666;
    font-size: 0.9rem;
}

.niveau-badge {
    display: inline-block;
    background: #e8f5e9;
    color: #27ae60;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-left: 8px;
}

.actions {
    display: flex;
    gap: 5px;
    white-space: nowrap;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    transition: transform 0.1s;
}

.btn-icon:hover {
    transform: scale(1.2);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.85rem;
}

.sequence-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sortable-container {
    min-height: 20px;
}

/* ==========================================================================
   Correctifs pour la gestion (séquences admin)
   ========================================================================== */
.sequence-block {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    margin-bottom: 15px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
}

.sequence-header-clickable {
    background: #f0f4f8;
    padding: 12px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sequence-header-clickable:hover {
    background: #e0e9f0;
}