/* ══════════════════════════════════════════════════════════
   COMPONENT SYSTEM
   Loaded last on every page, admin and public, so a button, a
   field, a dropdown or a tab is the same component everywhere.
   Each page family only sets the neutral tokens below (admin:
   neutral grey fills in app.css (slate text), the same greys in shop.css).

   Shape   Things you press (buttons, chips, tabs, badges, icon
           buttons) are pills or circles. Things you type in or
           pick from (inputs, search, dropdown triggers, date
           fields, textareas) are 12px rounded rectangles.
   Size    Buttons 32 / 44 / 52. Fields and dropdown triggers 44.
           Chips and tabs 40. Icon buttons 32 / 40 / 44.
           Badges 24.
   Fill    A control is told apart from what it sits on by its
           fill, never a line: white on a grey surface, grey on
           a white one (--ctl-fill is set per surface).
   States  Hover: one step darker fill. Focus while typing:
           indigo tint. Keyboard focus: the 2px ring. Selected
           (tab, chip, segment, date, option): solid indigo with
           white text.
   Popover Every dropdown, menu and date picker is the same white
           panel. With no shadows and no outlines, a white panel
           over a white card would have no edge, so while a popover
           is open the page behind it is dimmed slightly (a flat
           backdrop, not a drop shadow).

   Tokens each page family provides:
     --c-ink, --c-ink-2, --c-muted   text
     --ctl-fill, --ctl-fill-hover    control fill on a white surface
     --ctl-focus                     field fill while typing
     --ctl-fs                        control font size
     --accent, --accent-hover        indigo
   ══════════════════════════════════════════════════════════ */
:root {
  --ctl-h-sm: 32px;
  --ctl-h: 44px;
  --ctl-h-lg: 52px;
  --chip-h: 40px;
  --field-r: 12px;

  --pop-bg: #FFFFFF;
  --pop-fill: #F2F2F2;
  --pop-hover: #F2F2F2;
  --pop-text: var(--c-ink);
  --pop-text-2: var(--c-ink-2);
  --pop-dim: var(--c-muted);   /* disabled days, also struck through */
  --pop-today: #4338CA;        /* 7.9:1 on white */
  --pop-backdrop: rgba(15, 23, 42, 0.14);
}

/* Browsers give buttons and fields their own system font (Arial on
   most): they take the page's font like everything else */
button, input, select, textarea { font-family: inherit; }


/* ══ Surfaces: which fill a control gets ══════════════════ */

/* Admin: controls on the page background are white; inside a
   white card, modal or panel they are grey. */
