/* ============================================
   VoiceTranslate — Design System & Styles
   ============================================ */

:root {
    /* Color Palette */
    --clr-bg: #0a0a1a;
    --clr-surface: rgba(255, 255, 255, 0.04);
    --clr-surface-hover: rgba(255, 255, 255, 0.07);
    --clr-surface-elevated: rgba(255, 255, 255, 0.08);
    --clr-border: rgba(255, 255, 255, 0.08);
    --clr-border-focus: rgba(99, 102, 241, 0.5);
    --clr-text-primary: #f0f0f5;
    --clr-text-secondary: rgba(240, 240, 245, 0.6);
    --clr-text-tertiary: rgba(240, 240, 245, 0.35);
    --clr-accent-1: #6366f1;
    /* Indigo */
    --clr-accent-2: #a855f7;
    /* Purple */
    --clr-accent-3: #ec4899;
    /* Pink */
    --clr-success: #22c55e;
    --clr-danger: #ef4444;
    --clr-warning: #f59e0b;

    /* Gradients */
    --grad-accent: linear-gradient(135deg, var(--clr-accent-1), var(--clr-accent-2));
    --grad-accent-hover: linear-gradient(135deg, var(--clr-accent-2), var(--clr-accent-3));
    --grad-glass: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.15);
    --shadow-glow-active: 0 0 60px rgba(99, 102, 241, 0.3);

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;
}

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

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

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

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    font-size: inherit;
}

/* ---- App Container ---- */
.app-container {
    max-width: 720px;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-md) var(--space-2xl);
    position: relative;
    z-index: 1;
}

/* ---- Animated Background Orbs ---- */
.bg-orbs {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.4;
    animation: orbFloat 20s infinite ease-in-out;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--clr-accent-1), transparent 70%);
    top: -10%;
    left: -10%;
    animation-delay: 0s;
}

.orb-2 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, var(--clr-accent-2), transparent 70%);
    top: 40%;
    right: -15%;
    animation-delay: -7s;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--clr-accent-3), transparent 70%);
    bottom: -5%;
    left: 20%;
    animation-delay: -14s;
}

@keyframes orbFloat {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(30px, -40px) scale(1.1);
    }

    50% {
        transform: translate(-20px, 20px) scale(0.95);
    }

    75% {
        transform: translate(15px, 35px) scale(1.05);
    }
}

/* ---- Header ---- */
.header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-bottom: var(--space-xs);
}

.install-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.35);
    border-radius: var(--radius-full);
    color: #c7d2fe;
    font-size: 0.8rem;
    font-weight: 600;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all var(--duration-fast) var(--ease-out);
}

.install-btn:hover {
    background: rgba(99, 102, 241, 0.3);
    border-color: rgba(168, 85, 247, 0.6);
    color: #ffffff;
    box-shadow: 0 0 16px rgba(99, 102, 241, 0.35);
    transform: translateY(-50%) scale(1.03);
}

.install-btn.hidden {
    display: none;
}

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

.logo-icon svg {
    width: 36px;
    height: 36px;
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 800;
    background: var(--grad-accent);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.03em;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--clr-text-secondary);
    font-weight: 400;
}

/* ---- Language Bar ---- */
.language-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--duration-normal) var(--ease-out);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.lang-btn:hover {
    background: var(--clr-surface-hover);
    border-color: var(--clr-border-focus);
}

.lang-btn.active {
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.4);
}

.lang-flag {
    font-size: 1.25rem;
    line-height: 1;
}

.swap-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: 50%;
    color: var(--clr-text-secondary);
    transition: all var(--duration-normal) var(--ease-spring);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.swap-btn:hover {
    background: var(--clr-surface-elevated);
    color: var(--clr-text-primary);
    transform: scale(1.1);
    border-color: var(--clr-border-focus);
}

.swap-btn:active {
    transform: scale(0.95) rotate(180deg);
}

.swap-btn svg {
    width: 18px;
    height: 18px;
    transition: transform var(--duration-slow) var(--ease-spring);
}

.swap-btn.rotated svg {
    transform: rotate(180deg);
}

/* ---- Panels ---- */
.translator-grid {
    display: grid;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.panel {
    background: var(--grad-glass);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    overflow: hidden;
    transition: border-color var(--duration-normal) var(--ease-out),
        box-shadow var(--duration-normal) var(--ease-out);
}

.panel:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.panel:focus-within {
    border-color: var(--clr-border-focus);
    box-shadow: var(--shadow-glow);
}

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

.panel-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--clr-text-secondary);
}

.clear-btn,
.copy-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--clr-text-tertiary);
    transition: all var(--duration-fast);
}

.clear-btn:hover,
.copy-btn:hover {
    color: var(--clr-text-primary);
    background: var(--clr-surface-hover);
}

.text-area {
    min-height: 120px;
    padding: var(--space-md);
    font-size: 1.05rem;
    line-height: 1.7;
    outline: none;
    color: var(--clr-text-primary);
    word-break: break-word;
}

