/* ==========================================================================
   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;
}

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

/* ==========================================================================
   Header modernisé
   ========================================================================== */
.site-header {
    background: #0f4c5f;
    color: white;
    padding: 10px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.header-top-row {
    text-align: center;
}

.site-title {
    font-size: 1.5rem;
    margin: 0;
}

.header-bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left,
.header-center,
.header-right {
    position: relative;
}

.icon-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: rgba(255,255,255,0.3);
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 50px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
    min-width: 200px;
    z-index: 1000;
    overflow: hidden;
}

.dropdown-menu.show {
    display: block;
}

.header-left .dropdown-menu {
    left: 0;
}

.header-center .dropdown-menu {
    left: 50%;
    transform: translateX(-50%);
}

.header-right .dropdown-menu {
    right: 0;
}

.dropdown-menu a,
.dropdown-menu .dropdown-header {
    display: block;
    padding: 12px 20px;
    color: #333;
    text-decoration: none;
    font-size: 1rem;
    transition: background 0.2s;
}

.dropdown-menu a:hover {
    background: #f0f4f8;
}

.dropdown-header {
    font-weight: bold;
    color: #0f4c5f;
    border-bottom: 1px solid #eee;
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 1rem;
    color: #333;
}

.dropdown-item:hover {
    background: #f0f4f8;
}

.dropdown-item input[type="radio"] {
    margin-right: 10px;
}

/* ==========================================================================
   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;
}

/* 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;
}

.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;
}

/* ==========================================================================
   Boutons – styles de base communs à tous les boutons et liens-boutons
   ========================================================================== */

button[type="submit"],
button.btn-admin,
button.btn-valider,
button.btn-rejeter,
button.envoyer,
button.btn-pdf,
a.btn-pdf,
button.btn-danger,
a.btn-danger,
button.btn-success {
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 40px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1rem;
    text-decoration: none;
    display: inline-block;
    transition: background 0.2s, transform 0.1s;
}

/* Couleurs spécifiques */

/* Orange (par défaut pour submit, envoyer, etc.) */
button[type="submit"],
button.btn-admin,
button.btn-valider,
button.btn-rejeter,
button.envoyer {
    background-color: #e67e22;
}
button[type="submit"]:hover,
button.btn-admin:hover,
button.btn-valider:hover,
button.envoyer:hover {
    background-color: #b45f1b;
}

/* Rouge (danger) */
button.btn-danger,
a.btn-danger {
    background-color: #c0392b;
}
button.btn-danger:hover,
a.btn-danger:hover {
    background-color: #a93226;
}

/* Vert (succès) */
button.btn-success {
    background-color: #27ae60;
}
button.btn-success:hover {
    background-color: #219a52;
}

/* Bouton admin (lien) – bleu */
.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;
}

/* Bouton PDF (quiz) */
a.btn-pdf {
    background-color: #0f4c5f;
}
a.btn-pdf:hover {
    background-color: #0a3a4a;
}
a.btn-pdf.btn-continue {
    background-color: #c0392b;
}
a.btn-pdf.btn-continue:hover {
    background-color: #a93226;
}

/* Bouton vert (réfaire activité) */
a.btn-pdf.btn-success {
    background-color: #27ae60 !important;
    color: white !important;
}
a.btn-pdf.btn-success:hover {
    background-color: #219a52 !important;
}

/* Bouton PDF désactivé */
.btn-pdf.disabled {
    background: #ccc;
    cursor: not-allowed;
    color: #666;
    border-radius: 40px;
    padding: 10px 20px;
    display: inline-block;
}

/* Bouton taille réduite */
.btn-sm {
    padding: 4px 10px;
    font-size: 0.85rem;
}

/* Bouton icône (transparent) */
.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);
}

/* Boutons flottants */
.floating-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #e67e22;
    color: white;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.floating-btn-secondary {
    bottom: 30px;
    right: 100px;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    background: #0f4c5f;
}

/* ==========================================================================
   Messages et notifications
   ========================================================================== */

.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;
}

/* 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); }
}

/* ==========================================================================
   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;
}

/* ==========================================================================
   Séquences et cartes (accueil, cahier, gestion)
   ========================================================================== */

.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-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;
}

.sequence-content {
    padding: 15px;
    display: block;
    background: #fafbfc;
}
.sequence-content.collapsed {
    display: none;
}

.sequence-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}
.sequence-stats {
    font-size: 0.9rem;
    color: #888;
    margin-left: auto;
}

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

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

.carte-ressource {
    background: #f4f7fc;
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #dce3ec;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    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; }

/* ==========================================================================
   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;
}

/* ==========================================================================
   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);
}

/* ==========================================================================
   Gestion professeur (ressources, quiz)
   ========================================================================== */

.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;
}
.actions {
    display: flex;
    gap: 5px;
    white-space: nowrap;
}
.sequence-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.sortable-container {
    min-height: 20px;
}

/* ==========================================================================
   Badges (niveau, matière)
   ========================================================================== */

.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;
}
.matiere-badge {
    display: inline-block;
    background: #ede7f6;
    color: #5e35b1;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-left: 8px;
}
.matiere-heading {
    font-size: 1.4rem;
    color: #0f4c5f;
    margin: 25px 0 15px 0;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 5px;
}

/* ==========================================================================
   Vidéos YouTube (responsive)
   ========================================================================== */

.video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: 10px;
    margin-bottom: 10px;
}
.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    border: none;
}
.video-link {
    display: inline-block;
    margin-top: 5px;
    font-size: 0.9rem;
    color: #e67e22;
}

/* ==========================================================================
   Auth containers
   ========================================================================== */

.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%;
}

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

@media (max-width: 600px) {
    .form-inline {
        flex-direction: column;
    }
    .stat-grid {
        grid-template-columns: 1fr 1fr;
    }
    .header-center .dropdown-menu {
        left: 0;
        transform: none;
    }
}


/* ==========================================================================
   Activité – carte élément
   ========================================================================== */
.element-card {
    background: #ffffff;
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid #e0e4e8;
}

.element-card h3 {
    margin-bottom: 10px;
    font-size: 1.1rem;
    color: #0f4c5f;
}

.element-card .chat-area {
    background: #f9fafb;
    border-radius: 10px;
    padding: 10px;
    margin-top: 10px;
}

.element-card .chat-messages {
    background: #fff;
}

.element-card .chat-input {
    margin-top: 10px;
}

@media (max-width: 600px) {
    .element-card {
        padding: 10px;
    }
    .element-card h3 {
        font-size: 1rem;
        flex-wrap: wrap;
    }
}

/* ==========================================================================
   Boutons désactivés (tous les boutons)
   ========================================================================== */
button:disabled,
a.btn-pdf.disabled,
button.btn-danger:disabled,
a.btn-danger:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: auto; /* pour permettre le title ou les infobulles */
}

/* Conserver la couleur d'arrière-plan normale (pas de gris par défaut du navigateur) */
button:disabled {
    background-color: inherit;
    color: inherit;
}

#nav-menu {
    max-height: 80vh;
    overflow-y: auto;
}