/* CSS Variables */
:root {
    --bg-main: #1f2129;
    --bg-card: #23232f;
    --bg-card-hover: #2a2a38;
    --text-primary: rgba(222, 226, 230, 0.75);
    --text-white: #ffffff;
    --text-muted: #b3b3b3;
    --accent-primary: #5e72e4;
    --accent-secondary: #f5365c;
    --accent-success: #2dce89;
    --accent-warning: #fb6340;
    --accent-info: #11cdef;
    --border-color: #3d3d5c;
    --shadow-card: 0 10px 20px rgba(0, 0, 0, 0.2);
    --shadow-card-hover: 0 15px 25px rgba(0, 0, 0, 0.3);
    --radius-card: 15px;
    --radius-btn: 50px;
    --transition-smooth: all 0.3s ease;
}

.study-hero {
    padding: 60px 0 40px;
    text-align: center;
}

.study-hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-white);
    margin-bottom: 1rem;
}

.study-hero p {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

/* Subject Cards Grid */
.subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    padding: 2rem 0;
}

.subject-card {
    background: var(--bg-card);
    border-radius: var(--radius-card);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: var(--transition-smooth);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    display: block;
}

.subject-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-card-hover);
    border-color: var(--accent-primary);
}

.subject-card-header {
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--accent-primary) 0%, #7c3aed 100%);
    position: relative;
    overflow: hidden;
}

.subject-card-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 200%;
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(45deg);
}

.subject-card-header .icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.subject-card-header h3 {
    color: var(--text-white);
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
}

.subject-card-header .grade-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-white);
    margin-top: 0.5rem;
}

.subject-card-body {
    padding: 1.5rem;
}

.subject-card-body p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.subject-stats {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-white);
    display: block;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.subject-card-footer {
    padding: 0 1.5rem 1.5rem;
}

.btn-study {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: transparent;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-btn);
    color: var(--text-primary);
    font-family: "Inter", sans-serif;
    font-size: 1rem;
    font-weight: 600;
    transition: var(--transition-smooth);
    text-decoration: none;
}

.btn-study:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--text-white);
    transform: translateY(-2px);
}

.btn-study i {
    font-size: 1.1rem;
}

