/* =========================================================
   Barza Scorecard — styles
   1) Brand variables      2) App layout (form + preview)
   3) The A4 sheet         4) Print rules
   ========================================================= */

/* ---------- 1) Brand ---------- */
:root {
  --barza: #0F3D3E;        /* deep teal */
  --barza-2: #1C6466;
  --gold: #E2A72E;
  --ink: #1E2A2B;
  --muted: #5E6A6B;
  --line: #E3E7E7;
  --bg: #F3F5F4;
  --pass: #1E7B4A;
  --partial: #C27A12;
  --fail: #B23A3A;
  --font: "Segoe UI", Tahoma, "Noto Sans Arabic", "Geeza Pro", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* "hidden" attribute always wins */
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.45; }
[lang="en"] { direction: ltr; unicode-bidi: isolate; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- 2) App layout ---------- */
.app-header {
  display: flex; gap: 12px; align-items: center;
  padding: 16px 20px; background: var(--barza); color: #fff;
}
.app-header h1 { margin: 0; font-size: 1.2rem; }
.app-header h1 span { display: block; font-weight: 400; opacity: .8; font-size: .9rem; }
.app-header p { margin: 2px 0 0; font-size: .85rem; opacity: .85; }
.app-header p span { display: block; }

.layout {
  display: grid; gap: 20px; padding: 20px;
  grid-template-columns: 1fr;            /* phones: form on top, preview below */
  max-width: 1400px; margin: 0 auto;
}
@media (min-width: 1000px) {
  .layout { grid-template-columns: 380px 1fr; align-items: start; }
  .panel { position: sticky; top: 20px; }
}

