/* ========== Bouton Mon Compte ========== */
.account-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 25px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s, transform 0.2s;
    z-index: 10;
}

.account-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-1px);
}

.account-btn .account-icon {
    font-size: 1.1rem;
}

/* ========== Boutons verrouilles ========== */
.menu-btn.locked {
    opacity: 0.55;
    cursor: not-allowed;
    position: relative;
    filter: grayscale(30%);
}

.menu-btn.locked::after {
    content: '\1F512';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.3rem;
}

.menu-btn.locked:hover {
    transform: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

/* ========== Modal Auth ========== */
.auth-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-overlay.visible {
    display: flex;
}

.auth-modal {
    background: white;
    border-radius: 20px;
    width: 100%;
    max-width: 380px;
    color: #333;
    overflow: hidden;
    animation: authFadeIn 0.3s ease;
}

.auth-modal--wide {
    max-width: 520px;
}

@keyframes authFadeIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-modal-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.auth-modal-close {
    background: rgba(255,255,255,0.25);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-modal-body {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

/* ========== Formulaire ========== */
.auth-form-group {
    margin-bottom: 14px;
}

.auth-form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 5px;
}

.auth-form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s;
    outline: none;
}

.auth-form-group input:focus {
    border-color: #667eea;
}

.auth-submit {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
    margin-top: 6px;
}

.auth-submit:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.auth-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.auth-switch {
    text-align: center;
    margin-top: 14px;
    font-size: 0.85rem;
    color: #777;
}

.auth-switch a {
    color: #667eea;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

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

.auth-error {
    background: #ffebee;
    color: #c62828;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    margin-bottom: 12px;
    display: none;
}

.auth-error.visible {
    display: block;
}

.auth-success {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    margin-bottom: 12px;
    display: none;
}

.auth-success.visible {
    display: block;
}

/* ========== Profil (connecte) ========== */
.auth-profile {
    text-align: center;
    padding: 10px 0;
}

.auth-profile-avatar {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: white;
    margin: 0 auto 12px;
}

.auth-profile-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 4px;
}

.auth-profile-role {
    font-size: 0.8rem;
    color: #999;
    margin-bottom: 20px;
}

.auth-logout-btn {
    padding: 10px 30px;
    background: #ef5350;
    color: white;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.auth-logout-btn:hover {
    opacity: 0.85;
}

/* ========== Type Chooser (Enseignant / Parent) ========== */
.auth-type-chooser {
    display: flex;
    gap: 12px;
    margin: 10px 0;
}

.auth-type-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 16px;
    background: #fafafa;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.auth-type-btn:hover {
    border-color: #667eea;
    background: #f0f0ff;
    transform: translateY(-2px);
}

.auth-type-btn .type-icon {
    font-size: 2rem;
}

.auth-type-btn .type-label {
    font-size: 0.95rem;
    font-weight: 700;
    color: #333;
}

.auth-type-btn .type-desc {
    font-size: 0.75rem;
    color: #888;
    text-align: center;
}

/* ========== Dashboard Tabs (enseignant) ========== */
.auth-tabs {
    display: flex;
    border-bottom: 2px solid #eee;
    margin-bottom: 16px;
}

.auth-tab {
    flex: 1;
    padding: 10px 8px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: #999;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
    transition: color 0.2s, border-color 0.2s;
}

.auth-tab:hover {
    color: #667eea;
}

.auth-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.auth-tab-content {
    display: none;
}

.auth-tab-content.active {
    display: block;
}

/* ========== Group Cards ========== */
.group-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.group-card {
    padding: 14px;
    border: 2px solid #e8e8e8;
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.group-card:hover {
    border-color: #667eea;
    background: #f8f8ff;
}

.group-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.group-card-name {
    font-size: 1rem;
    font-weight: 700;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    max-width: 200px;
}

.group-card-code {
    font-size: 0.8rem;
    font-weight: 700;
    color: #667eea;
    background: #f0f0ff;
    padding: 3px 8px;
    border-radius: 6px;
    letter-spacing: 1px;
}

.group-card-info {
    font-size: 0.8rem;
    color: #888;
}

.group-create-btn {
    width: 100%;
    padding: 10px;
    border: 2px dashed #ccc;
    border-radius: 12px;
    background: none;
    color: #888;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.group-create-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

/* ========== Member List ========== */
.member-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.member-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

.member-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.member-avatar.compte {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.member-avatar.tablette {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: white;
}

.member-avatar.inactif {
    background: #ddd;
    color: #999;
}

.member-info {
    flex: 1;
    min-width: 0;
}

.member-pseudo {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
}

.member-type {
    font-size: 0.7rem;
    color: #999;
}

.member-stars {
    font-size: 0.75rem;
    flex-shrink: 0;
    color: #ff8f00;
}

/* ========== Invitations ========== */
.invite-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
    padding: 14px;
    background: #f8f9fa;
    border-radius: 12px;
}

.invite-form-row {
    display: flex;
    gap: 8px;
}

.invite-form-row input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
}

.invite-form-row input:focus {
    border-color: #667eea;
}

.invite-send-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.invite-send-btn:hover {
    opacity: 0.9;
}

.invite-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.invitation-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.invitation-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 0.82rem;
}

.invitation-pseudo {
    font-weight: 600;
    color: #333;
}

.invitation-email {
    color: #888;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.invitation-status {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    flex-shrink: 0;
}

.invitation-status.pending {
    background: #fff3e0;
    color: #e65100;
}

.invitation-status.used {
    background: #e8f5e9;
    color: #2e7d32;
}

/* ========== Session Bar (tablette) ========== */
.session-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px 16px;
    z-index: 50;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    flex-wrap: wrap;
}

.session-bar-pseudo {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 40%;
}

.session-bar.visible {
    display: flex;
}