/* Category colors */
/* History – deep royal purple */
.subject-card[data-category="history"] .subject-card-header {
    background: linear-gradient(135deg, #3a1c71 0%, #2a0845 100%);
}

/* Science – dark cyan / tech blue */
.subject-card[data-category="science"] .subject-card-header {
    background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
}

/* Maths – dark emerald */
.subject-card[data-category="maths"] .subject-card-header {
    background: linear-gradient(135deg, #134e5e 0%, #071a1f 100%);
}

/* Commerce – dark amber / bronze */
.subject-card[data-category="commerce"] .subject-card-header {
    background: linear-gradient(135deg, #3e2723 0%, #1b0f0a 100%);
}

/* Sinhala – muted violet */
.subject-card[data-category="sinhala-lan"] .subject-card-header {
    background: linear-gradient(135deg, #2b1055 0%, #1a052e 100%);
}

/* ICT – classic dark indigo */
.subject-card[data-category="ict"] .subject-card-header {
    background: linear-gradient(135deg, #1e3c72 0%, #0f2027 100%);
}

/* Arabic Literature – deep plum */
.subject-card[data-category="arabic-lit"] .subject-card-header {
    background: linear-gradient(135deg, #3c1053 0%, #1c0522 100%);
}

/* English – graphite blue */
.subject-card[data-category="english"] .subject-card-header {
    background: linear-gradient(135deg, #232526 0%, #1c1c1c 100%);
}



.study-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Study Header */
.study-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.study-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--bg-card);
    border: none;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1.25rem;
    transition: var(--transition-smooth);
    text-decoration: none;
}

.back-btn:hover {
    background: var(--accent-primary);
    color: var(--text-white);
}

.study-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-white);
    margin: 0;
}

.study-title span {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.study-header-stats {
    display: flex;
    gap: 1.5rem;
}

.header-stat {
    text-align: center;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border-radius: 12px;
}

.header-stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.header-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Progress Bar */
.progress-section {
    background: var(--bg-card);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-card);
    margin-bottom: 1.5rem;
}

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

.progress-text {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.progress-percentage {
    font-weight: 700;
    color: var(--accent-primary);
    font-size: 0.9rem;
}

.progress-bar-container {
    height: 8px;
    background: var(--bg-main);
    border-radius: 100px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary) 0%, #7c3aed 100%);
    border-radius: 100px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Control Buttons */
.controls-row {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.control-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-btn);
    color: var(--text-primary);
    font-family: "Inter", sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.control-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

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

.control-btn i {
    font-size: 1rem;
}

/* Category Pills */
.category-pills {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
    -webkit-overflow-scrolling: touch;
}

.category-pills::-webkit-scrollbar {
    height: 4px;
}

.category-pills::-webkit-scrollbar-track {
    background: var(--bg-card);
    border-radius: 100px;
}

.category-pills::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 100px;
}

.category-pill {
    flex-shrink: 0;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: none;
    border-radius: 100px;
    color: var(--text-muted);
    font-family: "Inter", sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    white-space: nowrap;
}

.category-pill:hover {
    background: var(--accent-primary);
    color: var(--text-white);
}

.category-pill.active {
    background: var(--accent-primary);
    color: var(--text-white);
}


.flashcard-wrapper {
    perspective: 1500px;
    margin-bottom: 2rem;
}

.flashcard {
    width: 100%;
    min-height: 380px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

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

.flashcard.known {
    opacity: 0.5;
    filter: grayscale(0.5);
}

.card-face {
    position: absolute;
    width: 100%;
    min-height: 380px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: var(--radius-card);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-card);
}

.card-front {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.card-back {
    background: linear-gradient(135deg, var(--accent-primary) 0%, #7c3aed 100%);
    transform: rotateY(180deg);
}

.card-category-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.875rem;
    background: rgba(94, 114, 228, 0.15);
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 1.5rem;
    align-self: flex-start;
}

.card-back .card-category-tag {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-white);
}

.card-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.card-back .card-label {
    color: rgba(255, 255, 255, 0.7);
}

.card-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-text {
    font-size: 1.35rem;
    line-height: 1.7;
    text-align: center;
    font-weight: 500;
    color: var(--text-white);
}

.card-back .card-text {
    font-weight: 400;
}

.card-hint {
    margin-top: auto;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.card-back .card-hint {
    color: rgba(255, 255, 255, 0.6);
}

.card-hint kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    font-family: "Inter", sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Navigation */
.card-navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.nav-btn:hover:not(:disabled) {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--text-white);
    transform: scale(1.1);
}

.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.card-counter {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 100px;
    text-align: center;
}

.card-counter .current {
    color: var(--text-white);
    font-size: 1.35rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--radius-btn);
    font-family: "Inter", sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.action-btn i {
    font-size: 1.1rem;
}

.btn-mastered {
    background: rgba(45, 206, 137, 0.15);
    color: var(--accent-success);
}

.btn-mastered:hover {
    background: var(--accent-success);
    color: var(--text-white);
    transform: translateY(-2px);
}

.btn-mastered.marked {
    background: var(--accent-success);
    color: var(--text-white);
}

.btn-reset {
    background: var(--bg-card);
    color: var(--text-muted);
    border: 2px solid var(--border-color);
}

.btn-reset:hover {
    border-color: var(--accent-warning);
    color: var(--accent-warning);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-card);
    border-radius: var(--radius-card);
}

.empty-state i {
    font-size: 4rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.empty-state h3 {
    font-size: 1.35rem;
    color: var(--text-white);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.empty-state .btn {
    padding: 0.75rem 2rem;
}

.shortcuts-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    padding: 1rem;
}

.shortcuts-modal.show {
    display: flex;
}

.shortcuts-content {
    background: var(--bg-card);
    border-radius: var(--radius-card);
    padding: 2rem;
    max-width: 420px;
    width: 100%;
    box-shadow: var(--shadow-card-hover);
    border: 1px solid var(--border-color);
}

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

.shortcuts-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-white);
    margin: 0;
}

.shortcuts-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-main);
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.shortcuts-close:hover {
    background: var(--accent-secondary);
    color: var(--text-white);
}

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

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

.shortcut-action {
    color: var(--text-muted);
}

.shortcut-keys {
    display: flex;
    gap: 0.25rem;
}

.shortcut-keys kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-family: "Inter", sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-white);
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--accent-primary);
    color: var(--text-white);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-card);
    font-weight: 600;
    box-shadow: var(--shadow-card-hover);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1060;
}

.toast-notification.show {
    transform: translateX(-50%) translateY(0);
}


@media (max-width: 768px) {
    .study-hero h1 {
        font-size: 2rem;
    }

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

    .study-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .study-header-stats {
        width: 100%;
        justify-content: space-around;
    }

    .card-face {
        min-height: 340px;
        padding: 1.5rem;
    }

    .card-text {
        font-size: 1.15rem;
    }

    .nav-btn {
        width: 48px;
        height: 48px;
    }

    .action-btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.85rem;
    }

    .controls-row {
        gap: 0.5rem;
    }

    .control-btn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 576px) {
    .study-container {
        padding: 1rem 0.75rem;
    }

    .study-title h1 {
        font-size: 1.25rem;
    }

    .header-stat {
        padding: 0.375rem 0.75rem;
    }

    .header-stat-value {
        font-size: 1rem;
    }
}