.panel { background: #fff; border-radius: 16px; padding: 16px; box-shadow: 0 2px 10px rgba(0,0,0,.05); display: grid; gap: 12px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 12px; margin: 0; display: grid; gap: 10px; }
legend { font-weight: 700; color: var(--barza); padding: 0 6px; }
label { display: grid; gap: 4px; font-size: .9rem; font-weight: 600; }
label span[lang="en"], legend span[lang="en"], .btn span[lang="en"] { font-weight: 400; color: var(--muted); font-size: .8rem; }
.btn span[lang="en"] { color: inherit; opacity: .8; }
input[type="text"], input[type="number"], select, textarea {
  font: inherit; font-weight: 400; width: 100%; min-height: 42px; padding: 8px 10px;
  border: 1px solid #CBD3D3; border-radius: 10px; background: #FBFCFC;
}
input:focus, select:focus, textarea:focus { border-color: var(--barza-2); outline: none; box-shadow: 0 0 0 3px rgba(28,100,102,.15); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.check { display: flex; align-items: center; gap: 8px; font-weight: 500; min-height: 32px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--barza-2); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  font: inherit; font-weight: 700; min-height: 44px; padding: 0 14px; border-radius: 12px; cursor: pointer;
  border: 1.5px solid var(--barza); background: #fff; color: var(--barza);
}
.btn.primary { background: var(--barza); color: #fff; flex: 1 1 100%; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.hint { margin: 0; font-size: .8rem; color: var(--muted); }

/* Preview area: the A4 sheet is scaled down by app.js to fit the space */
.preview { min-width: 0; }
.sheet-fit { position: relative; overflow: hidden; }

/* ---------- 3) The A4 sheet ---------- */
.sheet {
  width: 210mm; height: 297mm;           /* exact A4 */
  padding: 10mm 14mm 8mm;
  background: #fff; color: var(--ink);
  box-shadow: 0 6px 30px rgba(0,0,0,.12);
  transform-origin: 0 0;
  display: flex; flex-direction: column; gap: 4mm;
  overflow: hidden;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}

.sheet-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10mm;
  background: var(--barza); color: #fff; border-radius: 4mm; padding: 5mm 6mm;
}
.sheet-brand { display: flex; gap: 3mm; align-items: center; }
.sheet-brand strong { font-size: 20pt; display: block; line-height: 1.1; }
.sheet-brand strong span { color: var(--gold); font-size: 14pt; }
.sheet-brand small { font-size: 8pt; opacity: .85; }
.sheet-title { text-align: end; }
.sheet-title h2 { margin: 0; font-size: 14pt; }
.sheet-title p { margin: 0; font-size: 10pt; opacity: .85; }
.sheet-title time { font-size: 8.5pt; color: var(--gold); }

.sheet-hero { display: flex; align-items: center; justify-content: space-between; gap: 8mm; padding: 0 2mm; }
.shop-info h3 { margin: 0; font-size: 20pt; color: var(--barza); line-height: 1.2; }
.shop-info p { margin: 1mm 0 0; color: var(--muted); font-size: 11pt; }
.shop-stats span { display: inline-block; background: #F1F5F5; border-radius: 99px; padding: 1mm 3.5mm; margin-inline-end: 2mm; color: var(--ink); font-size: 10pt; }

.score-ring { position: relative; width: 36mm; height: 36mm; flex-shrink: 0; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: #EDF1F1; stroke-width: 11; }
.ring-fg { fill: none; stroke: var(--grade, var(--pass)); stroke-width: 11; stroke-linecap: round; transition: stroke-dashoffset .4s; }
.ring-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; direction: ltr; }
.ring-text strong { font-size: 24pt; line-height: 1; color: var(--ink); }
.ring-text span { font-size: 10pt; color: var(--muted); }
.ring-text em { font-style: normal; font-weight: 700; font-size: 8pt; line-height: 1.25; white-space: pre-line; color: var(--grade, var(--pass)); margin-top: 1mm; }

.sheet-block h4 { margin: 0 0 2.5mm; font-size: 12pt; color: var(--barza); border-bottom: 2px solid var(--gold); padding-bottom: 1.5mm; display: flex; justify-content: space-between; }
.sheet-block h4 span { font-weight: 400; color: var(--muted); font-size: 10pt; }

/* The 6 checks as rows with a progress bar */
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.5mm; }
.checks li { display: grid; grid-template-columns: 7mm 1fr 34mm 18mm; align-items: center; gap: 3mm; font-size: 10.5pt; }
.checks .icon { width: 6mm; height: 6mm; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 9pt; font-weight: 700; }
.checks .pass .icon { background: var(--pass); }
.checks .partial .icon { background: var(--partial); }
.checks .fail .icon { background: var(--fail); }
.checks .label small { color: var(--muted); font-size: 8.5pt; margin: 0 2mm; }
.checks .label em { font-style: normal; color: var(--muted); font-size: 9pt; }
.bar { height: 2.6mm; background: #EDF1F1; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; }
.pass .bar i { background: var(--pass); }
.partial .bar i { background: var(--partial); }
.fail .bar i { background: var(--fail); }
.checks .pts { text-align: end; font-weight: 700; direction: ltr; font-size: 10pt; white-space: nowrap; }

/* Top 3 fixes */
.fixes { list-style: none; margin: 0; padding: 0; display: grid; gap: 2.5mm; counter-reset: fix; }
.fixes li {
  counter-increment: fix; position: relative;
  background: #FBF6EA; border-radius: 3mm; padding: 2.5mm 4mm; padding-inline-start: 13mm;
  border-inline-start: 1.5mm solid var(--gold);
}
.fixes li::before {
  content: counter(fix); position: absolute; inset-inline-start: 3.5mm; top: 2.8mm;
  width: 6.5mm; height: 6.5mm; border-radius: 50%; background: var(--barza); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 10pt;
}
.fixes p { margin: 0; font-size: 10pt; line-height: 1.4; }
.fixes p[lang="en"] { color: var(--muted); font-size: 9pt; margin-top: .8mm; }
.fixes .gain { float: inline-end; font-size: 8.5pt; font-weight: 700; color: var(--pass); direction: ltr; margin-inline-start: 2mm; }
.fixes .none { padding-inline-start: 4mm; border-color: var(--pass); background: #EEF7F1; }
.fixes .none::before { display: none; }

.notes { margin: 0; font-size: 10pt; white-space: pre-wrap; color: var(--ink); }

.sheet-foot {
  margin-top: auto;
  display: flex; align-items: center; gap: 6mm;
  border: 1.5px solid var(--barza); border-radius: 4mm; padding: 3mm 5mm;
}
.qr { width: 27mm; height: 27mm; flex-shrink: 0; }
.qr svg { width: 100%; height: 100%; display: block; }
.cta { display: grid; gap: 1mm; }
.cta strong { font-size: 12pt; color: var(--barza); }
.cta span { color: var(--muted); font-size: 10pt; }
.cta b { font-size: 11pt; color: var(--ink); text-align: start; }
.disclaimer { margin: -2mm 0 0; font-size: 7.5pt; color: #8A9495; text-align: center; }

/* ---------- 4) Print: show only the A4 sheet ---------- */
@page { size: A4; margin: 0; }
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .layout { display: block; padding: 0; margin: 0; max-width: none; }
  .sheet-fit { height: auto !important; overflow: visible; }
  .sheet { transform: none !important; margin: 0 !important; box-shadow: none; }
}