.text-area .placeholder {
    color: var(--clr-text-tertiary);
    font-style: italic;
    pointer-events: none;
}

.result-text {
    color: var(--clr-text-primary);
    font-weight: 500;
}

.panel-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-md);
    border-top: 1px solid var(--clr-border);
}

.char-count {
    font-size: 0.75rem;
    color: var(--clr-text-tertiary);
}

.play-result-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 18px;
    background: var(--grad-accent);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    transition: all var(--duration-normal) var(--ease-out);
    opacity: 0.5;
    pointer-events: none;
}

.play-result-btn.enabled {
    opacity: 1;
    pointer-events: auto;
}

.play-result-btn.enabled:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.play-result-btn.enabled:active {
    transform: scale(0.97);
}

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

/* ---- Microphone Button ---- */
.mic-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    position: relative;
}

.mic-ring {
    position: absolute;
    width: 88px;
    height: 88px;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, calc(-50% - 12px));
    pointer-events: none;
}

.mic-ring-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: border-color var(--duration-normal);
}

.mic-ring.recording .mic-ring-pulse {
    border-color: var(--clr-danger);
    animation: micPulse 1.5s infinite ease-out;
}

@keyframes micPulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

.mic-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--grad-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-md), 0 0 30px rgba(99, 102, 241, 0.2);
    transition: all var(--duration-normal) var(--ease-spring);
    position: relative;
    z-index: 2;
}

.mic-btn:hover {
    transform: scale(1.08);
    box-shadow: var(--shadow-lg), var(--shadow-glow-active);
}

.mic-btn:active {
    transform: scale(0.95);
}

.mic-btn.recording {
    background: linear-gradient(135deg, var(--clr-danger), #dc2626);
    box-shadow: var(--shadow-md), 0 0 40px rgba(239, 68, 68, 0.3);
    animation: micBreathe 2s infinite ease-in-out;
}

@keyframes micBreathe {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

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

.mic-btn .hidden {
    display: none;
}

.mic-label {
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
    font-weight: 500;
    transition: color var(--duration-fast);
}

.mic-label.recording {
    color: var(--clr-danger);
    animation: labelPulse 1.5s infinite;
}

@keyframes labelPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ---- Waveform Visualizer ---- */
.visualizer-container {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-lg);
    transition: opacity var(--duration-normal);
}

.visualizer-container.hidden {
    display: none;
}

.visualizer-container canvas {
    width: 100%;
    max-width: 600px;
    height: 60px;
    border-radius: var(--radius-md);
}

/* ---- Status Bar ---- */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-xl);
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
    transition: color var(--duration-fast);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--clr-success);
    flex-shrink: 0;
}

.status-bar.error .status-dot {
    background: var(--clr-danger);
}

.status-bar.processing .status-dot {
    background: var(--clr-warning);
    animation: dotPulse 1s infinite;
}

@keyframes dotPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* ---- History ---- */
.history-section {
    margin-top: var(--space-lg);
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.history-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--clr-text-secondary);
}

.clear-history-btn {
    font-size: 0.75rem;
    color: var(--clr-text-tertiary);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    border: 1px solid var(--clr-border);
    transition: all var(--duration-fast);
}

.clear-history-btn:hover {
    color: var(--clr-danger);
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.08);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.history-item {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    transition: all var(--duration-fast);
    animation: historySlideIn var(--duration-slow) var(--ease-out);
}

.history-item:hover {
    background: var(--clr-surface-hover);
    border-color: rgba(255, 255, 255, 0.12);
}

@keyframes historySlideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.history-source {
    color: var(--clr-text-secondary);
    word-break: break-word;
}

.history-arrow {
    color: var(--clr-accent-1);
    font-size: 1rem;
    flex-shrink: 0;
}

.history-result {
    color: var(--clr-text-primary);
    font-weight: 500;
    word-break: break-word;
}

.history-play-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--clr-surface-elevated);
    color: var(--clr-accent-1);
    transition: all var(--duration-fast);
    margin-left: var(--space-xs);
    flex-shrink: 0;
}

.history-play-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    transform: scale(1.1);
}

.history-empty {
    text-align: center;
    padding: var(--space-xl);
    color: var(--clr-text-tertiary);
    font-size: 0.85rem;
}

/* ---- Toast Notification ---- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 10px 20px;
    background: var(--clr-surface-elevated);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    color: var(--clr-text-primary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    transition: transform var(--duration-slow) var(--ease-spring);
    pointer-events: none;
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
    .app-container {
        padding: var(--space-md) var(--space-sm) var(--space-xl);
    }

    .logo h1 {
        font-size: 1.4rem;
    }

    .text-area {
        min-height: 90px;
        font-size: 0.95rem;
    }

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

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

    .history-item {
        grid-template-columns: 1fr;
        gap: var(--space-xs);
    }

    .history-arrow {
        justify-self: center;
    }
}