/* =====================================================
   Voice Agent - ElevenLabs-style UI
   Modern, minimal design with animated orb
   ===================================================== */

:root {
    /* Colors */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.4);

    --accent: #22d3ee;
    --accent-glow: rgba(34, 211, 238, 0.3);

    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;

    /* Backgrounds */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a24;
    --bg-elevated: #22222e;

    /* Text */
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;

    /* Borders */
    --border-color: rgba(255, 255, 255, 0.1);
    --border-subtle: rgba(255, 255, 255, 0.05);

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;
}

/* Reset */
*, *::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: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow: hidden;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: radial-gradient(ellipse at top, var(--bg-secondary) 0%, var(--bg-primary) 60%);
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-xl);
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

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

.logo-icon svg {
    width: 100%;
    height: 100%;
}

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

.connection-status {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) var(--spacing-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
    animation: pulse 2s infinite;
}

.connection-status.connected .status-dot {
    background: var(--success);
    animation: none;
}

.connection-status.error .status-dot {
    background: var(--error);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.9); }
}

.status-text {
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl);
    gap: var(--spacing-xl);
    overflow: hidden;
}

/* Voice Orb */
.orb-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-lg);
}

.orb {
    position: relative;
    width: 200px;
    height: 200px;
    cursor: pointer;
    transition: transform var(--transition-base);
}

.orb:hover {
    transform: scale(1.02);
}

.orb-inner {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-elevated));
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.orb-glow {
    position: absolute;
    inset: -20%;
    background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
    opacity: 0;
    transition: opacity var(--transition-slow);
}

.orb.listening .orb-glow,
.orb.speaking .orb-glow {
    opacity: 1;
    animation: orbGlow 2s ease-in-out infinite;
}

@keyframes orbGlow {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

.orb-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--primary);
    opacity: 0;
}

.orb.listening .orb-pulse {
    animation: orbPulse 1.5s ease-out infinite;
}

.orb.speaking .orb-pulse {
    border-color: var(--accent);
    animation: orbPulse 1s ease-out infinite;
}

@keyframes orbPulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.5); opacity: 0; }
}

.orb-core {
    position: absolute;
    inset: 20%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-primary));
    border: 1px solid var(--border-subtle);
    color: var(--primary);
}

.orb.listening .orb-core {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
}

.orb.speaking .orb-core {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(34, 211, 238, 0.3));
    color: var(--accent);
    border-color: rgba(34, 211, 238, 0.3);
}

.waveform {
    width: 80%;
    height: 40%;
    stroke: currentColor;
    stroke-width: 3;
    stroke-linecap: round;
}

.orb.idle .waveform path {
    d: path("M0,20 Q25,20 50,20 T100,20");
}

.orb.listening .waveform path,
.orb.speaking .waveform path {
    animation: waveAnimate 0.5s ease-in-out infinite alternate;
}

@keyframes waveAnimate {
    0% { d: path("M0,20 Q25,5 50,20 T100,20"); }
    100% { d: path("M0,20 Q25,35 50,20 T100,20"); }
}

.orb-status {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
    min-height: 1.5em;
}

.orb-status.listening {
    color: var(--primary-light);
}

.orb-status.speaking {
    color: var(--accent);
}

.orb-status.processing {
    color: var(--warning);
}

/* Transcript Container */
.transcript-container {
    width: 100%;
    max-width: 600px;
    max-height: 250px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.transcript-scroll {
    max-height: 250px;
    overflow-y: auto;
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

/* Messages */
.message {
    display: flex;
    gap: var(--spacing-sm);
    animation: messageIn 0.3s ease;
}

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

.message.user {
    flex-direction: row-reverse;
}

.message-content {
    max-width: 80%;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-lg);
    font-size: 0.9375rem;
    line-height: 1.5;
}

.message.assistant .message-content {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    border-bottom-left-radius: var(--spacing-xs);
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-bottom-right-radius: var(--spacing-xs);
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-lg) var(--spacing-xl);
    gap: var(--spacing-md);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.5), transparent);
    flex-shrink: 0;
}

.live-transcript {
    min-height: 24px;
    max-width: 500px;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-muted);
    font-style: italic;
}

.live-transcript.active {
    color: var(--text-secondary);
}

/* Text Input - ElevenLabs Conversational AI Style */
.text-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 560px;
    margin: 0 auto var(--spacing-lg);
    padding: 6px 6px 6px 0;
    background: linear-gradient(135deg, rgba(30, 30, 40, 0.9), rgba(20, 20, 30, 0.95));
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 28px;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.03) inset;
    transition: all var(--transition-base);
}

.text-input-wrapper:focus-within {
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow:
        0 4px 32px rgba(99, 102, 241, 0.15),
        0 0 0 1px rgba(99, 102, 241, 0.2) inset,
        0 0 20px rgba(99, 102, 241, 0.1);
}

.text-input-wrapper input {
    flex: 1;
    padding: 14px 8px 14px 24px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-weight: 400;
    letter-spacing: 0.01em;
    outline: none;
    width: 100%;
}

.text-input-wrapper input::placeholder {
    color: rgba(161, 161, 170, 0.6);
    font-weight: 400;
}

.text-input-wrapper button {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.4);
    transition: all var(--transition-fast);
}

.text-input-wrapper button:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.5);
}

.text-input-wrapper button:active {
    transform: scale(0.95);
}

.text-input-wrapper button svg {
    width: 18px;
    height: 18px;
    fill: none;
    transform: translateX(1px);
}

.mic-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
}

.mic-button {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 20px var(--primary-glow);
    transition: all var(--transition-base);
    position: relative;
}

.mic-button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 6px 30px var(--primary-glow);
}

.mic-button:active:not(:disabled) {
    transform: scale(0.98);
}

.mic-button:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

.mic-button.listening {
    background: linear-gradient(135deg, var(--error), #dc2626);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
    animation: micPulse 1.5s ease-in-out infinite;
}

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

.mic-button svg {
    width: 28px;
    height: 28px;
}

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

.secondary-controls {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-sm);
}

.control-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

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

.control-btn svg {
    width: 18px;
    height: 18px;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 400px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.setting-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.setting-group select {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.setting-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.setting-group input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.setting-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    flex-direction: row;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.checkbox-label span {
    color: var(--text-primary);
    font-size: 0.875rem;
}

#volumeValue {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-sm) var(--spacing-lg);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition-base);
    z-index: 200;
}

.toast.active {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.toast.error {
    border-color: var(--error);
}

.toast.success {
    border-color: var(--success);
}

.toast-message {
    font-size: 0.875rem;
    color: var(--text-primary);
}

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

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

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

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

/* Focus styles */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        padding: var(--spacing-md);
    }

    .orb {
        width: 160px;
        height: 160px;
    }

    .transcript-container {
        max-height: 200px;
    }

    .controls {
        padding: var(--spacing-md);
    }

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

    .mic-button svg {
        width: 24px;
        height: 24px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .logo-text {
        display: none;
    }

    .orb {
        width: 140px;
        height: 140px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
