/* ==================== CSS Variables ==================== */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(20, 20, 30, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.03);
    
    --text-primary: #f0f0f5;
    --text-secondary: #8888a0;
    --text-muted: #555566;
    
    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.4);
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.4);
    
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.4);
    
    --warning: #f59e0b;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(99, 102, 241, 0.3);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px var(--accent-glow);
    
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Background gradient */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(129, 140, 248, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(16, 185, 129, 0.05) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

/* ==================== Layout ==================== */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ==================== Header ==================== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    margin-bottom: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.logo-icon {
    width: 28px;
    height: 28px;
    color: var(--accent-primary);
}

.auth-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.auth-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 500;
}

.auth-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background var(--transition-base);
}

.auth-badge.connected .auth-dot {
    background: var(--success);
    box-shadow: 0 0 8px var(--success-glow);
}

.auth-badge.disconnected .auth-dot {
    background: var(--warning);
}

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    outline: none;
}

.btn:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

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

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

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: var(--shadow-sm), 0 0 20px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), 0 0 30px var(--accent-glow);
}

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

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

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-primary);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: white;
    box-shadow: var(--shadow-sm), 0 0 20px var(--danger-glow);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), 0 0 30px var(--danger-glow);
}

/* ==================== Main Content ==================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

/* ==================== Voice Orb ==================== */
.orb-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem 0;
}

.voice-orb {
    position: relative;
    width: 180px;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.orb-ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid var(--accent-primary);
    opacity: 0.2;
    transition: all var(--transition-slow);
}

.ring-1 {
    width: 100%;
    height: 100%;
    animation: pulse-ring 3s ease-in-out infinite;
}

.ring-2 {
    width: 130%;
    height: 130%;
    animation: pulse-ring 3s ease-in-out infinite 0.5s;
}

.ring-3 {
    width: 160%;
    height: 160%;
    animation: pulse-ring 3s ease-in-out infinite 1s;
}

@keyframes pulse-ring {
    0%, 100% {
        transform: scale(1);
        opacity: 0.2;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.1;
    }
}

.orb-core {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
    transition: all var(--transition-base);
}

.mic-icon {
    width: 36px;
    height: 36px;
    color: white;
}

/* Orb States */
.voice-orb.idle .orb-core {
    background: var(--bg-secondary);
    box-shadow: var(--shadow-md);
}

.voice-orb.idle .orb-ring {
    border-color: var(--text-muted);
}

.voice-orb.listening .orb-core {
    background: linear-gradient(135deg, var(--success), #059669);
    box-shadow: 0 0 40px var(--success-glow);
}

.voice-orb.listening .orb-ring {
    border-color: var(--success);
    animation-duration: 1.5s;
}

.voice-orb.speaking .orb-core {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    animation: speaking-pulse 0.8s ease-in-out infinite;
}

.voice-orb.speaking .orb-ring {
    border-color: var(--accent-primary);
    animation-duration: 1s;
}

@keyframes speaking-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.voice-orb.error .orb-core {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    box-shadow: 0 0 40px var(--danger-glow);
}

.voice-orb.error .orb-ring {
    border-color: var(--danger);
}

.status-text {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-align: center;
}

/* ==================== Controls ==================== */
.controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* ==================== Transcript ==================== */
.transcript-container {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    backdrop-filter: blur(20px);
}

.transcript-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

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

.transcript {
    height: 280px;
    overflow-y: auto;
    padding: 1.25rem;
    scroll-behavior: smooth;
}

.transcript-placeholder {
    color: var(--text-muted);
    text-align: center;
    padding: 3rem 1rem;
    font-style: italic;
}

.transcript-message {
    margin-bottom: 1rem;
    animation: fade-in 0.3s ease;
}

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

.transcript-message:last-child {
    margin-bottom: 0;
}

.transcript-role {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.transcript-message.user .transcript-role {
    color: var(--success);
}

.transcript-message.assistant .transcript-role {
    color: var(--accent-secondary);
}

.transcript-text {
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 0.95rem;
}

.transcript-message.system {
    text-align: center;
    padding: 0.5rem 1rem;
    background: var(--bg-glass);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.transcript-message.system .transcript-text {
    color: var(--text-secondary);
}

.transcript-message.error .transcript-text {
    color: var(--danger);
}

.transcript-message.success .transcript-text {
    color: var(--success);
}

/* Scrollbar */
.transcript::-webkit-scrollbar {
    width: 6px;
}

.transcript::-webkit-scrollbar-track {
    background: transparent;
}

.transcript::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

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

/* ==================== Footer ==================== */
.footer {
    padding: 1.5rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ==================== Responsive ==================== */
@media (max-width: 640px) {
    .app-container {
        padding: 1rem;
    }
    
    .header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .auth-section {
        flex-direction: column;
    }
    
    .voice-orb {
        width: 150px;
        height: 150px;
    }
    
    .orb-core {
        width: 80px;
        height: 80px;
    }
    
    .mic-icon {
        width: 28px;
        height: 28px;
    }
    
    .transcript {
        height: 220px;
    }
    
    .btn-lg {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
}

/* ==================== Animations ==================== */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.loading {
    animation: rotate 1s linear infinite;
}
