/* ============================
   Study Pages – Common Layout
   ============================ */

/* Study page body – inherits from main style.css */
.study-page {
    padding-top: 70px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- Study Header ---- */
.study-header {
    background: linear-gradient(135deg, #1BA5A5 0%, #4ECDC4 100%);
    color: #fff;
    padding: 3rem 2rem 2rem;
    text-align: center;
}

.study-header h1 {
    font-size: 2.2rem;
    margin-bottom: 0.5rem;
}

.study-header p {
    font-size: 1.1rem;
    opacity: 0.92;
    max-width: 700px;
    margin: 0 auto 1rem;
    line-height: 1.6;
}

/* Header meta bar: language selector + progress */
.study-meta {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* Progress badge */
#progress-badge {
    display: none;
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    padding: 0.3rem 0.9rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Language selector */
.lang-select {
    padding: 0.35rem 0.7rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
}
.lang-select option {
    color: #333;
    background: #fff;
}

/* ---- Tab Navigation ---- */
.study-tabs {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    background: #f5fbfb;
    border-bottom: 1px solid #d8ecec;
    flex-wrap: wrap;
}

.study-tab-btn {
    padding: 0.6rem 1.4rem;
    border: 2px solid transparent;
    border-radius: 30px;
    background: #fff;
    color: var(--text-dark, #2C3E50);
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
}
.study-tab-btn:hover {
    border-color: #1BA5A5;
    color: #1BA5A5;
}
.study-tab-btn.active {
    background: #1BA5A5;
    color: #fff;
    border-color: #1BA5A5;
}

/* ---- Tab Panels ---- */
.study-panel {
    display: none;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}
.study-panel.active {
    display: block;
    animation: fadeInUp 0.4s ease;
}

/* ---- Study Content Area ---- */
.study-content {
    flex: 1;
    padding-bottom: 3rem;
}

/* ---- Cards ---- */
.study-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.study-item-card {
    background: #fff;
    border: 1px solid #e8eded;
    border-radius: 14px;
    padding: 1.5rem;
    transition: box-shadow 0.25s ease, transform 0.2s ease;
}
.study-item-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    transform: translateY(-3px);
}

.study-item-card h3 {
    font-size: 1.15rem;
    color: var(--text-dark, #2C3E50);
    margin-bottom: 0.5rem;
}

.study-item-card p {
    color: var(--text-light, #7F8C8D);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Tags */
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.5rem 0;
}
.tag {
    display: inline-block;
    background: #e9f8f8;
    color: #106d6d;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
}

/* Difficulty badge */
.difficulty {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}
.difficulty.easy { background: #d4edda; color: #155724; }
.difficulty.medium { background: #fff3cd; color: #856404; }
.difficulty.hard { background: #f8d7da; color: #721c24; }

/* ---- Buttons ---- */
.study-btn {
    display: inline-block;
    padding: 0.5rem 1.2rem;
    border-radius: 8px;
    border: none;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
}
.study-btn-primary {
    background: #1BA5A5;
    color: #fff;
}
.study-btn-primary:hover {
    background: #158d8d;
}
.study-btn-outline {
    background: transparent;
    color: #1BA5A5;
    border: 1.5px solid #1BA5A5;
}
.study-btn-outline:hover {
    background: #e9f8f8;
}

/* ---- Completion Checkbox ---- */
.completion-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.8rem;
    cursor: pointer;
    user-select: none;
}
.completion-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #1BA5A5;
    cursor: pointer;
}
.completion-check label {
    font-size: 0.9rem;
    color: var(--text-light, #7F8C8D);
    cursor: pointer;
}
.completion-check.completed label {
    text-decoration: line-through;
    color: #1BA5A5;
}

/* ---- Stepper / Roadmap ---- */
.roadmap-stepper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 0;
    margin: 2rem 0;
    flex-wrap: wrap;
}
.roadmap-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 1;
    min-width: 140px;
    max-width: 220px;
    position: relative;
    cursor: pointer;
}
.roadmap-step::after {
    content: '';
    position: absolute;
    top: 24px;
    left: 50%;
    width: 100%;
    height: 3px;
    background: #d8ecec;
    z-index: 0;
}
.roadmap-step:last-child::after {
    display: none;
}
.step-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #d8ecec;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    position: relative;
    z-index: 1;
    transition: all 0.3s ease;
}
.roadmap-step.active .step-circle {
    background: #1BA5A5;
    color: #fff;
}
.roadmap-step:hover .step-circle {
    background: #4ECDC4;
    color: #fff;
}
.step-label {
    margin-top: 0.6rem;
    font-size: 0.9rem;
    color: var(--text-dark, #2C3E50);
    font-weight: 500;
}

/* ---- Accordion ---- */
.accordion-item {
    border: 1px solid #e8eded;
    border-radius: 10px;
    margin-bottom: 0.8rem;
    overflow: hidden;
}
.accordion-header {
    padding: 1rem 1.2rem;
    background: #f9fdfd;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    transition: background 0.2s ease;
}
.accordion-header:hover {
    background: #e9f8f8;
}
.accordion-header::after {
    content: '\25BC';
    font-size: 0.75rem;
    transition: transform 0.3s ease;
    color: #999;
}
.accordion-item.open .accordion-header::after {
    transform: rotate(180deg);
}
.accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}
.accordion-item.open .accordion-body {
    max-height: 3000px;
}
.accordion-content {
    padding: 1rem 1.2rem 1.5rem;
}

/* ---- Code Block with Copy ---- */
.code-block-wrapper {
    position: relative;
    margin: 1rem 0;
}
.code-block-wrapper pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 1rem 1.2rem;
    border-radius: 10px;
    overflow-x: auto;
    font-size: 0.9rem;
    line-height: 1.5;
    font-family: 'Consolas', 'Monaco', monospace;
}
.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #cdd6f4;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s ease;
}
.copy-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}
.copy-btn.copied {
    background: #1BA5A5;
    color: #fff;
}

/* ---- Search & Filter ---- */
.filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}
.search-input {
    flex: 1;
    min-width: 200px;
    padding: 0.6rem 1rem;
    border: 2px solid #d8ecec;
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.3s ease;
}
.search-input:focus {
    outline: none;
    border-color: #1BA5A5;
}
.filter-select {
    padding: 0.6rem 1rem;
    border: 2px solid #d8ecec;
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    cursor: pointer;
}

