/* ===================================
   Voice Runtime Test Client
   A dark, terminal-inspired aesthetic
   =================================== */

:root {
    /* Dark theme inspired by Dracula/Monokai */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-elevated: #30363d;
    
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    
    --accent-cyan: #58a6ff;
    --accent-green: #3fb950;
    --accent-orange: #d29922;
    --accent-red: #f85149;
    --accent-purple: #a371f7;
    --accent-pink: #db61a2;
    
    --border-color: #30363d;
    --border-glow: rgba(88, 166, 255, 0.3);
    
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    --shadow-glow: 0 0 20px rgba(88, 166, 255, 0.15);
    --transition-fast: 150ms ease;
    --transition-medium: 250ms ease;
}

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

html, body {
    height: 100%;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    
    /* Subtle grid pattern */
    background-image: 
        linear-gradient(rgba(88, 166, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(88, 166, 255, 0.02) 1px, transparent 1px);
    background-size: 40px 40px;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--accent-cyan);
    filter: drop-shadow(0 0 8px rgba(88, 166, 255, 0.4));
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    font-weight: 500;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: var(--transition-medium);
}

.connection-status.connected .status-dot {
    background: var(--accent-green);
    box-shadow: 0 0 12px var(--accent-green);
    animation: pulse 2s infinite;
}

.connection-status.connecting .status-dot {
    background: var(--accent-orange);
    box-shadow: 0 0 12px var(--accent-orange);
    animation: pulse 0.5s infinite;
}

.connection-status.error .status-dot {
    background: var(--accent-red);
    box-shadow: 0 0 12px var(--accent-red);
}

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

/* Main Content */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr;
    gap: 20px;
    padding: 20px 0;
    overflow: hidden;
}

/* Section Headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.section-header h2 {
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

/* Config Section */
.config-section {
    grid-column: 1;
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    overflow: hidden;
}

.server-url {
    display: flex;
    align-items: center;
    gap: 12px;
}

.server-url label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.server-url input {
    flex: 1;
    padding: 8px 12px;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    outline: none;
    transition: var(--transition-fast);
}

.server-url input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

/* JSON Editor */
.json-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-top: 16px;
    overflow: hidden;
}

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

.editor-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

#jsonBody {
    flex: 1;
    width: 100%;
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.6;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--accent-green);
    resize: none;
    outline: none;
    transition: var(--transition-fast);
}

#jsonBody:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    outline: none;
}

.btn-icon {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    color: white;
    box-shadow: 0 4px 16px rgba(88, 166, 255, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(88, 166, 255, 0.4);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

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

.btn-danger {
    background: var(--accent-red);
    color: white;
    box-shadow: 0 4px 16px rgba(248, 81, 73, 0.3);
}

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

.btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

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

.btn-small {
    padding: 6px 12px;
    font-size: 0.8125rem;
}

.btn-small svg {
    width: 14px;
    height: 14px;
}

.controls {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

/* Microphone toggle button */
.mic-toggle {
    min-width: 140px;
}

.mic-toggle .mic-icon {
    display: none;
}

.mic-toggle[data-muted="false"] .mic-on {
    display: inline-block;
}

.mic-toggle[data-muted="true"] .mic-off {
    display: inline-block;
}

.mic-toggle[data-muted="true"] {
    color: var(--accent-red);
    border-color: rgba(248, 81, 73, 0.6);
    box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.10);
}

/* Audio Section */
.audio-section {
    grid-column: 2;
    grid-row: 1;
}

.audio-visualizer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    height: 100%;
}

.visualizer-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.panel-header svg {
    width: 16px;
    height: 16px;
    color: var(--accent-cyan);
}

.output-panel .panel-header svg {
    color: var(--accent-green);
}

.visualizer-panel canvas {
    flex: 1;
    width: 100%;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
}

.audio-level {
    height: 4px;
    background: var(--bg-primary);
    border-radius: 2px;
    margin-top: 12px;
    overflow: hidden;
}

.level-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
    border-radius: 2px;
    transition: width 50ms linear;
}

.level-bar.output {
    background: linear-gradient(90deg, var(--accent-green), var(--accent-cyan));
}

/* Log Section */
.log-section {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    overflow: hidden;
}

.chat-compose {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.chat-compose input {
    flex: 1;
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    outline: none;
    transition: var(--transition-fast);
}

.chat-compose input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.chat-compose button[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.log-container {
    flex: 1;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.8;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.log-entry {
    display: flex;
    gap: 12px;
    padding: 2px 0;
}

.log-time {
    color: var(--text-muted);
    flex-shrink: 0;
}

.log-message {
    word-break: break-word;
}

.log-entry.info .log-message {
    color: var(--text-secondary);
}

.log-entry.success .log-message {
    color: var(--accent-green);
}

.log-entry.warning .log-message {
    color: var(--accent-orange);
}

.log-entry.error .log-message {
    color: var(--accent-red);
}

.log-entry.data .log-message {
    color: var(--accent-cyan);
}

/* Scrollbar */
.log-container::-webkit-scrollbar {
    width: 8px;
}

.log-container::-webkit-scrollbar-track {
    background: transparent;
}

.log-container::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 4px;
}

.log-container::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

/* Footer */
.footer {
    padding: 16px 0;
    border-top: 1px solid var(--border-color);
}

.stats {
    display: flex;
    justify-content: center;
    gap: 48px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent-cyan);
}

/* Responsive */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
    }
    
    .config-section {
        grid-column: 1;
        grid-row: 1;
        max-height: 400px;
    }
    
    .audio-section {
        grid-column: 1;
        grid-row: 2;
    }
    
    .log-section {
        grid-column: 1;
        grid-row: 3;
    }
}

@media (max-width: 640px) {
    .app-container {
        padding: 0 16px;
    }
    
    .audio-visualizer {
        grid-template-columns: 1fr;
    }
    
    .stats {
        gap: 24px;
    }
}

