/*
 * خطوة كاشير (Khutwa Cashier): brand layer.
 *
 * Loaded after every other stylesheet by resources/views/layouts/partials/khutwa_brand.blade.php
 * (included from layouts/partials/css.blade.php, and from the guest/home layouts that do not use it).
 * Only the superadmin "additional CSS" setting is printed after this file, so it can still override.
 *
 * Source of truth: /brand/khutwa-tokens.css and /brand/BRAND_GUIDE_AR.md (shared by
 * خطوة كاشير، خطوة شات، حساب خطوة). Section 1 below is a verbatim copy of the tokens;
 * change the tokens there first, then copy them here.
 *
 * What this file does:
 *   1. Brand tokens (--kh-*).
 *   2. The brand blue scale (--kh-primary-50 … -950) that replaces Tailwind's `primary` palette.
 *   3. Remaps the compiled Tailwind `primary` classes (public/css/tailwind/app.css, tw- prefix)
 *      that the views actually use. The header/sidebar build their class names from
 *      business.theme_color and fall back to `primary`, so ONLY the default theme becomes the
 *      brand; purple/green/red/yellow/orange/sky keep their own Tailwind palettes.
 *   4. DaisyUI `primary` (tw-dw-btn-primary, tw-dw-badge-primary): was purple #491EFF.
 *   5. Bootstrap 3 / AdminLTE primary (btn-primary, box-primary, links …): was #1572E8/#337AB7/#3C8DBC.
 *   6. Tajawal as the base font for the admin, the cashier (POS) screen, auth pages and on-screen receipts.
 */

/* ---------------------------------------------------------------------------
 * 1. Brand tokens (copy of brand/khutwa-tokens.css)
 * ------------------------------------------------------------------------- */
