/* VDK Content Optimizer — bản web. Bảng màu riêng của VDK (teal → navy), sáng/tối. */
:root, :root[data-theme="light"] {
    --bg: #F4F6F8; --surface: #FFFFFF; --surface-alt: #EEF2F5; --header: #0F2847; --header-text: #FFFFFF;
    --border: #D9E0E6; --text: #1B2733; --muted: #5B6B7A; --accent: #0D9488; --accent-hover: #0F766E; --accent-text: #FFFFFF;
    --accent-soft: #DDF4F1; --high: #B42318; --high-soft: #FDECEA; --medium: #B54708; --medium-soft: #FEF3E2;
    --low: #1D5FA8; --low-soft: #E8F1FB; --info: #5B6B7A; --info-soft: #EEF2F5; --success: #067647; --success-soft: #E3F6EC;
    --diff-add: #C9F0D6; --diff-del: #F9D4D0; --demo: #7A2E9E; --demo-soft: #F3E8FA;
    color-scheme: light;
}
:root[data-theme="dark"] {
    --bg: #12171D; --surface: #1B222A; --surface-alt: #232C36; --header: #0B1C31; --header-text: #E8EEF3;
    --border: #323D49; --text: #E6EBEF; --muted: #9AA8B5; --accent: #2DD4BF; --accent-hover: #5EEAD4; --accent-text: #062A27;
    --accent-soft: #123A37; --high: #FF8A80; --high-soft: #3A1F1E; --medium: #FDB462; --medium-soft: #3A2C17;
    --low: #8AB8F0; --low-soft: #1A2A3E; --info: #9AA8B5; --info-soft: #232C36; --success: #6EE7A8; --success-soft: #163327;
    --diff-add: #1F4A32; --diff-del: #5A2522; --demo: #D8B4FE; --demo-soft: #33204A;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    background: var(--bg); color: var(--text);
    font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", sans-serif;
    font-size: 14.5px; line-height: 1.5;
}
h1 { font-size: 1.45rem; margin: 0 0 .2rem; font-weight: 600; }
h2 { font-size: 1.15rem; margin: .6rem 0 .3rem; }
h3 { font-size: 1.02rem; margin: 1rem 0 .4rem; }
h4 { margin: .4rem 0 .2rem; font-size: .98rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.mt { margin-top: 1rem; } .mt-s { margin-top: .5rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Khung ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: 58px 1fr 32px; height: 100vh; }
.topbar { grid-column: 1 / -1; background: var(--header); color: var(--header-text); display: flex; align-items: center; justify-content: space-between; padding: 0 14px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--header-text); text-decoration: none; min-width: 0; }
.brand-name { display: block; font-weight: 600; font-size: 1.05rem; }
.brand-sub { display: block; font-size: .78rem; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.topbar select { min-width: 180px; }
.muted-on-dark { opacity: .8; font-size: .9rem; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 10px 8px; overflow-y: auto; }
.nav-item { display: flex; gap: 10px; align-items: center; padding: 9px 10px; margin: 2px 0; border-radius: 8px; color: var(--text); text-decoration: none; }
.nav-item small { display: block; color: var(--muted); font-size: .76rem; }
.nav-item b { font-weight: 600; }
.nav-item:hover { background: var(--surface-alt); }
.nav-item.active { background: var(--accent-soft); }
.nav-ico { width: 22px; text-align: center; color: var(--accent); font-size: 1.1rem; }
.content { overflow-y: auto; padding: 14px 18px; }
.statusbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 0 14px; background: var(--surface); border-top: 1px solid var(--border); font-size: .82rem; white-space: nowrap; overflow: hidden; }
.statusbar .ok { color: var(--success); }
.status-msg { margin-left: auto; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Điều khiển ---------- */
.btn { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font: inherit; line-height: 1.3; }
.btn:hover { background: var(--surface-alt); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-dark { background: rgba(255,255,255,.08); color: var(--header-text); border-color: rgba(255,255,255,.25); }
.btn-dark:hover { background: rgba(255,255,255,.16); }
.btn-ghost { border: none; background: transparent; }
.btn-sm { padding: 3px 9px; font-size: .88rem; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
select, .input { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px; }
select { padding-right: 24px; }
.input { width: 100%; }
.input:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea.input { resize: vertical; }
.input[readonly] { background: var(--surface-alt); }
.field-label { display: block; color: var(--muted); font-size: .82rem; margin: 10px 0 3px; }
.check { display: inline-flex; gap: 6px; align-items: center; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px; }
.notice { background: var(--surface-alt); border-radius: 6px; padding: 8px 10px; margin: 8px 0; }
.notice-warn { background: var(--medium-soft); color: var(--medium); }
.notice-info { background: var(--low-soft); color: var(--low); }
.demo-notice { background: var(--demo-soft); color: var(--demo); font-weight: 600; }
.badge { display: inline-block; padding: 1px 9px; border-radius: 10px; background: var(--surface-alt); font-size: .82rem; }
.badge-accent { background: var(--accent-soft); font-weight: 600; }
.badge.demo { background: var(--demo-soft); color: var(--demo); font-weight: 700; }
.sev-high { background: var(--high-soft); color: var(--high); font-weight: 600; }
.sev-medium { background: var(--medium-soft); color: var(--medium); font-weight: 600; }
.sev-low { background: var(--low-soft); color: var(--low); font-weight: 600; }
.sev-info { background: var(--info-soft); color: var(--info); }
.st-accepted { background: var(--success-soft); color: var(--success); font-weight: 600; }
.st-conflict { background: var(--medium-soft); color: var(--medium); font-weight: 600; }
.st-blocked { background: var(--high-soft); color: var(--high); font-weight: 600; }
.st-pending { background: var(--accent-soft); font-weight: 600; }

/* ---------- Khu vực làm việc ---------- */
.workspace { display: grid; grid-template-columns: minmax(380px, 5fr) minmax(400px, 6fr); gap: 14px; align-items: start; }
.col-input { display: flex; flex-direction: column; min-width: 0; }
.col-result { padding: 0; min-width: 0; position: sticky; top: 0; max-height: calc(100vh - 120px); display: flex; flex-direction: column; }
.draft-bar { background: var(--surface-alt); border-radius: 6px; padding: 8px 10px; margin-top: 10px; }
.editor { min-height: 46vh; font-size: 15.5px; line-height: 1.55; padding: 10px 12px; }
.analyze-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 8px; flex-wrap: wrap; }
.tab { border: none; background: transparent; color: var(--text); font: inherit; padding: 10px 12px; cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { border-bottom-color: var(--accent); font-weight: 600; }
.tab-body { padding: 12px 14px; overflow-y: auto; }
.score-card { display: flex; gap: 14px; align-items: center; background: var(--surface-alt); border-radius: 8px; padding: 12px 14px; margin: 10px 0; }
.score { font-size: 2.6rem; font-weight: 600; color: var(--accent); min-width: 70px; }
.criterion { margin-bottom: 10px; }
.bar { height: 6px; background: var(--surface-alt); border-radius: 3px; overflow: hidden; margin: 4px 0 2px; }
.bar > div { height: 100%; background: var(--accent); }
.item { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: var(--surface); }
details summary { cursor: pointer; color: var(--accent); margin-top: 6px; }
.diff-box { background: var(--surface-alt); border-radius: 4px; padding: 6px 8px; max-height: 200px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; }
.diff-box.compare { max-height: 60vh; font-family: "Times New Roman", "Noto Serif", serif; font-size: 15px; }
.diff del { background: var(--diff-del); text-decoration: line-through; }
.diff ins { background: var(--diff-add); text-decoration: underline; }
ins { background: var(--diff-add); }
.claim-row { display: grid; grid-template-columns: 240px 1fr auto; gap: 8px; }

/* ---------- Content Lab ---------- */
.lab-grid { display: grid; grid-template-columns: minmax(320px, 5fr) minmax(320px, 6fr); gap: 14px; margin-top: 10px; }
.list { list-style: none; padding: 0; margin: 6px 0; }
.list li { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; margin-bottom: 6px; cursor: default; }
.list li.sel { border-color: var(--accent); background: var(--accent-soft); }
.lab-grid > div:first-child .list li { cursor: pointer; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--surface); }
th, td { border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: left; font-size: .88rem; }
th { color: var(--muted); font-weight: 600; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); color: var(--text); border-radius: 10px; width: min(900px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 12px 14px; overflow-y: auto; }
.modal-foot { padding: 10px 14px; border-top: 1px solid var(--border); }
pre.original { white-space: pre-wrap; word-break: break-word; font-family: "Times New Roman", "Noto Serif", serif; font-size: 15px; background: var(--surface-alt); padding: 10px; border-radius: 6px; }

/* ---------- Khởi động & lỗi ---------- */
.boot { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; gap: 8px; text-align: center; padding: 16px; }
.boot-title { font-size: 1.3rem; font-weight: 600; }
.boot-sub { color: var(--muted); }
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Đang tải"); color: var(--muted); }
#blazor-error-ui { background: var(--medium-soft); color: var(--medium); bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none; left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

/* ---------- Màn hình hẹp (điện thoại, máy tính bảng) ---------- */
@media (max-width: 1100px) {
    .workspace, .lab-grid { grid-template-columns: 1fr; }
    .col-result { position: static; max-height: none; }
}
@media (max-width: 760px) {
    .shell { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr auto; height: auto; min-height: 100vh; }
    .topbar { flex-wrap: wrap; padding: 8px 12px; }
    .brand-sub { display: none; }
    .sidebar { display: flex; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); padding: 4px; }
    .nav-item { flex: 0 0 auto; }
    .nav-item small { display: none; }
    .content { padding: 12px 16px; }
    .grid2, .claim-row { grid-template-columns: 1fr; }
    .statusbar { white-space: normal; flex-wrap: wrap; padding: 4px 12px; }
    .editor { min-height: 38vh; }
}
