/* ============================================================================
   theme.css — dono screens (public site aur admin panel) ka mushtarka theme.
   Sirf tokens aur mushtarka purze — page ke apne rules catalogue.css me hain,
   taake admin ka CSS badalne se public site na toote.

   Har theme sirf CSS variables badalti hai — markup ko haath nahi lagta.
   <html data-theme="white|ivory|midnight|bazaar" data-accent="#12634F">
   ============================================================================ */

/* ---------- Bunyadi (har theme me aik jaise) ---------- */
:root {
  --radius:     14px;
  --radius-sm:  9px;
  --radius-lg:  20px;

  /* Fonts project ke andar hain (wwwroot/fonts, css/fonts.css). Peeche ke naam sirf us
     lamhe ke liye jab file abhi aa rahi ho — Georgia (serif) nahi, warna sirwar pal bhar
     ko bilkul doosre andaz me jhalakte. */
  --font-display: 'Bricolage Grotesque', 'Archivo', ui-sans-serif, system-ui, 'Segoe UI', sans-serif;
  --font-body:    'Archivo', ui-sans-serif, system-ui, 'Segoe UI', sans-serif;
  --font-urdu:    'Noto Nastaliq Urdu', 'Jameel Noori Nastaleeq', 'Urdu Typesetting', 'Noto Naskh Arabic', Tahoma, serif;

  --step: 4px;

  /* Accent settings se aata hai — JS ise inline set kar deta hai */
  --accent:      #12634F;
  --accent-dark: #0C4A3B;
  --accent-soft: #E4EFE9;
  /* Likhne ke liye accent — JS ise parhne laiq bana kar set karta hai */
  --accent-text: #0C4A3B;
  --on-accent:   #FFFFFF;

  --ok-ink:   #166534;  --ok-soft:   #E3F2E7;
  --warn-ink: #8A3F0E;  --warn-soft: #F9EADC;
  --err-ink:  #A31E1E;  --err-soft:  #FBE6E6;
  --info-ink: #1D4F8C;  --info-soft: #E5EDF7;
}

/* ---------- 1. Safed — saaf, khali jagah zyada ---------- */
:root, [data-theme="white"] {
  --ground:    #FFFFFF;
  --surface:   #FFFFFF;
  --raised:    #F6F7F9;
  --ink:       #0E1116;
  --muted:     #545C66;
  --faint:     #858D97;
  --line:      #E3E6EA;
  --line-soft: #EFF1F4;
  --shadow:    0 1px 2px rgba(14,17,22,.05), 0 10px 30px -18px rgba(14,17,22,.28);
  --shadow-lg: 0 24px 60px -24px rgba(14,17,22,.35);
  --ph-bg:     #F1F3F6;
  --ph-ink:    #97A0AB;
  color-scheme: light;
}

/* ---------- 2. Ivory — garam off-white, tasveerein ubharti hain ---------- */
[data-theme="ivory"] {
  --ground:    #F7F5F0;
  --surface:   #FFFFFF;
  --raised:    #FBFAF7;
  --ink:       #17160F;
  --muted:     #57534A;
  --faint:     #8A857A;
  --line:      #E2DED3;
  --line-soft: #EFECE5;
  --shadow:    0 1px 2px rgba(23,22,15,.05), 0 10px 30px -18px rgba(23,22,15,.3);
  --shadow-lg: 0 24px 60px -24px rgba(23,22,15,.4);
  --ph-bg:     #EFEBE1;
  --ph-ink:    #9A9384;
  color-scheme: light;
}

/* ---------- 3. Midnight — raat ka theme ---------- */
[data-theme="midnight"] {
  --ground:    #0D1014;
  --surface:   #161A20;
  --raised:    #1D222A;
  --ink:       #EDF1F6;
  --muted:     #A2ACB8;
  --faint:     #79838F;
  --line:      #262C35;
  --line-soft: #1F242C;
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 14px 34px -18px rgba(0,0,0,.75);
  --shadow-lg: 0 28px 70px -24px rgba(0,0,0,.85);
  --ph-bg:     #212730;
  --ph-ink:    #6D7884;

  --ok-soft:   #13291B;  --ok-ink:   #7FD8A8;
  --warn-soft: #2E2113;  --warn-ink: #E9B189;
  --err-soft:  #2E1717;  --err-ink:  #F0A3A3;
  --info-soft: #14212F;  --info-ink: #8FBBEE;
  color-scheme: dark;
}

