/* ============================================================
   AWLY DESIGN SYSTEM — v1.0
   Single source of truth for all design tokens and base components.
   Shared by public site (styles.css) and admin (admin.css).
   ============================================================ */

/* ── 1. DESIGN TOKENS ───────────────────────────────────────── */
:root {

  /* Primary palette — forest green */
  --c-green-950: #0d2218;
  --c-green-900: #163526;
  --c-green-800: #1e4d36;
  --c-green-700: #256645;
  --c-green-600: #2d8057;
  --c-green-500: #389b6b;
  --c-green-400: #56b384;
  --c-green-300: #82cba4;
  --c-green-200: #b3dfc4;
  --c-green-100: #dff0e7;
  --c-green-50:  #f2faf5;

  /* Accent — warm gold */
  --c-gold-800:  #7a5318;
  --c-gold-700:  #9a6c22;
  --c-gold-600:  #b8852e;
  --c-gold-500:  #d4a045;
  --c-gold-400:  #e8bc6e;
  --c-gold-100:  #fdf2d8;
  --c-gold-50:   #fffbf0;

  /* Neutral palette */
  --c-ink:       #141f18;
  --c-ink-2:     #2c3d33;
  --c-muted:     #5e7267;
  --c-subtle:    #8fa898;
  --c-line:      #dce8e0;
  --c-line-soft: #eef4f0;
  --c-surface:   #f8fbf9;
  --c-paper:     #fbfaf6;
  --c-white:     #ffffff;

  /* Semantic colours */
  --c-success:      #1a7a45;
  --c-success-soft: #e6f5ec;
  --c-warning:      #8c5e10;
  --c-warning-soft: #fdf3dc;
  --c-danger:       #9b2a2a;
  --c-danger-soft:  #fde8e8;
  --c-info:         #1a5f8a;
  --c-info-soft:    #e4f2fb;

  /* Water / teal accent (water-meter initiative) */
  --c-water:      #0a7a96;
  --c-water-soft: #e4f6fb;
  --c-water-dark: #065870;

  /* ── 2. TYPOGRAPHY SCALE ─────────────────────────────────── */
  --font-base: "Cairo", Tahoma, Arial, sans-serif;

  /* Fluid sizes via clamp(min, preferred, max) */
  --text-xs:   .72rem;   /* 11.5px */
  --text-sm:   .82rem;   /* 13px   */
  --text-base: .94rem;   /* 15px   */
  --text-md:   1.06rem;  /* 17px   */
  --text-lg:   1.2rem;   /* 19px   */
  --text-xl:   1.4rem;   /* 22px   */
  --text-2xl:  1.7rem;   /* 27px   */
  --text-3xl:  clamp(1.8rem, 3.5vw, 2.4rem);
  --text-4xl:  clamp(2.2rem, 5vw,   3.4rem);
  --text-5xl:  clamp(2.8rem, 7vw,   5rem);

  --leading-tight:  1.2;
  --leading-snug:   1.45;
  --leading-normal: 1.7;
  --leading-loose:  2;

  --weight-normal:  400;
  --weight-medium:  600;
  --weight-bold:    700;
  --weight-heavy:   800;
  --weight-black:   900;

  /* ── 3. SPACING SCALE ────────────────────────────────────── */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;
  --sp-20: 80px;
  --sp-24: 96px;

  /* ── 4. BORDER RADIUS ────────────────────────────────────── */
  --r-xs:   6px;
  --r-sm:   10px;
  --r-md:   14px;
  --r-lg:   18px;
  --r-xl:   24px;
  --r-2xl:  32px;
  --r-full: 9999px;

  /* ── 5. SHADOWS ──────────────────────────────────────────── */
  --sh-xs:  0 1px 3px rgba(13, 34, 24, .06);
  --sh-sm:  0 4px 12px rgba(13, 34, 24, .07);
  --sh-md:  0 8px 24px rgba(13, 34, 24, .09);
  --sh-lg:  0 16px 40px rgba(13, 34, 24, .11);
  --sh-xl:  0 28px 60px rgba(13, 34, 24, .13);
  --sh-glow-green: 0 8px 24px rgba(56, 155, 107, .28);
  --sh-glow-gold:  0 8px 20px rgba(212, 160, 69, .30);

  /* ── 6. TRANSITIONS ──────────────────────────────────────── */
  --ease-out: cubic-bezier(.22, .61, .36, 1);
  --t-fast:   .15s var(--ease-out);
  --t-base:   .22s var(--ease-out);
  --t-slow:   .38s var(--ease-out);

  /* ── 7. LAYOUT ───────────────────────────────────────────── */
  --container:    1180px;
  --container-sm: 840px;

  /* ── 8. Z-INDEX ──────────────────────────────────────────── */
  --z-base:    1;
  --z-raised:  10;
  --z-sticky:  40;
  --z-overlay: 60;
  --z-modal:   80;
  --z-top:     999;
}