/* ---- Prompt/Practice Area (For Global) ---- */
.prompt-area {
    background: #f5fbfb;
    border: 1px solid #d8ecec;
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1rem;
}
.prompt-area textarea {
    width: 100%;
    min-height: 100px;
    padding: 0.8rem;
    border: 2px solid #d8ecec;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}
.prompt-area textarea:focus {
    outline: none;
    border-color: #1BA5A5;
}
.ai-response-placeholder {
    background: #fff;
    border: 2px dashed #d8ecec;
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1rem;
    text-align: center;
    color: #999;
    font-style: italic;
}

/* ---- Chat UI (For Global) ---- */
.chat-messages {
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    background: #fff;
    border: 1px solid #e8eded;
    border-radius: 12px;
    margin-bottom: 0.8rem;
}

.chat-bubble {
    max-width: 80%;
    padding: 0.8rem 1rem;
    border-radius: 14px;
    font-size: 0.95rem;
    line-height: 1.6;
    word-break: break-word;
}

.chat-user {
    align-self: flex-end;
    background: #1BA5A5;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-assistant {
    align-self: flex-start;
    background: #f0f0f0;
    color: #2C3E50;
    border-bottom-left-radius: 4px;
}

.chat-assistant strong {
    color: #1BA5A5;
}

.chat-loading {
    animation: chatPulse 1.2s ease-in-out infinite;
    color: #999;
    font-style: italic;
}

@keyframes chatPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.chat-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.chat-input-row textarea {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 0.6rem 0.8rem;
    border: 2px solid #d8ecec;
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    transition: border-color 0.3s ease;
}

.chat-input-row textarea:focus {
    outline: none;
    border-color: #1BA5A5;
}

.chat-input-row button {
    padding: 0.6rem 1.2rem;
    background: #1BA5A5;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.25s ease;
}

.chat-input-row button:hover {
    background: #158d8d;
}

.chat-input-row button:disabled {
    background: #b0d5d5;
    cursor: not-allowed;
}

.cultural-note-badge {
    display: inline-block;
    background: #fff3cd;
    color: #856404;
    padding: 0.15rem 0.5rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-right: 0.3rem;
}

/* ---- Lecture Grid (For Beginner) ---- */
.lecture-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 0 2rem;
}
.lecture-card {
    background: #fff;
    border: 1px solid #e8eded;
    border-radius: 12px;
    padding: 1.2rem;
    cursor: pointer;
    transition: box-shadow 0.25s ease, transform 0.2s ease, border-color 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.lecture-card:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
    border-color: #1BA5A5;
}
.lecture-card.completed {
    border-color: #1BA5A5;
    background: #f5fefe;
}
.lecture-card-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.lecture-num {
    background: #1BA5A5;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}
.lecture-card.completed .lecture-num {
    background: #4ECDC4;
}
.lecture-card-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-dark, #2C3E50);
    line-height: 1.4;
}
.lecture-card-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.lecture-card .complete-mark {
    color: #1BA5A5;
    font-size: 0.8rem;
    font-weight: 600;
}
.step-lecture-count {
    font-size: 0.8rem;
    color: #999;
    display: block;
    margin-top: 0.2rem;
}

