/* ============================================================
   تسكين — Booking UI · Design System
   Editorial calm · Cairo-warm palette · RTL-first
   ============================================================ */

:root {
  /* Palette (matches Taskeen TikTok brand — same source of truth) */
  --paper:      #EFE7D8;    /* sand cream */
  --paper-2:    #E5DDCE;    /* card face */
  --paper-3:    #DBD3C4;    /* deeper card */
  --ink:        #1A1A1A;    /* ink */
  --ink-2:      #2E2E2E;    /* softer ink */
  --muted:      #7A7060;    /* warm muted */
  --muted-2:    #A99F8F;    /* warmer soft */
  --hair:       #C7BEAB;    /* hairline */

  --gold:       #B8945A;    /* warm accent */
  --gold-soft:  #E7D6B3;
  --nile:       #1F3A5F;    /* deep nile blue */
  --nile-soft:  #B8CADE;

  --success:    #4A7A4A;
  --success-soft:#C9E0C9;
  --danger:     #8B4A3F;
  --danger-soft: #E9C9C4;
  --warn:       #C08A2E;
  --warn-soft:  #F4E4C1;

  /* Type */
  --f-body:    "IBM Plex Sans Arabic", "Segoe UI", system-ui, sans-serif;
  --f-mono:    "JetBrains Mono", ui-monospace, "SF Mono", monospace;

  /* Metrics */
  --container: 1360px;
  --gutter:    clamp(1rem, 3vw, 2rem);
  --radius:    12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(30, 20, 10, 0.05);
  --shadow-md: 0 4px 12px rgba(30, 20, 10, 0.08);

  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
}

/* ------------ Reset ------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body.app-body {
  font-family: var(--f-body);
  font-weight: 400;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  padding-bottom: 80px; /* space for mobile nav */
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
img, svg { display: block; max-width: 100%; }
[x-cloak] { display: none !important; }

::selection { background: var(--ink); color: var(--paper); }

.mono { font-family: var(--f-mono); font-feature-settings: "tnum"; }
.muted { color: var(--muted); }
.inline { display: inline; }

/* ------------ Header ------------ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem var(--gutter);
  background: rgba(239, 231, 216, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hair);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
}
.brand-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(184, 148, 90, 0.15);
}
.brand-dot.big { width: 16px; height: 16px; box-shadow: 0 0 0 6px rgba(184, 148, 90, 0.2); }

.site-nav {
  display: none;
  align-items: center;
  gap: 1.25rem;
  margin-inline-start: 1rem;
}
@media (min-width: 720px) {
  .site-nav { display: inline-flex; }
}
.nav-link {
  color: var(--ink-2);
  font-weight: 500;
  padding: 0.4rem 0.2rem;
  border-bottom: 2px solid transparent;
  transition: color .2s, border-color .2s;
}
.nav-link:hover { color: var(--ink); }
.nav-link.is-active { color: var(--ink); border-color: var(--gold); }
.nav-link.nav-cta {
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  padding: 0.55rem 1.15rem;
  font-weight: 600;
  border: 0;
}
.nav-link.nav-cta:hover { background: var(--gold); color: var(--ink); }

.user-chip {
  margin-inline-start: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.user-name { font-weight: 500; color: var(--ink-2); }
.text-btn {
  color: var(--muted);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  font-size: 0.85rem;
}
.text-btn:hover { color: var(--danger); }

/* ------------ Layout ------------ */
.site-main {
  max-width: var(--container);
  margin-inline: auto;
  padding: 1.5rem var(--gutter);
}
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--hair);
}
.page-eyebrow {
  font-family: var(--f-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--gold);
  display: block;
  margin-bottom: 0.25rem;
}
.page-title {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 700;
  line-height: 1.15;
  color: var(--ink);
}
.page-sub {
  color: var(--muted);
  margin-top: 0.35rem;
  font-size: 0.95rem;
}
.page-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.view-toggle {
  display: inline-flex;
  background: var(--paper-2);
  border: 1px solid var(--hair);
  border-radius: 999px;
  padding: 3px;
}
.toggle-btn {
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  border-radius: 999px;
  color: var(--muted);
  transition: background .2s, color .2s;
}
.toggle-btn.is-active {
  background: var(--ink);
  color: var(--paper);
}
.toggle-btn:hover:not(.is-active) { color: var(--ink); }