/* ---------- 4. Bazaar — garam mitti ke rang ---------- */
[data-theme="bazaar"] {
  --ground:    #FBF3E8;
  --surface:   #FFFBF5;
  --raised:    #F6ECDD;
  --ink:       #291B10;
  --muted:     #6B5741;
  --faint:     #9A8770;
  --line:      #E9DAC5;
  --line-soft: #F2E7D7;
  --shadow:    0 1px 2px rgba(41,27,16,.06), 0 10px 30px -18px rgba(41,27,16,.34);
  --shadow-lg: 0 24px 60px -24px rgba(41,27,16,.44);
  --ph-bg:     #F0E2CE;
  --ph-ink:    #9C8770;
  color-scheme: light;
}


/* ============================================================================
   Bunyadi elements
   ============================================================================ */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}

body[dir="rtl"] { font-family: var(--font-urdu); line-height: 2.05; }
body[dir="rtl"] .num { font-family: var(--font-body); line-height: 1.5; }

a { color: var(--accent-text); text-decoration: none; }
a:hover { color: var(--accent-dark); }

button, input, select, textarea { font: inherit; color: inherit; }

img { max-width: 100%; display: block; }

table { border-collapse: collapse; width: 100%; }

h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -.02em; }

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

.vh {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Rate aur code hamesha seedhe (LTR) — Urdu mode me bhi */
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

.wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 20px; }

/* "hidden" ka matlab chhupa hi ho — warna .btn ka display:inline-flex isay dhak deta tha
   (quotation ka "Share PDF" un browsers me bhi dikhta tha jahan share hota hi nahi). */
[hidden] { display: none !important; }


/* ============================================================================
   Buttons
   ============================================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; font-size: 14.5px; cursor: pointer; white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn svg { width: 17px; height: 17px; flex: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-dark); color: var(--on-accent); }

.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--muted); color: var(--ink); }

.btn-quiet { background: transparent; color: var(--muted); }
.btn-quiet:hover { background: var(--raised); color: var(--ink); }

.btn-danger { background: var(--err-soft); color: var(--err-ink); }

.btn-sm { min-height: 38px; padding: 0 14px; font-size: 13.5px; }
.btn-lg { min-height: 52px; padding: 0 24px; font-size: 15.5px; }

.btn-square { border-radius: var(--radius-sm); }

.icon-btn {
  width: 40px; height: 40px; flex: none;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { border-color: var(--muted); }
.icon-btn svg { width: 18px; height: 18px; }


/* ============================================================================
   Cards, fields, tags, switch
   ============================================================================ */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.card-head {
  padding: 16px 18px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.card-head h2 { font-size: 15.5px; margin: 0; font-weight: 600; font-family: var(--font-body); }
.card-body { padding: 18px; }
.spacer { flex: 1 1 auto; }

/* align-content:start — do field ek qatar (.row2) me hon aur sirf ek ke neeche hint ho,
   to doosre ka input phail kar 56-66px ka ho jata tha aur khane ek seedh me nahi rehte. */
.field { display: grid; gap: 6px; align-content: start; }
.field > label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12.5px; color: var(--faint); }
/* Field ke bahar wala hint (misal: tasveer chunne ke neeche) bhi hint hi lage, matn nahi. */
p.hint { font-size: 12.5px; color: var(--faint); line-height: 1.6; margin: 10px 0 0; }

.input {
  width: 100%; min-height: 44px; padding: 10px 13px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
}
textarea.input { min-height: 84px; resize: vertical; }
.input::placeholder { color: var(--faint); }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600;
}
.t-ok   { background: var(--ok-soft);   color: var(--ok-ink); }
.t-warn { background: var(--warn-soft); color: var(--warn-ink); }
.t-err  { background: var(--err-soft);  color: var(--err-ink); }
.t-info { background: var(--info-soft); color: var(--info-ink); }
.t-mute { background: var(--line-soft); color: var(--muted); }
.t-accent { background: var(--accent-soft); color: var(--accent-text); }

.sw { position: relative; display: inline-flex; align-items: center; flex: none; }
.sw input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
/* pointer-events: none — track (position: relative, DOM me baad me) chhupe input ke UPAR
   paint hota tha aur click kha jata tha; toggle sirf us ke upar/neeche ki patli patti par
   chalta tha. Ab click seedha input tak jata hai. */
