/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.08);
    --border-active: rgba(99, 102, 241, 0.4);
    --text-primary: #f1f1f4;
    --text-secondary: #8b8b9e;
    --text-muted: #55556a;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===== App Layout ===== */
.app {
    max-width: 720px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
.header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(10, 10, 15, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

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

.logo-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-radius: 10px;
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo-badge {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 2px 6px;
    background: var(--danger);
    color: white;
    border-radius: 4px;
    animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.language-select {
    appearance: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 32px 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: border-color var(--transition);
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b8b9e' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.language-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* ===== Main ===== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
}

/* ===== Status Bar ===== */
.status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background var(--transition);
    flex-shrink: 0;
}

.status-bar.recording .status-dot {
    background: var(--danger);
    box-shadow: 0 0 8px var(--danger);
    animation: dot-blink 1s ease-in-out infinite;
}

.status-bar.connected .status-dot {
    background: var(--success);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

@keyframes dot-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ===== Transcription ===== */
.transcription-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    min-height: 300px;
}

.transcription-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.transcription-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.btn-clear {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-clear:hover {
    background: var(--bg-card-hover);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.transcription-area {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    gap: 12px;
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
}

.empty-sub {
    font-size: 12px;
    opacity: 0.6;
}

.segment {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    animation: segment-in 0.3s ease-out;
}

.segment:last-child {
    border-bottom: none;
}

@keyframes segment-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.segment-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.segment-lang {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--accent-glow);
    color: var(--accent-light);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.segment-time {
    font-size: 11px;
    color: var(--text-muted);
}

.segment-text {
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
}

/* ===== Mic Button ===== */
.mic-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
}

.mic-btn {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mic-btn:hover {
    border-color: var(--accent);
    color: var(--accent-light);
    background: rgba(99, 102, 241, 0.08);
    transform: scale(1.05);
}

.mic-btn.recording {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.mic-btn.recording:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--danger);
    color: var(--danger);
}

.mic-icon {
    position: relative;
    z-index: 2;
}

.mic-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(1);
    background: transparent;
    pointer-events: none;
}

.mic-btn.recording .mic-pulse {
    animation: pulse-ring 1.5s ease-out infinite;
    background: rgba(239, 68, 68, 0.2);
}

@keyframes pulse-ring {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
    100% { transform: translate(-50%, -50%) scale(1.8); opacity: 0; }
}

.mic-label {
    font-size: 13px;
    color: var(--text-muted);
    transition: color var(--transition);
}

.mic-label.recording {
    color: var(--danger);
    font-weight: 500;
}

/* ===== Stats ===== */
.stats {
    display: flex;
    gap: 1px;
    background: var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.stat-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    background: var(--bg-card);
}

.stat-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.stat-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ===== Scrollbar ===== */
.transcription-area::-webkit-scrollbar {
    width: 4px;
}

.transcription-area::-webkit-scrollbar-track {
    background: transparent;
}

.transcription-area::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .app {
        max-width: 100%;
    }

    .main {
        padding: 12px;
    }

    .mic-btn {
        width: 64px;
        height: 64px;
    }

    .segment-text {
        font-size: 15px;
    }
}