.nav-arrows {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.arrow-btn {
  width: 36px; height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--paper-2);
  border: 1px solid var(--hair);
  border-radius: 999px;
  color: var(--ink);
  transition: background .2s;
}
.arrow-btn:hover { background: var(--gold-soft); }
.arrow-btn.disabled { opacity: 0.35; pointer-events: none; }

/* ------------ Buttons ------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.35rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: background .2s, color .2s, transform .3s var(--ease-out), border-color .2s;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: var(--ink);
  color: var(--paper);
}
.btn-primary:hover { background: var(--gold); color: var(--ink); }
.btn-primary[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-ghost {
  color: var(--ink);
  border-color: var(--ink);
}
.btn-ghost:hover { background: var(--ink); color: var(--paper); }
.btn-sm { padding: 0.4rem 1rem; font-size: 0.85rem; }
.btn-full { width: 100%; }

/* ------------ Alerts ------------ */
.alert {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.94rem;
  border-inline-start: 3px solid;
}
.alert-error { background: var(--danger-soft); border-color: var(--danger); color: #4a251e; }
.alert-warn  { background: var(--warn-soft);   border-color: var(--warn);   color: #4d3405; }
.alert-info  { background: var(--nile-soft);   border-color: var(--nile);   color: #0e2038; }

/* ------------ Legend ------------ */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  padding: 0.75rem 1rem;
  background: var(--paper-2);
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
  margin-top: 1.25rem;
  font-size: 0.85rem;
  color: var(--muted);
  justify-content: center;
}
.legend-item { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend .dot {
  width: 12px; height: 12px;
  border-radius: 3px;
  display: inline-block;
}
.legend .dot.free       { background: var(--paper); border: 1px solid var(--hair); }
.legend .dot.booked     { background: var(--gold); }
.legend .dot.blocked    { background: var(--muted-2); }
.legend .dot.today-ring { background: var(--paper); border: 2px solid var(--nile); border-radius: 50%; }

/* ------------ Apartment cards (availability) ------------ */
.apt-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  gap: 1.1rem;
}
.apt-card {
  background: var(--paper-2);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.15rem 1.2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  border-inline-start: 4px solid var(--hair);
}
.apt-card.status-free    { border-inline-start-color: var(--success); }
.apt-card.status-booked  { border-inline-start-color: var(--gold); }
.apt-card.status-blocked { border-inline-start-color: var(--muted-2); }

.apt-card-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.apt-color-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.apt-card-name {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
}
.status-chip {
  margin-inline-start: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}
.chip-free    { background: var(--success-soft); color: #1c3d1c; }
.chip-booked  { background: var(--gold-soft);    color: #4d3405; }
.chip-blocked { background: var(--paper-3);      color: var(--muted); }

.apt-card-detail {
  font-size: 0.92rem;
  color: var(--muted);
  margin: -0.35rem 0 0;
  line-height: 1.6;
}

/* Fortnight strip: 7 columns × 2 rows — fits any phone, no scroll */
.fortnight {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.fday {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0.35rem 0;
  border-radius: 8px;
  border: 1px solid var(--hair);
  min-height: 46px;
  transition: transform .15s var(--ease-out), filter .15s;
}
.fday:active { transform: scale(0.94); }
.fday-dow {
  font-size: 0.6rem;
  color: var(--muted);
  line-height: 1;
}
.fday-num {
  font-family: var(--f-mono);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
}
.fday-free    { background: var(--paper); }
.fday-free:hover { background: var(--success-soft); border-color: var(--success); }
.fday-booked  { background: var(--gold); border-color: var(--gold); }
.fday-booked .fday-dow { color: rgba(26,26,26,.55); }
.fday-blocked { background: var(--muted-2); border-color: var(--muted-2); color: var(--paper); }
.fday-blocked .fday-dow { color: rgba(248,244,237,.7); }
.fday.is-today {
  outline: 2px solid var(--nile);
  outline-offset: 1px;
}

/* Free-gap pills */
.gaps {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.gap-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.9rem;
  background: var(--success-soft);
  border: 1px solid var(--success);
  border-radius: 10px;
  color: #1c3d1c;
  font-size: 0.9rem;
  font-weight: 500;
  transition: filter .15s;
}
.gap-pill:hover { filter: brightness(0.96); }
.gap-nights {
  margin-inline-start: auto;
  font-family: var(--f-mono);
  font-size: 0.8rem;
  background: rgba(255,255,255,.55);
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}
.gap-all { justify-content: center; font-weight: 600; }

/* Upcoming bookings inside a card */
.upcoming-title {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 0.4rem;
  letter-spacing: 0.02em;
}
.upcoming-list {
  display: flex;
  flex-direction: column;
}
.upcoming-item {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.45rem 0;
  border-top: 1px dashed var(--hair);
  font-size: 0.9rem;
  flex-wrap: wrap;
}
.upcoming-guest { font-weight: 600; color: var(--ink); }
.upcoming-dates { color: var(--muted); font-size: 0.78rem; }
.upcoming-amount {
  margin-inline-start: auto;
  font-weight: 600;
  color: var(--success);
  font-size: 0.85rem;
}

.apt-card-actions {
  display: flex;
  gap: 0.6rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--hair);
  margin-top: auto;
}

/* ------------ Finance ------------ */
.totals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.total-card {
  padding: 1.25rem 1.35rem;
  background: var(--paper-2);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.total-card.income { border-inline-start: 3px solid var(--success); }
.total-card.expense { border-inline-start: 3px solid var(--danger); }
.total-card.net { border-inline-start: 3px solid var(--gold); }
.total-label {
  font-size: 0.85rem;
  color: var(--muted);
  display: block;
  margin-bottom: 0.5rem;
}
.total-value {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: baseline;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ink);
}
.total-value .negative { color: var(--danger); }

.apt-summaries {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.apt-summary-card {
  background: var(--paper-2);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.apt-summary-head {
  width: 100%;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-align: start;
  transition: background .2s;
}
.apt-summary-head:hover { background: var(--paper-3); }
.apt-name-lg {
  font-weight: 600;
  font-size: 1.05rem;
}
.apt-summary-numbers {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-inline-start: auto;
}
.chip {
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--hair);
  font-size: 0.8rem;
  font-weight: 500;
}
.chip.income   { background: var(--success-soft); border-color: transparent; color: #1c3d1c; }
.chip.expense  { background: var(--danger-soft);  border-color: transparent; color: #4a251e; }
.chip.muted    { background: var(--paper); color: var(--muted); }
.chevron {
  margin-inline-start: 0.4rem;
  color: var(--muted);
  font-size: 0.75rem;
}
.apt-summary-body {
  padding: 0.5rem 1.25rem 1.25rem;
  border-top: 1px solid var(--hair);
}
.event-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.event-item {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px dashed var(--hair);
  font-size: 0.92rem;
}
.event-item:last-child { border-bottom: 0; }
.event-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted-2);
}
.event-item.kind-booking .event-dot { background: var(--success); }
.event-item.kind-expense .event-dot { background: var(--danger); }
.event-item.kind-block .event-dot  { background: var(--muted-2); }
.event-when { font-size: 0.8rem; color: var(--muted); }
.event-title { color: var(--ink); }
.event-amount { font-weight: 600; }
.event-item.kind-expense .event-amount { color: var(--danger); }
.event-item.kind-booking .event-amount { color: var(--success); }

.empty-state {
  padding: 1rem;
  color: var(--muted);
  text-align: center;
  font-style: italic;
}

/* ------------ Add form ------------ */
.add-form {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
  max-width: 720px;
}
.kind-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  border: 0;
}
.kind-option {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1rem 0.75rem;
  border: 2px solid var(--hair);
  border-radius: var(--radius);
  background: var(--paper-2);
  transition: border-color .2s, background .2s;
}
.kind-option input { position: absolute; opacity: 0; }
.kind-option:hover { border-color: var(--muted); }
.kind-option.is-active { border-color: var(--ink); background: var(--paper); }
.kind-option.is-active.kind-booking { border-color: var(--success); }
.kind-option.is-active.kind-expense { border-color: var(--danger); }
.kind-icon { font-size: 1.5rem; }
.kind-label { font-weight: 600; }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.field-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}
.field input,
.field select,
.field textarea {
  padding: 0.7rem 0.85rem;
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--ink);
  transition: border-color .2s, background .2s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 0;
  border-color: var(--gold);
  background: var(--paper);
  box-shadow: 0 0 0 3px rgba(184, 148, 90, 0.15);
}
.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 0.85rem;
}
.field-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.15rem;
  background: var(--paper-2);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
}
.apt-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr));
  gap: 0.5rem;
}
.apt-option {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  background: var(--paper-2);
  border: 2px solid var(--hair);
  border-radius: var(--radius-sm);
  transition: border-color .2s, background .2s;
}
.apt-option input { position: absolute; opacity: 0; }
.apt-option:hover { border-color: var(--muted); }
.apt-option.is-active { border-color: var(--ink); background: var(--paper); }

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  padding-top: 0.5rem;
  border-top: 1px solid var(--hair);
}

