/* ========================================
   VideoTutor Styles
   ======================================== */

:root {
    --bg: #1a1a2e;
    --surface: #16213e;
    --surface-light: #1a2744;
    --accent: #f5c518;
    --accent-muted: #e0b400;
    --text: #eeeeee;
    --text-muted: #aabbcc;
    --text-dim: #778899;
    --border: #2a3a5e;
    --input-bg: #0f1a30;
    --success: #4ecca3;
}

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}


/* ---- Header ---- */

#header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.header-brand {
    font-size: 17px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.5px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-icon {
    flex-shrink: 0;
}

.header-controls {
    flex: 1;
    display: flex;
    gap: 8px;
    min-width: 200px;
}

#video-url-input {
    flex: 1;
    padding: 8px 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 15px;
    outline: none;
}

#video-url-input:focus {
    border-color: var(--accent);
}

#load-btn {
    padding: 8px 18px;
    background: var(--accent);
    border: none;
    border-radius: 6px;
    color: #1a1a1a;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

#load-btn:hover {
    background: var(--accent-muted);
}

.btn-secondary {
    padding: 8px 18px;
    background: transparent;
    border: none;
    border-radius: 6px;
    box-shadow: inset 0 0 0 1.5px var(--accent);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--accent);
    box-shadow: none;
    color: #1a1a1a;
}

.btn-secondary:disabled {
    box-shadow: inset 0 0 0 1.5px var(--border);
    color: var(--text-dim);
    cursor: default;
    opacity: 0.6;
}


/* ---- Focus indicators ---- */

button:focus-visible,
[role="tab"]:focus-visible,
[role="button"]:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex="0"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}


/* ---- Main Layout ---- */

#main {
    flex: 1;
    display: grid;
    grid-template-columns: 2fr 4px 1fr;
    grid-template-rows: 35vh 4px 1fr;
    overflow: hidden;
}

#video-area {
    grid-column: 1;
    grid-row: 1;
    position: relative;
    overflow: hidden;
    min-height: 0;
    background: #000;
    container-type: size;
}

#main > #resize-video {
    grid-column: 1;
    grid-row: 2;
}

#steps-panel {
    grid-column: 1;
    grid-row: 3;
    overflow-y: auto;
}

#main > #resize-panels {
    grid-column: 2;
    grid-row: 1 / -1;
}

#transcript-panel {
    grid-column: 3;
    grid-row: 1 / -1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}


/* ---- Resize Handles ---- */

.resize-handle {
    flex-shrink: 0;
    background: var(--border);
    position: relative;
    z-index: 5;
}

.resize-handle:hover,
.resize-handle.active {
    background: var(--accent);
}

.resize-h {
    height: 4px;
    cursor: ns-resize;
}

.resize-v {
    width: 4px;
    cursor: ew-resize;
}


/* ---- Theatre Mode ---- */

#theatre-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    opacity: 0.6;
    transition: opacity 0.15s, padding 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--accent);
    border-color: var(--accent);
    color: #1a1a1a;
}

.theatre-label {
    display: none;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

#theatre-btn:hover {
    opacity: 1;
    width: auto;
    padding: 5px 10px;
}

#theatre-btn:hover .theatre-label {
    display: inline;
}

#theatre-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #1a1a1a;
    opacity: 1;
}

#main.theatre {
    grid-template-columns: 2fr 4px 1fr;
    grid-template-rows: 45vh 4px 1fr;
}

#main.theatre #video-area {
    grid-column: 1 / -1;
    grid-row: 1;
}

#main.theatre > #resize-video {
    grid-column: 1 / -1;
    grid-row: 2;
}

#main.theatre #steps-panel {
    grid-column: 1;
    grid-row: 3;
}

#main.theatre > #resize-panels {
    grid-column: 2;
    grid-row: 3;
}

#main.theatre #transcript-panel {
    grid-column: 3;
    grid-row: 3;
}


/* ---- Video Player ---- */

#video-container {
    background: #000;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(100cqw, calc(100cqh * 16 / 9));
    height: min(100cqh, calc(100cqw * 9 / 16));
    overflow: hidden;
}

#video-placeholder {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    color: var(--text-dim);
    font-size: 16px;
}

.placeholder-icon {
    font-size: 36px;
    opacity: 0.3;
}

#video-player {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#video-player iframe {
    width: 100%;
    height: 100%;
}


