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

:root {
    --bg-base: #FAF9F5; /* Traditional Washi warm paper color */
    --bg-glass: rgba(255, 255, 255, 0.75);
    --bg-glass-hover: rgba(255, 245, 247, 0.95);
    --border-glass: rgba(188, 54, 86, 0.12);
    --border-glass-active: rgba(188, 54, 86, 0.4);
    
    --text-primary: #1F2421; /* Sumi Black */
    --text-secondary: #4A5650;
    --text-muted: #889A8F;
    
    --color-accent: #BC3656; /* Hinomaru Crimson */
    --color-accent-gradient: linear-gradient(135deg, #BC3656 0%, #D0104C 100%);
    --color-success: #3A8E72; /* Bamboo Green */
    --color-danger: #D0104C;
    --color-warning: #E29C45; /* Gold */
    
    --glow-accent: rgba(188, 54, 86, 0.25);
    --glow-success: rgba(58, 142, 114, 0.15);
    --shadow-main: 0 10px 30px 0 rgba(188, 54, 86, 0.06);
    --font-sans: 'Outfit', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-base);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='30' viewBox='0 0 60 30'%3E%3Cpath d='M15 0C6.7 0 0 6.7 0 15s6.7 15 15 15 15-6.7 15-15S23.3 0 15 0zm30 0C36.7 0 30 6.7 30 15s6.7 15 15 15 15-6.7 15-15S53.3 0 45 0zM0 15c0 8.3 6.7 15 15 15s15-6.7 15-15S23.3 0 15 0 0 6.7 0 15zm30 0c0 8.3 6.7 15 15 15s15-6.7 15-15S53.3 0 45 0 30 6.7 30 15z' fill='%23bc3656' fill-opacity='0.12' fill-rule='evenodd'/%3E%3C/svg%3E");
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
}

/* Ambient Warm Japanese Glows */
body::before, body::after {
    content: '';
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(140px);
    z-index: -1;
    pointer-events: none;
    animation: float-blob 25s infinite alternate ease-in-out;
}

body::before {
    top: -150px;
    left: -150px;
    background: rgba(252, 211, 224, 0.25); /* Cherry blossom light pink */
}

body::after {
    bottom: -150px;
    right: -150px;
    background: rgba(226, 156, 69, 0.08); /* Warm gold glow */
    animation-delay: -12.5s;
}

@keyframes float-blob {
    0% {
        transform: translate(0, 0) scale(1);
    }
    50% {
        transform: translate(80px, 50px) scale(1.15);
    }
    100% {
        transform: translate(-40px, 90px) scale(0.9);
    }
}

/* Glassmorphism utility */
.glass {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    box-shadow: var(--shadow-main);
}

header {
    padding: 24px 48px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-glass);
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    font-size: 26px;
    color: var(--color-accent);
    filter: drop-shadow(0 0 8px var(--glow-accent));
}

.logo-text {
    font-weight: 700;
    font-size: 22px;
    letter-spacing: 0.5px;
}

.logo-text span {
    background: var(--color-accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Live Streaming Indicator Badge */
.live-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.2);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--color-danger);
    letter-spacing: 1px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.live-indicator.active {
    opacity: 1;
    animation: flash 1.5s infinite alternate;
}

@keyframes flash {
    0% { opacity: 0.5; }
    100% { opacity: 1; }
}

.live-indicator::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--color-danger);
    box-shadow: 0 0 6px var(--color-danger);
}

/* Main Dashboard layout */
main {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 48px 48px;
    display: grid;
    grid-template-rows: auto auto 1fr;
    gap: 28px;
}

/* Top control dashboard */
.control-dashboard {
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 32px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.visualizer-container {
    flex: 1;
    height: 64px;
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--border-glass);
}

#waveform {
    width: 100%;
    height: 100%;
    display: block;
}

.action-buttons {
    display: flex;
    gap: 16px;
}

.btn {
    padding: 14px 28px;
    border-radius: 14px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--color-accent-gradient);
    color: white;
    box-shadow: 0 4px 20px var(--glow-accent);
}

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

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.6);
    color: var(--text-primary);
    border-color: var(--border-glass);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.btn-icon {
    width: 50px;
    height: 50px;
    padding: 0;
    justify-content: center;
}

.btn-danger {
    background: var(--color-danger);
    color: white;
    box-shadow: 0 4px 15px rgba(244, 63, 94, 0.2);
}

