/* Main CSS - V2 Updates */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-color: #0a0a0a;
    --text-color: #ffffff;
    --text-muted: #a0a0a0;
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.1);
    --card-hover-border: rgba(102, 126, 234, 0.5);
    --success-color: #4cd964;
    --warning-color: #ff9500;
    --error-color: #ff3b30;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    overflow-x: hidden;
    min-height: 100vh;
}

/* Starfield Background */
.starfield {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: twinkle linear infinite;
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

.shooting-star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 10px 2px rgba(255, 255, 255, 0.8);
    animation: shoot 3s linear infinite;
}

@keyframes shoot {
    0% {
        transform: translateX(0) translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateX(-300px) translateY(300px);
        opacity: 0;
    }
}

/* Base Styles */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    padding-top: 40px;
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 10px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.2rem;
}

/* Navigation */
.nav-menu {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.nav-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-color);
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.nav-btn:hover,
.nav-btn.active {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
}

.nav-btn.active {
    background: var(--primary-gradient);
    border: none;
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

/* App Content Area */
#app-content {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
}

/* Auth Forms */
.auth-wrapper {
    max-width: 400px;
    width: 100%;
}

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

.input-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.auth-input {
    width: 100%;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    color: white;
    font-size: 1rem;
}

.auth-input:focus {
    outline: none;
    border-color: #667eea;
}

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    width: 100%;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #667eea;
    margin: 10px 0;
}

.progress-bar-container {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    margin-top: 10px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary-gradient);
    width: 0%;
    transition: width 1s ease;
}

/* Selection Grids (Themes/Series) */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    width: 100%;
}

.selection-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.selection-card:hover {
    transform: translateY(-5px);
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

/* Cards (Standard) */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 800px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
}

/* Flashcards */
.flashcard-mode-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.flashcard-container {
    perspective: 1000px;
    width: 100%;
    max-width: 600px;
    height: 400px;
    cursor: pointer;
}

.flashcard {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s;
    transform-style: preserve-3d;
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
    border-radius: 20px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.flashcard-front {
    background: linear-gradient(145deg, rgba(30, 30, 40, 0.9), rgba(20, 20, 30, 0.9));
}

.flashcard-back {
    background: linear-gradient(145deg, rgba(40, 30, 50, 0.9), rgba(30, 20, 40, 0.9));
    transform: rotateY(180deg);
}

.flashcard-category {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.flashcard-text {
    font-size: 1.5rem;
    font-weight: 500;
    line-height: 1.6;
}

.flashcard-hint {
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
}

.controls {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    width: 100%;
    max-width: 600px;
}

.control-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.3s;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Quiz/Exam Styles */
.question-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--card-border);
}

.question-text {
    font-size: 1.3rem;
    margin-bottom: 30px;
    line-height: 1.6;
}

.options-grid {
    display: grid;
    gap: 15px;
}

.option-btn {
    text-align: left;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}

.option-btn:hover:not(:disabled) {
    background: rgba(102, 126, 234, 0.1);
    border-color: #667eea;
}

.option-btn.selected {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.2);
}

.option-btn.correct {
    border-color: var(--success-color);
    background: rgba(76, 217, 100, 0.2);
}

.option-btn.incorrect {
    border-color: var(--error-color);
    background: rgba(255, 59, 48, 0.2);
}

.feedback-area {
    margin-top: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    display: none;
}

.feedback-area.show {
    display: block;
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.action-btn {
    margin-top: 20px;
    padding: 15px 30px;
    background: var(--primary-gradient);
    border: none;
    border-radius: 50px;
    color: white;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    width: auto;
    transition: transform 0.2s;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.results-summary {
    text-align: center;
}

.score-display {
    font-size: 4rem;
    font-weight: 800;
    margin: 30px 0;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.lang-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 5px 15px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.8rem;
}

/* Timer */
.timer-display {
    font-family: monospace;
    font-size: 1.5rem;
    padding: 5px 15px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
}

.timer-warning {
    color: var(--warning-color);
    border-color: var(--warning-color);
}

.timer-critical {
    color: var(--error-color);
    border-color: var(--error-color);
    animation: pulse-red 1s infinite;
}

@keyframes pulse-red {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

/* Popup */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.popup-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.popup-content {
    background: #1a1a2e;
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.popup-overlay.active .popup-content {
    transform: scale(1);
}

#popupTitle {
    font-size: 2rem;
    margin-bottom: 20px;
    color: #667eea;
}

#popupMessage {
    font-size: 1.2rem;
    margin-bottom: 30px;
    color: var(--text-color);
}


/* Admin Table Styles */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
}

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

.data-table th {
    background: rgba(102, 126, 234, 0.2);
    font-weight: 600;
}

.data-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    .data-table {
        display: block;
        overflow-x: auto;
    }

    .nav-menu {
        gap: 10px;
    }

    .nav-btn {
        padding: 10px 15px;
        font-size: 0.9rem;
    }

    .card {
        padding: 20px;
    }

    .flashcard-container {
        height: 500px;
    }
}

/* Definitions & Glossaire */
.definitions-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding-bottom: 50px;
}

.definitions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.definition-tabs {
    display: flex;
    gap: 10px;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn.active {
    background: var(--primary-gradient);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.glossary-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.glossary-cat {
    margin: 30px 0 15px;
    color: #667eea;
    font-size: 1.4rem;
    border-bottom: 2px solid rgba(102, 126, 234, 0.3);
    padding-bottom: 5px;
}

.glossary-item {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 20px;
    transition: transform 0.2s;
}

.glossary-item:hover {
    transform: translateX(5px);
    border-color: var(--card-hover-border);
}

.glossary-term {
    font-weight: 700;
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: #ffffff;
}

.glossary-def {
    color: var(--text-muted);
    line-height: 1.6;
}

/* Schemas */
.schemas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 30px;
    width: 100%;
}

.schema-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    overflow: hidden;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
}

.schema-card:hover {
    transform: translateY(-5px);
    border-color: var(--card-hover-border);
}

.schema-img-wrapper {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.schema-img-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.schema-info {
    padding: 20px;
    flex: 1;
}

.schema-info h4 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: #667eea;
}

.schema-info p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .definitions-header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }

    .schemas-grid {
        grid-template-columns: 1fr;
    }
}

/* Image Viewer Overlay */
.image-viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    cursor: pointer;
    animation: fadeIn 0.3s ease;
}

.image-viewer-content {
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

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

.image-viewer-content img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border: 2px solid var(--card-border);
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(102, 126, 234, 0.3);
}

.close-viewer {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
}

.viewer-hint {
    color: var(--text-muted);
    font-style: italic;
}

.schema-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 20px;
    text-align: center;
}