/* ===================================================================
   Turkish Speech-to-Speech Assistant — Styles
   =================================================================== */

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-surface: #252540;
    --text-primary: #e8e8f0;
    --text-secondary: #8888a0;
    --accent-green: #00c853;
    --accent-red: #ff1744;
    --accent-yellow: #ffc107;
    --accent-blue: #448aff;
    --accent-gray: #555;
    --user-bubble: #1b3a2e;
    --assistant-bubble: #1e2050;
    --echo-accent: #7c4dff;
    --border-radius: 10px;
    --transition-speed: 0.2s;
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    touch-action: manipulation;
}

body {
    display: flex;
    flex-direction: column;
}

/* --- Header --- */

#header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    z-index: 10;
}

#header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

#header h1 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

#session-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot.connected { background-color: var(--accent-green); }
.dot.disconnected { background-color: var(--accent-red); }
.dot.processing { background-color: var(--accent-yellow); animation: pulse 1s infinite; }
.dot.worker-offline { background-color: var(--accent-gray); }

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

/* --- Toggle switch --- */

.toggle-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    width: 36px;
    height: 20px;
    background: var(--accent-gray);
    border-radius: 10px;
    position: relative;
    transition: background var(--transition-speed);
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform var(--transition-speed);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--echo-accent);
}

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

.toggle-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color var(--transition-speed);
}

.toggle-switch input:checked ~ .toggle-text {
    color: var(--echo-accent);
}

/* --- Status bar --- */

#status-bar {
    padding: 5px 16px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    flex-shrink: 0;
    transition: background-color var(--transition-speed);
}

#status-bar.ready { background-color: #1b5e20; }
#status-bar.connected { background-color: #1b5e20; }
#status-bar.processing { background-color: #e65100; }
#status-bar.disconnected { background-color: #b71c1c; }
#status-bar.worker-offline { background-color: #424242; }
#status-bar.queue-full { background-color: #f57f17; }
#status-bar.recording { background-color: #c62828; }

/* --- Chat area --- */

#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    scroll-behavior: smooth;
}

#chat-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 600px;
    margin: 0 auto;
}

#empty-state {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 40px 20px;
}

.chat-turn {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-width: 85%;
    animation: fadeIn 0.25s ease-in;
}

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

.chat-turn.user { align-self: flex-end; }
.chat-turn.assistant { align-self: flex-start; }

.chat-bubble {
    padding: 8px 12px;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    line-height: 1.4;
    word-break: break-word;
}

.chat-turn.user .chat-bubble {
    background-color: var(--user-bubble);
    border-bottom-right-radius: 3px;
}

.chat-turn.assistant .chat-bubble {
    background-color: var(--assistant-bubble);
    border-bottom-left-radius: 3px;
}

.chat-turn .role-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.06em;
}

.chat-turn.user .role-label { text-align: right; }

.chat-turn .timestamp {
    font-size: 0.6rem;
    color: var(--text-secondary);
}

.chat-turn.user .timestamp { text-align: right; }

.chat-turn audio {
    width: 100%;
    max-width: 280px;
    height: 32px;
    margin-top: 4px;
}

.processing-placeholder {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.8rem;
}

/* --- Bottom controls --- */

#controls {
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 10px 16px 16px;
}

#visualizer-container {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

#visualizer {
    width: 100%;
    max-width: 600px;
    height: 48px;
    background-color: var(--bg-primary);
    border-radius: 6px;
}

/* --- Push-to-talk button --- */

#ptt-container {
    display: flex;
    justify-content: center;
}

#ptt-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 320px;
    height: 56px;
    border-radius: 28px;
    border: 2px solid var(--accent-green);
    background-color: rgba(0, 200, 83, 0.1);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    transition: all var(--transition-speed);
    outline: none;
}

#ptt-button svg {
    flex-shrink: 0;
}

#ptt-button:disabled {
    border-color: var(--accent-gray);
    background-color: rgba(85, 85, 85, 0.1);
    color: var(--text-secondary);
    cursor: not-allowed;
}

#ptt-button.recording {
    border-color: var(--accent-red);
    background-color: rgba(255, 23, 68, 0.2);
    transform: scale(1.02);
    box-shadow: 0 0 20px rgba(255, 23, 68, 0.2);
}

#ptt-button:not(:disabled):not(.recording):hover {
    background-color: rgba(0, 200, 83, 0.2);
}

#ptt-button:not(:disabled):not(.recording):active {
    transform: scale(0.98);
}

/* --- Reconnection overlay --- */

#reconnect-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

#reconnect-overlay.hidden {
    display: none;
}

#reconnect-content {
    text-align: center;
    padding: 28px 36px;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

#reconnect-content p {
    margin-top: 10px;
    font-size: 0.9rem;
}

#reconnect-timer {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Responsive --- */

@media (max-width: 480px) {
    #header h1 { font-size: 0.9rem; }
    #ptt-button { max-width: 100%; height: 52px; font-size: 0.85rem; }
    .chat-turn { max-width: 92%; }
}