/* ------------ Auth ------------ */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background: radial-gradient(circle at 30% 20%, var(--gold-soft), var(--paper) 60%);
}
.auth-card {
  width: min(420px, 100%);
  padding: 2.25rem 2rem;
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 1.5rem;
}
.brand-name-big {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ink);
}
.auth-title {
  font-size: 1.65rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}
.auth-sub {
  color: var(--muted);
  margin-bottom: 1.75rem;
  font-size: 0.94rem;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.auth-footer {
  padding-top: 1.25rem;
  border-top: 1px solid var(--hair);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}
.pin-input {
  font-family: var(--f-mono) !important;
  font-size: 2rem !important;
  text-align: center;
  letter-spacing: 0.6em;
  padding-inline-start: 0.6em !important;
  direction: ltr;
}

/* ------------ Mobile nav ------------ */
.mobile-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  display: none;
  justify-content: space-around;
  padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom));
  background: rgba(239, 231, 216, 0.97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--hair);
}
@media (max-width: 720px) {
  .mobile-nav { display: flex; }
  .site-nav { display: none; }

  /* Comfortable touch targets */
  .arrow-btn { width: 42px; height: 42px; }
  .kind-option { padding: 0.85rem 0.5rem; }
  .fday { min-height: 52px; }

  /* Tighter page header + single-column cards */
  .page-head { margin-bottom: 1.1rem; padding-bottom: 0.9rem; }
  .apt-cards { gap: 0.9rem; }
  .apt-card { padding: 1rem 0.95rem 0.85rem; }
  .legend { gap: 0.55rem; font-size: 0.75rem; padding: 0.55rem 0.7rem; }
}
.m-nav-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.5rem 0.35rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.75rem;
}
.m-nav-link.is-active { color: var(--ink); }
.m-nav-link.accent {
  background: var(--ink);
  color: var(--paper);
  margin: 0 0.35rem;
}
.m-nav-link.accent .m-icon {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
}
.m-icon { font-size: 1.15rem; }

/* ------------ Error pages ------------ */
.error-page {
  display: grid;
  place-items: center;
  min-height: 60vh;
  text-align: center;
  padding: 2rem;
}
.error-code {
  font-family: var(--f-mono);
  font-size: 4rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 0.75rem;
}
.error-title {
  font-size: 1.65rem;
  margin-bottom: 0.6rem;
}
.error-sub {
  color: var(--muted);
  margin-bottom: 1.5rem;
}
