:root {
    --bg: #0f172a;
    --card: #1e293b;
    --border: #334155;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --ok: #22c55e;
    --err: #ef4444;
    --warn: #f59e0b;
}

[hidden] {
    display: none !important;
}

/* Chrome, Edge, Safari */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: transparent; /* nền trong suốt */
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.5); /* màu tối trong suốt */
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.8); /* hover đậm hơn */
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

.container {
    max-width: 1150px;
    margin: 0 auto;
    padding: 1.25rem 1rem 1.5rem;
}

.header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.header h1 {
    margin: 0 0 0.35rem;
    font-size: 1.5rem;
}

.header p { margin: 0; color: var(--muted); font-size: 0.95rem; }

.status-pill {
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: var(--card);
    border: 1px solid var(--border);
    white-space: nowrap;
}

.status-pill.ok { border-color: var(--ok); color: var(--ok); }
.status-pill.warn { border-color: var(--warn); color: var(--warn); }
.status-pill.err { border-color: var(--err); color: var(--err); }

.layout-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 1.25rem;
    align-items: start;
}

.main-column {
    min-width: 0;
}

.sidebar-column {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-width: 0;
}

@media (max-width: 900px) {
    .layout-grid {
        grid-template-columns: 1fr;
    }
    .sidebar-column {
        order: 2;
    }
}

.grid {
    display: grid;
    gap: 1.25rem;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
}

.card-title {
    margin: 0 0 1rem;
    font-size: 1.05rem;
}

label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.35rem;
    margin-top: 0.85rem;
}

label:first-of-type { margin-top: 0; }

input[type="url"],
input[type="text"],
input[type="password"],
select {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
}

input:focus, select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.btn-row {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

button {
    cursor: pointer;
    border: none;
    border-radius: 8px;
    padding: 0.7rem 1.1rem;
    font-size: 0.95rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

button.primary {
    background: var(--accent);
    color: #fff;
    flex: 1;
    justify-content: center;
}

button.primary:hover { background: var(--accent-hover); }
button.primary:disabled { opacity: 0.6; cursor: not-allowed; }

button.secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

button.secondary:hover { border-color: var(--muted); }
button.small { padding: 0.45rem 0.85rem; font-size: 0.85rem; }

.spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: none;
}

button.loading .spinner { display: inline-block; }

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

.message {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.message.error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--err);
    color: #fecaca;
}

.message.success {
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid var(--ok);
    color: #bbf7d0;
}

.hint { color: var(--muted); font-size: 0.85rem; margin: 0.25rem 0 0; }

.preview-box {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.preview-box img {
    border-radius: 6px;
    object-fit: cover;
    background: #000;
}

.progress-box { margin-top: 1rem; }

.progress-track {
    height: 8px;
    background: var(--bg);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), #60a5fa);
    transition: width 0.3s ease;
}

.jobs-list { display: flex; flex-direction: column; gap: 0.65rem; }

.history-card .card-title { margin: 0; }

.history-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.btn-history-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.btn-history-clear:hover {
    color: var(--err);
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.08);
}

.btn-history-clear:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.history-private { margin-bottom: 0.85rem; margin-top: 0; }
.history-empty { margin: 0; }

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    max-height: 420px;
    overflow-y: auto;
}

.history-item {
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 0.88rem;
}

.history-item .history-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-item .history-meta {
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.45;
}

