/* Shared styles for translation app */

:root {
    --font-scale: 1.0;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #1a1a2e;
    color: #eee;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

h1 {
    font-size: 1.8rem;
    margin-bottom: 10px;
    color: #fff;
}

.subtitle {
    color: #888;
    margin-bottom: 30px;
}

/* Status indicators */
.status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 10px 20px;
    background: #16213e;
    border-radius: 8px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #666;
    transition: background 0.3s;
}

.status-dot.connected {
    background: #4ade80;
    box-shadow: 0 0 10px #4ade80;
}

.status-dot.processing {
    background: #fbbf24;
    box-shadow: 0 0 10px #fbbf24;
    animation: pulse 1s infinite;
}

.status-dot.error {
    background: #f87171;
    box-shadow: 0 0 10px #f87171;
}

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

.status-text {
    font-size: 0.9rem;
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
    width: 100%;
    max-width: 400px;
}

select {
    padding: 12px 15px;
    font-size: 1rem;
    border: 2px solid #333;
    border-radius: 8px;
    background: #16213e;
    color: #fff;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: #6366f1;
}

button {
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-start {
    background: #4ade80;
    color: #1a1a2e;
}

.btn-start:hover:not(:disabled) {
    background: #22c55e;
    transform: translateY(-2px);
}

.btn-stop {
    background: #f87171;
    color: #fff;
}

.btn-stop:hover:not(:disabled) {
    background: #ef4444;
    transform: translateY(-2px);
}

.btn-flush {
    background: #6366f1;
    color: #fff;
}

.btn-flush:hover:not(:disabled) {
    background: #4f46e5;
    transform: translateY(-2px);
}

.btn-flush.active {
    background: #a5b4fc;
    color: #1a1a2e;
}

/* Waveform visualization */
.waveform-container {
    width: 100%;
    max-width: 600px;
    height: 100px;
    background: #16213e;
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
}

canvas {
    width: 100%;
    height: 100%;
}

/* Listener count */
.listener-count {
    font-size: 1.2rem;
    color: #6366f1;
    margin-bottom: 20px;
}

.latency {
    display: inline-block;
    margin-left: 10px;
    font-size: 0.9rem;
    color: #888;
}

.latency-ok    { color: #4ade80; }
.latency-med   { color: #fbbf24; }
.latency-high  { color: #f87171; }

/* Subtitle display */
.subtitles {
    width: 100%;
    max-width: 800px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.subtitle-box {
    padding: 20px;
    background: #16213e;
    border-radius: 12px;
    text-align: center;
}

.subtitle-box.spanish {
    border: 2px solid #6366f1;
}

.subtitle-box h2 {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.subtitle-box .text {
    font-size: 1.8rem;
    line-height: 1.4;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.subtitle-box.spanish .text {
    font-size: calc(2.2rem * var(--font-scale));
    color: #fff;
}

.subtitle-box.english .text {
    font-size: calc(1.2rem * var(--font-scale));
    color: #aaa;
}

/* Transcript container */
.transcript-container {
    width: 100%;
    max-width: 600px;
    margin-bottom: 20px;
}

.transcript-container h2 {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.transcript-box {
    background: #16213e;
    border-radius: 8px;
    padding: 15px;
    height: 200px;
    overflow-y: auto;
    margin-bottom: 10px;
    border: 1px solid #333;
}

.transcript-box p {
    margin-bottom: 8px;
    line-height: 1.5;
}

.transcript-box .transcript-placeholder {
    color: #666;
    font-style: italic;
}

.transcript-box .transcript-entry {
    color: #eee;
    border-bottom: 1px solid #333;
    padding-bottom: 8px;
}

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

.transcript-box .transcript-time {
    color: #6366f1;
    font-size: 0.8rem;
    margin-right: 8px;
}

.transcript-box .transcript-entry {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 8px 0;
}

.transcript-box .transcript-time {
    flex-shrink: 0;
    padding-top: 2px;
}

.transcript-box .transcript-text {
    flex: 1;
    min-width: 0;
}

.transcript-box .transcript-spanish {
    color: #fff;
    font-size: 1rem;
    line-height: 1.4;
}

.transcript-box .transcript-english {
    color: #888;
    font-size: 0.85rem;
    line-height: 1.4;
    margin-top: 2px;
}

/* Listener control bar */
.listener-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 20px;
    max-width: 800px;
    width: 100%;
}

.ctrl-btn {
    padding: 8px 14px;
    font-size: 0.9rem;
    font-weight: 500;
    background: #16213e;
    color: #ccc;
    border: 1px solid #333;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.ctrl-btn:hover:not(:disabled) {
    background: #1e2a4a;
    border-color: #6366f1;
    color: #fff;
}

.ctrl-btn.active {
    background: #6366f1;
    color: #fff;
    border-color: #6366f1;
}

select.ctrl-btn {
    appearance: none;
    -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #888 50%),
                      linear-gradient(135deg, #888 50%, transparent 50%);
    background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    padding-right: 26px;
}

/* Layout modes (data-layout on body) — hero | history | both */
body[data-layout="hero"]    .history-section { display: none; }
body[data-layout="history"] .hero-section    { display: none; }

/* Partial transcript line on source */
.partial-transcript {
    min-height: 1.2em;
    margin: 6px 2px 10px;
    color: #6366f1;
    font-style: italic;
    opacity: 0.85;
}

.btn-clear {
    background: #333;
    color: #aaa;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-clear:hover {
    background: #444;
    color: #fff;
}

/* Info box */
.info {
    margin-top: auto;
    padding-top: 30px;
    text-align: center;
    color: #666;
    font-size: 0.85rem;
}

.info a {
    color: #6366f1;
    text-decoration: none;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    body {
        padding: 15px;
    }

    h1 {
        font-size: 1.4rem;
    }

    .subtitle-box .text {
        font-size: 1.4rem;
    }

    .subtitle-box.spanish .text {
        font-size: 1.8rem;
    }

    .subtitle-box.english .text {
        font-size: 1rem;
    }
}