/* ---- Panel Headers ---- */

.panel-header {
    padding: 10px 16px;
    min-height: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.panel-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.panel-status {
    font-size: 13px;
    color: var(--text-dim);
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-tab {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-dim);
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: color 0.15s;
}

.panel-tab:hover {
    color: var(--text-muted);
}

.panel-tab.active {
    color: var(--text-muted);
}

.panel-tab-divider {
    color: var(--text-dim);
    font-size: 14px;
    opacity: 0.5;
}


/* ---- Transcript ---- */

#chapters-content {
    flex: 1;
    overflow-y: auto;
}

#chapters-list {
    padding: 12px 16px;
}

.chapter-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    color: var(--text-muted);
    font-size: 15px;
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 3px;
}

.chapter-link:hover {
    background: var(--surface-light);
    color: var(--text);
}

.chapter-link.active {
    background: var(--surface-light);
    color: var(--text);
}

.chapter-time {
    color: var(--accent);
    font-family: monospace;
    font-size: 13px;
    opacity: 0.8;
    flex-shrink: 0;
}

#transcript-content {
    flex: 1;
    overflow-y: auto;
    position: relative;
}

#transcript-paste {
    width: 100%;
    height: 100%;
    padding: 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.7;
    resize: none;
    outline: none;
    font-family: inherit;
    position: absolute;
    top: 0;
    left: 0;
}

#transcript-entries {
    padding: 12px 16px;
    display: none;
}

.transcript-entry {
    margin-bottom: 4px;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background 0.15s;
}

.transcript-entry:hover {
    background: var(--surface-light);
}

.transcript-entry.active {
    background: var(--surface-light);
    color: var(--text);
}

.transcript-timestamp {
    color: var(--accent);
    font-size: 13px;
    font-family: monospace;
    margin-right: 8px;
    opacity: 0.7;
}

.transcript-message {
    padding: 20px 16px;
    color: var(--text-dim);
    font-size: 15px;
    text-align: center;
}


/* ---- Right Panel Sections ---- */

.section-hint {
    font-size: 14px;
    color: var(--text-dim);
    line-height: 1.5;
    margin-bottom: 14px;
}

.section-divider {
    height: 1px;
    background: var(--border);
}

.panel-header.collapsible {
    cursor: pointer;
    user-select: none;
}

.panel-header.collapsible:hover {
    background: var(--input-bg);
}

.collapse-icon {
    display: inline-block;
    transition: transform 0.15s;
    margin-right: 4px;
    font-size: 16px;
}

.collapse-icon.collapsed {
    transform: rotate(-90deg);
}



/* ---- Field Groups ---- */

.field-group {
    margin-bottom: 14px;
}

.field-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}


/* ---- Related Threads ---- */

.thread-entry {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}

.thread-input {
    flex: 1;
    padding: 6px 10px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.thread-input:focus {
    border-color: var(--accent);
}

.btn-icon {
    width: 28px;
    height: 28px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

.btn-icon.remove {
    font-size: 12px;
    color: var(--text-dim);
}


/* ---- Option Buttons ---- */

.option-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.option-btn {
    padding: 5px 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
}

.option-btn:hover {
    border-color: var(--text-muted);
}

.option-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #1a1a1a;
}

.option-btn.action-btn {
    padding: 7px 18px;
    font-size: 15px;
}

.init-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
}

.checkbox-label.disabled {
    opacity: 0.4;
    cursor: default;
}

.checkbox-label input {
    accent-color: var(--accent);
}

.radio-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
}

.radio-label input {
    accent-color: var(--accent);
}


/* ---- Step Headings ---- */

.section-body h2 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    margin-top: 28px;
    margin-bottom: 12px;
    line-height: 1.4;
}

.section-body h2:first-child {
    margin-top: 10px;
}

.section-body p {
    font-size: 14px;
    color: var(--text-dim);
    line-height: 1.5;
    margin-bottom: 12px;
}


/* ---- Collapsible Sections ---- */

.section-body {
    padding: 14px 16px;
    overflow: hidden;
    transition: max-height 0.25s ease, padding 0.25s ease, opacity 0.2s ease;
    max-height: 2000px;
    opacity: 1;
}

.section-body.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

.section-count {
    font-size: 13px;
    color: var(--accent);
    font-weight: 600;
    margin-left: 8px;
}