.history-item .history-actions {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.history-item .history-actions a,
.history-item .history-actions button {
    font-size: 0.78rem;
    padding: 0.35rem 0.65rem;
}


.job-item {
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 0.88rem;
}

.job-item .job-title { font-weight: 600; margin-bottom: 0.25rem; }
.job-item .job-meta { color: var(--muted); font-size: 0.8rem; }

.status-pending { color: var(--warn); }
.status-running { color: var(--accent); }
.status-completed { color: var(--ok); }
.status-failed { color: var(--err); }

.site-footer {
    margin-top: 20px;
    padding-top: 0.65rem;
    text-align: center;
    font-size: 0.72rem;
    line-height: 1.45;
    color: var(--muted);
}

.site-footer p {
    margin: 0;
}

.site-footer b {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: #cbd5e1;
}

.footer-online {
    color: var(--ok) !important;
}

.footer-sep {
    margin: 0 0.28rem;
    opacity: 0.35;
}

.footer-brand {
    color: #93c5fd;
    font-weight: 600;
    text-decoration: none;
}

.footer-brand:hover {
    color: #bfdbfe;
}

.footer-note {
    color: #64748b;
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
}

.login-card h1 { margin: 0 0 0.5rem; font-size: 1.25rem; }

.field-label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}

/* Mode radio cards */
.mode-radio-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.mode-radio {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem 0.85rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.mode-radio input { position: absolute; opacity: 0; pointer-events: none; }

.mode-radio.is-active,
.mode-radio:has(input:checked) {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.25);
}

.mode-radio-icon { font-size: 1.35rem; line-height: 1; }

.mode-radio-text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.mode-radio-text strong { font-size: 0.9rem; }
.mode-radio-text small { font-size: 0.75rem; color: var(--muted); }

.mode-radio.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

/* Quality pills */
.quality-wrap { min-height: 2.5rem; }

.quality-placeholder {
    padding: 0.65rem 0.75rem;
    border: 1px dashed var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    margin: 0;
}

.quality-loading { padding: 0.25rem 0; }

.quality-loading-inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.65rem;
}

.quality-skeleton-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.quality-radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.quality-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.quality-pill input { position: absolute; opacity: 0; pointer-events: none; }

.quality-pill.is-active,
.quality-pill:has(input:checked) {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.15);
    color: #bfdbfe;
}

.quality-pill.is-disabled { opacity: 0.5; pointer-events: none; }

.quality-audio-note {
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0;
}

/* Preview + skeleton */
.preview-box {
    margin-top: 0.85rem;
    margin-bottom: 0.25rem;
}

.preview-thumb-wrap {
    flex-shrink: 0;
    width: 120px;
    height: 68px;
    border-radius: 6px;
    overflow: hidden;
    background: #000;
}

.preview-body { min-width: 0; flex: 1; }

.preview-skeleton {
    display: flex;
    gap: 1rem;
    margin-top: 0.85rem;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.sk-thumb {
    width: 120px;
    height: 68px;
    border-radius: 6px;
    flex-shrink: 0;
    background: var(--card);
}

.sk-lines { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; padding-top: 0.25rem; }

.sk-line {
    height: 14px;
    border-radius: 6px;
    background: var(--card);
}

.sk-line.short { width: 55%; }

.sk-pill {
    width: 72px;
    height: 32px;
    border-radius: 999px;
    background: var(--card);
}

.shimmer {
    position: relative;
    overflow: hidden;
}

.shimmer::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.06),
        transparent
    );
    animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
    100% { transform: translateX(100%); }
}

.mini-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(148, 163, 184, 0.3);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

@media (max-width: 520px) {
    .mode-radio-group { grid-template-columns: 1fr; }
}

.toast-stack {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    max-width: min(380px, calc(100vw - 1.5rem));
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    padding: 0.85rem 1.1rem;
    border-radius: 10px;
    font-size: 0.9rem;
    line-height: 1.45;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
    animation: toast-in 0.28s ease;
}

.toast-success {
    background: #14532d;
    border: 1px solid var(--ok);
    color: #bbf7d0;
}

.toast-error {
    background: #7f1d1d;
    border: 1px solid var(--err);
    color: #fecaca;
}

.toast-out {
    opacity: 0;
    transform: translateX(12px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

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

@media (max-width: 520px) {
    .toast-stack {
        left: 0.75rem;
        right: 0.75rem;
        bottom: 0.75rem;
        align-items: stretch;
    }
}