/* ── 9. GLOBAL RESET & BASE ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--c-paper);
  color: var(--c-ink);
  font-family: var(--font-base);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  max-width: 100%;
  overflow-x: hidden;
}

img, video, svg, canvas, iframe { max-width: 100%; display: block; }

a { color: inherit; text-decoration: none; }

button, input, textarea, select { font: inherit; }
button { cursor: pointer; border: 0; }

h1, h2, h3, h4, h5, h6 { margin: 0; line-height: var(--leading-tight); }
p { margin: 0 0 var(--sp-4); }
p:last-child { margin-bottom: 0; }

/* ── 10. UTILITY CLASSES ─────────────────────────────────────── */

/* Container */
.ds-container {
  width: min(calc(100% - var(--sp-8)), var(--container));
  margin-inline: auto;
}
.ds-container-sm {
  width: min(calc(100% - var(--sp-8)), var(--container-sm));
  margin-inline: auto;
}

/* Accessibility */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: -64px; inset-inline-end: var(--sp-4);
  z-index: var(--z-top); background: var(--c-white);
  color: var(--c-green-900); padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md); box-shadow: var(--sh-md);
  font-weight: var(--weight-bold); font-size: var(--text-sm);
  transition: top var(--t-base);
}
.skip-link:focus { top: var(--sp-4); }

/* Section label pill */
.ds-label {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-full);
  background: var(--c-green-100);
  color: var(--c-green-700);
  font-size: var(--text-xs);
  font-weight: var(--weight-black);
  letter-spacing: .03em;
}

/* Section head block */
.ds-section-head {
  text-align: center;
  max-width: 700px;
  margin: 0 auto var(--sp-12);
}
.ds-section-head h2 {
  font-size: var(--text-3xl);
  color: var(--c-green-950);
  font-weight: var(--weight-black);
  letter-spacing: -.02em;
  margin: var(--sp-3) 0 var(--sp-3);
}
.ds-section-head p {
  color: var(--c-muted);
  font-size: var(--text-md);
  margin: 0;
}

/* ── 11. BUTTON SYSTEM ───────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: .7em 1.4em;
  border-radius: var(--r-full);
  font-weight: var(--weight-black);
  font-size: var(--text-base);
  line-height: 1;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast),
              background var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover  { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

/* Sizes */
.btn-sm  { font-size: var(--text-sm);  padding: .5em 1.1em; }
.btn-lg  { font-size: var(--text-md);  padding: .8em 1.8em; }
.btn-xl  { font-size: var(--text-lg);  padding: .9em 2.2em; }
.btn-block { width: 100%; justify-content: center; }

/* Solid green — primary */
.btn-primary {
  background: var(--c-green-600);
  color: var(--c-white);
  box-shadow: var(--sh-glow-green);
  border-color: transparent;
}
.btn-primary:hover {
  background: var(--c-green-700);
  box-shadow: 0 12px 32px rgba(56,155,107,.36);
}