.session-bar-pseudo {
    display: flex;
    align-items: center;
    gap: 6px;
}

.session-bar-group {
    opacity: 0.85;
    font-weight: 400;
}

.session-bar-leave {
    padding: 4px 12px;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.4);
    color: white;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
}

.session-bar-leave:hover {
    background: rgba(255,255,255,0.35);
}

/* ========== Profil Eleve : infos groupe/prof ========== */
.auth-profile-group {
    background: #f0f0ff;
    padding: 10px 14px;
    border-radius: 10px;
    margin-bottom: 14px;
    text-align: left;
}

.auth-profile-group-label {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 2px;
}

.auth-profile-group-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
}

.auth-profile-teacher {
    background: #f0f0ff;
    padding: 10px 14px;
    border-radius: 10px;
    margin-bottom: 14px;
    text-align: left;
}

/* ========== Back link in dashboard ========== */
.auth-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.82rem;
    color: #667eea;
    cursor: pointer;
    margin-bottom: 12px;
    font-weight: 600;
}

.auth-back:hover {
    text-decoration: underline;
}

/* ========== Empty state ========== */
.auth-empty {
    text-align: center;
    padding: 20px;
    color: #bbb;
    font-size: 0.85rem;
}

/* ========== Bouton Rejoindre (index.html) ========== */
.menu-btn.rejoindre {
    background: linear-gradient(135deg, #43a047 0%, #66bb6a 100%);
    animation-delay: 0.65s;
}

/* Adjust app top padding when session bar is visible */
body.has-session-bar .app {
    padding-top: 56px;
}

/* ========== Join by Code — confirmation step ========== */
.auth-confirm-box {
    background: #e8f5e9;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    margin-bottom: 14px;
}

.auth-confirm-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: #2e7d32;
    margin: 8px 0 4px;
}

.auth-confirm-group {
    font-size: 0.85rem;
    color: #555;
}

/* ========== Student code badge (member list) ========== */
.member-code {
    display: inline-block;
    background: #fff3e0;
    color: #e65100;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    letter-spacing: 1px;
    margin-left: 4px;
    vertical-align: middle;
}

/* ========== Bulk add students — code results ========== */
.student-codes-list {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 12px;
}

.student-code-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
}

.student-code-row:last-child {
    border-bottom: none;
}

.student-code-pseudo {
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
}

.student-code-value {
    font-weight: 800;
    color: #667eea;
    font-size: 1rem;
    letter-spacing: 2px;
    background: #f0f0ff;
    padding: 3px 10px;
    border-radius: 6px;
}

/* ========== Upsell message (exercise victory modal) ========== */
.upsell-box {
    background: linear-gradient(135deg, #fff3e0, #ffe0b2);
    border: 2px solid #ffb74d;
    border-radius: 12px;
    padding: 14px;
    margin-top: 14px;
    text-align: center;
}

.upsell-box p {
    font-size: 0.85rem;
    color: #e65100;
    font-weight: 600;
    margin-bottom: 8px;
}

.upsell-btn {
    padding: 8px 18px;
    background: linear-gradient(135deg, #43a047, #66bb6a);
    color: white;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.upsell-btn:hover {
    opacity: 0.9;
}

/* ========== Admin dashboard ========== */
.admin-banner {
    background: linear-gradient(135deg, #1a237e, #283593);
    color: white;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 14px;
    text-align: center;
}

.admin-viewas-active {
    background: #fff3e0;
    border: 2px solid #ffb74d;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #e65100;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.admin-stop-btn {
    padding: 5px 14px;
    background: #ef5350;
    color: white;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.admin-stop-btn:hover {
    opacity: 0.85;
}

/* ========== View-as list ========== */
.viewas-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
}

.viewas-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #f8f9fa;
    border-radius: 8px;
    transition: background 0.15s;
}

.viewas-row:hover {
    background: #f0f0ff;
}

.viewas-row.active {
    background: #e8f5e9;
    border: 1px solid #66bb6a;
}

.viewas-info {
    flex: 1;
    min-width: 0;
}

.viewas-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: #333;
}

.viewas-detail {
    font-size: 0.72rem;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.viewas-btn {
    padding: 5px 14px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity 0.15s;
}

.viewas-btn:hover {
    opacity: 0.85;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 480px) {
    .auth-modal {
        max-width: 100%;
        border-radius: 16px;
    }

    .auth-modal--wide {
        max-width: 100%;
    }

    .auth-modal-header {
        padding: 12px 16px;
    }

    .auth-modal-header h2 {
        font-size: 1rem;
    }

    .auth-modal-body {
        padding: 14px;
    }

    .auth-type-chooser {
        flex-direction: column;
        gap: 8px;
    }

    .auth-type-btn {
        padding: 14px 12px;
    }

    .auth-tabs {
        gap: 0;
    }

    .auth-tab {
        padding: 8px 4px;
        font-size: 0.75rem;
    }

    .group-card-header {
        flex-wrap: wrap;
        gap: 6px;
    }

    .group-card-name {
        max-width: 160px;
    }

    .session-bar {
        font-size: 0.75rem;
        padding: 6px 12px;
        gap: 8px;
    }

    .invite-form-row {
        flex-direction: column;
    }

    .admin-viewas-active {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    .account-btn {
        top: 10px;
        right: 10px;
        padding: 6px 12px;
        font-size: 0.75rem;
    }
}

@media (max-width: 360px) {
    .auth-modal-body {
        padding: 10px;
    }

    .auth-form-group input {
        padding: 8px 10px;
        font-size: 0.85rem;
    }

    .auth-submit {
        padding: 10px;
        font-size: 0.9rem;
    }

    .member-row {
        padding: 6px 8px;
        gap: 8px;
    }

    .student-code-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}