.sw .track {
  width: 44px; height: 26px; border-radius: 999px; background: var(--line);
  transition: background-color .15s ease; position: relative; pointer-events: none;
}
.sw .track::after {
  content: ''; position: absolute; top: 3px; inset-inline-start: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .15s ease;
}
.sw input:checked + .track { background: var(--accent); }
.sw input:checked + .track::after { transform: translateX(18px); }
body[dir="rtl"] .sw input:checked + .track::after { transform: translateX(-18px); }
.sw input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--line-soft);
}
.setting-row:last-child { border-bottom: 0; }
/* Likha hua hissa simat sake — warna lamba jumla switch ko agli qatar me dhakel deta
   tha aur phone par switch ek ke neeche ek zig-zag me aate the. */
.setting-row > :first-child { flex: 1 1 12rem; min-width: 0; }
.setting-row .t { font-weight: 600; font-size: 14.5px; }
.setting-row .d { font-size: 13px; color: var(--muted); margin-top: 2px; }


/* ============================================================================
   Category ka nishan (menu, chips, admin) — ek hi shakal har jagah
   ============================================================================ */
/*
 * Project ke banay banaye nishan (wwwroot/img/categories/*.svg) CSS mask se lagte
 * hain: shakal SVG se, rang currentColor se. Isi liye chuni hui (accent) chip par
 * safed, andheri (midnight) theme me roshan — har jagah khud sahi rang.
 * Dukandar ka chadhaya hua logo rangeen tasveer hai: .caticon-pic, mask ke bina.
 */
.caticon {
  display: inline-block; flex: none;
  width: 20px; height: 20px;
  background-color: currentColor;
  -webkit-mask: var(--ci) center / contain no-repeat;
          mask: var(--ci) center / contain no-repeat;
}
.caticon-pic {
  background: var(--surface); -webkit-mask: none; mask: none;
  object-fit: contain; border-radius: 5px;
}
/* Windows High Contrast: background-color zabardasti canvas ka rang ban jata hai aur
   mask wala nishan ghaib — us mode me rang khud tay karne do (currentColor = matn ka rang). */
@media (forced-colors: active) {
  .caticon:not(.caticon-pic) { forced-color-adjust: none; }
}


/* ============================================================================
   Toast
   ============================================================================ */
.toast {
  position: fixed; inset-inline-end: 22px; bottom: 22px; z-index: 90;
  background: var(--ink); color: var(--ground);
  border-radius: var(--radius-sm); padding: 13px 18px; font-size: 14px;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.on { opacity: 1; transform: none; }
.toast svg { width: 17px; height: 17px; flex: none; }


/* ============================================================================
   Tasveer ki jagah (jab tak asli photo na ho)
   ============================================================================ */
.ph {
  background: var(--ph-bg); color: var(--ph-ink);
  display: grid; place-items: center; gap: 6px; position: relative;
}
.ph svg { width: 32px; height: 32px; opacity: .8; }
.ph span {
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  font-weight: 600; font-family: var(--font-body);
}


@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}


/* ============================================================================
   Responsive — dono screens ke liye mushtarka
   ============================================================================ */

/* Grid/flex ke bachche apne se bari cheez rakh kar page ko chaura kar dete hain.
   min-width:0 un ko simatne deta hai — horizontal scroll ka sab se aam sabab. */
.wrap > *, .card, .item, .tile, .setting-row { min-width: 0; }

img, table, pre { max-width: 100%; }

@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .wrap { padding: 0 16px; }
  .card-head { padding: 14px 15px; }
  .card-body { padding: 15px; }
  .btn { padding: 0 15px; }
  .btn-lg { min-height: 48px; padding: 0 18px; }

  /* Label + control ek qatar me na samayein to control neeche chala jaye */
  .setting-row { flex-wrap: wrap; gap: 10px; }
  .setting-row > :last-child { margin-inline-start: auto; }

  /* 16px se chhote input par iPhone ka Safari tap karte hi poora safha zoom kar deta
     hai (aur har rate badalne ke baad wapas chhota karna parta). */
  .input, .rate-in, .toolbar input, .toolbar select, .search input { font-size: 16px; }
}

@media (max-width: 420px) {
  .wrap { padding: 0 14px; }
  .btn { font-size: 14px; }
}

/*
 * Ungli se chalne wali screens (phone/tablet) par chhote buttons bara kar do.
 * Mouse wali screen par wahi ghana (dense) andaz rehta hai.
 */
@media (pointer: coarse) {
  .icon-btn { width: 44px; height: 44px; }
  .btn-sm { min-height: 44px; padding: 0 16px; }
  .sw .track { width: 48px; height: 28px; }
  .sw .track::after { width: 22px; height: 22px; }
  .sw input:checked + .track::after { transform: translateX(20px); }
  body[dir="rtl"] .sw input:checked + .track::after { transform: translateX(-20px); }
}
