/* ===========================================================================
   Document Translator — Styles
   Dark theme with glassmorphism, gradients, and micro-animations
   =========================================================================== */

:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-card: rgba(20, 20, 50, 0.65);
    --bg-card-hover: rgba(30, 30, 65, 0.75);
    --border-card: rgba(108, 99, 255, 0.15);
    --border-card-hover: rgba(108, 99, 255, 0.35);

    --text-primary: #e8e8f0;
    --text-secondary: #9090b0;
    --text-muted: #606080;

    --accent-1: #6C63FF;
    --accent-2: #00D2FF;
    --accent-gradient: linear-gradient(135deg, #6C63FF 0%, #00D2FF 100%);
    --success-gradient: linear-gradient(135deg, #00D26A 0%, #00D2FF 100%);
    --error: #FF4757;

    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --transition: 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Animated background */
.bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(108, 99, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(108, 99, 255, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    z-index: 0;
}

.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.4;
    z-index: 0;
    pointer-events: none;
}

.bg-glow-1 {
    width: 500px;
    height: 500px;
    background: var(--accent-1);
    top: -150px;
    right: -100px;
    animation: float1 15s ease-in-out infinite;
}

.bg-glow-2 {
    width: 400px;
    height: 400px;
    background: var(--accent-2);
    bottom: -100px;
    left: -100px;
    animation: float2 18s ease-in-out infinite;
}

@keyframes float1 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-60px, 80px); }
}

@keyframes float2 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(60px, -60px); }
}

/* Container */
.container {
    position: relative;
    z-index: 1;
    max-width: 580px;
    margin: 0 auto;
    padding: 60px 24px 40px;
    display: flex;
    flex-direction: column;
    align-items: center; /* Enforce horizontal centering of children */
    gap: 28px;
    min-height: 100vh;
}

/* UI Language Switcher */
.ui-lang-switcher {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 1000;
}

.ui-current-lang {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    padding: 6px 14px;
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition);
    box-shadow: var(--shadow);
}

.user-account {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    padding: 8px 18px;
    border-radius: 30px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all var(--transition);
}

.user-account:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-1);
    transform: translateY(-1px);
}

.user-name {
    font-size: 0.88rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.admin-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(108, 99, 255, 0.1);
    border: 1px solid rgba(108, 99, 255, 0.2);
    border-radius: 8px;
    color: var(--accent-1);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all var(--transition);
    margin: 0 4px;
}

.admin-link:hover {
    background: var(--accent-1);
    color: #fff;
    transform: rotate(45deg) scale(1.1);
    box-shadow: 0 0 15px rgba(108, 99, 255, 0.4);
}

.dashboard-trigger[data-t="open_command_center"]::before {
    content: attr(title);
    display: none; /* We will use the text inside or title */
}

.btn-logout {
    background: rgba(255, 71, 87, 0.08);
    border: 1px solid rgba(255, 71, 87, 0.2);
    color: var(--error);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 12px;
    transition: all var(--transition);
    margin-left: 4px;
}

.btn-logout:hover {
    background: var(--error);
    color: #fff;
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.25);
}

.ui-current-lang:hover {
    border-color: var(--accent-1);
    background: var(--bg-card-hover);
}

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

.ui-lang-popup {
    display: flex;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    padding: 6px 16px;
    border-radius: 24px;
    position: absolute;
    right: 110%; /* Slide left */
    top: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateX(20px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: var(--shadow);
}

.ui-lang-switcher:hover .ui-lang-popup,
.ui-lang-switcher.active .ui-lang-popup {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.ui-lang-btn {
    background: none;
    border: none;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 0;
    color: var(--text-primary);
    transition: all var(--transition);
    position: relative;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: grayscale(1) opacity(0.6);
}

.ui-lang-btn:hover {
    filter: grayscale(0) opacity(1);
    transform: scale(1.1);
}

.ui-lang-btn.active {
    filter: grayscale(0) opacity(1);
}

.ui-lang-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-gradient);
    border-radius: 2px;
}

