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

:root {
    --primary: #4A90E2;
    --primary-dark: #357ABD;
    --secondary: #50E3C2;
    --bg-main: #F5F7FA;
    --bg-card: #FFFFFF;
    --text-dark: #2C3E50;
    --text-light: #7F8C8D;
    --border: #E1E8ED;
    --shadow: rgba(0, 0, 0, 0.1);
    --success: #27AE60;
    --danger: #E74C3C;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-main);
    color: var(--text-dark);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1.5rem 0;
    margin-bottom: 2rem;
}

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

.logo {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--primary);
}

nav {
    display: flex;
    gap: 1rem;
}

.nav-btn {
    background: none;
    border: none;
    padding: 0.5rem 1.5rem;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-light);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background: var(--bg-main);
    color: var(--text-dark);
}

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

/* Sections */
.section {
    display: none;
}

.section.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

h2 {
    font-size: 2rem;
    color: var(--text-dark);
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--bg-main);
    color: var(--text-dark);
}

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

/* Subjects Grid */
.subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.subject-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow);
    transition: transform 0.3s ease;
    cursor: pointer;
    position: relative;
    border-left: 4px solid var(--primary);
}

.subject-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px var(--shadow);
}

.subject-card h3 {
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.subject-card p {
    color: var(--text-light);
    font-size: 0.9rem;
}

.subject-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.subject-actions button {
    flex: 1;
    padding: 0.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.add-flashcard-btn {
    background: var(--secondary);
    color: var(--text-dark);
}

.add-flashcard-btn:hover {
    background: #3DD4AF;
}

.delete-subject-btn {
    background: var(--danger);
    color: white;
}

.delete-subject-btn:hover {
    background: #C0392B;
}

/* Flashcards */
.flashcard-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

.flashcard-empty {
    text-align: center;
    color: var(--text-light);
}

.flashcard {
    width: 100%;
    max-width: 600px;
    height: 350px;
    perspective: 1000px;
}

.flashcard-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

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

.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    text-align: center;
}

.flashcard-back {
    transform: rotateY(180deg);
    background: var(--primary);
    color: white;
}

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

.flashcard-controls {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    justify-content: center;
}

.flashcard-controls button {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.flip-btn {
    background: var(--secondary);
    color: var(--text-dark);
}

.flip-btn:hover {
    background: #3DD4AF;
}

.next-btn {
    background: var(--primary);
    color: white;
}

.next-btn:hover {
    background: var(--primary-dark);
}

/* Progress */
.progress-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 2px 8px var(--shadow);
}

.stat-card h3 {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.stat-card p {
    color: var(--text-light);
    font-size: 1rem;
}

.progress-details {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 8px var(--shadow);
}

.progress-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.progress-item:last-child {
    border-bottom: none;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 2rem;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 20px var(--shadow);
}

.modal-content h3 {
    margin-bottom: 1.5rem;
    color: var(--text-dark);
}

.modal-content input,
.modal-content textarea,
.modal-content select {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
}

.modal-content input:focus,
.modal-content textarea:focus,
.modal-content select:focus {
    outline: none;
    border-color: var(--primary);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.subject-select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
    header .container {
        flex-direction: column;
        gap: 1rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

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

    .flashcard {
        max-width: 100%;
        height: 300px;
    }

    .flashcard-text {
        font-size: 1.2rem;
    }
}
