/* ===================================================================
   S.A Nail – shared stylesheet (RTL, mobile-first)
   =================================================================== */

/* S.A Nail brand palette — Soft · Clean · Luxury
   blush #F2E4E0 · dusty rose #EBCFC9 · rose-beige #DCC2B8 · taupe #C8B6A6 · gold #D4AF37 */
:root {
  --bg: #f7f0ea;            /* warm cream (logo card background) */
  --surface: #ffffff;
  --surface-2: #fbf3ef;     /* blush-tinted secondary surface */
  --primary: #9b6760;       /* deep dusty rose — buttons / selected (AA on white) */
  --primary-dark: #80504a;  /* hover / strong */
  --primary-soft: #f2e4e0;  /* blush — focus rings, soft fills */
  --accent: #d4af37;        /* gold accent */
  --accent-soft: #f4eccf;   /* pale gold */
  --rose: #c8a09a;          /* mid dusty rose for subtle accents */
  --taupe: #c8b6a6;
  --text: #463b36;          /* deep warm brown */
  --muted: #998a80;         /* warm taupe-gray */
  --border: #ecdfd5;
  --ok: #3f9d6f;
  --ok-soft: #e6f3ec;
  --danger: #c25c62;
  --danger-soft: #f7e7e7;
  --warn: #c8923a;
  --shadow: 0 6px 24px rgba(150, 110, 80, 0.12);
  --shadow-sm: 0 2px 10px rgba(150, 110, 80, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Assistant", "Heebo", system-ui, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body {
  direction: rtl;
  overflow-x: hidden;
  overscroll-behavior-y: none;
  min-height: 100vh;
}

/* Tap behaviour: no 300ms delay, subtle tap highlight */
* { -webkit-tap-highlight-color: rgba(176, 107, 139, .15); }
button, a, .chip, .service, .cal-day, .tab { touch-action: manipulation; }

h1, h2, h3, h4 { margin: 0 0 .4em; font-weight: 700; line-height: 1.25; }
p { margin: 0 0 1em; }
a { color: var(--primary-dark); }

/* --- Layout shells -------------------------------------------------- */
.app {
  max-width: 760px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh; /* dynamic viewport on mobile (handles browser chrome) */
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  /* respect notches / status bar in standalone PWA mode */
  padding-top: calc(16px + env(safe-area-inset-top));
  padding-right: calc(18px + env(safe-area-inset-right));
  padding-left: calc(18px + env(safe-area-inset-left));
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-bottom: 3px solid var(--accent); /* gold luxe line */
  color: #fff;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.2rem; font-weight: 800; letter-spacing: .2px;
}
.topbar .brand .logo {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255,255,255,.22);
  display: grid; place-items: center; font-size: 1.1rem;
}
.topbar .sub { font-size: .8rem; opacity: .85; font-weight: 600; }

.content {
  flex: 1;
  padding: 18px;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
  padding-right: calc(18px + env(safe-area-inset-right));
  padding-left: calc(18px + env(safe-area-inset-left));
}

/* --- Cards ----------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 { font-size: 1.15rem; }
.card .card-hint { color: var(--muted); font-size: .9rem; margin-top: -.3em; }

/* --- Buttons --------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  font-family: inherit; font-size: 1rem; font-weight: 700;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .2s ease, background .2s ease;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost { background: var(--surface); color: var(--primary-dark); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: var(--danger-soft); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: .85rem; }

/* --- Forms ----------------------------------------------------------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; color: #5a4d56; }
.input, .select, textarea.input {
  width: 100%;
  font-family: inherit; font-size: 1rem;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.input.ltr { direction: ltr; text-align: right; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 140px; }

/* --- Chips / slots --------------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 9px 16px;
  font-weight: 700; font-size: .95rem;
  cursor: pointer;
  transition: all .15s ease;
}
.chip:hover { border-color: var(--accent); }
.chip.selected { background: var(--primary); color: #fff; border-color: var(--primary); }

/* --- Service cards --------------------------------------------------- */
.service-list { display: grid; gap: 12px; }
.service {
  display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; background: var(--surface);
  transition: all .15s ease;
}
.service:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.service.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.service .swatch { width: 12px; align-self: stretch; border-radius: 6px; background: var(--accent); }
.service .s-main { flex: 1; }
.service .s-name { font-weight: 700; }
.service .s-meta { color: var(--muted); font-size: .85rem; }
.service .s-price { font-weight: 800; color: var(--primary-dark); white-space: nowrap; }

