/* CSS Variables */
:root {
    --background: #0f172a;
    --foreground: #f8fafc;
    --card: #1e293b;
    --card-hover: #334155;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --secondary: #475569;
    --muted: #64748b;
    --border: #334155;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius: 0.5rem;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--background);
    color: var(--foreground);
    line-height: 1.5;
    min-height: 100vh;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.header {
    background: linear-gradient(to bottom, var(--card), transparent);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.header-subtitle {
    color: var(--muted);
    font-size: 0.875rem;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--card);
    border: 1px solid var(--border);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
}

.status-badge.connected .status-dot {
    background: var(--success);
    animation: pulse 2s infinite;
}

.status-badge.connecting .status-dot {
    background: var(--warning);
    animation: pulse 1s infinite;
}

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

/* Main Content */
.main-content {
    padding: 1.5rem 1rem;
}

.layout {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1fr;
}

@media (min-width: 1200px) {
    .layout {
        grid-template-columns: 1fr 400px;
    }
}

/* Cards */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.card h3 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 1rem;
}

/* Preview Panel */
.preview-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.panel-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.preview-controls {
    display: flex;
    gap: 0.5rem;
}

.preview-controls input {
    width: 300px;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--foreground);
    font-size: 0.875rem;
}

.preview-container {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    height: 600px;
}

.preview-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Voice Panel */
.voice-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Voice Card */
.voice-card {
    text-align: center;
}

.voice-visualizer {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

#visualizer-bars {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 100%;
}

#visualizer-bars span {
    width: 4px;
    height: 20%;
    background: var(--primary);
    border-radius: 2px;
    transition: height 0.1s ease;
}

#visualizer-bars.active span {
    animation: visualize 0.5s ease infinite;
}

#visualizer-bars.active span:nth-child(1) { animation-delay: 0s; }
#visualizer-bars.active span:nth-child(2) { animation-delay: 0.1s; }
#visualizer-bars.active span:nth-child(3) { animation-delay: 0.2s; }
#visualizer-bars.active span:nth-child(4) { animation-delay: 0.3s; }
#visualizer-bars.active span:nth-child(5) { animation-delay: 0.4s; }
#visualizer-bars.active span:nth-child(6) { animation-delay: 0.3s; }
#visualizer-bars.active span:nth-child(7) { animation-delay: 0.2s; }
#visualizer-bars.active span:nth-child(8) { animation-delay: 0.1s; }
#visualizer-bars.active span:nth-child(9) { animation-delay: 0s; }
#visualizer-bars.active span:nth-child(10) { animation-delay: 0.1s; }

@keyframes visualize {
    0%, 100% { height: 20%; }
    50% { height: 80%; }
}

/* Microphone Button */
.mic-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem 2rem;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    background: var(--card);
    color: var(--foreground);
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0 auto 1rem;
}

.mic-button:hover:not(:disabled) {
    background: var(--card-hover);
    border-color: var(--primary);
}

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

.mic-button.recording {
    background: var(--danger);
    border-color: var(--danger);
    animation: recording-pulse 1.5s infinite;
}

@keyframes recording-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 20px rgba(239, 68, 68, 0); }
}

.mic-icon {
    width: 2rem;
    height: 2rem;
}

#mic-text {
    font-size: 0.875rem;
    font-weight: 500;
}

/* Transcript */
.transcript-container {
    text-align: left;
}

.transcript-container label {
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.partial-transcript {
    min-height: 3rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--primary);
    font-style: italic;
}

/* History Card */
.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.history-header h3 {
    margin-bottom: 0;
}

.command-history {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.command-item {
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.command-item .time {
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.command-item .text {
    color: var(--foreground);
}

.command-item .status {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.command-item .status.sent {
    color: var(--success);
}

.command-item .status.error {
    color: var(--danger);
}

.empty-state {
    color: var(--muted);
    font-size: 0.875rem;
    text-align: center;
    padding: 2rem;
}

/* Manual Input */
.manual-input {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.manual-input textarea {
    width: 100%;
    min-height: 80px;
    padding: 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
    color: var(--foreground);
    font-family: inherit;
    font-size: 0.875rem;
    resize: vertical;
}

.manual-input textarea:focus {
    outline: none;
    border-color: var(--primary);
}

/* Settings */
.settings-group {
    margin-bottom: 1rem;
}

.settings-group:last-child {
    margin-bottom: 0;
}

.settings-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--foreground);
    margin-bottom: 0.5rem;
}

.settings-group input[type="text"] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
    color: var(--foreground);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.settings-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

.settings-group input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    border: none;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: var(--muted);
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--card-hover);
    color: var(--foreground);
}

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

::-webkit-scrollbar-track {
    background: var(--card);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}
