/* ===========================================================
 * Palms Links — base stylesheet (P1 foundation, v=1)
 * Saudi Heritage palette · Material Symbols Rounded
 * =========================================================== */

/* Saudi Riyal symbol — official SAMA artwork via CSS mask (inherits currentColor) */
.pl-sar {
  display: inline-block;
  vertical-align: -0.12em;
  flex-shrink: 0;
  background-color: currentColor;
  -webkit-mask: url('/assets/brand/sar-official.png') no-repeat center / contain;
          mask: url('/assets/brand/sar-official.png') no-repeat center / contain;
}
.pl-money { white-space: nowrap; display: inline-flex; align-items: baseline; gap: 4px; }
.pl-money .pl-sar { margin-inline-start: 1px; }

:root {
  --brand-green:      #006c35;
  --brand-green-deep: #004f26;
  --brand-green-soft: #d9eee3;
  --brand-gold:       #c4a45c;
  --brand-gold-soft:  #f5edd7;
  --brand-gold-edge:  #e0c98a;
  --canvas:           #faf7ee;
  --surface:          #ffffff;
  --panel:            #f4f1e8;
  --ink:              #16241c;
  --ink-soft:         #4a5a52;
  --ink-faint:        #7c887f;
  --border:           #ede5cf;
  --border-soft:      #f3eddd;
  --success:          #1b8e4c;
  --warning:          #c08200;
  --danger:           #c0392b;
  --info:             #2876b8;

  --r-sm:  6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.06);
  --shadow-lg: 0 12px 32px rgba(0,76,38,.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }
html, body { min-height: 100%; }
body {
  font-family: 'Rubik', 'Tajawal', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body.lang-ar { font-family: 'Tajawal', 'Rubik', system-ui, sans-serif; }

a { color: var(--brand-green); text-decoration: none; }
a:hover { color: var(--brand-green-deep); text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* ---------- Material Symbols Rounded (self-hosted variable font) ---------- */
@font-face {
  font-family: 'Material Symbols Rounded';
  font-style: normal;
  font-weight: 300 700;
  font-display: block; /* keep tofu hidden — icons either show fully or wait */
  src: url('/assets/fonts/material-symbols-rounded.woff2') format('woff2');
}

.msi {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  display: inline-block;
  line-height: 1;
  text-transform: none;
  letter-spacing: normal;
  word-wrap: normal;
  white-space: nowrap;
  direction: ltr;
  font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  vertical-align: middle;
  font-variation-settings: 'opsz' 24, 'wght' 400, 'FILL' 0, 'GRAD' 0;
}
.msi.msi-filled { font-variation-settings: 'opsz' 24, 'wght' 400, 'FILL' 1, 'GRAD' 0; }
.msi.msi-green  { color: var(--brand-green); }
.msi.msi-deep   { color: var(--brand-green-deep); }
.msi.msi-gold   { color: var(--brand-gold); }
.msi.msi-mute   { color: var(--ink-faint); }
.msi.msi-danger { color: var(--danger); }
.msi.msi-white  { color: #fff; }

/* ---------- Skip link (a11y) ---------- */
.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--brand-green); color: #fff;
  padding: 8px 16px; border-radius: 0 0 8px 0;
  z-index: 999;
}
.skip-link:focus { left: 0; }

/* ---------- Flash messages ---------- */
.flash { padding: 12px 20px; text-align: center; font-size: 14px; font-weight: 600; }
.flash-success { background: #f1f9f3; color: var(--brand-green-deep); border-bottom: 1px solid #bbe0c7; }
.flash-error   { background: #fcf4f2; color: var(--danger); border-bottom: 1px solid #f0cfc6; }
.flash-info    { background: var(--brand-gold-soft); color: var(--warning); border-bottom: 1px solid var(--brand-gold-edge); }
.flash-stack { display: flex; flex-direction: column; gap: 8px; padding: 14px 24px 0; }
.flash-stack .flash { border-radius: var(--r-md); border-bottom: 0; box-shadow: var(--shadow-sm); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--r-md);
  font-weight: 600; font-size: 14px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: all .15s ease;
  font-family: inherit;
}
.btn-primary { background: var(--brand-green); color: #fff; }
.btn-primary:hover { background: var(--brand-green-deep); color: #fff; text-decoration: none; }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--border); }
.btn-ghost:hover { background: var(--brand-green-soft); color: var(--brand-green-deep); text-decoration: none; }
.btn-gold { background: var(--brand-gold); color: #16241c; }
.btn-gold:hover { background: var(--brand-gold-edge); color: #16241c; text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-lg { padding: 14px 26px; font-size: 15px; border-radius: var(--r-md); }
.btn-block { display: flex; width: 100%; }
.btn:focus-visible { outline: 3px solid var(--brand-gold); outline-offset: 2px; }

/* ---------- Form fields ---------- */
.input, input[type="text"], input[type="email"], input[type="password"],
input[type="tel"], input[type="number"], input[type="url"], textarea, select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand-green);
  box-shadow: 0 0 0 3px rgba(0,108,53,.12);
}
.label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.form-row { margin-bottom: 16px; }
.form-help { font-size: 12.5px; color: var(--ink-faint); margin-top: 4px; }
.form-error { font-size: 12.5px; color: var(--danger); margin-top: 4px; }

/* ---------- Card ---------- */
.card-pl {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
}
.card-pl.lg { padding: 28px; }

/* ---------- Site (non-app) header + footer ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50; backdrop-filter: blur(10px);
}
.site-header .brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }
.site-nav { display: flex; align-items: center; gap: 10px; }
.lang-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
}
.lang-pill:hover { background: var(--brand-green-soft); color: var(--brand-green-deep); border-color: var(--brand-green-soft); text-decoration: none; }

.site-wrap { min-height: calc(100vh - 80px); }
.site-footer { background: var(--brand-green-deep); color: rgba(255,255,255,.7); padding: 24px 28px; margin-top: 60px; }
.footer-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; font-size: 13px; }
.site-footer a { color: rgba(255,255,255,.85); }
.site-footer .muted { color: rgba(255,255,255,.6); }

/* ---------- Hero ---------- */
.hero { padding: 80px 28px 60px; background: radial-gradient(circle at 20% 0%, var(--brand-green-soft) 0%, var(--canvas) 60%); }
.hero-inner { max-width: 880px; margin: 0 auto; text-align: center; }
.eyebrow { display: inline-block; padding: 6px 14px; background: var(--brand-green-soft); color: var(--brand-green-deep); border-radius: 999px; font-size: 12.5px; font-weight: 700; letter-spacing: .3px; margin-bottom: 22px; }
.hero h1 { font-size: 56px; font-weight: 800; letter-spacing: -1.5px; color: var(--brand-green-deep); line-height: 1.1; margin-bottom: 20px; }
.hero .lead { font-size: 18px; color: var(--ink-soft); max-width: 660px; margin: 0 auto 32px; }
.hero-cta { display: inline-flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-bottom: 26px; }
.hero-status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-faint); }
.hero-status .dot { display: inline-block; width: 8px; height: 8px; background: var(--brand-green); border-radius: 50%; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .5; transform: scale(1.25); } }

/* ---------- Trust band ---------- */
.trust-band { padding: 60px 28px; background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.trust-grid { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.trust-item { display: flex; flex-direction: column; gap: 6px; padding: 18px; border: 1px solid var(--border-soft); border-radius: var(--r-lg); background: var(--canvas); }
.trust-item strong { font-size: 14.5px; font-weight: 700; color: var(--ink); }
.trust-item span { font-size: 13px; color: var(--ink-soft); }

/* ---------- App shell (admin/client/reseller) ---------- */
body.app-shell {
  background: var(--panel);
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh; height: 100vh; overflow: hidden;
}
html[dir="rtl"] body.app-shell { grid-template-columns: 1fr 250px; }

.app-sidebar {
  background: var(--brand-green-deep);
  color: rgba(255,255,255,.65);
  display: flex; flex-direction: column;
  min-height: 100vh; position: sticky; top: 0;
  font-family: 'Rubik', system-ui, sans-serif;
  padding: 20px 0;
  overflow-y: auto;
}
.sidebar-head { padding: 0 20px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-head .brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.sidebar-eyebrow { font-size: 11px; font-weight: 700; color: var(--brand-gold); text-transform: uppercase; letter-spacing: .8px; margin-top: 14px; }

.sidebar-nav { padding: 12px 0; flex: 1; }
.sidebar-section { font-size: 11px; font-weight: 700; color: rgba(255,255,255,.4); text-transform: uppercase; letter-spacing: .8px; padding: 18px 20px 8px; }
.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  color: rgba(255,255,255,.72);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all .15s ease;
}
.sidebar-link:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.sidebar-link.active { background: var(--brand-green); color: #fff; box-shadow: inset 3px 0 0 var(--brand-gold); }
.sidebar-link .ic { display: inline-flex; align-items: center; width: 20px; flex-shrink: 0; }
.sidebar-link .lb { flex: 1; }

.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.08); margin-top: auto; }
.sidebar-user .avatar { width: 34px; height: 34px; border-radius: 11px; background: var(--brand-gold); color: var(--brand-green-deep); display: flex; align-items: center; justify-content: center; font-weight: 800; }
.sidebar-user .name { color: #fff; font-size: 13.5px; font-weight: 600; }
.sidebar-user .sub { color: rgba(255,255,255,.5); font-size: 11.5px; }

.app-content { display: flex; flex-direction: column; min-height: 100vh; overflow: auto; }
.app-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px;
  background: rgba(255,255,255,.85);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(10px);
}
.app-topbar h1 { font-size: 20px; font-weight: 700; color: var(--ink); }
.app-topbar .sub { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-status { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; background: var(--brand-green-soft); color: var(--brand-green-deep); border-radius: 999px; font-size: 12px; font-weight: 600; }
.topbar-status .dot { display: inline-block; width: 8px; height: 8px; background: var(--brand-green); border-radius: 50%; }
.app-main { flex: 1; padding: 28px; }
.app-page { max-width: 1280px; margin: 0 auto; }

/* ---------- KPI cards (used in dashboards) ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.kpi::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, var(--brand-green), var(--brand-gold)); opacity: 0; transition: opacity .2s; }
.kpi:hover::before { opacity: 1; }
.kpi .kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kpi .chip { width: 32px; height: 32px; border-radius: var(--r-md); background: var(--brand-green-soft); color: var(--brand-green-deep); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; }
.kpi .value { font-size: 28px; font-weight: 800; color: var(--ink); line-height: 1.1; }
.kpi .label { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
  body.app-shell { grid-template-columns: 1fr; height: auto; overflow: visible; }
  html[dir="rtl"] body.app-shell { grid-template-columns: 1fr; }
  .app-sidebar { position: static; min-height: auto; }
  .app-content { overflow: visible; }
  .trust-grid { grid-template-columns: repeat(2, 1fr); }
  .hero h1 { font-size: 38px; }
  .hero .lead { font-size: 16px; }
  .site-footer .footer-inner { flex-direction: column; text-align: center; }
}
@media (max-width: 480px) {
  .trust-grid { grid-template-columns: 1fr; }
  .hero { padding: 50px 20px 40px; }
  .hero h1 { font-size: 32px; }
}
