/* Reset & Global Styles */
* {
    margin: 0;
    padding: 0;
    box-box-sizing: border-box;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: linear-gradient(135deg, #0e111d 0%, #05060b 100%);
    color: #ffffff;
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Helpers */
.hidden {
    display: none !important;
}

/* Glassmorphism base styling */
.glass-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 10px 30px 0 rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Layouts */
#app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 40px;
}

.screen-view {
    animation: fadeIn 0.4s ease;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Loading Spinner */
.loader-content {
    text-align: center;
}
.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid #6c5ce7;
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 1s linear infinite;
}
.loader-content p {
    color: #a0a0b0;
    font-size: 1.1rem;
    font-weight: 500;
}

/* Access Denied Screen */
.error-card {
    text-align: center;
    max-width: 400px;
    border-color: rgba(255, 107, 107, 0.15);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 75, 75, 0.02) 100%);
}
.icon-lock-wrapper {
    width: 70px;
    height: 70px;
    background: rgba(255, 107, 107, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    color: #ff6b6b;
}
.lock-icon {
    width: 32px;
    height: 32px;
}
.error-card h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(90deg, #ff6b6b, #ff8e8e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.error-card p {
    color: #a0a0b0;
    margin-bottom: 24px;
    font-size: 0.95rem;
}

/* Buttons */
.btn-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}
.btn {
    padding: 14px 24px;
    border-radius: 12px;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}
.btn-primary {
    background: linear-gradient(90deg, #6c5ce7 0%, #a8a5ff 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.45);
}
.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}
.btn-block {
    width: 100%;
}

/* App Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    margin-bottom: 24px;
}
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6c5ce7 0%, #00cec9 100%);
    color: white;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}
.user-info h4 {
    font-size: 0.95rem;
    font-weight: 600;
}
.status-badge {
    font-size: 0.75rem;
    color: #00cec9;
    background: rgba(0, 206, 201, 0.1);
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
    font-weight: 500;
}
.brand span {
    font-weight: 800;
    font-size: 1.1rem;
    background: linear-gradient(90deg, #6c5ce7, #00cec9);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Back Button */
.btn-back {
    background: none;
    border: none;
    color: #a0a0b0;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin-bottom: 20px;
    transition: color 0.2s ease;
    font-weight: 500;
}
.btn-back:hover {
    color: white;
}
.arrow-icon {
    width: 18px;
    height: 18px;
}

/* Sections Intro */
.section-intro {
    margin-bottom: 24px;
}
.section-intro h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 6px;
}
.section-intro p {
    color: #a0a0b0;
    font-size: 0.95rem;
}

/* Subjects Grid */
.grid-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
@media (min-width: 600px) {
    .grid-layout {
        grid-template-columns: 1fr 1fr;
    }
}
.subject-card {
    cursor: pointer;
}
.subject-card:hover {
    transform: translateY(-4px);
    border-color: rgba(108, 92, 231, 0.3);
    box-shadow: 0 10px 25px rgba(108, 92, 231, 0.15);
}
.subject-card h3 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: #ffffff;
}
.subject-card p {
    color: #a0a0b0;
    font-size: 0.9rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Lessons List */
.list-layout {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.lesson-row-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 20px;
}
.lesson-row-card:hover {
    transform: translateX(4px);
    border-color: rgba(108, 92, 231, 0.3);
    background: rgba(255, 255, 255, 0.05);
}
.lesson-row-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.lesson-index {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(108, 92, 231, 0.1);
    color: #6c5ce7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
}
.lesson-title-info h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 2px;
}
.lesson-title-info p {
    color: #a0a0b0;
    font-size: 0.85rem;
    max-width: 450px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lesson-row-right .icon-play {
    color: #6c5ce7;
    width: 24px;
    height: 24px;
}

/* Lesson Detail Screen Layout */
.lesson-header-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 20px;
}
.lesson-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}
@media (min-width: 768px) {
    .lesson-grid {
        grid-template-columns: 1.7fr 1.3fr;
    }
}

/* Video Player */
.video-card {
    padding: 0;
    overflow: hidden;
    border-radius: 16px;
}
.video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
}
.video-container iframe, .video-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 16px;
    background: #000;
}

#youtube-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 90px; /* Cover the entire top portion */
    background: transparent;
    z-index: 10;
    touch-action: none;
}

#youtube-overlay-bottom {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 150px;
    height: 60px; /* Cover the YouTube watermark/logo */
    background: transparent;
    z-index: 10;
    touch-action: none;
}

/* Content Details Card */
.content-card h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 8px;
}
.content-card p {
    font-size: 0.95rem;
    color: #c0c0d0;
}

