/* Design tokens and primitives shared by the client page and the admin panel. */

:root {
  --ivory:      #FBF7F4;
  --shell:      #FFFFFF;
  --sand:       #F2E9E2;
  --line:       #E7DAD0;
  --ink:        #2E2723;
  --ink-soft:   #6E625A;
  --ink-faint:  #9C8F86;
  --mocha:      #B08268;
  --mocha-dark: #90664F;
  --rose:       #C98A86;
  --gold:       #C9A227;

  --ok:         #3F7D5C;
  --ok-bg:      #E6F1EA;
  --warn:       #9A6B18;
  --warn-bg:    #FBF0DA;
  --danger:     #A8443C;
  --danger-bg:  #F8E6E4;
  --info:       #4A6C8F;
  --info-bg:    #E7EEF5;

  --radius:     14px;
  --radius-sm:  10px;
  --shadow:     0 1px 2px rgba(46, 39, 35, .05), 0 8px 24px rgba(46, 39, 35, .06);
  --shadow-lg:  0 12px 40px rgba(46, 39, 35, .14);
  --font:       'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --serif:      'Cormorant Garamond', Georgia, 'Times New Roman', serif;
}

/*
 * Arabic counterparts, picked to sit naturally beside the Latin faces rather
 * than leaving the browser to fall back to whatever it has: Tajawal is a
 * humanist sans that matches the UI font, Amiri a classical Naskh that matches
 * the old-style serif headings.
 *
 * Redefining the two variables under [dir="rtl"] means every existing rule
 * picks them up — no rule below needs to know a second script exists.
 */
html[dir="rtl"] {
  --font:  'Tajawal', 'Segoe UI', system-ui, sans-serif;
  --serif: 'Amiri', 'Cormorant Garamond', Georgia, serif;
}

/* Arabic script sits taller than Latin and reads better with more room. */
html[dir="rtl"] body { line-height: 1.75; }
html[dir="rtl"] h1,
html[dir="rtl"] h2,
html[dir="rtl"] h3 { line-height: 1.35; }

* { box-sizing: border-box; }

/* `hidden` must win over any layout `display` we set on modals and panels. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--ivory);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; font-weight: 600; }

a { color: var(--mocha-dark); }

button, input, select, textarea { font: inherit; color: inherit; }

/* --- form controls ------------------------------------------------------ */

.field { display: block; margin-bottom: 16px; }

.field > label,
.label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

input[type="text"], input[type="tel"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="time"], select, textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--shell);
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--mocha);
  box-shadow: 0 0 0 3px rgba(176, 130, 104, .18);
}

input[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(168, 68, 60, .12);
}

textarea { resize: vertical; min-height: 80px; }

.hint  { font-size: .82rem; color: var(--ink-faint); margin-top: 5px; }
.error { font-size: .82rem; color: var(--danger); margin-top: 5px; min-height: 1em; }

/* --- buttons ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--mocha);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .08s, box-shadow .15s, opacity .15s;
}

.btn:hover:not(:disabled) { background: var(--mocha-dark); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--line);
}
.btn-ghost:hover:not(:disabled) { background: var(--sand); color: var(--ink); }

.btn-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--ink-soft);
  padding: 8px 12px;
}
.btn-quiet:hover:not(:disabled) { background: var(--sand); color: var(--ink); }

.btn-ok     { background: var(--ok); }
.btn-ok:hover:not(:disabled) { background: #34664B; }
.btn-danger { background: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #8C3831; }

.btn-sm { padding: 7px 14px; font-size: .87rem; }

/* --- misc --------------------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.pill-pending   { background: var(--warn-bg);   color: var(--warn); }
.pill-approved  { background: var(--ok-bg);     color: var(--ok); }
.pill-declined  { background: var(--danger-bg); color: var(--danger); }
.pill-cancelled { background: var(--sand);      color: var(--ink-soft); }
.pill-completed { background: var(--info-bg);   color: var(--info); }

.card {
  background: var(--shell);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Toasts ---------------------------------------------------------------- */

#toasts {
  position: fixed;
  bottom: 20px;
  inset-inline-end: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-size: .92rem;
  max-width: 340px;
  animation: toast-in .22s ease-out;
}
.toast.ok    { background: var(--ok); }
.toast.error { background: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/*
 * Touch devices. A mouse pointer lands where you aim it; a fingertip is about
 * 44px across, which is the size both Apple and Google ask for. These rules
 * key off the input device rather than the screen width, so a tablet gets them
 * too and a desktop window narrowed to phone width does not.
 */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 44px; padding: 10px 16px; }
  .btn-quiet { min-height: 44px; }

  input[type="text"], input[type="tel"], input[type="email"], input[type="password"],
  input[type="number"], input[type="date"], input[type="time"], select {
    min-height: 44px;
  }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; }

  /* Small print is legible on a desk, less so at arm's length. */
  .pill { font-size: .8rem; }
  .hint, .error { font-size: .87rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
