/* Design System Variables */
:root {
    --bg-base: #060913;
    --bg-card: rgba(13, 20, 38, 0.45);
    --bg-card-hover: rgba(20, 30, 56, 0.55);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(0, 242, 254, 0.15);
    
    /* Harmonious HSL colors */
    --primary: hsl(190, 100%, 50%);       /* Vibrant Cyan */
    --secondary: hsl(270, 95%, 65%);     /* Deep Violet */
    --accent: hsl(325, 95%, 55%);        /* Neon Pink/Magenta */
    --success: hsl(145, 80%, 50%);       /* Emerald Green */
    --warning: hsl(40, 90%, 55%);        /* Sunset Orange */
    --danger: hsl(360, 85%, 55%);        /* Coral Red */

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base resets & styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', 'Noto Sans Arabic', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Glassmorphism utility card */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal), background-color var(--transition-normal);
}

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

/* Ambient Background Orbs */
.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.35;
    z-index: -1;
    pointer-events: none;
    animation: floatOrb 20s infinite alternate ease-in-out;
}

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

.orb-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--secondary) 0%, transparent 70%);
    bottom: -15%;
    right: -10%;
    animation-duration: 30s;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
    top: 30%;
    left: 45%;
    animation-duration: 18s;
}

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

/* Application Layout Structure */
.app-container {
    width: 95vw;
    max-width: 1400px;
    height: 90vh;
    max-height: 900px;
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 20px;
    position: relative;
    z-index: 1;
}

@media (max-width: 1024px) {
    .app-container {
        height: auto;
        max-height: none;
        width: 100%;
        padding: 16px;
    }
}

/* Header styling */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: rgba(13, 20, 38, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

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

.logo-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.powered-by {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.logo-icon {
    font-size: 2.2rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo h1 {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-sub {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Status Badge */
.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.04);
    padding: 6px 14px;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--success);
    box-shadow: 0 0 10px var(--success);
}

.status-badge.working .status-dot {
    background-color: var(--warning);
    box-shadow: 0 0 10px var(--warning);
    animation: pulse 1s infinite alternate;
}

.status-badge.recording .status-dot {
    background-color: var(--danger);
    box-shadow: 0 0 10px var(--danger);
    animation: pulse 0.6s infinite alternate;
}

@keyframes pulse {
    0% { opacity: 0.4; }
    100% { opacity: 1; }
}

/* Main Dashboard Grid */
.app-main {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 20px;
    flex: 1;
    min-height: 0; /* Important for scrollbars in grid */
}

@media (max-width: 1024px) {
    .app-main {
        grid-template-columns: 1fr;
        height: auto;
        min-height: auto;
    }
}

.translator-hub {
    display: flex;
    flex-direction: column;
    padding: 30px;
    gap: 24px;
}

.conversation-feed {
    display: flex;
    flex-direction: column;
    padding: 24px;
    min-height: 0; /* Enable inner scrolling */
}

/* Section titles */
.section-title {
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* Button & Controls Styles */
.control-group {
    display: flex;
    flex-direction: column;
}

.direction-selector {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.dir-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    transition: all var(--transition-normal);
    text-align: left;
}

.dir-btn .material-symbols-outlined {
    font-size: 1.6rem;
    color: var(--text-muted);
    transition: color var(--transition-fast);
}

.dir-btn-text {
    display: flex;
    flex-direction: column;
}

.dir-btn .primary-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.dir-btn .sub-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.dir-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
}

.dir-btn.active {
    background: rgba(0, 242, 254, 0.06);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.1);
}

.dir-btn.active .material-symbols-outlined {
    color: var(--primary);
}

.dir-btn.active:nth-child(2) {
    background: rgba(168, 85, 247, 0.06);
    border-color: var(--secondary);
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.1);
}
.dir-btn.active:nth-child(2) .material-symbols-outlined {
    color: var(--secondary);
}

/* Recording Arena */
.recording-arena {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    position: relative;
}

.visualizer-container {
    position: relative;
    width: 240px;
    height: 240px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.waveform-canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    z-index: 1;
    pointer-events: none;
}

/* Mic button & Pulse rings */
.mic-btn {
    position: relative;
    z-index: 2;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: none;
    outline: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: #060913;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 30px rgba(0, 242, 254, 0.35);
    transition: all var(--transition-normal);
}

.mic-btn .material-symbols-outlined {
    font-size: 3.2rem;
    font-weight: bold;
    transition: transform var(--transition-fast);
}

.mic-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 40px rgba(0, 242, 254, 0.5), 0 0 10px rgba(168, 85, 247, 0.3);
}

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

.pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background-color: var(--primary);
    opacity: 0.15;
    z-index: 0;
    pointer-events: none;
    transition: all var(--transition-normal);
}