:root {
  /* Brand blues */
  --kh-primary: #0057C2;        /* buttons, links, active states */
  --kh-primary-hover: #004AA6;  /* hover/pressed on primary */
  --kh-bright: #0D8BFF;         /* icons, focus rings, gradient end; never body text */
  --kh-deep: #003B82;           /* headings, sidebars, footers, dark panels */
  --kh-midnight: #002B62;       /* deepest panel shade */
  --kh-soft: #EAF4FF;           /* tinted backgrounds, selected rows, chips */
  --kh-sky: #F4FAFF;            /* page wash */

  /* Neutrals (blue-biased, never pure grey or #000) */
  --kh-text: #101828;
  --kh-copy: #4A5E7A;           /* secondary paragraphs */
  --kh-muted: #6A7F9E;          /* meta text, captions: never lighter than this */
  --kh-border: #CFE0F5;
  --kh-line: #DBE8F6;           /* hairlines inside panels */
  --kh-surface: #FFFFFF;
  --kh-page: #F8FBFF;

  /* Status (separate from the brand blue) */
  --kh-success: #16B979;
  --kh-success-text: #0E7C52;   /* success text on white (AA) */
  --kh-warning: #F5A623;
  --kh-warning-text: #9A5B00;   /* warning text on white (AA) */
  --kh-danger: #D92D20;
  --kh-info: #0D8BFF;

  /* Gradients: only for conversion moments (primary CTA panels, hero) */
  --kh-gradient: linear-gradient(25deg, #0057C2, #0D8BFF);
  --kh-gradient-deep: linear-gradient(230deg, #003B82, #001E42);

  /* Type */
  --kh-font: "Tajawal", "Cairo", system-ui, -apple-system, "Segoe UI", Tahoma, Arial, sans-serif;
  --kh-weight-regular: 400;
  --kh-weight-medium: 500;
  --kh-weight-bold: 700;
  --kh-weight-black: 800;
  --kh-line-body: 1.8;          /* Arabic paragraphs */
  --kh-line-ui: 1.45;           /* labels, buttons, table cells */

  /* Shape */
  --kh-radius-control: 8px;     /* inputs, buttons */
  --kh-radius-card: 12px;
  --kh-radius-panel: 16px;
  --kh-shadow: 0 1px 2px rgba(0, 59, 130, 0.06), 0 4px 16px rgba(0, 59, 130, 0.06);
}

/* Dark surfaces (خطوة شات has a dark mode; other products may adopt later) */
[data-bs-theme="dark"], .kh-dark {
  --kh-primary: #4C9BFF;
  --kh-primary-hover: #7AB6FF;
  --kh-deep: #BFD9FF;
  --kh-soft: #132A4A;
  --kh-sky: #0F2240;
  --kh-text: #E3EBF7;
  --kh-copy: #B4C4DB;
  --kh-muted: #93A8C6;
  --kh-border: #223B5E;
  --kh-line: #1B3152;
  --kh-surface: #10213A;
  --kh-page: #0A1628;
}

/* ---------------------------------------------------------------------------
 * 2. Brand blue scale (replaces Tailwind `primary`: #EFF4FF … #00359E)
 *    Space-separated RGB channels so utilities can keep var(--tw-*-opacity).
 * ------------------------------------------------------------------------- */
:root {
  --kh-primary-50: 234 244 255;   /* #EAF4FF */
  --kh-primary-100: 213 232 255;  /* #D5E8FF */
  --kh-primary-200: 169 208 255;  /* #A9D0FF */
  --kh-primary-300: 111 177 255;  /* #6FB1FF */
  --kh-primary-400: 47 140 245;   /* #2F8CF5 */
  --kh-primary-500: 10 107 224;   /* #0A6BE0 */
  --kh-primary-600: 0 87 194;     /* #0057C2 = --kh-primary */
  --kh-primary-700: 0 74 166;     /* #004AA6 = --kh-primary-hover */
  --kh-primary-800: 0 59 130;     /* #003B82 = --kh-deep */
  --kh-primary-900: 0 43 98;      /* #002B62 = --kh-midnight */
  --kh-primary-950: 0 30 66;      /* #001E42 */
}

/* ---------------------------------------------------------------------------
 * 3. Compiled Tailwind `primary` classes used by the views
 *    (same declarations as tailwind/app.css, only the colour changes)
 *    - header.blade.php:5 / home/index.blade.php: tw-from-primary-800 tw-to-primary-900
 *    - header/sidebar buttons and brand bar: tw-bg-primary-800 hover:tw-bg-primary-700
 *    - header/sidebar borders: tw-border-primary-500/30
 * ------------------------------------------------------------------------- */
.tw-bg-primary-800 {
  --tw-bg-opacity: 1;
  background-color: rgb(var(--kh-primary-800) / var(--tw-bg-opacity));
}
.hover\:tw-bg-primary-50:hover {
  --tw-bg-opacity: 1;
  background-color: rgb(var(--kh-primary-50) / var(--tw-bg-opacity));
}
.hover\:tw-bg-primary-700:hover {
  --tw-bg-opacity: 1;
  background-color: rgb(var(--kh-primary-700) / var(--tw-bg-opacity));
}
.tw-text-primary-700 {
  --tw-text-opacity: 1;
  color: rgb(var(--kh-primary-700) / var(--tw-text-opacity));
}
.tw-text-primary-800 {
  --tw-text-opacity: 1;
  color: rgb(var(--kh-primary-800) / var(--tw-text-opacity));
}
.tw-border-primary-500\/30 {
  border-color: rgb(var(--kh-primary-500) / 0.3);
}
.tw-from-primary-800 {
  --tw-gradient-from: #003B82 var(--tw-gradient-from-position);
  --tw-gradient-to: rgb(0 59 130 / 0) var(--tw-gradient-to-position);
  --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
.tw-to-primary-900 {
  --tw-gradient-to: #002B62 var(--tw-gradient-to-position);
}

/* Auth buttons (login, password reset/confirm, repair status) used an indigo→blue gradient:
   "tw-bg-gradient-to-r tw-from-indigo-500 tw-to-blue-500". Only that exact pair is remapped to
   the brand gradient (#0057C2 → #0D8BFF), so indigo/blue used elsewhere is untouched. */
.tw-from-indigo-500.tw-to-blue-500 {
  --tw-gradient-from: #0057C2 var(--tw-gradient-from-position);
  --tw-gradient-to: #0D8BFF var(--tw-gradient-to-position);
  --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
/* …and the same pair used as gradient TEXT on links ("forgot password", "register now"):
   the brand never uses gradient text for Arabic copy, so it becomes solid brand blue. */
.tw-from-indigo-500.tw-to-blue-500.tw-bg-clip-text {
  background-image: none;
  color: var(--kh-primary);
}
.tw-from-indigo-500.tw-to-blue-500.tw-bg-clip-text:hover {
  color: var(--kh-primary-hover);
}

/* ---------------------------------------------------------------------------
 * 4. DaisyUI `primary` (tw-dw-btn-primary is used ~470 times)
 *    --p / --pc are oklch channels; --fallback-* are for browsers without oklch.
 *    The compiled theme also flips --p in prefers-color-scheme:dark; keep the brand there too.
 * ------------------------------------------------------------------------- */
:root,
[data-theme] {
  --p: 48.18% 0.1823 258.49;      /* #0057C2 */
  --pc: 100% 0 0;                 /* white text on primary */
  --fallback-p: #0057C2;
  --fallback-pc: #FFFFFF;
  --rounded-btn: var(--kh-radius-control);
}
@media (prefers-color-scheme: dark) {
  :root {
    --p: 48.18% 0.1823 258.49;
    --pc: 100% 0 0;
    --fallback-p: #0057C2;
    --fallback-pc: #FFFFFF;
  }
}

/* ---------------------------------------------------------------------------
 * 5. Bootstrap 3 / AdminLTE primary (not theme-dependent in the app)
 * ------------------------------------------------------------------------- */
a {
  color: var(--kh-primary);
}
a:hover,
a:focus {
  color: var(--kh-primary-hover);
}

.btn-primary {
  color: #fff;
  background: var(--kh-primary);
  background-color: var(--kh-primary);
  border-color: var(--kh-primary-hover);
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary.focus,
.btn-primary:active,
.btn-primary.active,
.open > .dropdown-toggle.btn-primary,
.btn-primary:active:hover,
.btn-primary.active:hover,
.btn-primary:active:focus,
.btn-primary.active:focus {
  color: #fff;
  background: var(--kh-primary-hover);
  background-color: var(--kh-primary-hover);
  border-color: var(--kh-deep);
}
.btn-primary.disabled,
.btn-primary[disabled],
fieldset[disabled] .btn-primary,
.btn-primary.disabled:hover,
.btn-primary[disabled]:hover,
.btn-primary.disabled:focus,
.btn-primary[disabled]:focus {
  background: var(--kh-primary);
  background-color: var(--kh-primary);
  border-color: var(--kh-primary-hover);
}
.btn-primary .badge {
  color: var(--kh-primary);
}

.bg-primary,
.label-primary,
.badge-primary {
  color: #fff;
  background-color: var(--kh-primary) !important;
}
.text-primary {
  color: var(--kh-primary) !important;
}
.box.box-primary {
  border-top-color: var(--kh-primary);
}
.pagination > .active > a,
.pagination > .active > a:hover,
.pagination > .active > a:focus,
.pagination > .active > span,
.pagination > .active > span:hover,
.pagination > .active > span:focus {
  background-color: var(--kh-primary);
  border-color: var(--kh-primary);
}
.nav-tabs-custom > .nav-tabs > li.active {
  border-top-color: var(--kh-primary);
}
.form-control:focus {
  border-color: var(--kh-bright);
}

/* ---------------------------------------------------------------------------
 * 6. Type: Tajawal everywhere (Arabic and English), Cairo then system fonts as fallback.
 *    Icon fonts (FontAwesome, Glyphicons, tabler) set their own font-family on the icon
 *    element, so no universal selector is used here.
 * ------------------------------------------------------------------------- */
html,
body,
html[dir="rtl"] body,
html[dir="ltr"] body,
.tw-font-sans,
button,
input,
optgroup,
select,
textarea,
html[dir="rtl"] button,
html[dir="rtl"] input,
html[dir="rtl"] select,
html[dir="rtl"] textarea,
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6,
.main-header .logo,
.tooltip,
.popover,
.ui-widget,
.ui-widget button,
.ui-widget input,
.ui-widget select,
.ui-widget textarea,
.daterangepicker,
.select2-container,
.swal-modal,
.swal2-popup,
.toast,
#receipt_section {
  font-family: var(--kh-font);
}

html[dir="rtl"] body {
  letter-spacing: 0;
}
