/* ===== 9Spa AutoContent — giao diện trên nền Bootstrap 5 ===== */
:root {
    --ns-accent: #1f9d85;
    --ns-accent-hover: #178270;
    --ns-accent-soft: #e3f4f0;
    --ns-sidebar: #10231f;
    --ns-sidebar-text: #b9ccc7;
    --ns-sidebar-muted: #6f8c85;
    --ns-bg: #f5f7f6;
    --ns-surface: #ffffff;
    --ns-border: #e3e8e6;
    --ns-text: #1c2b28;
    --ns-muted: #6b7b77;
    --ns-radius: 12px;
    --bs-primary: var(--ns-accent);
    --bs-primary-rgb: 31, 157, 133;
    --bs-link-color: var(--ns-accent);
    --bs-link-hover-color: var(--ns-accent-hover);
    --bs-body-font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-color: var(--ns-text);
    --bs-body-bg: var(--ns-bg);
    --bs-border-color: var(--ns-border);
}

html, body { height: 100%; }
body { font-size: 0.94rem; -webkit-font-smoothing: antialiased; }
h1:focus { outline: none; }
.icon { flex-shrink: 0; vertical-align: -0.2em; }

.btn-primary { --bs-btn-bg: var(--ns-accent); --bs-btn-border-color: var(--ns-accent); --bs-btn-hover-bg: var(--ns-accent-hover); --bs-btn-hover-border-color: var(--ns-accent-hover); --bs-btn-active-bg: #136b5c; --bs-btn-active-border-color: #136b5c; --bs-btn-disabled-bg: var(--ns-accent); --bs-btn-disabled-border-color: var(--ns-accent); }
.btn-outline-primary { --bs-btn-color: var(--ns-accent); --bs-btn-border-color: var(--ns-accent); --bs-btn-hover-bg: var(--ns-accent); --bs-btn-hover-border-color: var(--ns-accent); --bs-btn-active-bg: var(--ns-accent-hover); }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: #7cc9b9; box-shadow: 0 0 0 .2rem rgba(31, 157, 133, .18); }
.form-check-input:checked { background-color: var(--ns-accent); border-color: var(--ns-accent); }
.text-accent { color: var(--ns-accent) !important; }
.bg-accent-soft { background: var(--ns-accent-soft) !important; }
.nav-pills .nav-link.active { background: var(--ns-accent); }
.nav-tabs .nav-link { color: var(--ns-muted); }
.nav-tabs .nav-link.active { color: var(--ns-text); font-weight: 600; }
.page-link { color: var(--ns-accent); }
.page-item.active .page-link { background: var(--ns-accent); border-color: var(--ns-accent); }

/* ===== Khung ứng dụng ===== */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar { width: 256px; flex-shrink: 0; background: var(--ns-sidebar); color: var(--ns-sidebar-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 1030; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar { height: 60px; background: var(--ns-surface); border-bottom: 1px solid var(--ns-border); display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem; position: sticky; top: 0; z-index: 1020; }
.app-content { padding: 1.75rem; max-width: 1440px; width: 100%; }
.app-backdrop { display: none; }

.app-brand { display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1.25rem 1rem; color: #fff; text-decoration: none; }
.app-brand:hover { color: #fff; }
.app-brand strong { display: block; font-size: 1.15rem; line-height: 1.1; }
.app-brand small { display: block; color: var(--ns-sidebar-muted); font-size: .75rem; }
.app-brand__logo { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, #2fb59c, #147a67); color: #fff; font-weight: 800; font-size: 1.2rem; display: grid; place-items: center; box-shadow: 0 4px 14px rgba(31, 157, 133, .35); }
.app-brand--auth { padding: 0; color: var(--ns-text); }
.app-brand--auth small { color: var(--ns-muted); }

.app-nav { padding: .25rem .75rem 1rem; flex: 1; }
.app-nav__section { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ns-sidebar-muted); padding: 1rem .75rem .35rem; }
.app-nav__link { display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; margin: 1px 0; border-radius: 8px; color: var(--ns-sidebar-text); text-decoration: none; font-weight: 500; }
.app-nav__link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.app-nav__link.active { background: rgba(47, 181, 156, .18); color: #fff; box-shadow: inset 3px 0 0 #2fb59c; }
.app-sidebar__footer { padding: 1rem 1.5rem; color: var(--ns-sidebar-muted); border-top: 1px solid rgba(255, 255, 255, .06); }

.credit-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .75rem; border-radius: 999px; background: var(--ns-accent-soft); color: #136b5c; font-weight: 600; font-size: .85rem; text-decoration: none; white-space: nowrap; }
.credit-chip:hover { color: #0f5448; background: #d2ede7; }
.credit-chip__sep { width: 1px; height: 14px; background: rgba(19, 107, 92, .25); margin: 0 .25rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--ns-accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .85rem; }

@media (max-width: 991.98px) {
    .app-sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar-open .app-sidebar { transform: translateX(0); }
    .sidebar-open .app-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 1025; }
    .app-content { padding: 1rem; }
}

/* ===== Thành phần chung ===== */
.card { border-color: var(--ns-border); border-radius: var(--ns-radius); box-shadow: 0 1px 2px rgba(16, 35, 31, .04); }
.card-header { background: transparent; border-bottom-color: var(--ns-border); font-weight: 600; }
.table { --bs-table-bg: transparent; }
.table > :not(caption) > * > * { padding: .7rem .75rem; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ns-muted); font-weight: 600; border-bottom-width: 1px; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: rgba(31, 157, 133, .04); }
.badge { font-weight: 600; }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.stat-card .stat-label { color: var(--ns-muted); font-size: .85rem; }
.empty-state__icon { color: #9fb3ae; }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ns-muted); font-weight: 700; margin-bottom: .75rem; }
.text-prewrap { white-space: pre-wrap; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .85rem; }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: #eef2f1; border: 1px solid var(--ns-border); }
.thumb-lg { width: 160px; height: 120px; border-radius: 10px; object-fit: contain; background: #f1f4f3; border: 1px solid var(--ns-border); }
.checker { background-color: #f3f5f4; background-image: linear-gradient(45deg, #e6ebe9 25%, transparent 25%), linear-gradient(-45deg, #e6ebe9 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e6ebe9 75%), linear-gradient(-45deg, transparent 75%, #e6ebe9 75%); background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0; }

/* Các bước quy trình */
.pipeline-steps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .75rem; }
.pipeline-step { border: 1px solid var(--ns-border); border-radius: 10px; padding: .85rem; background: var(--ns-surface); }
.pipeline-step__num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem; background: #eef2f1; color: var(--ns-muted); }
.pipeline-step.is-running { border-color: #6fc0d6; box-shadow: 0 0 0 3px rgba(13, 202, 240, .12); }
.pipeline-step.is-running .pipeline-step__num { background: #0dcaf0; color: #fff; }
.pipeline-step.is-done .pipeline-step__num { background: var(--ns-accent); color: #fff; }
.pipeline-step.is-failed .pipeline-step__num { background: #dc3545; color: #fff; }
.pipeline-step.is-waiting .pipeline-step__num { background: #ffc107; color: #3b2f00; }
@media (max-width: 767.98px) { .pipeline-steps { grid-template-columns: 1fr; } }

.log-list { max-height: 360px; overflow-y: auto; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .8rem; background: #0f1d1a; color: #c9dad6; border-radius: 10px; padding: .75rem 1rem; }
.log-list .log-error { color: #ff8f8f; }
.log-list .log-time { color: #6f8c85; margin-right: .5rem; }

.article-frame { width: 100%; min-height: 70vh; border: 1px solid var(--ns-border); border-radius: 10px; background: #fff; }
.code-box { max-height: 60vh; overflow: auto; background: #0f1d1a; color: #dfeae7; border-radius: 10px; padding: 1rem; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .8rem; white-space: pre-wrap; word-break: break-word; }

/* Thông báo */
.toast-stack { position: fixed; right: 1rem; bottom: 1rem; z-index: 1090; display: flex; flex-direction: column; gap: .5rem; max-width: min(420px, calc(100vw - 2rem)); }
.toast { box-shadow: 0 8px 24px rgba(16, 35, 31, .16); border-radius: 10px; }
.toast-success { background: #e3f4f0; color: #0f5448; }
.toast-info { background: #e7f3fb; color: #0b4a6f; }
.toast-warning { background: #fff6dd; color: #6b4e00; }
.toast-error { background: #fde8e8; color: #8a1c1c; }

/* Trang đăng nhập */
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem; background: radial-gradient(circle at 20% 10%, #e3f4f0 0, transparent 40%), radial-gradient(circle at 90% 90%, #e8efe9 0, transparent 40%), var(--ns-bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--ns-surface); border: 1px solid var(--ns-border); border-radius: 16px; padding: 2rem; box-shadow: 0 12px 40px rgba(16, 35, 31, .08); }
.auth-footer { color: var(--ns-muted); margin-top: 1.25rem; text-align: center; }

#blazor-error-ui { background: #fff6dd; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, .2); display: none; left: 0; padding: .6rem 1.25rem .7rem 1.25rem; position: fixed; width: 100%; z-index: 2000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
.blazor-error-boundary { background: #fde8e8; padding: 1rem; color: #8a1c1c; border-radius: 10px; }
.blazor-error-boundary::after { content: "Đã xảy ra lỗi khi hiển thị phần này."; }
.validation-message { color: #dc3545; font-size: .85rem; }
.invalid { outline: 1px solid #dc3545; }
.nav-scroll { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
