/* iConference Simple LMS Stylesheet */
:root {
    --primary-color: #1a56db;
    --primary-hover: #1e429f;
    --success-color: #0e9f6e;
    --success-hover: #057a55;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --radius: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.lms-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.brand-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand-title:hover {
    color: var(--primary-hover);
}

.course-switcher select {
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fff;
    color: var(--text-main);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.course-switcher select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}

/* Main Container */
.lms-main {
    max-width: 1000px;
    width: 100%;
    margin: 2rem auto;
    padding: 0 1rem;
    flex: 1;
}

.course-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.course-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.course-header h1 {
    font-size: 1.5rem;
    color: var(--text-main);
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 9999px;
    background: #e1effe;
    color: #1e429f;
}

.badge.completed {
    background: #def7ec;
    color: #03543f;
}

/* Player Stage (Video, Deck PNG, Slides PPTX) */
.player-stage {
    position: relative;
    background: #0f172a;
    width: 100%;
}

.player-view {
    width: 100%;
}

/* Video Container (16:9) */
.video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    height: 0;
    overflow: hidden;
    background: #000000;
}

.video-wrapper iframe,
.video-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Viewer Toolbars (Deck & Slides) */
.viewer-toolbar {
    background: #1e293b;
    border-bottom: 1px solid #334155;
    padding: 0.65rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.viewer-tag {
    color: #f1f5f9;
    font-weight: 600;
    font-size: 0.9rem;
}

.slide-counter-badge {
    background: #334155;
    color: #94a3b8;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.85rem;
}

.slide-counter-badge strong {
    color: #ffffff;
}

.btn-toolbar {
    background: #334155;
    color: #f8fafc;
    border: 1px solid #475569;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-toolbar:hover {
    background: #475569;
    color: #ffffff;
}

/* Deck PNG Scroll Container */
.deck-scroll-container {
    max-height: 580px;
    min-height: 400px;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: #0f172a;
}

#deck-img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    display: block;
}

/* Slides PPTX Scroll Container */
.slides-scroll-container {
    max-height: 580px;
    min-height: 400px;
    overflow-y: auto;
    scroll-behavior: smooth;
    padding: 1.5rem 2rem;
    background: #0f172a;
}

.slides-render-list {
    max-width: 820px;
    margin: 0 auto;
}

.slide-card {
    background: #1e293b;
    border-radius: 10px;
    border: 1px solid #334155;
    margin-bottom: 2rem;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.slide-card-header {
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #94a3b8;
    background: #1e293b;
    border-bottom: 1px solid #334155;
    text-align: left;
}

.slide-img {
    width: 100%;
    height: auto;
    display: block;
    background: #ffffff;
}

/* Placeholders & Spinners */
.viewer-placeholder {
    min-height: 380px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #94a3b8;
    text-align: center;
    padding: 2rem;
}

.placeholder-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.viewer-placeholder h3 {
    color: #f1f5f9;
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.viewer-placeholder p {
    font-size: 0.95rem;
    max-width: 480px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Bottom Course Controls */
.course-controls {
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.85rem;
    background: #fafafa;
    border-top: 1px solid var(--border-color);
}

.nav-btn-wrapper, .complete-btn-wrapper {
    display: flex;
    align-items: center;
}

/* In-line Content Toggle Group (Video | Deck | Slides) */
.content-toggle-group {
    display: inline-flex;
    background: #e2e8f0;
    padding: 4px;
    border-radius: 10px;
    gap: 3px;
}

.btn-toggle {
    border: none;
    outline: none;
    background: transparent;
    color: #475569;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.btn-toggle:hover {
    color: #1e293b;
}

.btn-toggle.active {
    background: #ffffff;
    color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

/* General Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border: 1px solid transparent;
}

.btn-secondary {
    background: #ffffff;
    color: var(--text-main);
    border-color: var(--border-color);
}

.btn-secondary:hover:not(.disabled) {
    background: #f1f5f9;
}

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

.btn-primary:hover:not(.disabled) {
    background: var(--primary-hover);
}

.btn-complete {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-complete.active {
    background: var(--success-color);
    color: #ffffff;
    border-color: var(--success-color);
}

.btn-complete.active:hover {
    background: var(--success-hover);
}

.btn.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* Catalog Grid (for index.php) */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.catalog-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.catalog-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--primary-color);
}

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

/* Footer */
.lms-footer {
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: auto;
}

@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        align-items: flex-start;
    }
    .course-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .content-toggle-group {
        width: 100%;
        justify-content: center;
    }
    .btn {
        justify-content: center;
        width: 100%;
    }
}

/* ==========================================================================
   Course Audio Controls ([audio.m4a])
   ========================================================================== */
.course-audio-section {
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.75rem;
    transition: opacity 0.2s ease-in-out;
}

.course-audio-section.audio-unavailable {
    background: #f1f5f9;
    opacity: 0.45;
    filter: grayscale(100%);
    pointer-events: none;
    cursor: not-allowed;
}

