:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --correct-color: #28a745;
    --wrong-color: #dc3545;
    --unseen-color: #ffc107;
    --background-color: #f8f9fa;
    --border-color: #e9ecef;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: #343a40;
}

header {
    background-color: var(--primary-color);
    color: white;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#app-container {
    display: flex;
    max-width: 1400px;
    margin: 20px auto;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
}

/* --- Sidebar Styling --- */
#sidebar {
    width: 300px;
    padding: 20px;
    background-color: white;
    border-right: 1px solid var(--border-color);
}

#file-upload-section, #playlist-summary {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.status-message {
    font-size: 0.9em;
    font-style: italic;
    margin-top: 5px;
}

.summary-box p {
    margin: 5px 0;
    font-weight: bold;
}

#shuffle-playlist-btn {
    width: 100%;
    padding: 10px;
    background-color: var(--correct-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

#shuffle-playlist-btn:not(:disabled):hover {
    background-color: #218838;
}

#shuffle-playlist-btn:disabled {
    background-color: var(--secondary-color);
    cursor: not-allowed;
}

/* Chapter Tree */
#chapter-tree {
    max-height: 50vh;
    overflow-y: auto;
}

.subject-header {
    font-size: 1.1em;
    font-weight: bold;
    margin-top: 15px;
    color: var(--primary-color);
    cursor: pointer;
}

.chapter-list {
    list-style: none;
    padding-left: 10px;
    margin: 5px 0;
}

.chapter-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    font-size: 0.95em;
}

.chapter-item label {
    flex-grow: 1;
    cursor: pointer;
}

.chapter-item input[type="checkbox"] {
    margin-right: 8px;
}

.progress-counter {
    font-weight: bold;
    font-size: 0.8em;
    color: var(--secondary-color);
}

/* --- Main Content Styling --- */
#main-content {
    flex-grow: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Flashcard Area */
#flashcard-container {
    width: 100%;
    max-width: 800px;
    perspective: 1000px; /* For 3D flip effect */
    margin-bottom: 20px;
}

#flashcard {
    position: relative;
    width: 100%;
    height: 400px;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    background: white;
}

.flashcard-disabled {
    cursor: not-allowed !important;
    opacity: 0.6;
}

#flashcard.flipped {
    transform: rotateY(180deg);
}

.flipper {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

.front, .back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
    box-sizing: border-box;
    border-radius: 10px;
}

.front {
    background-color: #fff;
    color: #333;
    z-index: 2;
}

.back {
    background-color: var(--primary-color);
    color: white;
    transform: rotateY(180deg);
}

.card-origin {
    position: absolute;
    top: 10px;
    left: 15px;
    font-size: 0.8em;
    font-style: italic;
    opacity: 0.7;
}

.back .card-origin {
    color: rgba(255, 255, 255, 0.7);
}

#card-question, #card-answer {
    font-size: 1.5em;
    margin: 10px 0;
}

.click-to-flip {
    position: absolute;
    bottom: 10px;
    font-size: 0.75em;
    opacity: 0.5;
}

/* Navigation & Grading */
#navigation-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    width: 100%;
    max-width: 800px;
    margin-bottom: 20px;
}

#navigation-controls button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.2s, opacity 0.2s;
}

#navigation-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#prev-btn, #next-btn {
    background-color: var(--secondary-color);
    color: white;
}

#prev-btn:not(:disabled):hover, #next-btn:not(:disabled):hover {
    background-color: #5a6268;
}

#grading-controls {
    display: flex;
    gap: 10px;
}

.correct-btn {
    background-color: var(--correct-color);
    color: white;
}

.correct-btn:not(:disabled):hover {
    background-color: #218838;
}

.wrong-btn {
    background-color: var(--wrong-color);
    color: white;
}

.wrong-btn:not(:disabled):hover {
    background-color: #c82333;
}

/* Question Navigator */
#question-navigator {
    width: 100%;
    max-width: 800px;
    text-align: center;
}

#navigator-tiles {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
    padding: 10px 0;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background-color: #fff;
}

.nav-tile {
    width: 20px;
    height: 20px;
    border-radius: 50%; /* Circle shape */
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.nav-tile:hover {
    transform: scale(1.2);
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

/* Status colors */
.status-unseen {
    background-color: var(--unseen-color);
}

.status-correct {
    background-color: var(--correct-color);
}

.status-wrong {
    background-color: var(--wrong-color);
}

.nav-tile.active {
    border: 3px solid var(--primary-color);
    transform: scale(1.3);
}

/* Responsive Adjustments */
@media (max-width: 900px) {
    #app-container {
        flex-direction: column;
    }

    #sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    #chapter-tree {
        max-height: 40vh; /* Shorter on mobile */
    }
}