.main-content { --ctl-fill: #FFFFFF; }
.main-content :is(.card, .modal, .dash-card, .dash-stat, .cal-surface,
  .table-wrapper-v3, .rep-card, .rep-step, .stg-card, .biz-card-modern,
  .bk-list, .cl-card, .cl-stat, .rv-card, .rv-summary, .sv-cats, .sv-group, .stg-nav) {
  --ctl-fill: #F2F2F2;
}

/* Public: the shop page is white, so controls are grey. The
   booking flow and review page are grey, so controls are white.
   Back on a white card they are grey again; on a grey card,
   white. */
body.flow-page, body.page-grey { --ctl-fill: #FFFFFF; }
:is(.summary-card, .center-card, .staff-popup, .success-content, .service-item, .svc-sub-accordion) {
  --ctl-fill: #F2F2F2;
}
:is(.svc-card, .book-card) { --ctl-fill: #FFFFFF; }
/* Grey boxes inside an admin card or modal: controls go white */
.main-content :is(.review-invite-box, .img-upload-zone) { --ctl-fill: #FFFFFF; }


/* ══ Buttons: primary, secondary, danger ══════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--ctl-h);
  min-height: 0;
  padding: 0 20px;
  border: none !important;
  border-radius: 9999px !important;
  background: var(--ctl-fill);
  color: var(--c-ink);
  font-family: var(--font);
  font-size: var(--ctl-fs);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover {
  background: var(--ctl-fill-hover);
  color: var(--c-ink);
  transform: none;
}
.btn-sm { height: var(--ctl-h-sm); padding: 0 14px; font-size: 13px; }
.btn-lg, .btn-large { height: var(--ctl-h-lg); padding: 0 28px; font-size: 16px; }
.btn-full, .btn-block { width: 100%; }

/* Primary */
.btn.btn-primary, .btn.btn-solid, .btn.btn-pill-black {
  background: var(--accent);
  color: #FFFFFF;
}
.btn.btn-primary:hover, .btn.btn-solid:hover, .btn.btn-pill-black:hover {
  background: var(--accent-hover);
  color: #FFFFFF;
}

/* Secondary: every other button (outline, ghost and pill
   variants are the same thing now) */
.btn:is(.btn-outline, .btn-pill-outline, .btn-ghost, .btn-secondary, .rep-export),
.stg .btn.btn-ghost {
  background: var(--ctl-fill);
  color: var(--c-ink);
}
.btn:is(.btn-outline, .btn-pill-outline, .btn-ghost, .btn-secondary, .rep-export):hover,
.stg .btn.btn-ghost:hover {
  background: var(--ctl-fill-hover);
  color: var(--c-ink);
}

/* Danger and success: tinted, coloured text */
.btn.btn-danger { background: #FEE2E2; color: #B91C1C; }
.btn.btn-danger:hover { background: #FECACA; color: #991B1B; }
/* On a red surface (Settings danger zone) the mist would vanish,
   so the button turns solid red (6.5:1) */
.stg-danger-row .btn.btn-danger { background: #B91C1C; color: #FFFFFF; }
.stg-danger-row .btn.btn-danger:hover { background: #991B1B; color: #FFFFFF; }
.btn.btn-success { background: #DCFCE7; color: #166534; }
.btn.btn-success:hover { background: #BBF7D0; color: #14532D; }

/* WhatsApp keeps its brand green (dark text, 7.5:1) */
.btn.btn-wa, .btn.btn-wa:hover { color: #052E16; }

/* Disabled: grey fill, readable text (it is exempt from 4.5:1,
   but stays legible) */
.btn:disabled, .btn[disabled], .btn[aria-disabled="true"],
.btn:disabled:hover, .btn[disabled]:hover {
  background: #E5E5E5;
  color: #4B5563;
  cursor: not-allowed;
  opacity: 1;
}


/* ══ Icon buttons: circles ════════════════════════════════ */
.icon-btn, .add-btn, .pub-cat-arrow, .modal-close, .dp-nav-btn, .rep-step-btn,
.cal-nav-btn, .ds-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  border: none !important;
  border-radius: 50% !important;
  cursor: pointer;
}
/* 44: page navigation (back, close, share, lightbox) */
.icon-btn { width: 44px; height: 44px; background: var(--ctl-fill); color: var(--c-ink); }
/* 40: next to chips and inside cards */
.add-btn, .pub-cat-arrow { width: 40px; height: 40px; background: var(--ctl-fill); color: var(--c-ink); }
/* 32: inside a panel, modal header or stepper */
.icon-btn-sm, .modal-close { width: var(--ctl-h-sm); height: var(--ctl-h-sm); }
.modal-close { background: var(--ctl-fill); color: var(--c-ink); }
.dp-nav-btn, .rep-step-btn, .cal-nav-btn, .ds-arrow {
  width: var(--ctl-h-sm);
  height: var(--ctl-h-sm);
  background: transparent;
  color: var(--c-ink);
}
.icon-btn:hover, .add-btn:hover, .pub-cat-arrow:hover, .modal-close:hover,
.rep-step-btn:hover:not(:disabled), .ds-arrow:hover:not(:disabled) {
  background: var(--ctl-fill-hover);
  color: var(--c-ink);
}
.add-btn.added, .add-btn.added:hover { background: var(--accent); color: #FFFFFF; }
.rep-step-btn:disabled, .ds-arrow:disabled { color: var(--c-muted); cursor: default; }
.rep-step { height: var(--chip-h); border-radius: 9999px; }


/* ══ Fields: inputs, search, dropdown triggers, date fields ══ */
.form-input, .form-input-v3, .search-input, .search-v3, .stg .stg-input,
.date-picker-trigger, .custom-select-trigger, .staff-change-bar,
.input, .pub-search-input,
.main-content :is(input[type="text"], input[type="email"], input[type="password"],
  input[type="number"], input[type="date"], input[type="datetime-local"],
  input[type="tel"], input[type="search"], input[type="url"], input[type="time"],
  select, textarea):not(.custom-select-search) {
  height: var(--ctl-h);
  border: none !important;
  border-radius: var(--field-r) !important;
  background-color: var(--ctl-fill);
  color: var(--c-ink);
  font-family: var(--font);
  font-size: var(--ctl-fs);
  font-weight: 400;
  outline: none;
}
.form-input, .form-input-v3, .stg .stg-input, .input,
.main-content :is(input[type="text"], input[type="email"], input[type="password"],
  input[type="number"], input[type="date"], input[type="datetime-local"],
  input[type="tel"], input[type="url"], input[type="time"]) {
  padding: 0 14px;
}
/* Search: icon at 14px, text after it */
.search-input, .search-v3, .main-content input[type="search"] { padding: 0 14px 0 40px !important; }
.pub-search-input { padding: 0 14px 0 44px; }
.pub-search-icon { left: 14px; }
.date-picker-trigger { padding: 0 44px 0 14px; }

.form-input:hover, .form-input-v3:hover, .search-input:hover, .search-v3:hover,
.stg .stg-input:hover, .date-picker-trigger:hover, .custom-select-trigger:hover,
.staff-change-bar:hover, .input:hover, .pub-search-input:hover {
  background-color: var(--ctl-fill-hover);
}
/* Typing in a field, or a dropdown that is open */
.form-input:focus, .form-input-v3:focus, .search-input:focus, .search-v3:focus,
.stg .stg-input:focus, .input:focus, .pub-search-input:focus,
.date-picker-trigger:focus, .date-picker-trigger.active,
.custom-select-trigger:focus, .custom-select-trigger.open,
.main-content :is(input, select, textarea):not(.custom-select-search):focus {
  background-color: var(--ctl-focus);
  box-shadow: none !important;
}
.stg .stg-input[readonly], .stg .stg-input[readonly]:hover, .stg .stg-input[readonly]:focus {
  background-color: var(--ctl-fill);
}

textarea.form-input, textarea.form-input-v3, .stg textarea.stg-input, textarea.input,
.main-content textarea {
  height: auto;
  min-height: 96px;
  padding: 12px 14px;
  line-height: 1.5;
}

/* Prefixed field (booking link): prefix and input share one shape */
.stg-prefix {
  height: var(--ctl-h);
  line-height: var(--ctl-h);
  border-radius: var(--field-r) 0 0 var(--field-r) !important;
}
.stg-prefixed .stg-input { border-radius: 0 var(--field-r) var(--field-r) 0 !important; }

/* Dropdown trigger: the value, then a chevron at the right. The
   admin select and the "Any professional" picker are the same
   component. */
.custom-select-trigger, .staff-change-bar {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  max-width: 100%;
  padding: 0 12px 0 14px;
  font-weight: 500;
  cursor: pointer;
}
.custom-select-trigger.placeholder { color: var(--c-muted); }
.custom-select-trigger .custom-select-chevron, .staff-change-bar > svg {
  margin-left: 0;
  color: var(--c-ink-2);
  flex-shrink: 0;
}
.filters-bar-v3 .custom-select-wrapper, .filters-bar-v3 .custom-select-trigger { width: 100%; }
.filters-bar .custom-select-trigger { min-width: 160px; }
.staff-change-bar { padding-left: 6px; }
.staff-change-avatar { width: 32px; height: 32px; }


/* ══ Chips, tabs and segmented controls ═══════════════════ */
.rep-seg-btn, .pill, .pub-cat-tab, .section-tabs a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
  height: var(--chip-h);
  padding: 0 16px;
  border: none !important;
  border-radius: 9999px;
  background: var(--ctl-fill);
  color: var(--c-ink);
  font-family: var(--font);
  font-size: var(--ctl-fs);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
:is(.rep-seg-btn, .pill, .pub-cat-tab, .section-tabs a):hover {
  background: var(--ctl-fill-hover);
  color: var(--c-ink);
}
.rep-seg-btn[aria-pressed="true"], .pill.active, .pub-cat-tab.active,
.section-tabs a.active,
:is(.rep-seg-btn[aria-pressed="true"], .pill.active, .pub-cat-tab.active, .section-tabs a.active):hover {
  background: var(--accent);
  color: #FFFFFF;
  font-weight: 600;
}
.rep-seg, .pills, .pub-cat-tabs, .section-tabs { gap: 8px; }
.rep-seg { padding: 0; background: transparent; border-radius: 0; }
.section-tabs { height: auto; align-items: center; }
.section-nav { --ctl-fill: #F2F2F2; }


/* ══ Badges ═══════════════════════════════════════════════ */
.badge, .badge-pill-gray, .badge-pill-success, .badge-pill-disabled, .rep-chip,
.count-badge, .svc-sub-count, .staff-rating, .team-rating {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 24px;
  padding: 0 10px;
  border: none !important;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
.count-badge, .svc-sub-count { background: var(--ctl-fill); color: var(--c-ink-2); }
/* Status badges keep their colours from app.css; one with no
   known status gets neutral grey */
.badge:not([class*="badge-"]) { background: #E5E5E5; color: #334155; }
.badge-pill-gray { background: #EEF2FF; color: #4338CA; }
.badge-pill-success { background: #DCFCE7; color: #166534; }
.badge-pill-disabled { background: #E5E5E5; color: #475569; }
button.badge-pill-success, button.badge-pill-disabled { height: 28px; cursor: pointer; }
.badge-cancelled, .badge-cancelled_customer, .badge-cancelled_business, .badge-cancelled_staff {
  background: #FEE2E2;
  color: #B91C1C;
}


/* ══ Modals and sheets ════════════════════════════════════ */
.modal-overlay, .staff-popup-overlay {
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: none;
}
.modal, .staff-popup { border-radius: 20px; }
@media (max-width: 768px) {
  .modal { border-radius: 20px 20px 0 0; }
}


/* ══ Popovers: one white panel ════════════════════════════ */
.custom-select-dropdown, .date-picker-dropdown, .float-menu, .calendar-popup {
  background: var(--pop-bg) !important;
  color: var(--pop-text);
  border: none !important;
  border-radius: 12px !important;
  padding: 6px;
}
/* The backdrop: a huge flat spread that dims everything behind the
   open panel evenly. It has no blur and no offset, and it does not
   catch clicks (a click outside still closes the panel). */
.custom-select-dropdown.open, .date-picker-dropdown.open, .float-menu, .calendar-popup.active {
  box-shadow: 0 0 0 100vmax var(--pop-backdrop) !important;
}
/* The sidebar sits above the page, so the backdrop can't reach it;
   it gets the same dim from a layer on top while a popover is open. */
body:has(.custom-select-dropdown.open, .date-picker-dropdown.open, .float-menu[style*="display: block"]) .sidebar-v2::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--pop-backdrop);
  pointer-events: none;
}
.date-picker-dropdown, .calendar-popup { padding: 12px; }
@media (max-width: 480px) {
  .date-picker-dropdown { border-radius: 20px 20px 0 0 !important; }
}

/* Options and menu items */
.custom-select-dropdown .custom-select-option, .float-menu-item {
  display: flex;
  align-items: center;
  min-height: 40px;
  margin: 0;
  padding: 0 12px;
  border-radius: 8px;
  background: transparent;
  color: var(--pop-text);
  font-size: 14px;
  font-weight: 500;
}
.custom-select-dropdown .custom-select-option:hover,
.custom-select-dropdown .custom-select-option.is-active,
.float-menu-item:hover {
  background: var(--pop-hover);
}
.custom-select-dropdown .custom-select-option.selected,
.custom-select-dropdown .custom-select-option.selected:hover {
  background: var(--accent);
  color: #FFFFFF !important;
  font-weight: 600;
}
.custom-select-dropdown .custom-select-option.selected.is-active { background: var(--accent-hover); }
.custom-select-dropdown .custom-select-group-label,
.custom-select-dropdown .custom-select-empty { color: var(--pop-text-2); opacity: 1; }
.custom-select-dropdown .custom-select-search {
  height: 40px;
  margin-bottom: 6px;
  border: none;
  border-radius: 8px;
  background-color: var(--pop-fill);
  color: var(--pop-text);
  font-size: 14px;
}
.custom-select-dropdown .custom-select-search::placeholder { color: var(--pop-text-2); }
/* The search is focused as soon as the list opens, so it shows focus
   with its fill (indigo tint, 1.2:1 against the white panel, plus the
   caret) instead of the ring: the panel is already the focus area. */
.custom-select-dropdown .custom-select-search:focus,
.custom-select-dropdown .custom-select-search:focus-visible {
  background-color: #E0E7FF;
  box-shadow: none;
  outline: none !important;
}
.float-menu-item.is-danger { color: #B91C1C; } /* 6.5:1 on white */

/* Month calendars (admin date picker and the booking flow's
   calendar are the same) */
.dp-header, .calendar-popup .cal-header { margin-bottom: 8px; }
.dp-month-label, .calendar-popup .cal-month { color: var(--pop-text); font-size: 15px; font-weight: 700; }
.date-picker-dropdown .dp-nav-btn, .calendar-popup .cal-nav-btn { background: transparent; color: var(--pop-text); }
.date-picker-dropdown .dp-nav-btn:hover, .calendar-popup .cal-nav-btn:hover { background: var(--pop-hover); color: var(--pop-text); }
.date-picker-dropdown .dp-weekday, .calendar-popup .cal-day-label {
  color: var(--pop-text-2);
  font-size: 12px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}
.calendar-popup .cal-grid { gap: 2px; }
.date-picker-dropdown .dp-day, .calendar-popup .cal-cell {
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border-radius: 50%;
  background: transparent;
  color: var(--pop-text);
  font-size: 14px;
  font-weight: 500;
}
.date-picker-dropdown .dp-day:hover, .calendar-popup .cal-cell:hover:not(.disabled):not(.empty) { background: var(--pop-hover); }
.date-picker-dropdown .dp-day.other { color: var(--pop-dim); }
.date-picker-dropdown .dp-day.today, .calendar-popup .cal-cell.today {
  background: transparent;
  color: var(--pop-today);
  font-weight: 700;
}
.date-picker-dropdown .dp-day.selected, .date-picker-dropdown .dp-day.selected:hover,
.calendar-popup .cal-cell.selected, .calendar-popup .cal-cell.selected:hover {
  background: var(--accent);
  color: #FFFFFF;
  font-weight: 700;
}
.date-picker-dropdown .dp-day.disabled, .calendar-popup .cal-cell.disabled {
  background: transparent;
  color: var(--pop-dim);
  opacity: 1;
  text-decoration: line-through;
  cursor: not-allowed;
}
.date-picker-dropdown .dp-footer-btn {
  height: var(--ctl-h-sm);
  padding: 0 14px;
  border-radius: 9999px;
  font-size: 13px;
}
.date-picker-dropdown .dp-clear-btn { color: var(--pop-text-2); }
.date-picker-dropdown .dp-today-btn { color: var(--pop-today); }
.date-picker-dropdown .dp-footer-btn:hover { background: var(--pop-hover); color: var(--pop-text); }

/* "Show more" under a service list is a full-width secondary button */
.svc-more {
  height: var(--ctl-h);
  border: none !important;
  border-radius: 9999px;
  background: var(--ctl-fill);
  color: var(--c-ink);
  font-size: var(--ctl-fs);
  font-weight: 600;
}
.svc-more:hover { background: var(--ctl-fill-hover); }
.svc-sub-body .svc-more { border-radius: 0; background: transparent; color: var(--accent); }

/* WhatsApp keeps its brand green with dark text (7.5:1) */
.btn.btn-wa { background: #25D366; color: #052E16; }
.btn.btn-wa:hover { background: #1EBE5A; color: #052E16; }

/* Date field: the text sits in the middle, the icon at the right */
.date-picker-trigger { display: flex; align-items: center; }
.date-picker-icon { display: flex; color: var(--c-ink-2); }

/* Filter bars: search grows, the other filters sit beside it */
.filters-bar .filter-group { flex-wrap: nowrap; align-items: center; }
.filters-bar .filter-group .date-picker-wrapper { width: 200px; }
@media (max-width: 768px) {
  .filters-bar .filter-group .date-picker-wrapper,
  .filters-bar .filter-group .custom-select-wrapper,
  .filters-bar .filter-group .custom-select-trigger { width: 100%; }
  .filters-bar :is(.form-input, select, input) { height: var(--ctl-h) !important; }
}

/* ══════════════════════════════════════════════════════════
   Platform admin inside a business ("Sign in as owner"): a dark
   strip above the whole app with the way back to /admin.
   ══════════════════════════════════════════════════════════ */
body.is-impersonating { --imp-h: 44px; }
.imp-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 170;
  height: var(--imp-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 0 16px;
  background: #171717;
  color: #FFFFFF;
  font-size: 0.875rem;
  animation: m-drop var(--dur-4, 320ms) var(--ease-out, ease-out) both;
}
.imp-bar p { flex: 1; min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-bar strong { font-weight: 700; }
.imp-bar-by { color: #A3A3A3; }
.imp-bar-ico { display: inline-flex; width: 18px; height: 18px; flex: none; color: #FACC15; }
.imp-bar-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: 32px;
  padding: 0 12px;
  border: none;
  border-radius: 999px;
  background: #FACC15;
  color: #171717;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--dur-2, 160ms) var(--ease-std, ease), transform var(--dur-1, 100ms) var(--ease-std, ease);
}
.imp-bar-back:hover { background: #FDE047; }
.imp-bar-back:active { transform: scale(0.97); }
.imp-bar-back:disabled { opacity: 0.6; cursor: progress; }
body.is-impersonating .sidebar-v2,
body.is-impersonating .bp { top: var(--imp-h); }
body.is-impersonating .main-content { padding-top: calc(var(--sp-section) + var(--imp-h)); }
@media (max-width: 768px) {
  .imp-bar { padding-left: 12px; font-size: 0.8rem; }
  .imp-bar-by { display: none; }
  body.is-impersonating .mobile-header { top: var(--imp-h); }
  body.is-impersonating .main-content,
  body.is-impersonating.has-sidebar-v2 .main-content { margin-top: calc(60px + var(--imp-h)); padding-top: 16px; }
}
