/* =================================================================
   NLLB-200 Machine Translation Studio - Modern Design System
   ================================================================= */

:root {
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-card-hover: rgba(30, 41, 59, 0.85);
    --bg-pane: #1e293b;
    --bg-input: #0f172a;
    --border-color: rgba(255, 255, 255, 0.1);
    --border-focus: #3b82f6;

    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #6366f1 50%, #8b5cf6 100%);
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow-glow: 0 10px 30px -10px rgba(99, 102, 241, 0.3);
    --shadow-card: 0 20px 40px rgba(0, 0, 0, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Dynamic Glow Effects */
.app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background: 
        radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.15) 0%, transparent 40%);
    filter: blur(60px);
}

/* Header Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2.5rem;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-md);
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #fff;
    box-shadow: var(--shadow-glow);
}

.brand-text h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
}

.brand-text h1 span {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text p {
    font-size: 0.825rem;
    color: var(--text-muted);
}

.status-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.85rem;
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.green {
    background-color: var(--accent-emerald);
    box-shadow: 0 0 10px var(--accent-emerald);
}

.btn-swagger {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    border: 1px solid rgba(59, 130, 246, 0.3);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-swagger:hover {
    background: rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}

/* Main Container */
.container {
    max-width: 1280px;
    margin: 2.5rem auto;
    padding: 0 1.5rem;
}

/* Translation Workbench Card */
.translation-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
    padding: 1.75rem;
    margin-bottom: 2.5rem;
}

/* Language Selector Bar */
.lang-selector-bar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.lang-picker-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.quick-lang-tabs {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
}

.lang-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.lang-tab:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.lang-tab.active {
    color: #fff;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.lang-dropdown {
    background: var(--bg-pane);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    outline: none;
    cursor: pointer;
    max-width: 180px;
}

.btn-swap {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.btn-swap:hover {
    color: #fff;
    background: var(--primary-gradient);
    transform: rotate(180deg) scale(1.05);
    box-shadow: var(--shadow-glow);
}

/* Dual Panes Container */
.panes-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    min-height: 280px;
}

.pane {
    background: var(--bg-pane);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    transition: border-color 0.2s ease;
}

.pane:focus-within {
    border-color: var(--border-focus);
}

/* Input Area */
textarea {
    width: 100%;
    height: 180px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-size: 1.05rem;
    line-height: 1.6;
    resize: none;
}

textarea::placeholder {
    color: var(--text-dim);
}

/* Output Area */
.output-placeholder {
    height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--text-dim);
}

.output-placeholder i {
    font-size: 2rem;
    color: var(--text-dim);
}

.output-text {
    width: 100%;
    height: 180px;
    color: #fff;
    font-size: 1.1rem;
    line-height: 1.6;
    word-break: break-word;
    overflow-y: auto;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(4px);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.spinner {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(59, 130, 246, 0.2);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Pane Footers */
.pane-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.85rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 0.5rem;
}

.sample-presets {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.preset-label {
    font-size: 0.775rem;
    color: var(--text-dim);
    margin-right: 0.25rem;
}

.preset-chip {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-chip:hover {
    background: rgba(59, 130, 246, 0.2);
    color: #fff;
    border-color: rgba(59, 130, 246, 0.4);
}

.input-actions, .output-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.char-count {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.95rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* Action Bar below Panes */
.translation-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.checkbox-container input {
    accent-color: var(--accent-blue);
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #fff;
    border: none;
    padding: 0.75rem 1.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    box-shadow: var(--shadow-glow);
    transition: all 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px -8px rgba(99, 102, 241, 0.5);
}

/* Metric Pills */
.metrics-tags {
    display: flex;
    gap: 0.5rem;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.775rem;
    font-weight: 500;
}

.tag-cached {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.tag-live {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.tag-time {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-amber);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* History Log Section */
.history-section {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.table-card {
    overflow-x: auto;
}

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

.history-table th {
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-muted);
    padding: 0.75rem 1rem;
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
}

.history-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.empty-row td {
    text-align: center;
    color: var(--text-dim);
    padding: 2rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 1000;
}

.toast {
    background: #1e293b;
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.875rem;
    animation: slideIn 0.3s ease forwards;
}

.toast-success { border-left: 4px solid var(--accent-emerald); }
.toast-error { border-left: 4px solid #ef4444; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.hidden { display: none !important; }

/* Responsive Mobile Layout */
@media (max-width: 768px) {
    .panes-container {
        grid-template-columns: 1fr;
    }
    .lang-selector-bar {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    .btn-swap {
        margin: 0 auto;
    }
}

/* ---- API key entry (the console is a normal API client and needs a key) ---- */
.api-key-box {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 14px;
}

.api-key-label {
    font-size: 12px;
    font-weight: 600;
    opacity: 0.75;
    white-space: nowrap;
}

.api-key-input {
    width: 190px;
    padding: 7px 10px;
    font-family: inherit;
    font-size: 12px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: inherit;
}

.api-key-input::placeholder { opacity: 0.5; }

.api-key-input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.14);
}

.btn-key-save {
    padding: 7px 12px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    color: inherit;
    cursor: pointer;
}

.btn-key-save:hover { background: rgba(255, 255, 255, 0.2); }

@media (max-width: 900px) {
    .api-key-box { display: none; }
}
