/* =====================================================================
   DBIM Compliance Checker – UI styles
   The tool itself follows DBIM: Noto Sans, Blue colour group, functional palette,
   DBIM type scale (36/24/20/16/14/12) and a key-colour footer.
   ===================================================================== */
:root {
  /* DBIM Blue colour group (Section 2.1) */
  --dbim-key: #162F6A;
  --dbim-2: #214AAB;
  --dbim-3: #5279D7;
  --dbim-4: #A3BBF3;
  --dbim-5: #D2DFFF;
  /* Functional palette (Section 2.2) */
  --dbim-linen: #EBEAEA;
  --dbim-white: #FFFFFF;
  --dbim-text: #150202;
  --dbim-success: #198754;
  --dbim-warning: #FFC107;
  --dbim-error: #DC3545;
  --dbim-info: #0D6EFD;
  --dbim-grey-1: #C6C6C6;
  --dbim-grey-2: #8E8E8E;
  --dbim-grey-3: #606060;

  --app-bg: var(--dbim-white);
  --app-surface: var(--dbim-white);
  --app-surface-2: #F6F6F6;
  --app-border: var(--dbim-linen);
  --app-text: var(--dbim-text);
  --app-muted: var(--dbim-grey-3);
  --app-hero: linear-gradient(180deg, var(--dbim-5), var(--dbim-white));
  --app-shadow: 0 1px 2px rgba(21, 2, 2, .06), 0 6px 24px rgba(22, 47, 106, .08);

  --bs-body-font-family: "Noto Sans", "Noto Sans Devanagari", system-ui, sans-serif;
  --bs-body-color: var(--app-text);
  --bs-body-bg: var(--app-bg);
  --bs-link-color: var(--dbim-info);
  --bs-link-color-rgb: 13, 110, 253;
  --bs-link-hover-color: var(--dbim-key);
  --bs-border-color: var(--app-border);
  --font-scale: 1;
}

