/* =============================================
   BabelDOC Web UI — Dark Glassmorphism Theme
   ============================================= */

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

:root {
    --bg-primary: #07070e;
    --bg-secondary: #0d0d1a;
    --bg-card: rgba(15, 15, 30, 0.7);
    --bg-input: rgba(20, 20, 40, 0.6);
    --glass-border: rgba(80, 80, 160, 0.15);
    --glass-highlight: rgba(100, 100, 200, 0.08);
    --accent-1: #6c5ce7;
    --accent-2: #a29bfe;
    --accent-3: #00cec9;
    --accent-gradient: linear-gradient(135deg, #6c5ce7, #a29bfe, #00cec9);
    --text-primary: #e8e8f0;
    --text-secondary: #9090b0;
    --text-muted: #606080;
    --success: #00b894;
    --warning: #fdcb6e;
    --error: #ff7675;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background gradient orbs */
body::before,
body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    z-index: 0;
    pointer-events: none;
}
body::before {
    width: 600px; height: 600px;
    background: #6c5ce7;
    top: -200px; left: -100px;
}
body::after {
    width: 500px; height: 500px;
    background: #00cec9;
    bottom: -150px; right: -100px;
}

/* ---- Layout ---- */
.app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 20px 60px;
    position: relative;
    z-index: 1;
}

/* ---- Header ---- */
.header {
    text-align: center;
    margin-bottom: 36px;
    padding: 28px 0 20px;
}
.header h1 {
    font-size: 2.4rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}
.header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 6px;
}
.header .version {
    display: inline-block;
    font-size: 0.72rem;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    padding: 2px 10px;
    border-radius: 20px;
    color: var(--accent-2);
    margin-top: 8px;
}

/* ---- Card ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 20px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.card:hover {
    border-color: rgba(100, 100, 200, 0.25);
}
.card-title {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-secondary);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-title .icon { font-size: 1rem; }

/* ---- Upload Zone ---- */
.upload-zone {
    border: 2px dashed var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--accent-1);
    background: rgba(108, 92, 231, 0.06);
}
.upload-zone.drag-over {
    transform: scale(1.01);
}
.upload-zone .upload-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.7;
}
.upload-zone .upload-text {
    font-size: 1rem;
    color: var(--text-secondary);
}
.upload-zone .upload-text strong {
    color: var(--accent-2);
}
.upload-zone .upload-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 8px;
}
.upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* File preview */
.file-preview {
    display: none;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    margin-top: 14px;
}
.file-preview.visible { display: flex; }
.file-preview .file-icon { font-size: 2rem; }
.file-preview .file-info { flex: 1; text-align: left; }
.file-preview .file-name {
    font-weight: 500;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
}
.file-preview .file-size {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.file-preview .remove-file {
    background: none;
    border: none;
    color: var(--error);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    transition: var(--transition);
}
.file-preview .remove-file:hover { opacity: 0.7; }

/* ---- Form Controls ---- */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.form-group.full-width { grid-column: 1 / -1; }
.form-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.form-input, .form-select {
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: inherit;
    transition: var(--transition);
    width: 100%;
    outline: none;
}
.form-input:focus, .form-select:focus {
    border-color: var(--accent-1);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}
.form-input::placeholder { color: var(--text-muted); }
.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239090b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* Toggle section */
.toggle-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 8px 0;
    user-select: none;
}
.toggle-header .arrow {
    transition: transform 0.3s;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.toggle-header.open .arrow { transform: rotate(180deg); }
.toggle-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}
.toggle-content.open { max-height: 1200px; }

/* Checkbox row */
.checkbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: var(--transition);
}
.checkbox-label:hover { background: var(--glass-highlight); }
.checkbox-label input[type="checkbox"] {
    accent-color: var(--accent-1);
    width: 16px;
    height: 16px;
}

/* ---- Translate Button ---- */
.translate-btn {
    display: block;
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent-gradient);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.translate-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s;
}
.translate-btn:hover::before { transform: translateX(100%); }
.translate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(108, 92, 231, 0.4);
}
.translate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.translate-btn:disabled::before { display: none; }

/* ---- Progress Section ---- */
.progress-section { display: none; }
.progress-section.visible { display: block; }

.overall-progress {
    margin-bottom: 20px;
}
.overall-bar-bg {
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}
.overall-bar-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 4px;
    width: 0%;
    transition: width 0.4s ease;
}
.overall-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* Stage list */
.stage-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stage-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
    transition: var(--transition);
}
.stage-item.active {
    background: rgba(108, 92, 231, 0.08);
    color: var(--accent-2);
}
.stage-item.done {
    color: var(--success);
}
.stage-item .stage-icon {
    width: 20px;
    text-align: center;
    font-size: 0.9rem;
}
.stage-item .stage-name { flex: 1; }
.stage-item .stage-pct {
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    min-width: 40px;
    text-align: right;
}

/* ---- Results Section ---- */
.results-section { display: none; }
.results-section.visible { display: block; }

.result-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.stat-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    font-size: 0.8rem;
}
.stat-chip .stat-value {
    color: var(--accent-3);
    font-weight: 600;
}

.download-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
}
.download-btn:hover {
    border-color: var(--accent-1);
    background: rgba(108, 92, 231, 0.1);
    transform: translateY(-1px);
}
.download-btn .dl-icon { font-size: 1.1rem; }

/* ---- Error ---- */
.error-banner {
    display: none;
    padding: 14px 18px;
    background: rgba(255, 118, 117, 0.1);
    border: 1px solid rgba(255, 118, 117, 0.3);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 0.88rem;
    margin-bottom: 16px;
}
.error-banner.visible { display: block; }

/* ---- Footer ---- */
.footer {
    text-align: center;
    padding: 24px 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ---- Animations ---- */
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(108, 92, 231, 0); }
    50% { box-shadow: 0 0 16px 4px rgba(108, 92, 231, 0.2); }
}
.translating { animation: pulse-glow 2s infinite; }

@keyframes spin {
    to { transform: rotate(360deg); }
}
.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid var(--accent-2);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .app-container { padding: 16px 12px 40px; }
    .header h1 { font-size: 1.8rem; }
    .card { padding: 20px; }
    .form-grid { grid-template-columns: 1fr; }
    .checkbox-grid { grid-template-columns: 1fr; }
    .download-grid { grid-template-columns: 1fr; }
    .upload-zone { padding: 32px 16px; }
}