@media (max-width: 480px) {
    .header-nav-group {
        top: 10px;
        right: 10px;
        gap: 8px;
    }
    .btn-icon-nav span {
        display: none !important;
    }
    .btn-icon-nav {
        padding: 6px 10px;
    }
    .ui-lang-switcher {
        position: relative;
    }
    .ui-lang-popup {
        flex-direction: column;
        right: 0;
        left: auto;
        top: 45px;
        transform: scale(0.9) translateY(-10px);
        opacity: 0;
        visibility: hidden;
        gap: 8px;
        padding: 12px 14px;
        align-items: center;
        width: 46px; 
        border-radius: 20px;
    }
    .ui-lang-switcher:hover .ui-lang-popup,
    .ui-lang-switcher.active .ui-lang-popup {
        opacity: 1;
        visibility: visible;
        transform: scale(1) translateY(0);
    }
}

/* Header */
.header {
    text-align: center;
    position: relative; /* Anchor for absolute children */
    margin-bottom: 24px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo h1 {
    font-size: 1.6rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 300;
}

/* Card */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius);
    padding: 32px;
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow);
    transition: border-color var(--transition);
    animation: cardIn 0.5s ease-out;
    position: relative; /* Ensure child absolute positioning works */
}

.card-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 50%;
}

.card-close:hover {
    color: var(--accent-1);
    background: rgba(108, 99, 255, 0.1);
    transform: scale(1.1);
}

.card:hover {
    border-color: var(--border-card-hover);
}

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

/* Drop Zone */
.drop-zone {
    border: 2px dashed rgba(108, 99, 255, 0.3);
    border-radius: var(--radius-sm);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent-1);
    background: rgba(108, 99, 255, 0.06);
}

.drop-zone.drag-over {
    transform: scale(1.01);
}

.drop-zone-icon {
    color: var(--accent-1);
    margin-bottom: 16px;
    transition: transform var(--transition);
}

.drop-zone:hover .drop-zone-icon {
    transform: translateY(-4px);
}

.drop-zone-text {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.drop-zone-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* File info */
.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(108, 99, 255, 0.08);
    border: 1px solid rgba(108, 99, 255, 0.2);
    border-radius: var(--radius-sm);
    margin-top: 16px;
    animation: fadeIn 0.3s ease;
}

.file-info-icon {
    color: var(--accent-2);
    flex-shrink: 0;
}

.file-info-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.file-name {
    font-size: 0.92rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all var(--transition);
    flex-shrink: 0;
}

.btn-icon:hover {
    color: var(--error);
    background: rgba(255, 71, 87, 0.1);
}

/* Language row */
.lang-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 20px;
}

.label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.select-wrapper {
    flex: 1;
    position: relative;
}

.select-wrapper::after {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-top-color: var(--text-secondary);
    pointer-events: none;
}

select {
    width: 100%;
    padding: 10px 36px 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(108, 99, 255, 0.2);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color var(--transition);
}

select:hover,
select:focus {
    border-color: var(--accent-1);
    outline: none;
}

select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Buttons */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 24px;
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    margin-top: 20px;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
    opacity: 0;
    transition: opacity var(--transition);
}

.btn-primary:hover:not(:disabled)::before {
    opacity: 1;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(108, 99, 255, 0.35);
}

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

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-arrow {
    transition: transform var(--transition);
}

.btn-primary:hover:not(:disabled) .btn-arrow {
    transform: translateX(3px);
}

.btn-secondary {
    display: block;
    width: 100%;
    padding: 12px 24px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid rgba(108, 99, 255, 0.2);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    margin-top: 12px;
}

.btn-secondary:hover {
    background: rgba(108, 99, 255, 0.08);
    border-color: rgba(108, 99, 255, 0.35);
    color: var(--text-primary);
}

.btn-download {
    background: var(--success-gradient);
}

.btn-download:hover:not(:disabled) {
    box-shadow: 0 8px 24px rgba(0, 210, 106, 0.3);
}