.btn-danger:hover {
    box-shadow: 0 6px 22px rgba(244, 63, 94, 0.3);
    transform: translateY(-2px);
}

/* Pulsing microphone status circle around active start button */
.pulse-ring {
    position: relative;
}

.pulse-ring::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 18px;
    border: 2px solid var(--color-success);
    opacity: 0;
    pointer-events: none;
}

.recording .pulse-ring::after {
    animation: ring-pulse 1.8s infinite cubic-bezier(0.24, 0, 0.38, 1);
}

@keyframes ring-pulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { opacity: 0.4; }
    100% { transform: scale(1.15); opacity: 0; }
}

/* Status Indicator */
.status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    font-size: 13px;
    font-weight: 600;
}

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

.status-dot.active {
    background-color: var(--color-success);
    box-shadow: 0 0 10px var(--color-success);
    animation: pulse 1.2s infinite alternate;
}

.status-dot.error {
    background-color: var(--color-danger);
    box-shadow: 0 0 10px var(--color-danger);
}

/* Live Japanese transcript box */
.source-panel {
    padding: 28px 32px;
    position: relative;
    border: 1px solid var(--border-glass);
    transition: all 0.4s ease;
}

.source-panel.recording {
    border-color: var(--border-glass-active);
    box-shadow: 0 0 25px rgba(0, 198, 251, 0.08);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.panel-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--color-accent);
    font-weight: 700;
}

.lang-tag {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 6px;
    background: rgba(0, 198, 251, 0.12);
    color: var(--color-accent);
    border: 1px solid rgba(0, 198, 251, 0.25);
    letter-spacing: 0.5px;
}

.transcript-area {
    min-height: 100px;
    max-height: 200px;
    overflow-y: auto;
    font-size: 24px;
    line-height: 1.7;
    color: var(--text-primary);
    font-weight: 400;
    letter-spacing: 0.5px;
}

.transcript-area .interim {
    color: var(--text-muted);
    font-style: italic;
    font-weight: 300;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
}

.transcript-placeholder {
    color: var(--text-muted);
    font-size: 18px;
    font-style: italic;
}

/* 4-Language Output Grid */
.translation-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

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

.target-card {
    padding: 28px 32px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 240px;
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    position: relative;
    overflow: hidden;
    border-left-width: 4px; /* Theme specific colors */
}

/* Accent borders per language */
#cardLang1 { border-left-color: #3b82f6; } /* Blue for English */
#cardLang2 { border-left-color: #ef4444; } /* Red for Indonesia */
#cardLang3 { border-left-color: #f59e0b; } /* Yellow for Vietnam */
#cardLang4 { border-left-color: #8b5cf6; } /* Purple/Amethyst for Khmer */

.target-card:hover {
    background: var(--bg-glass-hover);
    transform: translateY(-6px) scale(1.01);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 20px 38px rgba(0, 0, 0, 0.45);
}

.target-card.active-translation {
    box-shadow: 0 0 30px rgba(0, 198, 251, 0.15);
    border-color: rgba(0, 198, 251, 0.35);
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-lang-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Flag SVG badge circular container */
.flag-badge {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-lang {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-lang-tag {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
}

.translation-content {
    font-size: 22px;
    line-height: 1.6;
    color: var(--text-primary);
    font-weight: 400;
    flex: 1;
    margin-bottom: 24px;
    letter-spacing: 0.3px;
}

.translation-placeholder {
    color: var(--text-muted);
    font-size: 17px;
    font-style: italic;
}

.card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    padding-top: 16px;
}

.action-icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
}

.action-icon-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.action-icon-btn:active {
    transform: scale(0.92);
}

/* Spinner animation for loading */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s infinite linear;
    display: none;
}

.spinner.show {
    display: block;
}

/* Modal dialogue (Settings) */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(3, 5, 11, 0.85);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

.modal-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 90%;
    max-width: 520px;
    padding: 36px;
    border: 1px solid var(--border-glass);
    transform: translateY(30px);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 25px 50px -12px rgba(188, 54, 86, 0.15);
}

.modal-backdrop.show .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.modal-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.form-input {
    width: 100%;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 12px rgba(0, 198, 251, 0.25);
}

select.form-input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
    padding-right: 48px;
}

.help-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
    line-height: 1.5;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    margin-top: 36px;
}