/* Outline green */
.btn-outline-green {
  background: transparent;
  color: var(--c-green-700);
  border-color: var(--c-green-300);
}
.btn-outline-green:hover {
  background: var(--c-green-50);
  border-color: var(--c-green-500);
}

/* Solid gold — accent */
.btn-gold {
  background: linear-gradient(135deg, var(--c-gold-500), var(--c-gold-600));
  color: var(--c-white);
  box-shadow: var(--sh-glow-gold);
}
.btn-gold:hover { filter: brightness(1.07); }

/* Light — on dark backgrounds */
.btn-light {
  background: var(--c-white);
  color: var(--c-green-900);
  box-shadow: var(--sh-sm);
}
.btn-light:hover { background: var(--c-green-50); }

/* Ghost — on dark */
.btn-ghost-dark {
  background: rgba(255,255,255,.12);
  color: var(--c-white);
  border-color: rgba(255,255,255,.22);
  backdrop-filter: blur(6px);
}
.btn-ghost-dark:hover { background: rgba(255,255,255,.2); }

/* Danger */
.btn-danger {
  background: var(--c-danger-soft);
  color: var(--c-danger);
  border-color: rgba(155,42,42,.15);
}
.btn-danger:hover { background: #fbd4d4; }

/* Water teal */
.btn-water {
  background: var(--c-water);
  color: var(--c-white);
  box-shadow: 0 8px 20px rgba(10,122,150,.25);
}
.btn-water:hover { background: var(--c-water-dark); }

/* Secondary / subdued */
.btn-secondary {
  background: var(--c-surface);
  color: var(--c-green-800);
  border-color: var(--c-line);
}
.btn-secondary:hover { background: var(--c-green-50); border-color: var(--c-green-200); }

/* ── 12. CARD SYSTEM ─────────────────────────────────────────── */

.ds-card {
  background: var(--c-white);
  border: 1px solid var(--c-line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-sm);
  overflow: hidden;
}
.ds-card-body  { padding: var(--sp-6); }
.ds-card-body-sm { padding: var(--sp-4); }

/* Elevated card — hover lift */
.ds-card-lift {
  transition: transform var(--t-base), box-shadow var(--t-base),
              border-color var(--t-base);
}
.ds-card-lift:hover {
  transform: translateY(-5px);
  box-shadow: var(--sh-lg);
  border-color: var(--c-green-200);
}

/* Tinted card */
.ds-card-tint {
  background: var(--c-green-50);
  border-color: var(--c-green-100);
}

/* Dark card */
.ds-card-dark {
  background: var(--c-green-950);
  color: var(--c-white);
  border-color: rgba(255,255,255,.06);
}

/* Accent left border */
.ds-card-accent {
  border-inline-start: 4px solid var(--c-green-500);
}
.ds-card-accent-gold {
  border-inline-start: 4px solid var(--c-gold-500);
}
.ds-card-accent-water {
  border-inline-start: 4px solid var(--c-water);
}

/* Stat card */
.ds-stat-card {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-5);
}
.ds-stat-icon {
  width: 52px; height: 52px; flex: 0 0 52px;
  border-radius: var(--r-lg);
  display: grid; place-items: center;
  background: var(--c-green-50);
  color: var(--c-green-700);
}
.ds-stat-icon svg { width: 24px; height: 24px; }
.ds-stat-value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-black);
  color: var(--c-green-700);
  line-height: 1;
}
.ds-stat-label {
  font-size: var(--text-xs);
  color: var(--c-muted);
  font-weight: var(--weight-bold);
  margin-top: var(--sp-1);
}

/* ── 13. BADGE SYSTEM ────────────────────────────────────────── */