/* Progress */
.progress-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding-right: 32px; /* Avoid overlap with close button */
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(108, 99, 255, 0.15);
    border-top-color: var(--accent-1);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

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

.progress-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.progress-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 3px;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: rgba(108, 99, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent-gradient);
    border-radius: 4px;
    transition: width 0.5s ease;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 40px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3));
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

.progress-percent {
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 8px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* Result */
.result-icon,
.error-icon {
    text-align: center;
    margin-bottom: 16px;
}

.result-title {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    background: var(--success-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.result-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-top: 6px;
    margin-bottom: 20px;
}

/* Error */
.error-title {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--error);
}

.error-message {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-top: 8px;
    margin-bottom: 20px;
    word-break: break-word;
}

/* Footer */
.footer {
    text-align: center;
    padding-top: 10px;
}

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

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

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

/* History Items */
.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateX(4px);
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-name {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.history-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.history-status {
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 600;
    font-size: 0.65rem;
}

.status-done { background: rgba(52, 211, 153, 0.1); color: #34d399; }
.status-proc, .status-processing, .status-queued { background: rgba(96, 165, 250, 0.1); color: #60a5fa; }
.status-error { background: rgba(248, 113, 113, 0.1); color: #f87171; }

.history-delete {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 12px;
}

.history-delete:hover {
    background: rgba(248, 113, 113, 0.1);
    color: #f87171;
}

/* Custom Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: rgba(30, 30, 45, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-align: center;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.modal-content p {
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-actions button, .modal-actions .btn-secondary, .modal-actions .btn-danger {
    flex: 1;
    width: auto !important; /* Reset global width: 100% */
    margin-top: 0 !important;
}

.btn-danger {
    background: #f87171;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 480px) {
    .container {
        padding: 36px 16px 32px;
    }

    .card {
        padding: 24px 20px;
    }

    .drop-zone {
        padding: 36px 16px;
    }

    .logo h1 {
        font-size: 1.35rem;
    }

    .lang-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .mode-toggle-wrapper {
        justify-content: space-between;
    }
}

/* Mode Toggle Styles */
.mode-toggle-wrapper {
    display: flex;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(108, 99, 255, 0.2);
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
}

.mode-option {
    flex: 1;
    position: relative;
}

.mode-option input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.mode-option label {
    display: block;
    padding: 8px 12px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: 9px;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.mode-option input:checked + label {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 4px 12px rgba(108, 99, 255, 0.2);
}

.mode-option:hover label:not(input:checked + label) {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.hidden {
    display: none !important;
}

/* OCR Context Block */
.ocr-context-block {
    background: rgba(108, 99, 255, 0.05);
    border: 1px solid rgba(108, 99, 255, 0.15);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 20px;
}

.context-header {
    margin-bottom: 12px;
}

.context-hint {
    font-size: 0.75rem;
    color: var(--accent-2);
    margin-top: 4px;
    opacity: 0.8;
}

.context-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.context-field label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.context-field input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(108, 99, 255, 0.2);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.85rem;
    transition: all var(--transition);
}

.context-field input:focus {
    outline: none;
    border-color: var(--accent-1);
    background: rgba(108, 99, 255, 0.1);
}
/* Dashboard Sidebar */
.dashboard-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    height: 100vh;
    background: rgba(10, 10, 26, 0.95);
    -webkit-backdrop-filter: blur(25px);
    backdrop-filter: blur(25px);
    border-left: 1px solid rgba(108, 99, 255, 0.2);
    box-shadow: -20px 0 50px rgba(0, 0, 0, 0.8);
    z-index: 2000;
    transition: right 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    display: flex;
    flex-direction: column;
    visibility: hidden; /* Prevent phantom presence */
    pointer-events: none;
}

.dashboard-sidebar.active {
    right: 0;
    visibility: visible;
    pointer-events: auto;
}

.dashboard-header {
    padding: 24px;
    border-bottom: 1px solid rgba(108, 99, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dashboard-title {
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--accent-2);
    text-shadow: 0 0 10px rgba(0, 210, 255, 0.4);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color var(--transition);
}

.close-btn:hover {
    color: var(--accent-1);
}

.dashboard-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-1) transparent;
}

.dashboard-content::-webkit-scrollbar {
    width: 4px;
}

.dashboard-content::-webkit-scrollbar-thumb {
    background: var(--accent-1);
    border-radius: 10px;
}

/* User Profile Card */
.user-profile-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01));
    border: 1px solid rgba(108, 99, 255, 0.2);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.user-profile-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(108, 99, 255, 0.05) 0%, transparent 70%);
    pointer-events: none;
}

