/* ===================================================================
   S.A Nail — design system  (RTL · mobile-first · soft nude luxury)
   Display: Assistant (sans) · Body: Heebo (sans)
   =================================================================== */

:root {
  /* palette */
  --bg: #f6efea;
  --bg-2: #f1e4dd;
  --surface: #fffdfc;
  --surface-2: #f7ece7;
  --soft: #f2e4e0;
  --primary: #ebcfc9;
  --primary-hover: #dcc2b8;
  --primary-strong: #c8a99f;
  --accent: #c8a99f;
  --gold: #d4af37;
  --gold-soft: #efe2bf;
  --text: #4f342f;
  --text-soft: #6b4a43;
  --muted: #9a8178;
  --border: #ecdcd3;
  --hairline: #e7d6cc;
  --ok: #8aa087;
  --ok-soft: #eaf0e6;
  --danger: #c0726b;
  --danger-soft: #f6e5e2;
  --warn: #b9852f;

  /* elevation — warm, layered, soft */
  --sh-1: 0 1px 2px rgba(79,52,47,.05), 0 3px 8px -4px rgba(150,110,90,.18);
  --sh-2: 0 2px 4px rgba(79,52,47,.05), 0 18px 38px -16px rgba(150,110,90,.28);
  --sh-float: 0 -2px 10px rgba(79,52,47,.04), 0 14px 34px -10px rgba(150,110,90,.40);

  --radius: 22px;
  --radius-sm: 14px;
  --font: "Heebo", system-ui, "Segoe UI", Arial, sans-serif;
  --display: "Assistant", system-ui, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; direction: rtl;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  /* atmospheric nude gradient instead of a flat fill */
  background:
    radial-gradient(120% 70% at 50% -10%, #fdf8f4 0%, rgba(253,248,244,0) 60%),
    linear-gradient(180deg, #f8f1ec 0%, var(--bg) 45%, var(--bg-2) 100%);
  background-attachment: fixed;
}

* { -webkit-tap-highlight-color: rgba(200,169,159,.16); }
button, a, .chip, .service, .cal-day, .tab, .seg-btn, .week-day, input[type="checkbox"] { touch-action: manipulation; }

h1, h2, h3, h4 { margin: 0 0 .4em; font-family: var(--display); font-weight: 700; line-height: 1.2; letter-spacing: .2px; color: var(--text); }
p { margin: 0 0 1em; }
a { color: var(--text-soft); }

/* --- Layout shell --------------------------------------------------- */
.app {
  max-width: 720px; margin: 0 auto;
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  overflow-x: clip;
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px;
  padding-top: calc(10px + env(safe-area-inset-top));
  padding-right: calc(18px + env(safe-area-inset-right));
  padding-left: calc(18px + env(safe-area-inset-left));
  background: rgba(255,253,252,.82);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--hairline);
  box-shadow: 0 1px 0 rgba(212,175,55,.25), var(--sh-1);
  color: var(--text);
}
.topbar-logo { height: 52px; width: auto; display: block; flex-shrink: 0; }
.topbar > .flex { margin-inline-start: auto; }
.topbar-tag { font-family: var(--display); font-size: .82rem; font-weight: 700; color: var(--muted); }
.topbar .btn-ghost { background: var(--surface-2); border-color: var(--hairline); color: var(--text-soft); }

.content {
  flex: 1; width: 100%;
  padding: 20px;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
  padding-right: calc(20px + env(safe-area-inset-right));
  padding-left: calc(20px + env(safe-area-inset-left));
}

/* --- Cards ---------------------------------------------------------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--sh-1);
  padding: 22px;
  margin-bottom: 18px;
}
.card > h2:first-child, .card > h2 { font-size: 1.3rem; }
.card h2 { font-size: 1.22rem; }
/* gold hairline accent under the first heading of a card */
.card > h2:first-child::after {
  content: ""; display: block; width: 38px; height: 2px; margin-top: 8px;
  background: linear-gradient(90deg, var(--gold), transparent);
  border-radius: 2px;
}
.card .card-hint { color: var(--muted); font-size: .92rem; margin: -.1em 0 0; }

/* --- Buttons -------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: 1rem; font-weight: 700;
  padding: 14px 22px; min-height: 48px;
  border-radius: 999px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; letter-spacing: .2px;
  transition: transform .12s cubic-bezier(.2,.8,.2,1), box-shadow .25s ease, background .25s ease, border-color .25s ease, opacity .2s ease;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(180deg, #f0dbd5 0%, #e7cbc3 100%);
  color: var(--text); border-color: #ddc4bb;
  box-shadow: 0 6px 16px -8px rgba(176,124,118,.6), inset 0 1px 0 rgba(255,255,255,.6);
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #ecd2cb 0%, #ddc0b7 100%); box-shadow: 0 10px 22px -10px rgba(176,124,118,.7); }
.btn-ghost { background: var(--surface); color: var(--text-soft); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.95); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: var(--danger-soft); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; min-height: 38px; font-size: .85rem; }

/* --- Forms ---------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-weight: 700; font-size: .82rem; margin-bottom: 7px;
  color: var(--text-soft); letter-spacing: .3px;
}
.input, .select, textarea.input {
  width: 100%; font-family: inherit; font-size: 1rem;
  padding: 14px 15px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
textarea.input { resize: vertical; min-height: 64px; line-height: 1.6; }
.input::placeholder, textarea.input::placeholder { color: #c2ac9f; }
.input:focus, .select:focus, textarea.input:focus {
  outline: none; border-color: var(--accent); background: #fffefd;
  box-shadow: 0 0 0 4px rgba(200,169,159,.18);
}
.input.ltr { direction: ltr; text-align: right; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 140px; }

/* --- Chips / time slots --------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 0 18px; min-height: 46px;
  display: inline-flex; align-items: center;
  font-weight: 700; font-size: .98rem; color: var(--text); cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: all .16s ease; box-shadow: var(--sh-1);
}
.chip:hover { border-color: var(--accent); transform: translateY(-1px); }
.chip.selected {
  background: linear-gradient(180deg, var(--primary-strong), #bd9c92); color: #fff;
  border-color: var(--primary-strong); box-shadow: 0 8px 18px -8px rgba(176,124,118,.7);
}

/* --- Service cards -------------------------------------------------- */
.service-list { display: grid; gap: 14px; }
.service {
  position: relative; display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--border); border-radius: 18px;
  padding: 16px 18px; cursor: pointer; background: var(--surface);
  box-shadow: var(--sh-1); transition: all .18s cubic-bezier(.2,.8,.2,1);
}
.service:hover { transform: translateY(-2px); box-shadow: var(--sh-2); border-color: var(--accent); }
.service.selected { border-color: var(--primary-strong); box-shadow: 0 0 0 2px var(--primary-strong), var(--sh-2); }
.service.selected::after {
  content: "✓"; position: absolute; inset-inline-start: 14px; top: 14px;
  width: 22px; height: 22px; border-radius: 50%; background: var(--primary-strong); color: #fff;
  font-size: 13px; display: grid; place-items: center; font-weight: 800;
}
.service .swatch { width: 6px; align-self: stretch; border-radius: 6px; background: linear-gradient(var(--primary-strong), var(--gold)); }
.service .s-main { flex: 1; min-width: 0; }
.service .s-name { font-family: var(--display); font-weight: 700; font-size: 1.08rem; }
.service .s-meta { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.service .s-price { font-weight: 800; color: var(--text); white-space: nowrap; font-size: 1.05rem; }

/* --- Calendar ------------------------------------------------------- */
.cal-head { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; }
.cal-head strong { flex: 1; text-align: center; min-width: 0; font-family: var(--display); font-size: 1.05rem; }
.cal-head .btn { flex: 0 0 auto; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; min-width: 0; }
.cal-dow { text-align: center; font-size: .72rem; color: var(--muted); font-weight: 700; padding: 2px 0; min-width: 0; }
.cal-day {
  aspect-ratio: 1 / 1; border: 1px solid transparent; border-radius: 13px;
  display: grid; place-items: center; font-weight: 700; cursor: pointer; min-width: 0;
  background: var(--surface-2); color: var(--text); position: relative; transition: all .14s ease;
  font-variant-numeric: tabular-nums; font-size: .92rem;
}
.cal-day.has-slots { background: var(--surface); border-color: var(--border); box-shadow: var(--sh-1); }
.cal-day.has-slots:hover { border-color: var(--accent); transform: translateY(-1px); }
.cal-day.dim, .cal-day.none { color: #c9b6ac; cursor: default; background: transparent; }
.cal-day.selected { background: linear-gradient(180deg, var(--primary-strong), #bd9c92); color: #fff; border-color: var(--primary-strong); box-shadow: 0 8px 16px -8px rgba(176,124,118,.7); transform: translateY(-1px); }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--gold); }
.cal-day .dot { position: absolute; bottom: 6px; width: 5px; height: 5px; border-radius: 50%; background: var(--ok); }
.cal-day.selected .dot { background: #fff; }

/* --- Badges --------------------------------------------------------- */
.badge { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: .74rem; font-weight: 800; letter-spacing: .2px; vertical-align: middle; }
.badge.pending { background: #f7edd6; color: #9a7a22; }
.badge.booked { background: var(--ok-soft); color: #5d7256; }
.badge.cancelled { background: var(--danger-soft); color: var(--danger); }
.badge.completed { background: #efe6e1; color: var(--muted); }
.badge.no_show { background: #fdeede; color: var(--warn); }
.badge.waitlist { background: var(--gold-soft); color: #8a6a1f; }

/* --- Appointment rows ----------------------------------------------- */
.appt {
  display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap;
  padding: 14px 16px; border: 1px solid var(--border);
  border-radius: 16px; margin-bottom: 12px; background: var(--surface); box-shadow: var(--sh-1);
}
.appt .when {
  text-align: center; min-width: 56px; padding: 6px 4px; border-radius: 12px;
  background: var(--soft); flex-shrink: 0;
}
.appt .when .d { font-family: var(--display); font-weight: 800; font-size: 1.25rem; line-height: 1; color: var(--text); }
.appt .when .m { font-size: .7rem; color: var(--muted); margin-top: 2px; }
.appt .info { flex: 1 1 150px; min-width: 0; }
.appt .info .t { font-weight: 700; }
.appt .info .sub { color: var(--muted); font-size: .85rem; }
.appt .info .sub.note { font-style: italic; }
/* Action buttons: on phones they drop to their own full-width row under the
   text (no more overlap); on tablet+ they sit inline at the end of the card. */
.appt-actions {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  flex-basis: 100%; justify-content: flex-start;
  margin-top: 4px; padding-top: 11px; border-top: 1px solid var(--hairline);
}
.appt-actions .btn, .appt-actions a.btn { flex: 0 0 auto; }

/* --- Tabs (admin) --------------------------------------------------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 5px; background: var(--surface-2);
        border: 1px solid var(--hairline); border-radius: 999px; margin-bottom: 18px; -ms-overflow-style: none; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; padding: 10px 16px; min-height: 42px; border-radius: 999px; font-weight: 700;
       color: var(--muted); cursor: pointer; white-space: nowrap; border: none; background: transparent; font-family: inherit; font-size: .9rem; transition: all .2s ease; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); }

/* --- Segmented toggle (day/week) ------------------------------------ */
.seg { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--hairline); border-radius: 999px; padding: 5px; margin-bottom: 16px; }
.seg-btn { flex: 1; border: none; background: transparent; padding: 11px 12px; min-height: 44px; border-radius: 999px;
           font-weight: 700; color: var(--muted); cursor: pointer; font-family: inherit; font-size: .95rem; transition: all .2s ease; }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); }

/* --- Week view ------------------------------------------------------ */
.week-day { padding: 14px 16px; cursor: pointer; transition: all .16s ease; }
.week-day:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--sh-2); }
.week-day.wk-today { box-shadow: inset 0 0 0 2px var(--gold), var(--sh-1); }
.week-day strong { font-family: var(--display); }
.week-appt { display: flex; align-items: center; gap: 9px; padding: 7px 0; border-top: 1px solid var(--hairline); font-size: .9rem; flex-wrap: wrap; }
.week-appt .wk-time { font-weight: 800; min-width: 46px; font-variant-numeric: tabular-nums; }
.week-appt .wk-name { flex: 1; min-width: 0; }

/* --- Policy box ----------------------------------------------------- */
.policy { background: var(--surface-2); border: 1px solid var(--hairline); border-radius: var(--radius-sm);
          padding: 13px 15px; margin: 14px 0; font-size: .9rem; }
.policy strong { display: block; margin-bottom: 6px; font-family: var(--display); color: var(--text); }
.policy ul { margin: 0; padding-inline-start: 18px; }
.policy li { margin: 5px 0; color: var(--text-soft); }

/* --- Generic list row ----------------------------------------------- */
.list-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--border);
            border-radius: 16px; margin-bottom: 10px; background: var(--surface); box-shadow: var(--sh-1); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .name { font-weight: 700; }
.list-row .meta { color: var(--muted); font-size: .85rem; direction: ltr; text-align: right; }

/* --- Modal ---------------------------------------------------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(79,52,47,.42); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal-backdrop.open { display: flex; animation: fade .2s ease both; }
.modal { background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 460px;
  max-height: 90vh; max-height: 90dvh; overflow-y: auto; box-shadow: var(--sh-2); padding: 24px;
  -webkit-overflow-scrolling: touch; animation: pop .26s cubic-bezier(.2,.9,.3,1.2) both; border: 1px solid var(--border); }
.modal h3 { font-size: 1.3rem; }
.modal .modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal .modal-actions .btn { flex: 1; }

/* --- Toast ---------------------------------------------------------- */
.toast { position: fixed; bottom: calc(22px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%) translateY(24px); background: var(--text); color: #fff;
  padding: 13px 22px; border-radius: 999px; font-weight: 600; box-shadow: var(--sh-float);
  opacity: 0; pointer-events: none; transition: all .3s cubic-bezier(.2,.9,.3,1.2); z-index: 100; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: #5f7457; }
.toast.err { background: #b25c55; }

/* --- Booking CTA ---------------------------------------------------- */
/* Identical to every other .btn-primary (no floating shadow / bigger size),
   in normal flow so it sits at the END of the steps and scrolls with the
   page like the rest of the form. */
#book-btn { margin-top: 6px; }

/* --- Misc ----------------------------------------------------------- */
.center { text-align: center; }
.brand-logo { display: block; margin: 10px auto 20px; max-width: 320px; width: 84%; height: auto; }
.muted { color: var(--muted); }
.spacer { height: 8px; }
.hidden { display: none !important; }
.flex { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.empty { text-align: center; color: var(--muted); padding: 34px 14px; font-size: .95rem; }
.empty::before { content: "🤍"; display: block; font-size: 1.8rem; margin-bottom: 8px; opacity: .8; }

.spinner { width: 24px; height: 24px; border: 3px solid var(--soft); border-top-color: var(--primary-strong); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-screen { min-height: 62vh; display: grid; place-items: center; gap: 14px; color: var(--muted); }

.link-box { display: flex; gap: 8px; align-items: stretch; background: var(--surface-2);
  border: 1px dashed var(--accent); border-radius: var(--radius-sm); padding: 11px 13px; margin-top: 8px; }
.link-box input { flex: 1; border: none; background: transparent; direction: ltr; text-align: left; font-size: .85rem; color: var(--text-soft); }
.link-box input:focus { outline: none; }

/* reCAPTCHA: invisible mode still drops a floating badge — hide it and show the
   required attribution text on the login screens instead (per Google's terms). */
.grecaptcha-badge { visibility: hidden; }
.recaptcha-note { margin-top: 16px; font-size: .72rem; line-height: 1.55; color: var(--muted); text-align: center; }
.recaptcha-note a { color: var(--accent); text-decoration: underline; }

/* greeting heading uses the serif display, larger */
#greeting { font-size: 1.5rem; }
.greeting-bar { margin: 2px 2px 14px; }

/* count pill inside the "my appointments" tab */
.count-pill { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  margin-inline-start: 6px; border-radius: 999px; background: var(--primary-strong); color: #fff;
  font-size: .72rem; font-weight: 800; vertical-align: middle; font-variant-numeric: tabular-nums; }

/* grouped appointment sections (client "my appointments") */
.appt-group { margin-bottom: 18px; }
.appt-group:last-child { margin-bottom: 0; }
.group-title { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 700;
  color: var(--text); font-size: 1.05rem; margin: 0 2px 10px; }
.group-count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--hairline); color: var(--muted);
  font-family: var(--font); font-size: .78rem; font-weight: 800; }
.appt.past { opacity: .72; box-shadow: none; background: var(--surface-2); }
.appt.past .when { background: transparent; color: var(--muted); }

/* --- Motion: staggered reveal on screen show ------------------------ */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
#screen-login .card, #screen-register .card,
#screen-booking .tab-panel:not(.hidden) > .card,
#screen-admin > .tab-panel:not(.hidden) > .card,
#screen-admin > .tab-panel:not(.hidden) > #day-view, #screen-admin > .tab-panel:not(.hidden) > #week-view {
  animation: rise .5s cubic-bezier(.2,.8,.2,1) both;
}
.brand-logo { animation: rise .6s ease both; }

/* --- Accessibility -------------------------------------------------- */
.btn:focus-visible, .chip:focus-visible, .tab:focus-visible, .seg-btn:focus-visible,
.cal-day:focus-visible, .service:focus-visible, .week-day:focus-visible,
.input:focus-visible, .select:focus-visible, textarea.input:focus-visible,
a:focus-visible, input[type="checkbox"]:focus-visible {
  outline: 3px solid var(--primary-strong); outline-offset: 2px;
}
.chip:active, .service:active, .cal-day.has-slots:active, .week-day:active, .list-row:active { transform: scale(.985); }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary-strong); flex-shrink: 0; }

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

/* --- Responsive ----------------------------------------------------- */
@media (min-width: 640px) {
  .content { padding: 28px; }
  .topbar-logo { height: 62px; }
  .topbar { padding-block: 12px; }
  .service-list { grid-template-columns: 1fr 1fr; }
  #clients-list, #services-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  #clients-list > *, #services-list > * { margin-bottom: 0; }
  /* roomy enough for an inline action group again */
  .appt { align-items: center; }
  .appt-actions { flex-basis: auto; justify-content: flex-end; margin-top: 0; padding-top: 0; border-top: none; }
}
@media (min-width: 900px) { .app { max-width: 860px; } }
@media (max-width: 360px) {
  .content { padding: 15px; }
  .card { padding: 17px; }
  .topbar-logo { height: 46px; }
  .cal-grid { gap: 4px; }
  .chip { padding: 0 14px; }
}

/* "Install app" prompt only on touch devices, not desktops */
@media (hover: hover) and (pointer: fine) { #install-btn { display: none !important; } }
@media (min-width: 1024px) { #install-btn { display: none !important; } }