.audio-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.audio-info-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.audio-icon {
    font-size: 1.15rem;
}

.audio-title {
    font-size: 0.95rem;
    color: var(--text-main);
}

.audio-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
}

.audio-badge.ready {
    background: #def7ec;
    color: #03543f;
}

.audio-badge.disabled {
    background: #e2e8f0;
    color: #64748b;
}

.audio-control-container {
    width: 100%;
}

.audio-player-element {
    width: 100%;
    height: 40px;
    outline: none;
}

/* ==========================================================================
   Course Discussion & Robust Comments Section (Markdown & 4-Level Nesting)
   ========================================================================== */
.course-comments-section {
    border-top: 1px solid var(--border-color);
    padding: 2rem;
    background: #ffffff;
}

.comments-section-header h3 {
    font-size: 1.25rem;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.comments-section-sub {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* Comment Composer (Markdown Editor) */
.comment-composer-box {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 2rem;
}

.comment-composer-box.inline-reply-box {
    background: #f1f5f9;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    border-color: #cbd5e1;
}

.reply-header-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.author-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.author-row label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
}

.comment-author-input {
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 100%;
    max-width: 320px;
    background: #fff;
    outline: none;
}

.comment-author-input:focus {
    border-color: var(--primary-color);
}

/* Markdown Toolbar & Tabs */
.md-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    padding: 0.35rem 0.6rem;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.md-toolbar {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
}

.md-toolbar button {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #334155;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
    border-radius: 4px;
    cursor: pointer;
    min-width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.md-toolbar button:hover {
    background: #f1f5f9;
    color: var(--primary-color);
}

.editor-tabs {
    display: flex;
    gap: 2px;
}

.tab-btn {
    border: none;
    background: transparent;
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    border-radius: 4px;
    cursor: pointer;
}

.tab-btn.active {
    background: #ffffff;
    color: var(--primary-color);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.editor-write-pane textarea.comment-textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 0 0 8px 8px;
    padding: 0.75rem;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-main);
    resize: vertical;
    outline: none;
    background: #ffffff;
    min-height: 110px;
    display: block;
}

.editor-write-pane textarea.comment-textarea:focus {
    border-color: var(--primary-color);
}

.editor-preview-pane {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 0 0 8px 8px;
    padding: 1rem;
    min-height: 110px;
    font-size: 0.95rem;
    color: var(--text-main);
}

.preview-empty {
    color: var(--text-muted);
    font-style: italic;
}

.composer-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* Comments List & 4-Level Nesting Hierarchy */
.comments-tree-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.comment-thread-item {
    position: relative;
}

/* Nested subcomments visual lines & margins up to 4 levels */
.comment-level-1 {
    margin-left: 1.5rem;
    border-left: 2px solid #cbd5e1;
    padding-left: 1rem;
    margin-top: 0.75rem;
}

.comment-level-2 {
    margin-left: 1.5rem;
    border-left: 2px solid #94a3b8;
    padding-left: 1rem;
    margin-top: 0.75rem;
}

.comment-level-3 {
    margin-left: 1.5rem;
    border-left: 2px solid #64748b;
    padding-left: 1rem;
    margin-top: 0.75rem;
}

.comment-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.comment-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e1effe;
    color: var(--primary-color);
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.comment-author-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.comment-author-name {
    font-size: 0.95rem;
    color: var(--text-main);
}

.comment-timestamp {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.comment-level-tag {
    font-size: 0.75rem;
    background: #f1f5f9;
    color: #475569;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-weight: 500;
}

/* Rendered Markdown Body in Comments */
.comment-body {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-main);
    word-break: break-word;
}

.comment-para {
    margin-bottom: 0.5rem;
}

.comment-para:last-child {
    margin-bottom: 0;
}

.comment-heading {
    margin: 0.75rem 0 0.35rem 0;
    color: var(--text-main);
}

.comment-quote {
    border-left: 3px solid var(--primary-color);
    padding-left: 0.75rem;
    margin: 0.5rem 0;
    color: #475569;
    font-style: italic;
}

.comment-inline-code {
    background: #f1f5f9;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
    color: #b91c1c;
}

.comment-code-block {
    background: #0f172a;
    color: #f8fafc;
    padding: 0.75rem;
    border-radius: 6px;
    overflow-x: auto;
    font-family: monospace;
    font-size: 0.85rem;
    margin: 0.5rem 0;
}

.comment-list {
    margin: 0.5rem 0 0.5rem 1.5rem;
}

.comment-link {
    color: var(--primary-color);
    text-decoration: underline;
}

.comment-footer-actions {
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-comment-reply {
    background: transparent;
    border: none;
    color: var(--primary-color);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: background 0.15s;
}

.btn-comment-reply:hover {
    background: #eff6ff;
}

.comments-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}
