/*
 * Mlath Alaml unified public UI layer
 * TASK-20260714-MLATH-UI-001 / TASK-20260714-MLATH-UI-002 / TASK-20260714-MLATH-UI-003
 * Loaded last so the legacy Joomla/T3 and component styles share one system.
 */

:root {
  --ml-brand: #8b3c8d;
  --ml-brand-hover: #6b2d6d;
  --ml-brand-soft: #f4ecf8;
  --ml-canvas: #faf8fb;
  --ml-surface: #ffffff;
  --ml-ink: #303842;
  --ml-text: #514b55;
  --ml-muted: #746b78;
  --ml-border: #e7dfe9;
  --ml-focus: rgba(139, 60, 141, .2);
  --ml-success: #237247;
  --ml-danger: #a74436;
  --ml-radius-sm: 8px;
  --ml-radius: 14px;
  --ml-shadow: 0 8px 24px rgba(74, 38, 83, .08);
  --ml-glass: rgba(255, 255, 255, .78);
  --ml-glass-border: rgba(255, 255, 255, .82);
  --ml-glass-shadow: 0 18px 48px rgba(67, 32, 77, .11), inset 0 1px 0 rgba(255, 255, 255, .85);
  --ml-coral: #d97992;
  --ml-aqua: #4f9da3;
  --ml-gold: #c79545;
  --ml-lilac: #ad83bf;
  --ml-glass-clear: rgba(255, 255, 255, .58);
  --ml-glass-regular: rgba(255, 255, 255, .76);
  --ml-glass-thick: rgba(255, 255, 255, .9);
  --ml-glass-edge: rgba(255, 255, 255, .92);
  --ml-ease-liquid: cubic-bezier(.16, 1, .3, 1);
  --ml-content: 1120px;
  color-scheme: light;
}

html.dark,
html[data-theme="dark"] {
  --ml-brand: #ca91cc;
  --ml-brand-hover: #dfa9e1;
  --ml-brand-soft: #30233b;
  --ml-canvas: #171220;
  --ml-surface: #241b2e;
  --ml-ink: #f0e9f3;
  --ml-text: #d0c5d5;
  --ml-muted: #b4a6bc;
  --ml-border: #403249;
  --ml-focus: rgba(202, 145, 204, .22);
  --ml-coral: #e39aae;
  --ml-aqua: #75bdc1;
  --ml-gold: #dbb873;
  --ml-lilac: #c99bd8;
  --ml-glass-clear: rgba(35, 26, 46, .58);
  --ml-glass-regular: rgba(35, 26, 46, .78);
  --ml-glass-thick: rgba(35, 26, 46, .92);
  --ml-glass-edge: rgba(255, 255, 255, .18);
  color-scheme: dark;
}

html { scroll-behavior: smooth; }
body {
  background:
    radial-gradient(circle at 8% 14%, rgba(79, 157, 163, .12), transparent 29rem),
    radial-gradient(circle at 91% 18%, rgba(217, 121, 146, .11), transparent 31rem),
    radial-gradient(circle at 72% 82%, rgba(199, 149, 69, .08), transparent 28rem),
    var(--ml-canvas);
  color: var(--ml-text);
  font-family: "IBM Plex Sans Arabic", "Cairo", system-ui, sans-serif !important;
  font-size: 16px;
  line-height: 1.75;
  overflow-x: clip;
}

a, button, input, select, textarea { -webkit-tap-highlight-color: transparent; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--ml-focus) !important;
  outline-offset: 2px;
}
input, select, textarea { color: var(--ml-ink); }

/* Accessible system messages and field-level validation.
   [TASK-20260929-PUBLIC-UI] Joomla's messages (payment results, "invoice not found",
   form errors) sit in the page flow above the content — no longer a floating toast
   over the header that hid the logo and menu on phones — and take the colour of their
   type from the design-system tokens: warning amber, error red, success green,
   info blue. The close control is a 44px target. */