/* Download Materials section */
.files-card h3, .quiz-card h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 8px;
}
.download-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.download-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    text-decoration: none;
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.05);
}
.download-link.pdf {
    background: rgba(255, 76, 76, 0.05);
    border-color: rgba(255, 76, 76, 0.1);
}
.download-link.pdf:hover {
    background: rgba(255, 76, 76, 0.1);
    border-color: rgba(255, 76, 76, 0.2);
}
.download-link.word {
    background: rgba(74, 144, 226, 0.05);
    border-color: rgba(74, 144, 226, 0.1);
}
.download-link.word:hover {
    background: rgba(74, 144, 226, 0.1);
    border-color: rgba(74, 144, 226, 0.2);
}
.file-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}
.download-link.pdf .file-icon { color: #ff4c4c; }
.download-link.word .file-icon { color: #4a90e2; }

/* Quiz Components */
.quiz-view {
    animation: fadeIn 0.3s ease;
}
.quiz-view p {
    color: #a0a0b0;
    font-size: 0.95rem;
    margin-bottom: 16px;
}
.quiz-progress {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}
#quiz-progress-text {
    font-size: 0.85rem;
    color: #a0a0b0;
    font-weight: 500;
}
.progress-bar-bg {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #6c5ce7, #00cec9);
    border-radius: 3px;
    transition: width 0.3s ease;
}
#quiz-question-text {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 16px;
}
.options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}
.option-btn {
    text-align: left;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 14px 16px;
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}
.option-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.15);
}
.option-btn:disabled {
    cursor: default;
}
.option-btn.correct {
    background: rgba(46, 204, 113, 0.1) !important;
    border-color: #2ecc71 !important;
    color: #2ecc71;
    font-weight: 600;
}
.option-btn.incorrect {
    background: rgba(231, 76, 60, 0.1) !important;
    border-color: #e74c3c !important;
    color: #e74c3c;
}

/* Quiz Result Celebration */
.result-celebration {
    text-align: center;
    padding: 16px 0;
}
.score-badge {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.15) 0%, rgba(0, 206, 201, 0.15) 100%);
    border: 2px solid #6c5ce7;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}
#quiz-score-val {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(90deg, #6c5ce7, #00cec9);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
#quiz-result-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 6px;
}
#quiz-result-desc {
    color: #a0a0b0;
    font-size: 0.95rem;
    margin-bottom: 24px;
}

/* Modal Overlay Styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    width: 95%;
    max-width: 800px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    padding: 16px;
    border-color: rgba(255, 255, 255, 0.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
}

.btn-close {
    background: none;
    border: none;
    color: #a0a0b0;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}

.btn-close:hover {
    color: #ffffff;
}

.modal-body {
    flex: 1;
    overflow: hidden;
    position: relative;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
}

#doc-viewer-iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 12px;
}

#main-content {
    padding-bottom: 90px; /* Leave space for bottom navigation bar */
}

/* Bottom Navigation Bar */
.bottom-nav {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 500px;
    background: rgba(15, 18, 30, 0.4);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 99;
}
.nav-item {
    background: none;
    border: none;
    color: #a0a0b0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 6px 16px;
    border-radius: 12px;
}
.nav-item:hover {
    color: #ffffff;
}
.nav-item.active {
    color: #6c5ce7;
    background: rgba(108, 92, 231, 0.08);
}
.nav-item svg {
    transition: transform 0.2s ease;
}
.nav-item.active svg {
    transform: scale(1.1);
}

/* Profile Screen CSS */
.profile-info-card {
    margin-bottom: 20px;
}
.profile-card-header {
    display: flex;
    align-items: center;
    gap: 20px;
}
.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6c5ce7 0%, #00cec9 100%);
    color: white;
    font-weight: 800;
    font-size: 2.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 15px rgba(108, 92, 231, 0.3);
}
.profile-meta h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.profile-meta p {
    color: #a0a0b0;
    font-size: 0.95rem;
    margin-bottom: 8px;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.stat-item-card {
    text-align: center;
    padding: 16px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.stat-icon {
    font-size: 1.6rem;
    margin-bottom: 8px;
}
.stat-item-card h3 {
    font-size: 1.4rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 2px;
}
.stat-item-card p {
    font-size: 0.75rem;
    color: #a0a0b0;
    font-weight: 500;
}
.support-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.support-card p {
    font-size: 0.9rem;
    color: #a0a0b0;
    margin-bottom: 16px;
}

/* Leaderboard Screen CSS */
.user-rank-summary-card {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.08) 0%, rgba(0, 206, 201, 0.03) 100%);
    border-color: rgba(108, 92, 231, 0.15);
    margin-bottom: 20px;
    padding: 16px 24px;
}
.rank-summary-info {
    display: flex;
    justify-content: space-around;
    align-items: center;
}
.rank-summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.rank-summary-label {
    font-size: 0.8rem;
    color: #a0a0b0;
    font-weight: 500;
}
.rank-summary-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #ffffff;
}
.rank-divider {
    width: 1px;
    height: 40px;
    background: rgba(255, 255, 255, 0.08);
}
.leaderboard-list-card {
    padding: 16px;
}
.leaderboard-header {
    display: flex;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: #a0a0b0;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 8px;
}
.leaderboard-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.leaderboard-row {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.03);
    transition: all 0.2s ease;
}
.leaderboard-row.current-user {
    background: rgba(108, 92, 231, 0.06);
    border-color: rgba(108, 92, 231, 0.2);
}
.col-rank {
    width: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}
.col-name {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 8px;
}
.leaderboard-row.current-user .col-name {
    color: #a8a5ff;
}
.col-score {
    width: 60px;
    text-align: right;
    font-weight: 700;
    color: #00cec9;
}
.rank-badge {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

/* Quiz HTML content styles */
#quiz-question-text img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 10px 0;
}
#quiz-question-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
}
#quiz-question-text table, #quiz-question-text th, #quiz-question-text td {
    border: 1px solid #e2e8f0;
}
#quiz-question-text th, #quiz-question-text td {
    padding: 8px;
    text-align: left;
}
