/* ============================================================
   OmniVoice Clone — Premium Dark UI
   ============================================================ */

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

:root {
    --bg-primary: #09090b;
    --bg-card: rgba(255,255,255, 0.03);
    --bg-card-hover: rgba(255,255,255, 0.06);
    --bg-input: rgba(255,255,255, 0.05);
    --border: rgba(255,255,255, 0.07);
    --border-focus: rgba(129,140,248, 0.5);
    --text-primary: #f0f0f8;
    --text-secondary: #a1a1b5;
    --text-muted: #5a5a72;
    --accent-1: #818cf8;
    --accent-2: #c084fc;
    --accent-gradient: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
    --accent-glow: rgba(129,140,248, 0.25);
    --success: #34d399;
    --danger: #f87171;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --shadow-glow: 0 0 40px rgba(129,140,248, 0.15);
    --transition: 0.25s cubic-bezier(.4,0,.2,1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html { font-size: 15px; }

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---------- 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(120px);
    opacity: 0.12;
    animation: float 20s ease-in-out infinite;
}
.orb-1 {
    width: 600px; height: 600px;
    background: #818cf8;
    top: -200px; left: -100px;
    animation-duration: 25s;
}
.orb-2 {
    width: 500px; height: 500px;
    background: #c084fc;
    bottom: -150px; right: -100px;
    animation-duration: 30s;
    animation-delay: -5s;
}
.orb-3 {
    width: 400px; height: 400px;
    background: #6366f1;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    animation-duration: 22s;
    animation-delay: -10s;
}
@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -40px) scale(1.05); }
    66% { transform: translate(-20px, 30px) scale(0.95); }
}

/* ---------- Container ---------- */
.container {
    position: relative; z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* ---------- Header ---------- */
.header {
    text-align: center;
    margin-bottom: 2.5rem;
}
.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 6px;
}
.logo-icon {
    display: flex;
    align-items: center;
    animation: pulse-glow 3s ease-in-out infinite;
}
@keyframes pulse-glow {
    0%, 100% { filter: drop-shadow(0 0 8px rgba(129,140,248,0.3)); }
    50% { filter: drop-shadow(0 0 20px rgba(129,140,248,0.6)); }
}
.header h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}
.header h1 .accent {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.tagline {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 400;
    letter-spacing: 0.02em;
}

/* ---------- Grid Layout ---------- */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 800px) {
    .main-grid { grid-template-columns: 1fr; }
}

/* ---------- Panel ---------- */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.75rem;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

/* ---------- Section ---------- */
.section { margin-bottom: 1.5rem; }
.section:last-child { margin-bottom: 0; }

.section-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
}
.label-icon { font-size: 1rem; }

/* ---------- Voice Selector ---------- */
.voice-selector {
    position: relative;
}
.voice-search-wrapper {
    position: relative;
}
.voice-search {
    width: 100%;
    padding: 12px 16px 12px 42px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: var(--font);
    outline: none;
    transition: var(--transition);
}
.voice-search::placeholder { color: var(--text-muted); }
.voice-search:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.search-icon {
    position: absolute;
    left: 14px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.voice-list {
    max-height: 220px;
    overflow-y: auto;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.voice-list::-webkit-scrollbar { width: 4px; }
.voice-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
}

.voice-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}
.voice-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border);
}
.voice-item.active {
    background: rgba(129,140,248, 0.1);
    border-color: rgba(129,140,248, 0.3);
}
.voice-item-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
}
.voice-item-tags {
    font-size: 0.75rem;
    color: var(--text-muted);
    max-width: 50%;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Selected Voice Info ---------- */
.voice-info {
    margin-top: 10px;
    padding: 14px 16px;
    background: rgba(129,140,248, 0.06);
    border: 1px solid rgba(129,140,248, 0.15);
    border-radius: var(--radius-md);
    animation: fade-in 0.3s ease;
}
.voice-info.hidden { display: none; }

.voice-info-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}
.voice-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--accent-1);
}
.voice-desc {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}
.btn-preview {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent-gradient);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
}
.btn-preview:hover {
    transform: scale(1.1);
    box-shadow: 0 0 16px var(--accent-glow);
}
.btn-preview.playing {
    animation: pulse-ring 1.2s ease-in-out infinite;
}
@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(129,140,248,0.4); }
    70% { box-shadow: 0 0 0 10px rgba(129,140,248,0); }
    100% { box-shadow: 0 0 0 0 rgba(129,140,248,0); }
}