#system-message-container {
  position: static;
  width: auto;
  max-width: min(1080px, 100%);
  margin: 0 auto 16px;
}
#system-message-container:empty { display: none; }
#system-message-container .alert {
  --msg-c: var(--ml-info, #2B5C9A); --msg-bg: var(--ml-info-soft, #EAF1FA); --msg-line: var(--ml-info-line, #BCD0EA);
  position: relative;
  margin: 0 0 12px !important;
  padding-block: 14px !important;
  padding-inline: 48px 56px !important;
  border: 1px solid var(--msg-line) !important;
  border-inline-start: 4px solid var(--msg-c) !important;
  border-radius: 12px !important;
  background: var(--msg-bg) !important;
  color: var(--ml-ink) !important;
  box-shadow: none !important;
  font-size: .95rem;
  line-height: 1.7;
}
#system-message-container .alert-warning, #system-message-container .alert-notice { --msg-c: var(--ml-warning, #8F5300); --msg-bg: var(--ml-warning-soft, #FDF3E2); --msg-line: var(--ml-warning-line, #EFD2A0); }
#system-message-container .alert-error, #system-message-container .alert-danger { --msg-c: var(--ml-danger, #B3261E); --msg-bg: var(--ml-danger-soft, #FCECEA); --msg-line: var(--ml-danger-line, #F2BDB8); }
#system-message-container .alert-success, #system-message-container .alert-message { --msg-c: var(--ml-success, #1C7A48); --msg-bg: var(--ml-success-soft, #E7F4EC); --msg-line: var(--ml-success-line, #B9DFC8); }
#system-message-container .alert::before {
  content: "!";
  position: absolute;
  inset-inline-start: 14px;
  top: 15px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--msg-c);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}