/* History log UI overlay or sidebar */
.history-drawer {
    position: fixed;
    top: 0;
    right: -420px;
    width: 420px;
    height: 100vh;
    z-index: 900;
    transition: right 0.45s cubic-bezier(0.16, 1, 0.3, 1);
    border-left: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: -10px 0 30px rgba(188, 54, 86, 0.08);
}

.history-drawer.open {
    right: 0;
}

.history-header {
    padding: 28px 32px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-header h3 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.history-body {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.history-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 20px;
}

.history-item-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.history-item-source {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.history-item-translations {
    font-size: 14px;
    color: var(--text-secondary);
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 12px;
    background: rgba(255, 255, 255, 0.01);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.history-item-translations span.lang {
    color: var(--color-accent);
    font-weight: 700;
}

.history-footer {
    padding: 28px 32px;
    border-top: 1px solid var(--border-glass);
}

/* Keyframes animations */
@keyframes pulse {
    0% {
        transform: scale(0.9);
        opacity: 0.7;
    }
    100% {
        transform: scale(1.1);
        opacity: 1;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

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

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

::-webkit-scrollbar-thumb {
    background: rgba(188, 54, 86, 0.15);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(188, 54, 86, 0.3);
}

/* Custom Japanese Hinomaru Logo */
.hinomaru-logo {
    width: 40px;
    height: 40px;
    background-color: var(--color-accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(188, 54, 86, 0.25);
    flex-shrink: 0;
}

.kanji-logo {
    color: #FFFFFF;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -1px;
}

.japan-tag {
    background: rgba(188, 54, 86, 0.08);
    color: var(--color-accent);
    border: 1px solid rgba(188, 54, 86, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    margin-left: 6px;
}

/* Sakura (Cherry Blossom) Floating Animation */
.sakura-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    pointer-events: none;
    z-index: -1;
}

.petal {
    position: absolute;
    background: #ff8da9; /* Traditional richer sakura pink */
    border-radius: 150% 0 150% 150%;
    opacity: 0.8;
    transform-origin: left top;
    animation: fall 10s linear infinite;
}

@keyframes fall {
    0% {
        top: -10%;
        transform: translateX(0) rotate(0deg) scale(0.6);
    }
    100% {
        top: 110%;
        transform: translateX(120px) rotate(360deg) scale(1.0);
    }
}

.petal:nth-child(1) { left: 10%; animation-duration: 8s; animation-delay: 0s; }
.petal:nth-child(2) { left: 25%; animation-duration: 11s; animation-delay: 1.5s; }
.petal:nth-child(3) { left: 40%; animation-duration: 9s; animation-delay: 3s; }
.petal:nth-child(4) { left: 55%; animation-duration: 12s; animation-delay: 0.5s; }
.petal:nth-child(5) { left: 70%; animation-duration: 10s; animation-delay: 2s; }
.petal:nth-child(6) { left: 85%; animation-duration: 13s; animation-delay: 4s; }
.petal:nth-child(7) { left: 18%; animation-duration: 14s; animation-delay: 1s; }
.petal:nth-child(8) { left: 62%; animation-duration: 9s; animation-delay: 5s; }

/* Japan Mascot Waving Animation */
.japan-mascot {
    filter: drop-shadow(0 2px 6px rgba(188, 54, 86, 0.1));
    transition: all 0.3s ease;
}

.recording .japan-mascot {
    animation: mascot-bounce 0.6s infinite alternate ease-in-out;
}

.japan-mascot .paw {
    transform-origin: 65px 55px;
    animation: paw-wave 1.5s ease-in-out infinite alternate;
}

@keyframes paw-wave {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(-25deg); }
}

@keyframes mascot-bounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-4px); }
}

/* Japanese Landscape Silhouette Background */
.japan-landscape {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 180px;
    z-index: -3;
    pointer-events: none;
    opacity: 0.9;
}

/* Large Background Mascot Floating */
.large-bg-mascot {
    position: fixed;
    right: 3%;
    bottom: 12%;
    width: 320px;
    height: 320px;
    z-index: -2;
    pointer-events: none;
    opacity: 0.85;
    animation: float-character 8s infinite alternate ease-in-out;
}

@keyframes float-character {
    0% { transform: translateY(0) rotate(0deg); }
    100% { transform: translateY(-12px) rotate(2deg); }
}
