/* CSS Variables for theming */
:root {
    --text-color: #ffffff;
    --bg-color: #000000;
    --font-size: 32px;
    --font-family: system-ui, sans-serif;
    --accent-color: #4a9eff;
    --header-bg: #1a1a1a;
    --panel-bg: #2a2a2a;
}

/* Reset and base styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    width: 100%;
}

body {
    background: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    font-size: var(--font-size);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
header {
    background: var(--header-bg);
    padding: 0.5rem 1rem;
    flex-shrink: 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

header h1 {
    font-size: 1.2rem;
    font-weight: normal;
    opacity: 0.8;
}

.controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

#feed-selector {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
    border-radius: 4px;
    border: 1px solid #444;
    background: #333;
    color: white;
}

#settings-btn {
    padding: 0.4rem 0.6rem;
    font-size: 1.2rem;
    border-radius: 4px;
    border: 1px solid #444;
    background: #333;
    color: white;
    cursor: pointer;
}

#settings-btn:hover {
    background: #444;
}

#connection-status {
    text-align: center;
    font-size: 0.75rem;
    padding: 0.2rem;
    margin-top: 0.3rem;
}

.status-connected {
    color: #4caf50;
}

.status-disconnected {
    color: #f44336;
}

.status-connecting {
    color: #ff9800;
}

/* Main caption display */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

#caption-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 2rem;
    scroll-behavior: smooth;
}

#caption-scroll {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    max-width: 1200px;
    margin: 0 auto;
}

.caption-line {
    line-height: 1.4;
    word-wrap: break-word;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    animation: fadeIn 0.3s ease;
}

.caption-line:first-child {
    font-weight: 500;
}

.caption-line.interim {
    opacity: 0.6;
    font-style: italic;
    border-bottom: none;
}

.caption-time {
    font-size: 0.5em;
    opacity: 0.5;
    margin-right: 0.5em;
}

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

#caption-scroll:empty::before {
    content: "Waiting for captions...";
    opacity: 0.4;
    font-style: italic;
    text-align: center;
    padding: 2rem;
}

/* Return to live button */
#return-to-live {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    border-radius: 25px;
    border: none;
    background: var(--accent-color);
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 100;
    transition: all 0.2s ease;
}

#return-to-live:hover {
    background: #3a8aef;
    transform: translateX(-50%) scale(1.05);
}

#return-to-live.hidden {
    display: none;
}

/* Settings panel */
#settings-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100%;
    background: var(--panel-bg);
    padding: 1rem;
    z-index: 1000;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

#settings-panel:not(.hidden) {
    transform: translateX(0);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #444;
}

.settings-header h2 {
    font-size: 1.1rem;
    font-weight: normal;
}

#close-settings {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
}

.setting-group {
    margin-bottom: 1rem;
}

.setting-group label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    opacity: 0.9;
}

.setting-group select,
.setting-group input[type="range"] {
    width: 100%;
}

.setting-group select {
    padding: 0.4rem;
    border-radius: 4px;
    border: 1px solid #444;
    background: #333;
    color: white;
    font-size: 0.9rem;
}

.setting-group input[type="color"] {
    width: 100%;
    height: 40px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.setting-group input[type="checkbox"] {
    margin-right: 0.5rem;
}

.settings-actions {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #444;
}

.settings-actions button {
    width: 100%;
    padding: 0.6rem;
    border-radius: 4px;
    border: 1px solid #444;
    background: #333;
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
}

.settings-actions button:hover {
    background: #444;
}

/* Overlay */
#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.hidden {
    display: none !important;
}

/* High contrast mode */
body.high-contrast {
    --text-color: #ffff00;
    --bg-color: #000000;
}

body.high-contrast #current-caption {
    text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
}

/* Responsive */
@media (max-width: 600px) {
    header h1 {
        font-size: 1rem;
    }

    #caption-display {
        padding: 1rem;
    }

    #settings-panel {
        width: 100%;
    }
}

