@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Brand Theme - Dark First */
    --bg-color-dark: #0f172a;
    --grad-1-dark: #c084fc; /* Violet */
    --grad-2-dark: #38bdf8; /* Sky Blue */
    --container-bg-dark: rgba(30, 41, 59, 0.75);
    --text-color-dark: #f8fafc;
    --primary-color-dark: #8b5cf6;
    --primary-hover-dark: #7c3aed;
    --secondary-bg-dark: rgba(15, 23, 42, 0.6);
    --secondary-hover-dark: rgba(51, 65, 85, 0.8);
    --border-color-dark: rgba(255, 255, 255, 0.1);
    --glass-bg-dark: rgba(30, 41, 59, 0.7);
    --glass-border-dark: rgba(255, 255, 255, 0.1);
    --switch-bg-dark: #475569;
    --switch-slider-dark: #f8fafc;

    /* Light Theme (Preserved compatibility) */
    --bg-color-light: #f8fafc;
    --grad-1-light: #8b5cf6;
    --grad-2-light: #38bdf8;
    --container-bg-light: #ffffff;
    --text-color-light: #0f172a;
    --primary-color-light: #8b5cf6;
    --primary-hover-light: #7c3aed;
    --secondary-bg-light: #e2e8f0;
    --secondary-hover-light: #cbd5e1;
    --border-color-light: #e2e8f0;
    --glass-bg-light: rgba(255, 255, 255, 0.7);
    --glass-border-light: rgba(0, 0, 0, 0.1);
    --switch-bg-light: #cbd5e1;
    --switch-slider-light: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem 1rem;
    background-color: var(--bg-color-dark);
    color: var(--text-color-dark);
    position: relative;
    overflow-x: hidden;
    transition: color 0.4s ease, background-color 0.4s ease;
}

/* Background Glowing Orbs */
.orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    pointer-events: none;
    animation: floatOrb 10s infinite ease-in-out alternate;
}
.orb-1 {
    width: 450px;
    height: 450px;
    background: rgba(139, 92, 246, 0.35);
    top: -100px;
    left: -100px;
}
.orb-2 {
    width: 500px;
    height: 500px;
    background: rgba(56, 189, 248, 0.28);
    bottom: -150px;
    right: -100px;
    animation-delay: -5s;
}

@keyframes floatOrb {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(35px, 50px) scale(1.1); }
}

body.light-mode {
    background-color: var(--bg-color-light);
    color: var(--text-color-light);
}

/* Top Brand Bar */
.brand-top-bar {
    width: 100%;
    max-width: 750px;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 50;
}

.brand-back-btn {
    background: rgba(30, 41, 59, 0.65);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 12px;
    text-decoration: none;
    color: #cbd5e1;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.12);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.25s ease;
}

.brand-back-btn:hover {
    background: rgba(51, 65, 85, 0.8);
    border-color: rgba(56, 189, 248, 0.4);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.brand-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #94a3b8;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.brand-badge img {
    height: 22px;
    width: auto;
}

.container {
    width: 100%;
    max-width: 750px;
    background: var(--container-bg-dark);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 2.2rem;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.55);
    border: 1px solid var(--border-color-dark);
    transition: background 0.4s ease, border-color 0.4s ease;
}
body.light-mode .container {
    background: var(--container-bg-light);
    border-color: var(--border-color-light);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color-dark);
    padding-bottom: 1rem;
    transition: border-color 0.4s ease;
}
body.light-mode .header { border-color: var(--border-color-light); }