.ds-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-heavy);
  line-height: 1.4;
}
.ds-badge-green   { background: var(--c-success-soft); color: var(--c-success); }
.ds-badge-gold    { background: var(--c-gold-100);     color: var(--c-gold-700); }
.ds-badge-red     { background: var(--c-danger-soft);  color: var(--c-danger); }
.ds-badge-blue    { background: var(--c-info-soft);    color: var(--c-info); }
.ds-badge-water   { background: var(--c-water-soft);   color: var(--c-water-dark); }
.ds-badge-subtle  { background: var(--c-line-soft);    color: var(--c-muted); }
.ds-badge-warning { background: var(--c-warning-soft); color: var(--c-warning); }

/* ── 14. FORM SYSTEM ─────────────────────────────────────────── */

.ds-field {
  display: grid;
  gap: var(--sp-2);
}
.ds-field label {
  font-size: var(--text-sm);
  font-weight: var(--weight-heavy);
  color: var(--c-green-900);
}
.ds-field label .req {
  color: var(--c-danger);
  margin-inline-start: 2px;
}
.ds-input,
.ds-select,
.ds-textarea {
  width: 100%;
  border: 1.5px solid var(--c-line);
  border-radius: var(--r-md);
  padding: .65em .9em;
  background: var(--c-white);
  color: var(--c-ink);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: 0;
  min-height: 48px;
}
.ds-input:focus,
.ds-select:focus,
.ds-textarea:focus {
  border-color: var(--c-green-500);
  box-shadow: 0 0 0 4px rgba(56,155,107,.12);
}
.ds-input::placeholder,
.ds-textarea::placeholder { color: var(--c-subtle); }
.ds-textarea { resize: vertical; min-height: 100px; padding-top: .65em; }
.ds-input-error { border-color: var(--c-danger) !important; }
.ds-field-hint {
  font-size: var(--text-xs);
  color: var(--c-muted);
  line-height: 1.6;
}
.ds-field-error {
  font-size: var(--text-xs);
  color: var(--c-danger);
  font-weight: var(--weight-bold);
}

/* Input with leading icon */
.ds-input-shell {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 0 var(--sp-3);
  border: 1.5px solid var(--c-line);
  border-radius: var(--r-md);
  background: var(--c-white);
  min-height: 48px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.ds-input-shell:focus-within {
  border-color: var(--c-green-500);
  box-shadow: 0 0 0 4px rgba(56,155,107,.12);
}
.ds-input-shell input {
  flex: 1; min-width: 0; border: 0; outline: 0;
  background: transparent; padding: 0;
  font: inherit; color: var(--c-ink);
}
.ds-input-icon { color: var(--c-subtle); flex: 0 0 auto; }

/* Form grid */
.ds-form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4); }
.ds-form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .ds-form-grid { grid-template-columns: 1fr; } }

/* ── 15. TABLE SYSTEM ────────────────────────────────────────── */

.ds-table-wrap {
  overflow-x: auto;
  border-radius: var(--r-lg);
  border: 1px solid var(--c-line);
}
.ds-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
  background: var(--c-white);
}
.ds-table th {
  padding: var(--sp-3) var(--sp-4);
  text-align: right;
  font-size: var(--text-xs);
  font-weight: var(--weight-black);
  color: var(--c-muted);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-line);
  white-space: nowrap;
  letter-spacing: .03em;
}
.ds-table td {
  padding: var(--sp-3) var(--sp-4);
  text-align: right;
  border-bottom: 1px solid var(--c-line-soft);
  vertical-align: middle;
  font-size: var(--text-sm);
}
.ds-table tbody tr:last-child td { border-bottom: 0; }
.ds-table tbody tr {
  transition: background var(--t-fast);
}
.ds-table tbody tr:hover { background: var(--c-green-50); }

/* File number pill */
.ds-file-num {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: var(--r-sm);
  background: var(--c-green-50);
  color: var(--c-green-700);
  font-size: var(--text-xs);
  font-weight: var(--weight-black);
  font-variant-numeric: tabular-nums;
  direction: ltr;
}