/* ---- Split-Screen Player Panel ---- */
.player-panel {
    display: none;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem 3rem;
}
.player-panel.active {
    display: block;
    animation: fadeInUp 0.4s ease;
}

.player-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: none;
    border: none;
    color: #1BA5A5;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
    transition: color 0.2s ease;
}
.player-back-btn:hover {
    color: #158d8d;
}

.player-lecture-title {
    font-size: 1.4rem;
    color: var(--text-dark, #2C3E50);
    margin-bottom: 1rem;
    font-weight: 600;
}

.player-split {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

/* Left: YouTube thumbnail + link */
.player-video-col {
    flex: 1;
    min-width: 0;
    position: sticky;
    top: 80px;
}
.video-thumb-link {
    display: block;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
}
.video-thumb-img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    transition: opacity 0.2s ease;
}
.video-thumb-link:hover .video-thumb-img {
    opacity: 0.85;
}
.video-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.85;
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}
.video-thumb-link:hover .video-play-overlay {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

.player-video-meta {
    margin-top: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

/* Right: Commentary */
.player-commentary-col {
    flex: 1;
    min-width: 0;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding-right: 0.5rem;
}
.player-commentary-col::-webkit-scrollbar {
    width: 6px;
}
.player-commentary-col::-webkit-scrollbar-thumb {
    background: #d8ecec;
    border-radius: 3px;
}
.player-commentary-col::-webkit-scrollbar-thumb:hover {
    background: #1BA5A5;
}

.commentary-section {
    margin-bottom: 1.5rem;
}
.commentary-section h3 {
    font-size: 1.05rem;
    color: #1BA5A5;
    margin-bottom: 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid #e9f8f8;
}
.commentary-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.commentary-section li {
    padding: 0.4rem 0 0.4rem 1.2rem;
    position: relative;
    line-height: 1.6;
    font-size: 0.95rem;
    color: var(--text-dark, #2C3E50);
}
.commentary-section li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.85rem;
    width: 6px;
    height: 6px;
    background: #4ECDC4;
    border-radius: 50%;
}
.concept-term {
    font-weight: 600;
    color: #1BA5A5;
}

/* Player navigation */
.player-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e8eded;
    gap: 1rem;
}
.player-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    border: 2px solid #1BA5A5;
    border-radius: 8px;
    background: #fff;
    color: #1BA5A5;
    font-size: 0.9rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}
.player-nav-btn:hover {
    background: #1BA5A5;
    color: #fff;
}
.player-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.player-nav-btn:disabled:hover {
    background: #fff;
    color: #1BA5A5;
}

/* ---- Study Footer ---- */
.study-footer {
    background: #222;
    color: #fff;
    padding: 2rem;
    text-align: center;
    font-size: 0.9rem;
}
.study-footer p {
    color: #ccc;
    margin: 0.3rem 0;
}
.study-footer a {
    color: #4ECDC4;
    text-decoration: none;
}
.study-footer a:hover {
    text-decoration: underline;
}

/* ---- Responsive: Split-screen ---- */
@media (max-width: 900px) {
    .player-split {
        flex-direction: column;
    }
    .player-video-col {
        position: static;
        width: 100%;
    }
    .player-commentary-col {
        max-height: none;
        overflow-y: visible;
        padding-right: 0;
    }
    .player-panel {
        padding: 1rem 1.2rem 2rem;
    }
    .player-lecture-title {
        font-size: 1.15rem;
    }
    .lecture-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        padding: 0 1.2rem;
    }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .study-header h1 {
        font-size: 1.6rem;
    }
    .study-header p {
        font-size: 0.95rem;
    }
    .study-tabs {
        padding: 0.8rem 1rem;
        gap: 0.4rem;
    }
    .study-tab-btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
    .study-panel {
        padding: 1.2rem;
    }
    .study-card-grid {
        grid-template-columns: 1fr;
    }
    .roadmap-stepper {
        flex-direction: column;
        align-items: center;
    }
    .roadmap-step::after {
        display: none;
    }
    .roadmap-step {
        min-width: auto;
    }
    .filter-bar {
        flex-direction: column;
    }
    .search-input {
        min-width: 100%;
    }
    .lecture-grid {
        grid-template-columns: 1fr;
        padding: 0 1rem;
    }
    .player-nav {
        flex-direction: column;
    }
    .player-nav-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .study-header {
        padding: 2rem 1rem 1.5rem;
    }
    .study-header h1 {
        font-size: 1.3rem;
    }
    .study-meta {
        flex-direction: column;
        gap: 0.8rem;
    }
}