#system-message-container .alert-success::before, #system-message-container .alert-message::before { content: "✓"; }
#system-message-container .alert-info::before { content: "i"; }
#system-message-container .alert-heading {
  margin: 0 0 2px !important;
  color: var(--msg-c) !important;
  font-size: .95rem !important;
  font-weight: 700 !important;
  line-height: 1.5 !important;
}
#system-message-container .alert p, #system-message-container .alert .alert-message { margin: 0; }
#system-message-container .close {
  position: absolute;
  inset-inline-end: 4px;
  top: 4px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 10px;
  background: transparent !important;
  color: var(--ml-ink) !important;
  font-size: 22px;
  line-height: 1;
  opacity: .7 !important;
}
#system-message-container .close:hover { opacity: 1 !important; background: rgba(38,33,48,.06) !important; }
#system-message-container .close:focus-visible { outline: 2px solid var(--ml-purple, #8B3E90); outline-offset: 1px; opacity: 1 !important; }
.ml-alert-list { margin: 0 34px 0 0; padding: 0 20px 0 0; color: var(--ml-text); font-size: 14px; line-height: 1.7; }
.ml-alert-list li::marker { color: var(--ml-danger); }
.ml-field-error { display: block; margin: 6px 2px 0; color: var(--ml-danger); font-size: 13px; font-weight: 600; line-height: 1.5; }
.inv-edit input.invalid,
.inv-edit textarea.invalid,
.inv-edit select.invalid { border-color: rgba(167,68,54,.72) !important; background: rgba(255,247,247,.9) !important; box-shadow: 0 0 0 3px rgba(167,68,54,.1) !important; }
.ml-inline-alert { margin: 0 0 12px; padding: 12px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; line-height: 1.6; }
.ml-inline-alert-success { background: rgba(35,114,71,.1); color: #185c37; }
.ml-inline-alert-danger { background: rgba(167,68,54,.1); color: #873329; }
@keyframes mlAlertIn { from { opacity: 0; transform: translateY(-10px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* Deterministic section motion replaces the removed random decoration layer. */
.ml-reveal { transform: translateY(12px); filter: blur(2px); transition: transform .72s var(--ml-ease-liquid), filter .72s var(--ml-ease-liquid); }
.ml-reveal.ml-reveal-visible { transform: translateY(0); filter: blur(0); }

/* [TASK-20260929-PUBLIC-UI-CHROME] Header rules removed: the header is styled by mlath-ds.css alone, as on the static pages; these Joomla-only rules gave the menu pill links and different sizes. */

/* [TASK-20260929-PUBLIC-UI-CHROME] Button rules removed: `button.validate` out-ranked mlath-ds.css's
   `.btn`, so the invoice-search button stayed a 999px pill with the glass-era gradient while
   every other button follows the design system's roles (10px, flat). */

/* Quick-pay search */
.inv-edit.front-end-edit {
  width: min(560px, calc(100% - 32px));
  margin: clamp(24px, 4vw, 42px) auto clamp(18px, 3vw, 30px);
  padding: clamp(26px, 5vw, 46px);
  background: var(--ml-surface);
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius);
  box-shadow: var(--ml-shadow);
}
.inv-edit.front-end-edit h1 { color: var(--ml-ink); font-size: clamp(27px, 4vw, 33px); line-height: 1.35; margin-bottom: 12px; }
.inv-edit .control-group { margin-bottom: 18px !important; }
.inv-edit label { color: var(--ml-ink) !important; font-size: 16px !important; font-weight: 600; line-height: 1.55; margin: 0 0 8px !important; }
/* [TASK-20260929-PUBLIC-UI-CHROME] field border/radius/background/focus rules removed — the
   search fields take them from mlath-ds.css like every other field. */
.inv-edit .button-div { margin: 8px 0 0 !important; display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.inv-edit .button-div .btn { min-width: 190px; } /* padding, size and line-height from mlath-ds.css [TASK-20260929-PUBLIC-UI-CHROME] */

html.ml-page-quickpay #t3-mainbody,
html.ml-page-invoice #t3-mainbody,
html.ml-page-edoc #t3-mainbody { padding-top: clamp(22px, 4vw, 42px) !important; padding-bottom: clamp(18px, 3vw, 30px) !important; }

html.ml-page-quickpay #t3-mainbody,
html.ml-page-invoice #t3-mainbody,
html.ml-page-edoc #t3-mainbody {
  background:
    radial-gradient(circle at 12% 18%, rgba(79,157,163,.17), transparent 24rem),
    radial-gradient(circle at 88% 22%, rgba(217,121,146,.16), transparent 27rem),
    radial-gradient(circle at 60% 92%, rgba(173,131,191,.14), transparent 28rem);
}

/* Current invoice */
.item_fields { width: min(900px, 100%); margin-inline: auto; }
.item_fields .paper_feeling {
  background: var(--ml-surface) !important;
  color: var(--ml-text);
  border: 1px solid var(--ml-border) !important;
  border-radius: var(--ml-radius) !important;
  box-shadow: var(--ml-shadow) !important;
}
.item_fields .table th { color: var(--ml-muted); font-weight: 500; }
.item_fields .table td { color: var(--ml-ink); font-weight: 600; }
.item_fields .table td, .item_fields .table th { border-color: var(--ml-border); padding-block: 12px; }
.item_fields h2, .item_fields h3 { color: var(--ml-ink); }

/* Electronic-document toolbar and paper */
.ml-inv { background: var(--ml-canvas) !important; }
.ml-inv-toolbar { gap: 8px !important; }
.ml-inv-toolbar a, .ml-inv-toolbar button { min-height: 44px; } /* هدف لمس 44px [TASK-20260929-PUBLIC-UI] */
.ml-inv-paper { border-radius: var(--ml-radius) !important; box-shadow: var(--ml-shadow) !important; }
.ml-inv-logo { width: min(250px, 48vw); height: auto; }
.ml-inv-primary { opacity: 1 !important; filter: none !important; color: #fff !important; }
.ml-inv-primary:hover, .ml-inv-primary:focus { color: #fff !important; }
.ml-inv-toolbar .ml-inv-ghost,
.ml-inv-toolbar .ml-inv-share-menu,
.payment-methods .payment-method,
.payment-methods > * {
  transition: transform .28s var(--ml-ease-liquid), box-shadow .28s var(--ml-ease-liquid), background-color .28s var(--ml-ease-liquid);
}
.ml-inv-toolbar .ml-inv-ghost:hover,
.payment-methods .payment-method:hover,
.payment-methods > *:hover { transform: translateY(-2px); }

/* Home fixes: legacy Quix rows use negative gutters and forced half widths. */
#qx-section-991126 .qx-row { margin-inline: 0 !important; }
#qx-section-991126 [id^="qx-column-"] { min-width: 0; }
.ml-contact-phones a { min-height: 44px; }
#mlath-contact-form input, #mlath-contact-form textarea { font-size: 16px !important; }
#qx-contact-form-272072 input[type="tel"] {
  width: 100% !important;
  box-sizing: border-box !important;
  padding: 11px 15px !important;
  border: 1.5px solid var(--cf-field-brd, var(--ml-border)) !important;
  border-radius: 10px !important;
  background: var(--cf-field-bg, var(--ml-canvas)) !important;
  color: var(--cf-field-text, var(--ml-ink)) !important;
  text-align: left;
}

/* [TASK-20260929-PUBLIC-UI-CHROME] Footer rules removed: every page renders the same footer body (tpls/blocks/ml-footer-*.php and the static pages), styled by mlath-ds.css alone; these !important rules made Joomla footers smaller and greyer. */

/* [TASK-20260929-PUBLIC-UI-CHROME] Legal-page rules removed: no page uses that class (the legal pages are static and load mlath-ds.css only). */

.mlath-form-help {
  max-width: 44ch;
  margin: 0 auto 24px;
  color: var(--ml-muted);
  font-size: 16px;
  line-height: 1.75;
  text-align: center;
}

@media (max-width: 767px) {
  #qx-section-991126 #qx-column-173673,
  #qx-section-991126 #qx-column-123675 {
    width: 100% !important;
    float: none !important;
    margin: 0 !important;
    min-height: 0 !important;
  }
  #qx-section-991126 .qx-element-number-counter {
    width: 100% !important;
    margin-inline: 0 !important;
    text-align: center !important;
  }
  #qx-section-991126 .qx-nc-number,
  #qx-section-991126 .qx-nc-title,
  #qx-section-991126 .ml-counter-icon { width: 100% !important; margin-inline: 0 !important; }

  .item_fields .paper_feeling { padding: 24px 16px !important; }
  .item_fields .table { table-layout: fixed; }
  .item_fields .table th { width: 38%; }
  .item_fields .table td { overflow-wrap: anywhere; }
  .ml-inv-toolbar { flex-wrap: wrap; }
  .ml-inv-toolbar .ml-inv-spacer { display: none; }
  .ml-inv-toolbar > * { flex: 1 1 auto; justify-content: center; }

}

@media (max-width: 480px) {
  .inv-edit.front-end-edit { width: calc(100% - 24px); padding: 24px 18px; }
  .inv-edit .button-div .btn { flex: 1 1 100%; width: 100%; }
  .ml-inv-toolbar a, .ml-inv-toolbar button { font-size: .875rem !important; padding-inline: 11px !important; } /* كان 12px: صغير لزرّ على الهاتف */
}

@supports ((-webkit-backdrop-filter: blur(16px)) or (backdrop-filter: blur(16px))) {
  /* [TASK-20260929-PUBLIC-UI] The header, the invoice search card and the invoice papers
     left this "glass" treatment (radial highlights, pink/teal washes, 28px shadow) — it
     printed as a tinted page and fought the design system's flat surfaces. They take
     their surface from mlath-ds.css now. */
  .ml-inv-ghost {
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
    backdrop-filter: blur(12px) saturate(1.2);
  }
  .ml-liquid {
    will-change: transform;
    background-position: center;
  }
  html.dark .inv-edit.front-end-edit,
  html.dark .item_fields .paper_feeling,
  html.dark .ml-inv-paper,
  html[data-theme="dark"] .inv-edit.front-end-edit,
  html[data-theme="dark"] .item_fields .paper_feeling,
  html[data-theme="dark"] .ml-inv-paper {
    background:
      radial-gradient(circle at var(--ml-glass-x,18%) var(--ml-glass-y,6%), rgba(202,145,204,.14), transparent 32%),
      linear-gradient(145deg, rgba(40,30,51,.9), rgba(30,23,40,.78)) !important;
  }
  html.dark #system-message-container .alert,
  html[data-theme="dark"] #system-message-container .alert {
    background: rgba(36,27,46,.94) !important;
    color: var(--ml-ink) !important;
    box-shadow: 0 8px 18px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.12) !important;
  }
}

@media (prefers-contrast: more) {
  :root { --ml-glass-clear: rgba(255,255,255,.9); --ml-glass-regular: rgba(255,255,255,.94); }
  .inv-edit.front-end-edit,
  .item_fields .paper_feeling,
  .ml-inv-paper { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
}

@media (prefers-reduced-transparency: reduce) {
  :root { --ml-glass-clear: var(--ml-surface); --ml-glass-regular: var(--ml-surface); --ml-glass-thick: var(--ml-surface); }
  .inv-edit.front-end-edit,
  .item_fields .paper_feeling,
  .ml-inv-paper { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; background: var(--ml-surface) !important; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