/* ── 16. FLASH / ALERT SYSTEM ───────────────────────────────── */

.ds-alert {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  line-height: var(--leading-normal);
}
.ds-alert-icon { flex: 0 0 20px; margin-top: 2px; }
.ds-alert-success {
  background: var(--c-success-soft);
  color: var(--c-success);
  border-color: rgba(26,122,69,.15);
}
.ds-alert-warning {
  background: var(--c-warning-soft);
  color: var(--c-warning);
  border-color: rgba(140,94,16,.15);
}
.ds-alert-error {
  background: var(--c-danger-soft);
  color: var(--c-danger);
  border-color: rgba(155,42,42,.15);
}
.ds-alert-info {
  background: var(--c-info-soft);
  color: var(--c-info);
  border-color: rgba(26,95,138,.15);
}

/* Important note block (with left border) */
.ds-note {
  padding: var(--sp-4);
  border-radius: var(--r-md);
  border-inline-start: 4px solid var(--c-gold-500);
  background: var(--c-gold-50);
  color: var(--c-gold-800);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}
.ds-note strong { color: var(--c-gold-700); }

/* ── 17. PAGINATION ──────────────────────────────────────────── */

.ds-pagination {
  display: flex; flex-wrap: wrap; gap: var(--sp-2);
  margin-top: var(--sp-5);
}
.ds-pagination a,
.ds-pagination span {
  min-width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-md);
  border: 1px solid var(--c-line);
  background: var(--c-white);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--c-green-800);
  padding: 0 var(--sp-2);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.ds-pagination a:hover { background: var(--c-green-50); border-color: var(--c-green-300); }
.ds-pagination a.active {
  background: var(--c-green-700);
  color: var(--c-white);
  border-color: var(--c-green-700);
}

/* ── 18. DIALOG / MODAL ──────────────────────────────────────── */

.ds-dialog {
  border: 0;
  border-radius: var(--r-xl);
  padding: 0;
  max-width: min(92vw, 520px);
  width: 100%;
  box-shadow: var(--sh-xl);
  overflow: hidden;
}
.ds-dialog::backdrop {
  background: rgba(5, 14, 9, .68);
  backdrop-filter: blur(6px);
}
.ds-dialog-inner { padding: var(--sp-6); }
.ds-dialog-head {
  display: flex; justify-content: space-between;
  align-items: flex-start; gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}
.ds-dialog-head h2 {
  font-size: var(--text-xl);
  color: var(--c-green-950);
}
.ds-dialog-close {
  width: 36px; height: 36px; flex: 0 0 36px;
  border-radius: var(--r-full);
  background: var(--c-surface);
  color: var(--c-muted);
  display: grid; place-items: center;
  font-size: 1.2rem; line-height: 1;
  border: 1px solid var(--c-line);
  transition: background var(--t-fast), color var(--t-fast);
}
.ds-dialog-close:hover { background: var(--c-line); color: var(--c-ink); }

/* ── 19. EMPTY STATE ─────────────────────────────────────────── */

.ds-empty {
  padding: var(--sp-16) var(--sp-8);
  text-align: center;
  color: var(--c-muted);
}
.ds-empty-icon {
  width: 60px; height: 60px;
  border-radius: var(--r-xl);
  background: var(--c-green-50);
  color: var(--c-green-400);
  display: grid; place-items: center;
  margin: 0 auto var(--sp-4);
}
.ds-empty-icon svg { width: 28px; height: 28px; }
.ds-empty strong { display: block; color: var(--c-ink); font-size: var(--text-md); margin-bottom: var(--sp-2); }
.ds-empty p { font-size: var(--text-sm); margin: 0; }

/* ── 20. DIVIDER ─────────────────────────────────────────────── */

.ds-divider {
  border: 0;
  border-top: 1px solid var(--c-line);
  margin: var(--sp-6) 0;
}

/* ── 21. REDUCED MOTION ──────────────────────────────────────── */

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