/* =====================================================================
   Manzomia Cloud — design tokens (single source for Back Office + POS)
   Derived from the legacy SMACC look (custom.css, pos.css) so existing
   users feel at home: blue primary, grey-blue page, soft slate text.
   Use CSS logical properties everywhere. No second RTL stylesheet.
   ===================================================================== */

@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=Inter:wght@400;500;600;700&display=swap");

@font-face {
  font-family: "SaudiRiyal";
  src: url("assets/fonts/saudi_riyal.woff2") format("woff2");
  font-display: block;
}

:root {
  color-scheme: light;

  /* ---- Brand (legacy #226bb2 / logo #1369B2) ---- */
  --brand-50:  #eaf4ff;   /* legacy info tint */
  --brand-100: #d4e7fb;
  --brand-200: #a9cdf5;
  --brand-300: #89c0f6;   /* legacy light accent */
  --brand-400: #418dd9;   /* legacy accent */
  --brand-500: #2d7cc9;
  --brand-600: #226bb2;   /* PRIMARY — 5.4:1 on white */
  --brand-700: #1b5a97;
  --brand-800: #164a7c;
  --brand-900: #0f355a;

  /* ---- Neutrals (slate, legacy #4e5966 text) ---- */
  --gray-0:   #ffffff;
  --gray-25:  #f7f9fc;
  --gray-50:  #eff3f8;    /* legacy page background */
  --gray-100: #e4e9f0;
  --gray-200: #d5dce5;
  --gray-300: #b9c2cd;
  --gray-400: #8e98a4;
  --gray-500: #6b747e;    /* legacy secondary text */
  --gray-600: #4e5966;    /* legacy body text */
  --gray-700: #3a4350;
  --gray-800: #262d37;
  --gray-900: #161b22;

  /* ---- Semantic ---- */
  --color-primary:        var(--brand-600);
  --color-primary-hover:  var(--brand-700);
  --color-primary-active: var(--brand-800);
  --color-primary-tint:   var(--brand-50);
  --color-on-primary:     #ffffff;

  --color-success:      #1f8a4c;  --color-success-tint: #e6f5ec;
  --color-warning:      #b26b00;  --color-warning-tint: #fff4e0;
  --color-danger:       #c93333;  --color-danger-tint:  #ffebeb;  /* errors / delete / ZATCA rejected ONLY */
  --color-info:         var(--brand-600); --color-info-tint: var(--brand-50);

  /* ZATCA status palette (chips) */
  --zatca-pending:  var(--color-warning);
  --zatca-reported: var(--color-success);
  --zatca-cleared:  var(--color-success);
  --zatca-warning:  #8a6d00;
  --zatca-error:    var(--color-danger);

  /* ---- Surfaces ---- */
  --bg-page:      var(--gray-50);
  --bg-surface:   var(--gray-0);
  --bg-subtle:    var(--gray-25);
  --bg-sunken:    var(--gray-100);
  --bg-selected:  var(--brand-50);
  --bg-sidebar:   #ffffff;
  --bg-header:    var(--brand-600);
  --border:       #e5e5e5;
  --border-strong:#cccccc;
  --text:         var(--gray-600);
  --text-strong:  var(--gray-800);
  --text-muted:   var(--gray-500);
  --text-on-header:#ffffff;
  --focus-ring:   0 0 0 3px rgb(34 107 178 / .35);

  /* ---- Typography ---- */
  --font-latin:  "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-arabic: "IBM Plex Sans Arabic", "Noto Kufi Arabic", Tahoma, sans-serif;
  --font-sans:   var(--font-latin), var(--font-arabic);
  --font-mono:   ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --text-xs:  12px;  --text-sm: 14px;  --text-md: 16px;
  --text-lg:  20px;  --text-xl: 24px;  --text-2xl: 32px;  --text-pos-total: 40px;
  --leading-tight: 1.25; --leading: 1.5;
  --weight-regular: 400; --weight-medium: 500; --weight-semibold: 600; --weight-bold: 700;

  /* ---- Spacing (4px grid) ---- */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px; --space-12: 48px;

  /* ---- Radius / elevation ---- */
  --radius-sm: 4px; --radius: 6px; --radius-lg: 10px; --radius-xl: 14px; --radius-full: 999px;
  --shadow-1: 0 1px 2px rgb(22 27 34 / .06), 0 1px 3px rgb(22 27 34 / .08);
  --shadow-2: 0 4px 12px rgb(22 27 34 / .10);
  --shadow-3: 0 12px 32px rgb(22 27 34 / .18);

  /* ---- Layout ---- */
  --header-h: 56px;
  --sidebar-w: 264px;
  --sidebar-w-collapsed: 64px;
  --control-h: 36px;          /* back office inputs/buttons */
  --control-h-pos: 48px;      /* POS min touch target */
  --duration: 120ms;          /* keep under 150ms */
  --ease: cubic-bezier(.2,.8,.2,1);
}

/* Dark mode (legacy had none) — auto unless the user forced light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --color-primary: #4d9be6; --color-primary-hover: #6aaeee; --color-primary-active: #89c0f6;
    --color-primary-tint: #15304d; --color-on-primary: #0b1724;
    --color-success: #45c07a; --color-success-tint: #12301f;
    --color-warning: #f0a83a; --color-warning-tint: #33240b;
    --color-danger:  #f06565; --color-danger-tint:  #3a1616;
    --color-info: #4d9be6; --color-info-tint: #15304d;
    --bg-page: #0f141a; --bg-surface: #171d25; --bg-subtle: #1c232c; --bg-sunken: #0b1015;
    --bg-selected: #15304d; --bg-sidebar: #131920; --bg-header: #131920;
    --border: #2a333e; --border-strong: #3a4552;
    --text: #c5cdd6; --text-strong: #eef2f6; --text-muted: #8e98a4;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --color-primary: #4d9be6; --color-primary-hover: #6aaeee; --color-primary-active: #89c0f6;
  --color-primary-tint: #15304d; --color-on-primary: #0b1724;
  --color-success: #45c07a; --color-success-tint: #12301f;
  --color-warning: #f0a83a; --color-warning-tint: #33240b;
  --color-danger:  #f06565; --color-danger-tint:  #3a1616;
    --color-info: #4d9be6; --color-info-tint: #15304d;
  --bg-page: #0f141a; --bg-surface: #171d25; --bg-subtle: #1c232c; --bg-sunken: #0b1015;
  --bg-selected: #15304d; --bg-sidebar: #131920; --bg-header: #131920;
  --border: #2a333e; --border-strong: #3a4552;
  --text: #c5cdd6; --text-strong: #eef2f6; --text-muted: #8e98a4;
}

/* Arabic gets the Arabic face first */
:root[lang="ar"] { --font-sans: var(--font-arabic), var(--font-latin); }

/* Shared helpers */
.num, .money { font-variant-numeric: tabular-nums; unicode-bidi: isolate; direction: ltr; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.sar::before { content: "\e900"; font-family: "SaudiRiyal"; margin-inline-end: .2em; }
