/* ==========================================================================
   CSS Variables & Reset
   ========================================================================== */
   :root {
    /* Brand & Accents */
    --brand-dark: #09090b; /* Zinc 950 */
    --brand-accent: #059669; /* Emerald 600 */
    --brand-accent-hover: #047857; /* Emerald 700 */
    --brand-danger: #e11d48; /* Rose 600 */
    
    /* Surfaces */
    --bg-app: #fcfcfd;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f4f4f5;
    
    /* Typography */
    --text-primary: #18181b;
    --text-secondary: #71717a;
    --text-tertiary: #a1a1aa;
    
    /* Borders & Details */
    --border-subtle: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.15);
    --radius-sm: 0.5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-diffusion: 0 20px 40px -15px rgba(0,0,0,0.05);
    
    /* Fonts */
    --font-sans: 'Satoshi', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-arabic: 'Noto Sans Arabic', sans-serif;
    
    /* Transitions */
    --spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-app);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   Navigation
   ========================================================================== */
.navbar {
    background-color: var(--brand-dark);
    color: white;
    padding: 0 2rem;
    height: 4rem;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 0 rgba(255,255,255,0.1);
}

.navbar-content {
    max-w-[1400px];
    width: 100%;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-img {
    height: 24px;
    width: auto;
    border-radius: 4px;
}

.logo-text {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-link {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.2s var(--ease-out);
}

.nav-link:hover {
    color: white;
}

.nav-link.active {
    color: white;
}

/* ==========================================================================
   Layout: Bento Grid
   ========================================================================== */
.main-container {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
}

.bento-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 1.5rem;
    height: calc(100dvh - 8rem);
    min-height: 600px;
}

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

.bento-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-diffusion);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-subtle);
}

.panel-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.panel-header .subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* ==========================================================================
   Left Panel: Controls
   ========================================================================== */
.control-panel {
    padding-bottom: 1.5rem;
}

.control-group {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-subtle);
}

.control-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Custom Select */
.custom-select-wrapper {
    position: relative;
}

.language-select {
    width: 100%;
    appearance: none;
    background: var(--bg-app);
    border: 1px solid var(--border-strong);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}

.language-select:focus {
    outline: none;
    border-color: var(--brand-dark);
    box-shadow: 0 0 0 1px var(--brand-dark);
}

.select-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-secondary);
}

/* Hotwords */
.hotwords-group {
    flex: 1;
}

.label-with-help {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.tooltip-trigger {
    color: var(--text-tertiary);
    cursor: help;
}

.hotword-input-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.hw-input {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    transition: border-color 0.2s var(--ease-out);
}

.hw-input:focus {
    outline: none;
    border-color: var(--brand-dark);
}

.icon-button {
    align-self: flex-end;
    background: var(--bg-surface-hover);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    cursor: pointer;
    color: var(--brand-dark);
    transition: all 0.2s var(--ease-out);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-button:hover {
    background: var(--border-subtle);
    transform: scale(0.98);
}

.hotwords-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.hw-tag {
    background: var(--bg-app);
    border: 1px solid var(--border-strong);
    padding: 0.25rem 0.5rem 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: popIn 0.3s var(--spring);
    position: relative;
}

.hw-tag.has-sounds-like {
    border-color: var(--brand-accent);
    background: rgba(5, 150, 105, 0.05);
}

.hw-tag .remove-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.hw-tag .remove-btn:hover {
    color: var(--brand-danger);
}

.hw-tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    background: var(--brand-dark);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
    z-index: 10;
}

.hw-tag:hover .hw-tooltip {
    display: block;
    animation: fadeIn 0.2s var(--ease-out);
}

/* Action Area */
.action-area {
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: auto;
}

.primary-button {
    width: 100%;
    background: var(--brand-dark);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s var(--ease-out);
}

.primary-button:hover {
    background: #27272a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.primary-button:active {
    transform: scale(0.98);
}

.primary-button.recording {
    background: var(--brand-danger);
    animation: buttonPulse 2s infinite cubic-bezier(0.66, 0, 0, 1);
}

.recording-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--brand-danger);
    font-variant-numeric: tabular-nums;
    font-family: 'Satoshi', monospace;
    font-weight: 500;
}

.pulse-ring {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand-danger);
    position: relative;
}

.pulse-ring::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--brand-danger);
    animation: ringPulse 1.5s infinite cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   Right Panel: Transcript
   ========================================================================== */
.transcript-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.text-button {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-family: var(--font-sans);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: color 0.2s;
}

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

.transcript-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    scroll-behavior: smooth;
}

.transcript-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.empty-state {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    gap: 1rem;
    margin-top: 4rem;
}

.empty-icon {
    font-size: 2.5rem;
    opacity: 0.5;
}

.transcript-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    animation: slideUp 0.4s var(--spring);
}

.speaker-badge {
    align-self: flex-start;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    background: var(--bg-app);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.transcript-text {
    font-size: 1.125rem;
    line-height: 1.6;
    color: var(--text-primary);
}

/* Arabic Specific */
.transcript-text[dir="rtl"] {
    font-family: var(--font-arabic);
    font-size: 1.25rem;
}

.transcript-text.interim {
    color: var(--text-secondary);
    font-style: italic;
}

span.interim {
    color: var(--text-secondary);
    font-style: italic;
    opacity: 0.8;
}

/* ==========================================================================
   Modals & Toasts
   ========================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s var(--ease-out);
}

.modal-card {
    background: var(--bg-surface);
    padding: 2rem;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    text-align: center;
    animation: slideUp 0.3s var(--spring);
}

.modal-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.modal-icon.success {
    color: var(--brand-accent);
}

.modal-card h3 {
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

.modal-card p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.secondary-button {
    background: var(--bg-app);
    border: 1px solid var(--border-strong);
    color: var(--text-primary);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    font-family: var(--font-sans);
    transition: all 0.2s var(--ease-out);
}

.secondary-button:hover {
    background: var(--bg-surface-hover);
}

.toast-notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--brand-dark);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-md);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s var(--spring);
    z-index: 1000;
}

.toast-notification.show {
    transform: translateY(0);
    opacity: 1;
}

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

@keyframes popIn {
    0% { opacity: 0; transform: scale(0.9); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes buttonPulse {
    0% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(225, 29, 72, 0); }
    100% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0); }
}

@keyframes ringPulse {
    0% { transform: scale(0.8); opacity: 1; }
    100% { transform: scale(2.5); opacity: 0; }
}

/* ==========================================================================
   History Dashboard Styles
   ========================================================================== */
.dashboard-header {
    margin-bottom: 2rem;
}

.dashboard-header h1 {
    font-size: 2rem;
    letter-spacing: -0.02em;
}

.table-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.history-table th {
    background: var(--bg-app);
    padding: 1rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
}

.history-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: top;
}

.history-table tr:last-child td {
    border-bottom: none;
}

.history-table tr:hover {
    background: var(--bg-app);
}

.col-id { width: 10%; }
.col-lang { width: 10%; }
.col-text { width: 50%; }
.col-date { width: 15%; }
.col-action { width: 15%; text-align: right; }

.text-preview {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    color: var(--brand-dark);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--brand-dark);
    color: white;
}