/* ---- Discussion Section ---- */

.discussion-header {
    flex-wrap: wrap;
    gap: 8px;
    cursor: default;
}

.discussion-header .panel-label {
    cursor: pointer;
}

.discussion-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.discussion-tab {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-dim);
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: color 0.15s;
}

.discussion-tab:hover {
    color: var(--text-muted);
}

.discussion-tab.active {
    color: var(--accent);
}

.discussion-tab-divider {
    color: var(--text-dim);
    font-size: 13px;
    opacity: 0.5;
}

.context-body {
    display: flex;
    align-items: center;
    gap: 12px;
}

.context-timestamp {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
    font-family: monospace;
    flex-shrink: 0;
}

.context-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.context-detail-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
}

.context-detail-label {
    font-size: 14px;
    color: var(--text-dim);
    flex-shrink: 0;
}

.context-detail {
    font-size: 14px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-compact {
    padding: 6px 14px;
    font-size: 14px;
    white-space: nowrap;
    flex-shrink: 0;
}


/* ---- Notebook Input ---- */

.notebook-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 10px;
}

#notebook-input {
    flex: 1;
    padding: 8px 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    resize: vertical;
    outline: none;
    font-family: inherit;
}

#notebook-input:focus {
    border-color: var(--accent);
}


/* ---- Action Row ---- */

.action-row {
    display: flex;
    align-items: center;
    gap: 10px;
}


/* ---- Buttons ---- */

.btn-primary {
    padding: 8px 18px;
    background: var(--accent);
    border: none;
    border-radius: 6px;
    color: #1a1a1a;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

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

.btn-primary:disabled {
    opacity: 0.4;
    cursor: default;
}


.btn-text {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
}

.btn-text:hover {
    color: var(--text-muted);
}

.btn-small {
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 600;
    cursor: default;
}

.btn-small.active {
    background: var(--surface-light);
    border-color: var(--text-dim);
    color: var(--text);
    cursor: pointer;
}

.btn-small.active:hover {
    background: var(--text-dim);
    color: #fff;
}

.copy-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    font-weight: 700;
    color: #fff;
    background: rgba(0, 0, 0, 0.7);
    padding: 40px 60px;
    border-radius: 16px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.6s ease;
    z-index: 9999;
}

.copy-toast.visible {
    opacity: 1;
}


/* ---- Preview Block ---- */

.preview-block {
    margin-top: 10px;
    padding: 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-dim);
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'Consolas', 'Monaco', monospace;
}


/* ---- Notebook Log ---- */

.log-placeholder {
    padding: 14px 0;
    color: var(--text-dim);
    font-size: 14px;
}

.log-entry {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    line-height: 1.5;
    position: relative;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.log-timestamp {
    color: var(--accent);
    font-family: monospace;
    font-size: 13px;
    opacity: 0.8;
}

.log-chapter {
    color: var(--text-dim);
    font-size: 13px;
}

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

.log-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.15s;
}

.log-entry:hover .log-actions,
.log-entry:focus-within .log-actions {
    opacity: 1;
}

.log-action-btn {
    width: 26px;
    height: 26px;
}

.log-action-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}


/* ---- Info Modal ---- */

#info-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

#info-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    max-width: 520px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 30px;
    position: relative;
    animation: modalSlideIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

#info-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
}

#info-modal h2 {
    font-size: 20px;
    color: var(--accent);
    margin-bottom: 4px;
}

#info-modal .modal-subtitle {
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 20px;
}

#info-modal h3 {
    font-size: 15px;
    color: var(--text);
    margin: 18px 0 8px;
}

#info-modal ol,
#info-modal ul {
    padding-left: 20px;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.7;
}

#info-modal li {
    margin-bottom: 4px;
}

#info-modal p {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.6;
}

#info-modal a {
    color: var(--accent);
    text-decoration: none;
}

#info-modal a:hover {
    text-decoration: underline;
}


/* ---- Mobile ---- */

@media (max-width: 768px) {
    body {
        height: auto;
        overflow: auto;
    }

    #main {
        display: flex;
        flex-direction: column;
        overflow: visible;
    }

    #video-area {
        height: 30vh;
    }

    #transcript-panel {
        min-height: 50vh;
        border-top: 1px solid var(--border);
    }

    #theatre-btn {
        display: none;
    }

    .resize-v {
        display: none;
    }
}