.user-avatar-container {
    position: relative;
    width: 60px;
    height: 60px;
    flex-shrink: 0;
}

.user-avatar {
    width: 60px;
    height: 60px;
    aspect-ratio: 1/1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    position: relative;
    z-index: 1;
    box-shadow: 0 0 20px rgba(108, 99, 255, 0.2);
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-info h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
}

.credits-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(0, 210, 255, 0.1);
    border: 1px solid rgba(0, 210, 255, 0.2);
    border-radius: 20px;
    color: var(--accent-2);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.1);
    cursor: pointer;
    transition: all var(--transition);
}

.credits-badge:hover {
    background: rgba(0, 210, 255, 0.2);
    transform: translateY(-1px);
}

.credits-badge.zero-balance {
    background: rgba(255, 71, 87, 0.15);
    border-color: rgba(255, 71, 87, 0.4);
    color: #ff4757;
    box-shadow: 0 0 15px rgba(255, 71, 87, 0.2);
}

.credits-badge.zero-balance svg {
    color: #ff4757;
}

.credits-badge.zero-balance:hover {
    background: rgba(255, 71, 87, 0.25);
}

.credits-badge svg {
    color: var(--accent-2);
}

.credits-label {
    opacity: 0.8;
    font-weight: 400;
}
.avatar-glow {
    position: absolute;
    inset: -3px;
    background: var(--accent-gradient);
    border-radius: 50%;
    opacity: 0.4;
    filter: blur(8px);
    animation: avatarPulse 3s ease-in-out infinite;
}

@keyframes avatarPulse {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.1); opacity: 0.5; }
}

