/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    background: #1a1a2e;
}

body {
    height: 100%;
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
}

.hidden {
    display: none !important;
}

/* ===== EDIT VIEW ===== */
#edit-view {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

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

.edit-header h1 {
    font-size: 24px;
    font-weight: 300;
    color: #fff;
}

.edit-actions {
    display: flex;
    gap: 8px;
}

.edit-instructions {
    font-size: 13px;
    color: #888;
    margin-bottom: 12px;
    line-height: 1.5;
}

.edit-instructions em {
    color: #f0c040;
    font-style: italic;
}

.bracket-example {
    color: #888;
    background: #2a2a3e;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 12px;
}

/* Rich text editor */
#editor {
    flex: 1;
    background: #ffffff;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 24px;
    font-size: 16px;
    line-height: 1.7;
    color: #222;
    overflow-y: auto;
    outline: none;
    cursor: text;
    transition: background 0.3s, color 0.3s;
}

#editor.dark-bg {
    background: #16213e;
    color: #e0e0e0;
}

#editor:focus {
    border-color: #4a6fa5;
}

#editor p {
    margin-bottom: 0.5em;
}

#editor [style*="font-style: italic"],
#editor i,
#editor em {
    color: #f0c040;
}

/* ===== BUTTONS ===== */
button {
    background: #2a2a3e;
    color: #e0e0e0;
    border: 1px solid #444;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

button:hover {
    background: #3a3a5e;
}

button.primary {
    background: #4a6fa5;
    border-color: #4a6fa5;
    color: #fff;
    font-weight: 600;
}

button.primary:hover {
    background: #5a8fc5;
}

/* ===== PROMPTER VIEW ===== */
#prompter-view {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #000;
}

/* Control bar */
#control-bar {
    display: flex;
    align-items: center;
    padding: 0;
    background: #111;
    border-bottom: 1px solid #333;
    z-index: 10;
    transition: opacity 0.3s;
}

#btn-toggle-controls {
    background: none;
    border: none;
    color: #888;
    font-size: 14px;
    padding: 6px 10px;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s;
}
#btn-toggle-controls:hover {
    color: #fff;
}
#btn-toggle-controls.collapsed {
    transform: rotate(-90deg);
}

#control-bar-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 8px;
    flex-wrap: nowrap;
    overflow: hidden;
    transition: max-height 0.3s, opacity 0.3s, padding 0.3s;
    max-height: 50px;
}
#control-bar-controls.collapsed {
    max-height: 0;
    opacity: 0;
    padding: 0 8px;
}

#control-bar label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.control-group select {
    background: #222;
    color: #ddd;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
}

.control-group input[type="range"] {
    width: 60px;
    accent-color: #4a6fa5;
}

.control-group input[type="color"] {
    width: 28px;
    height: 28px;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 0;
    cursor: pointer;
    background: none;
}

.control-group input.spinner {
    width: 50px;
    background: #222;
    color: #ddd;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 2px 4px;
    font-size: 11px;
    text-align: center;
}

.control-group input.spinner::-webkit-inner-spin-button,
.control-group input.spinner::-webkit-outer-spin-button {
    opacity: 1;
}

.control-group span {
    font-size: 11px;
    color: #888;
    min-width: 30px;
}

/* Prompter content area */
#prompter-container {
    flex: 1;
    overflow: hidden;
    position: relative;
}

#prompter-content {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    padding: 40px 0;
    color: #fff;
    font-size: 40px;
    line-height: 1.6;
    /* Start with content below the visible area */
    top: 100%;
    outline: none;
}

#prompter-content[contenteditable="true"] {
    cursor: text;
}

#prompter-content[contenteditable="false"] {
    cursor: default;
}

#prompter-content.mirrored {
    transform: translateX(-50%) scaleX(-1);
}

/* Dim bracketed text */
#prompter-content .stage-direction {
    color: #555;
    font-style: italic;
    font-size: 0.7em;
}

/* Highlight riff/italic sections */
#prompter-content .riff-section {
    border-left: 3px solid #f0c040;
    padding-left: 12px;
    color: #f0c040;
}

/* Current position highlight during listen mode */
#prompter-content .current-position {
    background: rgba(74, 111, 165, 0.3);
    border-radius: 4px;
}

/* Dim already-read text above guide line */
#prompter-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 30%;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.7) 0%,
        rgba(0, 0, 0, 0.5) 60%,
        rgba(0, 0, 0, 0.2) 90%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 5;
}

/* Reading guide line */
#prompter-container::after {
    content: '';
    position: absolute;
    top: 30%;
    left: 10%;
    right: 10%;
    height: 2px;
    background: linear-gradient(
        to right,
        transparent,
        rgba(74, 111, 165, 0.6) 20%,
        rgba(74, 111, 165, 0.6) 80%,
        transparent
    );
    pointer-events: none;
    z-index: 5;
    box-shadow: 0 0 8px rgba(74, 111, 165, 0.3);
}

/* Transport bar */
#transport-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #111;
    border-top: 1px solid #333;
    z-index: 10;
}

.mode-btn {
    padding: 8px 20px;
    font-size: 14px;
}

.mode-btn.active {
    background: #4a6fa5;
    border-color: #4a6fa5;
    color: #fff;
}

.transport-btn {
    padding: 8px 20px;
    font-size: 14px;
}

.transport-spacer {
    flex: 1;
}

/* Listen mode indicator */
#listen-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 16px;
}

#listen-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e74c3c;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