.header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, var(--grad-1-dark), var(--grad-2-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
body.light-mode .header h1 {
    background: linear-gradient(135deg, var(--grad-1-light), var(--grad-2-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.header-logo { height: 32px; filter: drop-shadow(0 4px 10px rgba(139, 92, 246, 0.4)); }

.glass-btn {
    background: var(--glass-bg-dark);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border-dark);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}
body.light-mode .glass-btn {
    background: var(--glass-bg-light);
    border-color: var(--glass-border-light);
}
.glass-btn:hover {
    transform: translateY(-2px);
    border-color: rgba(56, 189, 248, 0.4);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.theme-btn {
    color: var(--text-color-dark);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}
body.light-mode .theme-btn { color: var(--text-color-light); }

.controls { margin-bottom: 1.5rem; display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.control-group { display: flex; align-items: center; gap: 10px; }
.control-group label { color: #cbd5e1; font-weight: 500; font-size: 0.95rem; }

#language-select {
    padding: 9px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color-dark);
    background-color: var(--secondary-bg-dark);
    color: var(--text-color-dark);
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}
#language-select:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}
body.light-mode #language-select {
    border-color: var(--border-color-light);
    background-color: var(--bg-color-light);
    color: var(--text-color-light);
}

.switch { position: relative; display: inline-block; width: 48px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--switch-bg-dark); transition: .3s; }
body.light-mode .slider { background-color: var(--switch-bg-light); }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background-color: white; transition: .3s; }
input:checked + .slider { background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%); }
body.light-mode input:checked + .slider { background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%); }
input:checked + .slider:before { background-color: #ffffff; }
input:checked + .slider:before { transform: translateX(22px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

.transcription-wrapper { 
    width: 100%; 
    display: flex; 
    flex-direction: column; 
    gap: 0; 
    margin-bottom: 1.5rem;
    transition: gap 0.5s ease; 
}
.transcription-wrapper.append-active { gap: 1rem; }

.textarea-container { position: relative; height: 300px; }
.transcription-wrapper.append-active .textarea-container { height: 240px; }

#result-text, #append-text {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color-dark);
    background-color: var(--secondary-bg-dark);
    color: var(--text-color-dark);
    font-size: 1rem;
    line-height: 1.6;
    resize: none;
    transition: all 0.3s ease;
    font-family: inherit;
    outline: none;
}
#result-text:focus, #append-text:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}
body.light-mode #result-text, body.light-mode #append-text {
    border-color: var(--border-color-light);
    background-color: var(--bg-color-light);
    color: var(--text-color-light);
}
#result-text { height: 100%; padding-right: 50px; }

.copy-icon-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(30, 41, 59, 0.8);
    color: #cbd5e1;
    border: 1px solid var(--border-color-dark);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    opacity: 0.85;
    transition: all 0.25s ease;
}
body.light-mode .copy-icon-btn {
    background: var(--secondary-bg-light);
    color: var(--text-color-light);
}
.copy-icon-btn:hover {
    background: var(--primary-color-dark);
    color: white;
    border-color: var(--primary-color-dark);
    transform: scale(1.05);
}

.append-container { height: 0; opacity: 0; overflow: hidden; transition: height 0.5s ease, opacity 0.5s ease; }
.transcription-wrapper.append-active .append-container { height: 60px; opacity: 1; }
#append-text { height: 100%; }

.stats-container {
    text-align: center;
    margin-top: 0.75rem;
    width: 100%;
    font-size: 0.9rem;
    color: #94a3b8;
    order: 3;
}
body.light-mode .stats-container { color: #64748b; }
.stats-container .separator { margin: 0 10px; color: #475569; }

.button-group { display: flex; gap: 1rem; flex-wrap: wrap; }
.btn { padding: 14px 22px; border: none; border-radius: 12px; font-size: 1rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; position: relative; overflow: hidden; transition: all 0.3s ease; }
.btn:active { transform: scale(0.98); }

.primary-btn {
    color: white;
    flex-grow: 1;
    min-height: 50px;
    background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
    background-size: 200% 200%;
    box-shadow: 0 8px 20px -3px rgba(59, 130, 246, 0.35);
}
.primary-btn:hover { 
    background-position: 100% 100%; 
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -3px rgba(59, 130, 246, 0.5);
}

.secondary-btn { 
    color: #cbd5e1; 
    background-color: rgba(30, 41, 59, 0.8); 
    border: 1px solid var(--border-color-dark);
}
body.light-mode .secondary-btn { color: var(--text-color-light); background-color: var(--secondary-bg-light); }
.secondary-btn:hover { 
    background-color: rgba(51, 65, 85, 0.85); 
    color: white;
    border-color: rgba(56, 189, 248, 0.4);
    transform: translateY(-2px);
}

.wave-container { display: none; align-items: flex-end; height: 20px; gap: 3px; }
.wave-bar { width: 4px; height: 100%; background-color: white; border-radius: 2px; animation: wave-animation 1.2s ease-in-out infinite; }
.wave-bar:nth-child(2) { animation-delay: 0.2s; }
.wave-bar:nth-child(3) { animation-delay: 0.4s; }
.wave-bar:nth-child(4) { animation-delay: 0.6s; }
.wave-bar:nth-child(5) { animation-delay: 0.8s; }
@keyframes wave-animation { 0%, 100% { transform: scaleY(0.2); } 50% { transform: scaleY(1); } }
.primary-btn.listening .btn-text { display: none; }
.primary-btn.listening .wave-container { display: flex; }

/* Responsive Design */
@media (max-width: 768px) {
    .container { padding: 1.5rem; }
    .header h1 { font-size: 1.5rem; }
    .header-logo { height: 28px; }
    .textarea-container { height: 250px; }
    .transcription-wrapper.append-active .textarea-container { height: 200px; }
}

@media (max-width: 480px) {
    body { padding: 1rem 0.5rem; }
    .container { padding: 1.2rem; border-radius: 18px; }
    .header h1 { font-size: 1.2rem; gap: 8px; }
    .header-logo { height: 24px; }
    .controls { flex-direction: column; align-items: flex-start; gap: 15px; }
    .button-group { flex-direction: column; }
    .btn { width: 100%; }
}