/* --- Calendar -------------------------------------------------------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: .75rem; color: var(--muted); font-weight: 700; padding: 4px 0; }
.cal-day {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--border); border-radius: 12px;
  display: grid; place-items: center; font-weight: 700;
  cursor: pointer; background: var(--surface); position: relative;
  transition: all .12s ease;
}
.cal-day.dim { color: #cdbfc7; cursor: default; background: var(--surface-2); }
.cal-day.has-slots:hover { border-color: var(--accent); }
.cal-day.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-day .dot { position: absolute; bottom: 6px; width: 5px; height: 5px; border-radius: 50%; background: var(--ok); }
.cal-day.selected .dot { background: #fff; }
.cal-day.none { color: #cdbfc7; cursor: default; }

/* --- Badges / status ------------------------------------------------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge.booked { background: var(--ok-soft); color: var(--ok); }
.badge.cancelled { background: var(--danger-soft); color: var(--danger); }
.badge.completed { background: #eee6f2; color: #6a4f86; }
.badge.no_show { background: #fdeede; color: var(--warn); }
.badge.pending { background: #fff3e0; color: #b9791f; }

/* --- Lists / appointments ------------------------------------------- */
.appt {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 10px; background: var(--surface);
}
.appt .when { text-align: center; min-width: 58px; }
.appt .when .d { font-weight: 800; font-size: 1.1rem; }
.appt .when .m { font-size: .72rem; color: var(--muted); }
.appt .info { flex: 1; }
.appt .info .t { font-weight: 700; }
.appt .info .sub { color: var(--muted); font-size: .85rem; }

/* --- Tabs (admin) ---------------------------------------------------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 6px; background: var(--surface-2);
        border-radius: var(--radius); margin-bottom: 16px; }
.tab {
  flex: 0 0 auto; padding: 10px 16px; border-radius: 10px;
  font-weight: 700; color: var(--muted); cursor: pointer; white-space: nowrap; border: none; background: transparent;
}
.tab.active { background: var(--surface); color: var(--primary-dark); box-shadow: var(--shadow-sm); }

/* --- Table-ish list -------------------------------------------------- */
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 8px; background: var(--surface);
}
.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(45,36,48,.45);
  display: none; align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.modal-backdrop.open { display: flex; }
.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(--shadow); padding: 22px;
  -webkit-overflow-scrolling: touch;
}
.modal h3 { font-size: 1.2rem; }
.modal .modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal .modal-actions .btn { flex: 1; }

/* --- Toast ----------------------------------------------------------- */
.toast {
  position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%) translateY(20px);
  background: #322; color: #fff; padding: 12px 20px; border-radius: 999px;
  font-weight: 600; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: all .25s ease; z-index: 100; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: #2f8a5f; }
.toast.err { background: #b8425f; }

/* --- Misc ------------------------------------------------------------ */
.center { text-align: center; }
.brand-logo {
  display: block;
  margin: 6px auto 16px;
  max-width: 320px;
  width: 86%;
  height: auto;
  border-radius: 14px;
}
.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: 28px 10px; }

.spinner {
  width: 22px; height: 22px; border: 3px solid var(--primary-soft);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-screen { min-height: 60vh; display: grid; place-items: center; gap: 12px; 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: 10px; margin-top: 8px;
}
.link-box input { flex: 1; border: none; background: transparent; direction: ltr; text-align: left; font-size: .85rem; color: #5a4d56; }
.link-box input:focus { outline: none; }

@media (min-width: 620px) {
  .content { padding: 24px; }
}
