/* Reset et base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #1cb0f6;
    --primary-dark: #1899d6;
    --secondary-color: #58cc02;
    --danger-color: #ff4b4b;
    --warning-color: #ffc800;
    --bg-color: #f7f7f7;
    --card-bg: #ffffff;
    --text-dark: #3c3c3c;
    --text-light: #777777;
    --border-color: #e5e5e5;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* Mode sombre */
[data-theme="dark"] {
    --primary-color: #1cb0f6;
    --primary-dark: #1899d6;
    --secondary-color: #58cc02;
    --danger-color: #ff4b4b;
    --warning-color: #ffc800;
    --bg-color: #1a1a1a;
    --card-bg: #2d2d2d;
    --text-dark: #e0e0e0;
    --text-light: #a0a0a0;
    --border-color: #404040;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
}

body {
    font-family: 'Nunito', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-dark);
    overflow-x: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* Écran de chargement */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.loading-screen.active {
    opacity: 1;
    pointer-events: all;
}

.loader {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-screen p {
    color: white;
    margin-top: 20px;
    font-size: 18px;
    font-weight: 600;
}

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

/* Gestion des écrans */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: block;
}

body {
    overflow-x: hidden;
}

/* Écran d'authentification */
#auth-screen {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-container {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 40px;
    max-width: 450px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h1 {
    font-size: 36px;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.tagline {
    color: var(--text-light);
    font-size: 16px;
}

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

.auth-content h2 {
    font-size: 24px;
    margin-bottom: 15px;
    color: var(--text-dark);
}

.auth-description {
    color: var(--text-light);
    margin-bottom: 30px;
    line-height: 1.6;
}

.btn-google {
    width: 100%;
    padding: 15px;
    background: white;
    color: var(--text-dark);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Nunito', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-google:hover {
    background: var(--bg-color);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.btn-google:active {
    transform: translateY(0);
}

.auth-error {
    color: var(--danger-color);
    font-size: 14px;
    margin-top: 10px;
    min-height: 20px;
}

/* Boutons */
.btn-primary {
    width: 100%;
    padding: 15px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Nunito', sans-serif;
}

.btn-primary:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    padding: 12px 24px;
    background: white;
    color: var(--text-dark);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Nunito', sans-serif;
}

.btn-secondary:hover {
    background: var(--bg-color);
}

/* Header principal */
.main-header {
    background: white;
    padding: 15px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left h1 {
    font-size: 24px;
    color: var(--primary-color);
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.streak-counter {
    background: linear-gradient(135deg, #ff9a56, #ff6b6b);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 18px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-stats {
    display: flex;
    gap: 15px;
    align-items: center;
}

.xp-display, .level-display {
    background: var(--bg-color);
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: 700;
    color: var(--text-dark);
}

.hearts-display {
    background: #ffe6e6;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: 700;
    color: var(--danger-color);
}

[data-theme="dark"] .hearts-display {
    background: #4a1f1f;
}

.xp-display {
    color: var(--warning-color);
}

.theme-toggle {
    margin: 0 15px;
}

.lang-toggle {
    margin: 0 5px;
}

.lang-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Nunito', sans-serif;
}

.lang-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow);
}

.lang-btn:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(28,176,246,0.12);
    transform: scale(1.05);
}

.lang-btn.active,
.lang-btn:active {
    border-color: var(--primary-color);
    background: linear-gradient(180deg, rgba(28,176,246,0.08), rgba(24,153,214,0.04));
    color: var(--primary-color);
}

.theme-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s;
}

.theme-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow);
}

.user-menu {
    position: relative;
}

.user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--primary-color);
    border: none;
    font-size: 24px;
    cursor: pointer;
    transition: transform 0.3s;
}

.user-avatar:hover {
    transform: scale(1.1);
}

.dropdown-menu {
    position: absolute;
    top: 55px;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 15px;
    min-width: 200px;
    display: none;
}

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

.user-info {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.user-info p {
    margin: 5px 0;
}

.user-info p:first-child {
    font-weight: 700;
}

.user-info p:last-child {
    font-size: 14px;
    color: var(--text-light);
}

#logout-btn {
    width: 100%;
    padding: 10px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
}

/* Navigation des modules */
.modules-nav {
    background: white;
    padding: 20px 0;
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.nav-wrapper {
    display: flex;
    gap: 15px;
    padding: 0 30px;
    min-width: max-content;
}

.module-btn {
    padding: 12px 24px;
    background: var(--bg-color);
    border: 3px solid transparent;
    border-radius: 15px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    font-family: 'Nunito', sans-serif;
}

.module-btn:hover {
    background: #ececec;
}

.module-btn.active {
    background: white;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Conteneur des niveaux */
.levels-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 40px 20px;
}

.progress-bar-container {
    margin-bottom: 40px;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #e5e5e5;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary-color), #a5dd00);
    border-radius: 10px;
    transition: width 0.5s ease;
    width: 0%;
}

.progress-text {
    font-weight: 700;
    color: var(--text-light);
}

/* Chemin des niveaux */
.levels-path {
    position: relative;
}

.level-node {
    margin: 40px 0;
    display: flex;
    justify-content: center;
    position: relative;
}

.level-node:nth-child(even) {
    justify-content: flex-start;
    margin-left: 20%;
}

.level-node:nth-child(odd) {
    justify-content: flex-end;
    margin-right: 20%;
}

.level-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid #e5e5e5;
    background: white;
    font-size: 32px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.level-btn:hover {
    transform: scale(1.1);
}

.level-btn.completed {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
}

.level-btn.current {
    border-color: var(--primary-color);
    animation: pulse 2s infinite;
}

.level-btn.locked {
    background: #d7d7d7;
    border-color: #c7c7c7;
    cursor: not-allowed;
    filter: grayscale(1);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(28, 176, 246, 0.7);
    }
    50% {
        box-shadow: 0 0 0 15px rgba(28, 176, 246, 0);
    }
}