.user-info h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* Refresh Button Styling */
.btn-refresh {
    background: rgba(108, 99, 255, 0.08);
    border: 1px solid rgba(108, 99, 255, 0.2);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 8px 16px;
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.btn-refresh:hover {
    background: rgba(108, 99, 255, 0.15);
    border-color: var(--accent-1);
    box-shadow: 0 0 20px rgba(108, 99, 255, 0.25);
    transform: translateY(-1px);
}

.btn-refresh svg {
    transition: transform 0.6s cubic-bezier(0.19, 1, 0.22, 1);
}

.btn-refresh:hover svg {
    transform: rotate(180deg);
}

.history-item-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.history-filename {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-status-badge {
    font-size: 0.6rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.history-status-badge.done {
    background: rgba(0, 210, 106, 0.15);
    color: #00D26A;
}

.history-status-badge.processing {
    background: rgba(255, 171, 0, 0.15);
    color: #FFAB00;
    animation: statusPulse 1.5s infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.download-icon {
    color: var(--text-muted);
    transition: color var(--transition);
}

.history-item:hover .download-icon {
    color: var(--accent-2);
}

.history-empty {
    text-align: center;
    padding: 40px 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
}

/* Footer */
.dashboard-footer {
    padding: 24px;
    border-top: 1px solid rgba(108, 99, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.footer-btn {
    width: 100%;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all var(--transition);
}

.footer-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-card-hover);
}

.footer-btn.logout {
    color: var(--error);
    border-color: rgba(255, 71, 87, 0.2);
}

.footer-btn.logout:hover {
    background: rgba(255, 71, 87, 0.1);
    border-color: var(--error);
}

/* User Trigger */
.dashboard-trigger {
    cursor: pointer;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.dashboard-title {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(108, 99, 255, 0.3);
}

.gradient-text {
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.user-name {
    font-weight: 600;
    color: var(--accent-1);
}

.history-filename {
    font-weight: 600;
    color: var(--text-primary);
    display: block;
    margin-bottom: 4px;
    background: linear-gradient(90deg, var(--text-primary), var(--text-muted));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.toast {
    min-width: 300px;
    max-width: 400px;
    padding: 16px 20px;
    background: rgba(15, 12, 41, 0.8);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--text-primary);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    animation: toastIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    transition: all 0.3s ease;
}

.toast.hiding {
    animation: toastOut 0.3s ease forwards;
}

.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.toast-content {
    flex-grow: 1;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
}

.toast.success { border-left: 4px solid var(--accent-2); }
.toast.error { border-left: 4px solid var(--error); }
.toast.info { border-left: 4px solid var(--accent-1); }

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

@keyframes toastOut {
    from {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
    to {
        transform: translateX(20%) scale(0.9);
        opacity: 0;
    }
}

/* --- Auth Component --- */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    z-index: 1;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    animation: cardIn 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    position: relative; /* For lang switcher positioning */
    padding-top: 40px;  /* Space for switcher */
}

.auth-lang-switcher {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
}
.auth-header {
    text-align: center;
    margin-bottom: 32px;
}
.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}
.auth-logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.auth-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 300;
}
.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-left: 4px;
}
.form-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(108, 99, 255, 0.2);
    border-radius: 12px;
    color: var(--text-primary) !important;
    font-family: var(--font);
    font-size: 0.95rem;
    transition: all var(--transition);
}

/* [BUG-009] Fix white/black background on autofill/focus in Chrome/Safari */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text-primary) !important;
    -webkit-box-shadow: 0 0 0px 1000px #12122a inset !important;
    transition: background-color 5000s ease-in-out 0s;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-1);
    box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.1);
}

.form-input:invalid:not(:placeholder-shown) {
    border-color: var(--error);
}

/* Password Toggle Styles */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper .form-input {
    padding-right: 48px;
}

.toggle-password {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition);
    z-index: 2;
}

.toggle-password:hover {
    color: var(--accent-2);
}

.toggle-password svg {
    width: 20px;
    height: 20px;
}
.auth-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.auth-link {
    color: var(--accent-2);
    text-decoration: none;
    font-weight: 600;
    transition: opacity var(--transition);
}
.auth-link:hover {
    opacity: 0.8;
}
.error-alert {
    color: #ff4757;
    font-size: 0.85rem;
    margin-bottom: 16px;
    text-align: center;
    display: none;
    background: rgba(255, 71, 87, 0.1);
    padding: 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 71, 87, 0.2);
    animation: shake 0.4s ease-in-out;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}
.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 24px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.divider:not(:empty)::before { margin-right: 1em; }
.divider:not(:empty)::after { margin-left: 1em; }

.btn-google {
    background: #fff;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-weight: 500;
    font-size: 0.95rem;
    border: none;
    border-radius: 12px;
    padding: 12px;
    width: 100%;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-google:hover {
    background: #f1f1f1;
    transform: translateY(-1px);
}

/* --- Top Navigation Refinement --- */
.header-nav-group {
    position: absolute;
    right: 0;
    top: -38px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 100;
}

#dashboard-toggle-btn {
    z-index: 10;
}

.btn-icon-nav {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    padding: 6px 16px;
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition);
    box-shadow: var(--shadow);
    text-decoration: none;
    line-height: 1;
}

.btn-icon-nav:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-1);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(108, 99, 255, 0.2);
}

.btn-icon-nav span {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: inline-block;
}

.btn-icon-nav svg {
    display: block;
    color: var(--accent-1);
}

/* Shift main container to avoid overlap if needed */

.progress-trace {
    font-size: 0.75rem;
    color: var(--accent-1);
    margin-top: -1rem;
    margin-bottom: 1rem;
    font-family: 'Space Mono', monospace;
    opacity: 0.8;
}