#listen-text {
    font-size: 13px;
    color: #888;
}

#listen-cost {
    font-size: 11px;
    color: #666;
    font-family: monospace;
}

/* Speech engine selector in transport bar */
.listen-option select {
    max-width: 200px;
}

.listen-option label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Mode toggle switch */
.mode-toggle-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mode-label {
    font-size: 12px;
    color: #888;
    min-width: 45px;
    text-align: center;
    transition: color 0.3s, font-weight 0.3s;
}

.mode-label.active {
    color: #4a6fa5;
    font-weight: 600;
}

.mode-label#mode-scroll-label.active {
    color: #4a6fa5;
}

.mode-label#mode-listen-label.active {
    color: #e74c3c;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #4a6fa5;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #e74c3c;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* ===== FULLSCREEN ADJUSTMENTS ===== */
:fullscreen #control-bar,
:-webkit-full-screen #control-bar {
    opacity: 0;
    transition: opacity 0.3s;
}

:fullscreen #control-bar:hover,
:-webkit-full-screen #control-bar:hover {
    opacity: 1;
}

:fullscreen #transport-bar,
:-webkit-full-screen #transport-bar {
    opacity: 0;
    transition: opacity 0.3s;
}

:fullscreen #transport-bar:hover,
:-webkit-full-screen #transport-bar:hover {
    opacity: 1;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #111;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* API Keys Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: #1a1a2e;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 24px;
    width: 420px;
    max-width: 90vw;
}

.modal-content h2 {
    font-size: 18px;
    font-weight: 400;
    color: #fff;
    margin-bottom: 12px;
}

.modal-content label {
    display: block;
    font-size: 13px;
    color: #aaa;
    margin-top: 12px;
    margin-bottom: 4px;
}

.modal-hint {
    font-size: 11px;
    color: #666;
}

.modal-content input[type="password"],
.modal-content input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    background: #222;
    border: 1px solid #444;
    border-radius: 6px;
    color: #ddd;
    font-size: 13px;
    font-family: monospace;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

/* Progress bar */
#progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #222;
    z-index: 10;
}

#progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(to right, #4a6fa5, #5a8fc5);
    transition: width 0.3s ease;
}

/* Timer display */
#timer-display {
    font-size: 11px;
    color: #888;
    font-family: monospace;
    margin-left: 8px;
    white-space: nowrap;
}

/* Countdown overlay */
#countdown-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    font-size: 120px;
    font-weight: 200;
    color: #fff;
    font-family: 'Segoe UI', Arial, sans-serif;
}

#countdown-overlay.fade {
    animation: countFade 0.8s ease-out;
}

@keyframes countFade {
    0% { transform: scale(1.5); opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { transform: scale(1); opacity: 0.6; }
}

/* Keyboard hints overlay */
#keyboard-hints {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid #444;
    border-radius: 12px;
    padding: 24px 32px;
    z-index: 50;
    font-size: 14px;
    color: #ccc;
    line-height: 2;
    min-width: 280px;
}

#keyboard-hints h3 {
    font-size: 16px;
    font-weight: 400;
    color: #fff;
    margin-bottom: 8px;
    text-align: center;
}

#keyboard-hints kbd {
    display: inline-block;
    background: #333;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 1px 6px;
    font-family: monospace;
    font-size: 12px;
    color: #fff;
    min-width: 24px;
    text-align: center;
}

#keyboard-hints .hint-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

#keyboard-hints .hint-key {
    min-width: 80px;
    text-align: right;
}

/* Save/load scripts */
.script-list {
    max-height: 200px;
    overflow-y: auto;
    margin: 8px 0;
}

.script-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border: 1px solid #333;
    border-radius: 4px;
    margin-bottom: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.script-item:hover {
    background: #2a2a3e;
}

.script-item .script-name {
    flex: 1;
    color: #ddd;
}

.script-item .script-date {
    font-size: 11px;
    color: #666;
    margin: 0 8px;
}

.script-item .script-delete {
    color: #888;
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
}

.script-item .script-delete:hover {
    color: #e74c3c;
}

/* Google Doc linked badge */
.gdoc-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 12px;
    color: #8f8;
    background: rgba(80, 200, 80, 0.12);
    border: 1px solid rgba(80, 200, 80, 0.3);
    border-radius: 12px;
    cursor: pointer;
    user-select: none;
    transition: background 0.3s, color 0.3s;
}

.gdoc-badge:hover {
    background: rgba(80, 200, 80, 0.25);
}

.gdoc-badge.gdoc-synced {
    color: #fff;
    background: rgba(80, 200, 80, 0.4);
}

/* Electron-only elements (hidden in browser, shown in Electron) */
.electron-only {
    display: none;
}
.electron-show {
    display: inline-block !important;
    background: #e74c3c;
    color: #fff;
    border: none;
    padding: 4px 10px;
    font-size: 14px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: auto;
}
.electron-show:hover {
    background: #c0392b;
}

/* Electron frameless window drag regions */
.edit-header, #control-bar, #drag-bar {
    -webkit-app-region: drag;
}

#drag-bar {
    display: none;
    height: 8px;
    width: 100%;
    cursor: move;
}
.edit-header button, .edit-header select, .edit-header input,
#control-bar button, #control-bar select, #control-bar input {
    -webkit-app-region: no-drag;
}

/* Version stamp */
#version-stamp {
    position: fixed;
    bottom: 4px;
    right: 8px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.15);
    font-family: monospace;
    pointer-events: none;
    z-index: 1000;
}