.voice-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.voice-tags .tag {
    padding: 3px 10px;
    background: rgba(255,255,255, 0.06);
    border: 1px solid rgba(255,255,255, 0.08);
    border-radius: 20px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ---------- Text Input ---------- */
.text-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: var(--font);
    line-height: 1.6;
    resize: vertical;
    outline: none;
    transition: var(--transition);
}
.text-input::placeholder { color: var(--text-muted); }
.text-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.char-count {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ---------- Settings ---------- */
.settings-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.setting-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: block;
}
.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}
.slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    outline: none;
}
.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px; height: 16px;
    background: var(--accent-1);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(129,140,248,0.4);
    transition: var(--transition);
}
.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 16px rgba(129,140,248,0.6);
}
.slider-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-1);
    min-width: 32px;
    text-align: right;
}

/* ---------- Generate Button ---------- */
.btn-generate {
    width: 100%;
    padding: 16px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: var(--font);
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.02em;
    margin-top: 0.5rem;
}
.btn-generate::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
    opacity: 0;
    transition: var(--transition);
}
.btn-generate:hover::before { opacity: 1; }
.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(129,140,248,0.35);
}
.btn-generate:active {
    transform: translateY(0);
}
.btn-generate:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-text, .btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}
.btn-loading.hidden, .btn-text.hidden { display: none; }

.spinner {
    width: 20px; height: 20px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Output Panel ---------- */
.panel-output {
    position: sticky;
    top: 2rem;
}

.output-placeholder {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-muted);
}
.output-placeholder.hidden { display: none; }
.placeholder-icon { margin-bottom: 16px; }
.placeholder-sub {
    font-size: 0.8rem;
    margin-top: 6px;
    opacity: 0.5;
}

.output-result { animation: fade-in 0.5s ease; }
.output-result.hidden { display: none; }

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

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.result-header h3 {
    font-size: 1rem;
    font-weight: 600;
}
.result-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ---------- Waveform ---------- */
.waveform-container {
    position: relative;
    height: 100px;
    background: rgba(255,255,255, 0.03);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    margin-bottom: 14px;
}
#waveformCanvas {
    width: 100%;
    height: 100%;
    display: block;
}
.playback-progress {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 0%;
    background: linear-gradient(90deg, rgba(129,140,248,0.15), rgba(192,132,252,0.1));
    border-right: 2px solid var(--accent-1);
    pointer-events: none;
    transition: width 0.1s linear;
}

/* ---------- Audio Controls ---------- */
.audio-controls {
    display: flex;
    align-items: center;
    gap: 14px;
}
.btn-play {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent-gradient);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
}
.btn-play:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 20px var(--accent-glow);
}
.icon-play.hidden, .icon-pause.hidden { display: none; }

.time-display {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    flex: 1;
}
.time-sep { color: var(--text-muted); margin: 0 3px; }

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(255,255,255, 0.06);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}
.btn-download:hover {
    background: rgba(255,255,255, 0.1);
    color: var(--text-primary);
    border-color: rgba(255,255,255, 0.15);
}

/* ---------- History ---------- */
.history-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}
.history-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
}
.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255,255,255, 0.03);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}
.history-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border);
}
.history-play {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent-gradient);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 0.7rem;
}
.history-text {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-voice {
    font-size: 0.7rem;
    color: var(--accent-1);
    font-weight: 500;
    flex-shrink: 0;
}