.recording .mic-btn {
    background: linear-gradient(135deg, var(--accent) 0%, var(--danger) 100%);
    box-shadow: 0 0 35px rgba(244, 63, 94, 0.4);
}

.recording .pulse-ring {
    background-color: var(--accent);
    animation: growRing 1.5s infinite ease-out;
}

.recording .ring-2 {
    animation-delay: 0.75s;
}

@keyframes growRing {
    0% {
        width: 120px;
        height: 120px;
        opacity: 0.25;
    }
    100% {
        width: 220px;
        height: 220px;
        opacity: 0;
    }
}

.status-display {
    text-align: center;
    max-width: 400px;
}

.status-display h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.status-display p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Mini translation preview panel */
.translation-preview {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--primary);
}

.preview-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    flex: 1;
    min-height: 0;
}

@media (max-width: 550px) {
    .preview-body {
        grid-template-columns: 1fr;
    }
}

.speech-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.04);
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.speech-box.translation {
    background: rgba(0, 242, 254, 0.02);
    border-color: rgba(0, 242, 254, 0.05);
}

.lang-tag {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.speech-box.translation .lang-tag {
    color: var(--primary);
}

.speech-box .text {
    font-size: 1.35rem;
    line-height: 1.6;
    font-weight: 500;
}

/* Buttons utility */
.icon-btn, .icon-btn-small {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all var(--transition-fast);
}

.icon-btn {
    width: 44px;
    height: 44px;
}

.icon-btn-small {
    width: 32px;
    height: 32px;
}

.icon-btn:hover, .icon-btn-small:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--primary);
}

.text-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.text-btn:hover {
    color: var(--danger);
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border: none;
    color: #060913;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.primary-btn:hover {
    opacity: 0.9;
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.25);
}

/* Conversation Feed / History List */
.feed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-right: 4px;
}

/* History scrollbar */
.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

.empty-state {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    gap: 12px;
}

.empty-icon {
    font-size: 3.5rem;
    opacity: 0.3;
}

/* History Item Card */
.history-item {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    padding: 16px;
    position: relative;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item-dir {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--secondary);
    text-transform: uppercase;
}

.history-item-actions {
    display: flex;
    gap: 8px;
}

.history-bubble {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-bubble.original {
    border-left: 2px solid var(--text-muted);
    padding-left: 10px;
}

.history-bubble.translated {
    border-left: 2px solid var(--primary);
    padding-left: 10px;
    margin-top: 4px;
}

.history-bubble .label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.history-bubble.translated .label {
    color: var(--primary);
}

.history-bubble .text {
    font-size: 0.95rem;
    line-height: 1.4;
}

/* Settings Modal styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(3, 5, 10, 0.75);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity var(--transition-normal);
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    width: 90vw;
    max-width: 480px;
    padding: 28px;
    animation: zoomIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.hidden .modal {
    animation: none;
}

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

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

.modal-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: 65vh;
    overflow-y: auto;
    padding-right: 6px;
}

/* Modal body custom scrollbar */
.modal-body::-webkit-scrollbar {
    width: 6px;
}
.modal-body::-webkit-scrollbar-track {
    background: transparent;
}
.modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Settings Group Cards */
.settings-group-card {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: border-color var(--transition-normal);
}
.settings-group-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}
.settings-group-card .group-title {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
    margin-bottom: 4px;
}
/* Alternate color theme for Language B group */
.settings-group-card:nth-of-type(2) .group-title {
    color: var(--secondary);
}

.settings-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon input {
    width: 100%;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 12px 12px 42px;
    color: var(--text-primary);
    outline: none;
    font-family: inherit;
    transition: border-color var(--transition-fast);
}

.input-with-icon input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 8px rgba(0, 242, 254, 0.1);
}

.input-icon {
    position: absolute;
    left: 14px;
    font-size: 1.25rem;
    color: var(--text-muted);
}

.input-with-icon .icon-btn-small {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
}

.input-with-icon .icon-btn-small:hover {
    color: var(--text-primary);
}

.field-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.settings-field select {
    width: 100%;
    background: rgba(13, 20, 38, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: var(--text-primary);
    outline: none;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2394a3b8'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 20px;
}

.settings-field select:focus {
    border-color: var(--primary);
}

.checkbox-field label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 500;
}

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

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

/* Utilities */
.hidden {
    display: none !important;
}

.skeleton-text {
    height: 16px;
    margin: 6px 0;
    border-radius: 4px;
    background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Enforce Auto-Detect mode selection and hide manual alternatives */
#dirBtnAB, #dirBtnBA {
    display: none !important;
}

/* Shake animation for incorrect password challenge */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}