[data-bs-theme="dark"] {
  --app-bg: #0E1424;
  --app-surface: #151D33;
  --app-surface-2: #1B2540;
  --app-border: #2A3557;
  --app-text: #F2F2F2;
  --app-muted: #B5BCCD;
  --app-hero: linear-gradient(180deg, #16213D, #0E1424);
  --app-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 24px rgba(0, 0, 0, .35);
  --bs-body-color: var(--app-text);
  --bs-body-bg: var(--app-bg);
  --bs-link-color: #8FB4FF;
  --bs-link-color-rgb: 143, 180, 255;
  --bs-link-hover-color: #FFFFFF;
  --bs-border-color: var(--app-border);
}

html { font-size: calc(16px * var(--font-scale)); }
body { background: var(--app-bg); color: var(--app-text); line-height: 1.5; font-size: 1rem; }
a:focus-visible, button:focus-visible, .btn:focus-visible, summary:focus-visible, .form-control:focus, .form-select:focus {
  outline: 2px solid var(--dbim-info); outline-offset: 2px; box-shadow: none;
}
.skip-link { position: absolute; z-index: 2000; top: .5rem; left: .5rem; background: var(--dbim-white); color: var(--dbim-key); padding: .5rem 1rem; border: 2px solid var(--dbim-key); }

/* ---------- type scale (DBIM 4.3) ---------- */
.hero-title { font-size: 2.25rem; font-weight: 700; line-height: 1.25; color: var(--dbim-key); }
.h-section { font-size: 1.5rem; font-weight: 600; line-height: 1.3; margin-bottom: 1rem; }
.h-sub { font-size: 1.25rem; font-weight: 600; line-height: 1.3; }
.small, small { font-size: .875rem; }
.tiny { font-size: .75rem; }
[data-bs-theme="dark"] .hero-title { color: #FFFFFF; }
@media (max-width: 767.98px) {
  .hero-title { font-size: 1.5rem; }
  .h-section { font-size: 1.25rem; }
  .h-sub { font-size: 1rem; }
  body { font-size: .875rem; }
}

/* ---------- header ---------- */
.site-header { background: var(--app-surface); border-bottom: 1px solid var(--app-border); }
.utility-bar { background: var(--dbim-key); color: var(--dbim-white); font-size: .875rem; }
.utility-btn { color: var(--dbim-white) !important; text-decoration: none; padding: .125rem .5rem; font-weight: 600; }
.utility-btn:hover { background: var(--dbim-2); }
.brand-row { display: flex; align-items: center; gap: 1rem; padding-top: .75rem; padding-bottom: .75rem; }
.brand-lockup { display: flex; align-items: center; gap: .75rem; color: var(--app-text); }
.brand-lockup:hover .brand-title { color: var(--dbim-2); }
.brand-kicker { display: block; font-size: .75rem; color: var(--app-muted); letter-spacing: .02em; }
.brand-title { display: block; font-size: 1.25rem; font-weight: 700; color: var(--dbim-key); line-height: 1.2; }
[data-bs-theme="dark"] .brand-title { color: #FFFFFF; }
.api-status { font-size: .875rem; color: var(--app-muted); display: inline-flex; align-items: center; gap: .375rem; }
.api-status .bi { font-size: .5rem; }
.api-status.ok .bi { color: var(--dbim-success); }
.api-status.down .bi { color: var(--dbim-error); }

/* ---------- hero & form ---------- */
.hero { background: var(--app-hero); padding: 3rem 0 2.5rem; }
.hero-lead { color: var(--app-muted); }
.hero-points li { display: flex; gap: .5rem; margin-bottom: .375rem; }
.hero-points .bi { color: var(--dbim-success); }
.audit-card, .progress-card, .panel { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: .75rem; box-shadow: var(--app-shadow); padding: 1.5rem; }
.form-label { font-weight: 600; }
.advanced summary { cursor: pointer; font-weight: 600; color: var(--dbim-2); font-size: .875rem; }
[data-bs-theme="dark"] .advanced summary { color: var(--dbim-4); }
.btn-dbim { --bs-btn-bg: var(--dbim-key); --bs-btn-border-color: var(--dbim-key); --bs-btn-color: #fff; --bs-btn-hover-bg: var(--dbim-2); --bs-btn-hover-border-color: var(--dbim-2); --bs-btn-hover-color: #fff; --bs-btn-active-bg: var(--dbim-2); --bs-btn-disabled-bg: var(--dbim-grey-2); --bs-btn-disabled-border-color: var(--dbim-grey-2); padding: .5rem 1.5rem; font-weight: 600; }
.btn-outline-dbim { --bs-btn-color: var(--dbim-key); --bs-btn-border-color: var(--dbim-key); --bs-btn-hover-bg: var(--dbim-key); --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: var(--dbim-key); --bs-btn-active-bg: var(--dbim-2); --bs-btn-active-color: #fff; }
[data-bs-theme="dark"] .btn-outline-dbim { --bs-btn-color: var(--dbim-4); --bs-btn-border-color: var(--dbim-4); }
.bg-dbim { background-color: var(--dbim-2) !important; }
.swatch-row { display: flex; gap: 4px; min-height: 14px; }
.swatch { display: inline-block; width: 1.125rem; height: 1.125rem; border-radius: 4px; border: 1px solid rgba(0,0,0,.15); vertical-align: middle; flex: none; }
.swatch-lg { width: 2rem; height: 2rem; border-radius: 6px; }

/* ---------- report: summary ---------- */
.report-head { display: grid; grid-template-columns: auto 1fr; gap: 1.5rem; align-items: center; }
@media (max-width: 767.98px) { .report-head { grid-template-columns: 1fr; justify-items: start; } }
.score-ring { position: relative; width: 168px; height: 168px; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring .ring-bg { stroke: var(--app-border); }
.score-ring .ring-val { transition: stroke-dashoffset 1s ease; stroke-linecap: round; }
.score-ring .ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score-ring .ring-score { font-size: 2.25rem; font-weight: 700; line-height: 1; }
.score-ring .ring-grade { font-size: .875rem; font-weight: 600; color: var(--app-muted); }
.meta-list { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; font-size: .875rem; margin: 0; }
.meta-list dt { color: var(--app-muted); font-weight: 500; }
.meta-list dd { margin: 0; word-break: break-word; }
.count-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.count-chip { display: inline-flex; align-items: center; gap: .375rem; padding: .25rem .75rem; border-radius: 999px; font-size: .875rem; font-weight: 600; border: 1px solid var(--app-border); background: var(--app-surface-2); }
.shot-thumb { border: 1px solid var(--app-border); border-radius: .5rem; overflow: hidden; display: block; padding: 0; background: none; }
.shot-thumb img { display: block; width: 100%; height: 140px; object-fit: cover; object-position: top; }
.shot-thumb.mobile img { width: 80px; height: 140px; }
.shot-thumb:hover { border-color: var(--dbim-3); }

/* ---------- status colours ---------- */
.st-pass { --st: var(--dbim-success); }
.st-warn { --st: #B58100; }
.st-fail { --st: var(--dbim-error); }
.st-manual { --st: var(--dbim-info); }
.st-na, .st-error { --st: var(--dbim-grey-2); }
[data-bs-theme="dark"] .st-warn { --st: var(--dbim-warning); }
[data-bs-theme="dark"] .st-manual { --st: #6EA8FE; }
[data-bs-theme="dark"] .st-fail { --st: #F07B86; }
[data-bs-theme="dark"] .st-pass { --st: #4FC08D; }
.status-badge { display: inline-flex; align-items: center; gap: .25rem; font-size: .75rem; font-weight: 600; padding: .125rem .5rem; border-radius: 999px; color: var(--st); border: 1px solid var(--st); white-space: nowrap; background: transparent; }
.status-dot { color: var(--st); }

/* ---------- category grid ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .75rem; }
.cat-card { display: block; text-align: left; width: 100%; background: var(--app-surface); border: 1px solid var(--app-border); border-radius: .75rem; padding: 1rem; color: inherit; text-decoration: none; transition: border-color .15s, transform .15s; }
.cat-card:hover { border-color: var(--dbim-3); transform: translateY(-1px); color: inherit; }
.cat-card .cat-name { font-weight: 600; font-size: .875rem; line-height: 1.3; }
.cat-card .cat-score { font-size: 1.5rem; font-weight: 700; }
.cat-card .progress { height: 6px; }
.cat-card.disabled { opacity: .6; }
.score-bar-pass { background: var(--dbim-success); }
.score-bar-warn { background: var(--dbim-warning); }
.score-bar-fail { background: var(--dbim-error); }

/* ---------- priority fixes ---------- */
.fix-list { counter-reset: fix; }
.fix-item { display: grid; grid-template-columns: 2rem 1fr; gap: .75rem; padding: .75rem 0; border-bottom: 1px solid var(--app-border); }
.fix-item:last-child { border-bottom: 0; }
.fix-item::before { counter-increment: fix; content: counter(fix); width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; background: var(--dbim-5); color: var(--dbim-key); font-weight: 700; font-size: .875rem; }
[data-bs-theme="dark"] .fix-item::before { background: var(--dbim-key); color: #fff; }

/* ---------- toolbar ---------- */
.report-toolbar { position: sticky; top: var(--header-h, 110px); z-index: 5; background: var(--app-bg); padding: .75rem 0; border-bottom: 1px solid var(--app-border); }
.filter-btn.active { background: var(--dbim-key); color: #fff; border-color: var(--dbim-key); }

/* ---------- category sections & rules ---------- */
.cat-section { scroll-margin-top: 180px; }
.cat-header { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.cat-icon { width: 2.5rem; height: 2.5rem; border-radius: .5rem; display: grid; place-items: center; background: var(--dbim-5); color: var(--dbim-key); font-size: 1.25rem; flex: none; }
[data-bs-theme="dark"] .cat-icon { background: var(--dbim-key); color: #fff; }
.rule { border: 1px solid var(--app-border); border-left: 4px solid var(--st); border-radius: .5rem; margin-bottom: .5rem; background: var(--app-surface); }
.rule > summary { list-style: none; cursor: pointer; padding: .75rem 1rem; display: grid; grid-template-columns: auto 1fr auto; gap: .75rem; align-items: start; }
.rule > summary::-webkit-details-marker { display: none; }
.rule > summary:hover { background: var(--app-surface-2); }
.rule[open] > summary { border-bottom: 1px solid var(--app-border); }
.rule-title { font-weight: 600; font-size: 1rem; }
.rule-summary { font-size: .875rem; color: var(--app-muted); margin-top: .125rem; }
.rule-score { font-weight: 700; font-size: 1rem; min-width: 3rem; text-align: right; }
.rule-body { padding: 1rem; }
.chip { display: inline-block; font-size: .75rem; padding: .0625rem .5rem; border-radius: 999px; background: var(--app-surface-2); border: 1px solid var(--app-border); color: var(--app-muted); margin-right: .25rem; white-space: nowrap; }
.chip-must { color: var(--dbim-error); border-color: currentColor; }
.chip-should { color: #9A6B00; border-color: currentColor; }
[data-bs-theme="dark"] .chip-should { color: var(--dbim-warning); }
.chip-may { color: var(--dbim-grey-3); }
.evidence { list-style: none; padding: 0; margin: 0; font-size: .875rem; }
.evidence li { padding: .375rem 0; border-bottom: 1px dashed var(--app-border); display: flex; gap: .5rem; align-items: flex-start; flex-wrap: wrap; }
.evidence li:last-child { border-bottom: 0; }
.evidence code { font-size: .75rem; color: var(--app-muted); background: var(--app-surface-2); padding: .0625rem .375rem; border-radius: 4px; word-break: break-all; }
.fix-box { background: var(--dbim-5); border-left: 4px solid var(--dbim-key); padding: .75rem 1rem; border-radius: .375rem; font-size: .875rem; color: var(--dbim-text); }
[data-bs-theme="dark"] .fix-box { background: #1E2B4F; color: var(--app-text); border-left-color: var(--dbim-4); }
.fix-box strong { color: var(--dbim-key); }
[data-bs-theme="dark"] .fix-box strong { color: var(--dbim-4); }
.palette-table td { vertical-align: middle; }
.metric { text-align: center; padding: .75rem; border: 1px solid var(--app-border); border-radius: .5rem; background: var(--app-surface); }
.metric .metric-val { font-size: 1.25rem; font-weight: 700; }
.metric .metric-lbl { font-size: .75rem; color: var(--app-muted); }

/* ---------- footer (DBIM 5.6: key colour of the selected group) ---------- */
.site-footer { background: var(--dbim-key); color: var(--dbim-white); padding: 2rem 0; margin-top: 3rem; }
.site-footer a { color: var(--dbim-white); }
.site-footer a:hover { color: var(--dbim-4); }

.list-group-item-action:hover { background: var(--app-surface-2); }
.empty-note { color: var(--app-muted); font-size: .875rem; }

/* ---------- print / PDF ---------- */
@media print {
  .site-header, .hero, .report-toolbar, #historySection, .site-footer, .no-print, .skip-link { display: none !important; }
  body { background: #fff; color: #000; font-size: 12px; }
  .panel, .rule { box-shadow: none; break-inside: avoid; }
  .rule:not([open]) > .rule-body { display: block !important; }
  details.rule > .rule-body { display: block; }
  .cat-section { break-before: page; }
  a { color: #000; text-decoration: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* keep anchored sections clear of the sticky header */
#reportSection, #progressSection, #errorSection, .rule { scroll-margin-top: calc(var(--header-h, 110px) + 1rem); }
@media (max-width: 767.98px) {
  .site-header { position: static; }
  .report-toolbar { top: 0; }
  #reportSection, #progressSection, #errorSection, .rule, .cat-section { scroll-margin-top: 1rem; }
  .brand-title { font-size: 1rem; }
}