.level-info {
    position: absolute;
    bottom: -30px;
    text-align: center;
    width: 100px;
    left: 50%;
    transform: translateX(-50%);
}

.level-info p {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
    margin-top: 5px;
}

/* Écran de challenge */
.challenge-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.challenge-header {
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.back-btn {
    padding: 10px 20px;
    background: var(--bg-color);
    border: none;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    font-size: 16px;
}

.back-btn:hover {
    background: #e5e5e5;
}

.challenge-info {
    flex: 1;
    margin: 0 20px;
}

.challenge-info h2 {
    font-size: 24px;
    margin-bottom: 5px;
}

.challenge-meta {
    display: flex;
    align-items: center;
    gap: 15px;
}

.challenge-difficulty {
    display: inline-block;
    padding: 5px 15px;
    background: var(--secondary-color);
    color: white;
    border-radius: 15px;
    font-size: 14px;
    font-weight: 700;
}

.challenge-timer {
    display: inline-flex;
    align-items: center;
    padding: 5px 15px;
    background: var(--warning-color);
    color: white;
    border-radius: 15px;
    font-size: 14px;
    font-weight: 700;
    gap: 5px;
}

.challenge-timer.danger {
    background: var(--danger-color);
    animation: pulse-timer 1s infinite;
}

@keyframes pulse-timer {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.challenge-difficulty.medium {
    background: var(--warning-color);
}

.challenge-difficulty.hard {
    background: var(--danger-color);
}

.xp-reward {
    background: var(--warning-color);
    color: white;
    padding: 8px 15px;
    border-radius: 15px;
    font-weight: 700;
}

.challenge-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: var(--shadow);
}

.challenge-description {
    margin-bottom: 30px;
}

.challenge-description h3 {
    font-size: 20px;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.challenge-description p {
    line-height: 1.6;
    color: var(--text-dark);
}

.challenge-hint {
    margin-bottom: 30px;
}

.hint-btn {
    padding: 10px 20px;
    background: var(--warning-color);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
}

.hint-text {
    margin-top: 15px;
    padding: 15px;
    background: #fff9e6;
    border-left: 4px solid var(--warning-color);
    border-radius: 8px;
    display: none;
}

.hint-text.visible {
    display: block;
}

.challenge-interface {
    margin-bottom: 30px;
}

/* Types d'interfaces de challenge */
.input-challenge input,
.input-challenge textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    font-family: 'Courier New', monospace;
    margin-bottom: 15px;
}

.input-challenge textarea {
    min-height: 100px;
    resize: vertical;
}

.mcq-challenge {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.mcq-option {
    padding: 15px;
    background: var(--bg-color);
    border: 3px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.mcq-option:hover {
    background: #e5e5e5;
}

.mcq-option.selected {
    background: white;
    border-color: var(--primary-color);
}

.code-challenge {
    background: #1e1e1e;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 15px;
}

.code-challenge pre {
    color: #d4d4d4;
    font-family: 'Courier New', monospace;
    overflow-x: auto;
}

.terminal-challenge {
    background: #000;
    color: #00ff00;
    padding: 20px;
    border-radius: 12px;
    font-family: 'Courier New', monospace;
    margin-bottom: 15px;
}

.terminal-output {
    margin-bottom: 10px;
    white-space: pre-wrap;
}

.terminal-input {
    display: flex;
    align-items: center;
}

.terminal-input::before {
    content: '$ ';
    color: #00ff00;
}

.terminal-input input {
    flex: 1;
    background: transparent;
    border: none;
    color: #00ff00;
    font-family: 'Courier New', monospace;
    outline: none;
}

.challenge-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

.challenge-feedback {
    margin-top: 20px;
    padding: 15px;
    border-radius: 12px;
    display: none;
}

.challenge-feedback.visible {
    display: block;
}

.challenge-feedback.success {
    background: #e6f9e6;
    border-left: 4px solid var(--secondary-color);
}

.challenge-feedback.error {
    background: #ffe6e6;
    border-left: 4px solid var(--danger-color);
}

/* Modales */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.success-animation,
.failure-animation {
    font-size: 80px;
    margin-bottom: 20px;
    animation: bounce 0.6s;
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.modal-content h2 {
    font-size: 28px;
    margin-bottom: 15px;
}

.modal-content p {
    font-size: 16px;
    color: var(--text-light);
    margin-bottom: 25px;
}

.rewards-earned {
    margin: 25px 0;
    display: flex;
    justify-content: center;
    gap: 20px;
}

.reward-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.reward-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.reward-value {
    font-weight: 700;
    font-size: 18px;
    color: var(--warning-color);
}

.countdown-text {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    margin: 20px 0;
}

.hint-message {
    font-size: 14px;
    color: var(--text-light);
    margin-top: 10px;
}

/* Responsive */
@media (max-width: 768px) {
    .main-header {
        padding: 10px 15px;
        flex-wrap: wrap;
    }

    .header-center {
        order: 3;
        flex-basis: 100%;
        margin-top: 10px;
    }

    .user-stats {
        flex-direction: column;
        gap: 5px;
    }

    .auth-container {
        padding: 20px;
    }

    .challenge-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .challenge-info {
        margin: 0;
    }

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

    .challenge-actions button {
        width: 100%;
    }

    .level-node:nth-child(even),
    .level-node:nth-child(odd) {
        justify-content: center;
        margin-left: 0;
        margin-right: 0;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.level-node {
    animation: fadeIn 0.5s ease-out;
}

/* Scrollbar personnalisée */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 5px;
}

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