/* ================================================================
   TraceNode — Dark Sleek Theme
   ================================================================ */

:root {
    --bg-primary: #08080c;
    --bg-secondary: #101018;
    --bg-card: #14141e;
    --bg-card-hover: #1a1a28;
    --bg-input: #0c0c14;
    --border: #1e1e30;
    --border-focus: #6c5ce7;
    --text-primary: #e8e8f0;
    --text-secondary: #8888a0;
    --text-muted: #555570;
    --accent: #6c5ce7;
    --accent-glow: rgba(108, 92, 231, 0.25);
    --accent-hover: #7c6df7;
    --highlight-row: rgba(108, 92, 231, 0.10);
    --highlight-word: rgba(108, 92, 231, 0.55);
    --success: #00d2a0;
    --error: #ff4757;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
}

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

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
}

/* ================================================================
   NAV
   ================================================================ */

#navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    height: 64px;
    background: rgba(8, 8, 12, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.nav-brand {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.brand-trace { color: var(--text-primary); }
.brand-node  { color: var(--accent); }

.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.credits-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--accent-glow);
    border: 1px solid rgba(108, 92, 231, 0.3);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-hover);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
}

.btn-ghost {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

#loginNavBtn {
    border-color: rgba(124, 109, 247, 0.65);
    color: #f3f0ff;
    background: rgba(124, 109, 247, 0.18);
    box-shadow: 0 0 20px rgba(124, 109, 247, 0.22);
}

#loginNavBtn:hover {
    border-color: var(--accent-hover);
    background: rgba(124, 109, 247, 0.28);
    color: #ffffff;
}

/* ================================================================
   LOGIN MODAL
   ================================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

.modal-header {
    text-align: center;
    margin-bottom: 28px;
    font-size: 28px;
    font-weight: 800;
}

.modal-sub {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 6px;
    font-weight: 400;
}

.input-group { margin-bottom: 18px; }

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

.input-group input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-error {
    color: var(--error);
    font-size: 13px;
    min-height: 20px;
    margin-bottom: 8px;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ================================================================
   UPLOAD SECTION
   ================================================================ */

#uploadSection {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 32px 32px;
}

.upload-hero {
    text-align: center;
    max-width: 680px;
    width: 100%;
    animation: slideUp 0.5s ease;
}

.hero-title {
    font-size: 48px;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 12px;
    line-height: 1.1;
}

.accent { color: var(--accent); }

.hero-sub {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 40px;
    line-height: 1.6;
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 60px 40px;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-secondary);
    min-width: 540px;
    position: relative;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.05);
    box-shadow: 0 0 40px var(--accent-glow);
}

.upload-icon {
    width: 56px;
    height: 56px;
    stroke: var(--text-muted);
    margin-bottom: 16px;
    transition: var(--transition);
}

.upload-zone:hover .upload-icon {
    stroke: var(--accent);
    transform: translateY(-2px);
}

.upload-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.upload-subtext {
    font-size: 13px;
    color: var(--text-muted);
}

/* ================================================================
   UPLOAD / PROCESSING OVERLAY
   ================================================================ */

.overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.overlay-card {
    text-align: center;
    padding: 48px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    min-width: 320px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

.overlay-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 28px;
}

.circular-progress {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 24px;
}

.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring-bg {
    stroke: var(--border);
}

.progress-ring-circle {
    stroke: var(--accent);
    stroke-linecap: round;
    transition: stroke-dashoffset 0.3s ease;
}

.progress-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.overlay-status {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ================================================================
   RESULTS SECTION
   ================================================================ */

#resultsSection {
    min-height: 100vh;
    padding: 80px 24px 24px;
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
    height: calc(100vh - 100px);
    max-width: 1600px;
    margin: 0 auto;
    animation: fadeIn 0.4s ease;
}

/* Left panel — table */
.table-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.table-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.table-title {
    font-size: 16px;
    font-weight: 700;
}

.table-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.current-time-display {
    display: flex;
    align-items: center;
    gap: 6px;
}

.time-display {
    font-size: 18px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}

.block-size-select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
}

.block-size-select:focus { border-color: var(--accent); }

.table-scroll {
    flex: 1;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
}

table {
    width: 100%;
    min-width: 700px;
    border-collapse: collapse;
    font-size: 13px;
    line-height: 1.55;
}

thead { position: sticky; top: 0; z-index: 2; }

thead th {
    background: var(--bg-card);
    border-bottom: 2px solid var(--border);
    padding: 12px 14px;
    text-align: left;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid rgba(30, 30, 48, 0.5);
    transition: background 0.15s ease;
    cursor: pointer;
}

tbody tr:hover { background: var(--bg-card-hover); }

tbody tr.active-row {
    background: var(--highlight-row);
    border-left: 3px solid var(--accent);
}

td {
    padding: 12px 14px;
    vertical-align: top;
}

.col-time {
    width: 100px;
    min-width: 100px;
    font-weight: 600;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.col-visual { min-width: 220px; color: var(--text-primary); }
.col-transcript { min-width: 180px; }
.col-notes { min-width: 120px; color: var(--text-muted); font-size: 12px; }

/* Word-level highlighting */
.transcript-text span {
    transition: background 0.1s ease, color 0.1s ease;
    border-radius: 2px;
    padding: 0 1px;
    cursor: pointer;
}

.transcript-text span.word-active {
    background: var(--highlight-word);
    color: #fff;
    font-weight: 600;
}

.transcript-text span.word-past {
    color: var(--text-primary);
}

.transcript-text span.word-future {
    color: var(--text-secondary);
}

/* Right panel — video */
.video-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.video-box {
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
    border: 1px solid var(--border);
}

.video-box video {
    width: 100%;
    display: block;
}

.video-filename {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}

.info-cards {
    display: flex;
    gap: 10px;
}

.info-card {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
}

.info-card-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 600;
}

.info-card-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

/* ================================================================
   SCROLLBAR
   ================================================================ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ================================================================
   ANIMATIONS
   ================================================================ */

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

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 900px) {
    .results-grid {
        grid-template-columns: 1fr;
        height: auto;
    }
    .hero-title { font-size: 36px; }
    .upload-zone { min-width: unset; }
}
