:root {
  --brand: #c2185b;
  --brand-dark: #9c1147;
  --brand-soft: #fdf2f7;

  --surface: #ffffff;
  --canvas: #f6f7fa;
  --border-subtle: #e9ecf2;
  --text-main: #181c25;
  --text-muted: #6b7280;

  /* Slot semantic colors */
  --free-bg: #f0fdf4;
  --free-border: #bbf7d0;
  --free-accent: #15803d;

  --partial-bg: #fffbeb;
  --partial-border: #f59e0b;
  --partial-accent: #b45309;

  --full-bg: #fef2f2;
  --full-border: #ef4444;
  --full-accent: #b91c1c;

  --new-dashed: #e11d48;
  --closed-bg: #f3f4f6;
  --closed-border: #d1d5db;

  --nav-height: 68px;
}

* {
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--canvas);
  color: var(--text-main);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  margin: 0;
}

/* ========================================================================= */
/* AUTH VIEW                                                                 */
/* ========================================================================= */
.auth-shell {
  min-height: 100vh;
  max-width: 440px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-badge {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(194, 24, 91, 0.25);
}

/* ========================================================================= */
/* APP SHELL & TOPBAR                                                        */
/* ========================================================================= */
.app-shell {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  background-color: var(--canvas);
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 20px);
}

.app-topbar {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.75rem 1rem;
  z-index: 1020;
}

.card-clean {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.03);
}

.btn-brand {
  background-color: var(--brand);
  border-color: var(--brand);
  color: #fff;
  border-radius: 12px;
}

.btn-brand:hover,
.btn-brand:focus {
  background-color: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
}

.text-brand {
  color: var(--brand) !important;
}

.btn-icon-soft {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #f3f4f6;
  border: 1px solid transparent;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-soft:active {
  background: #e5e7eb;
}

/* Segmented control */
.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #f1f3f7;
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
}

.segmented-control.segmented-2 {
  grid-template-columns: repeat(2, 1fr);
}

.btn-xs {
  padding: 0.2rem 0.55rem;
  font-size: 0.74rem;
  border-radius: 99px;
}

.bg-brand {
  background-color: var(--brand) !important;
}

/* Client Card Photos Grid */
.photos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.photo-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: #f3f4f6;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-del-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
}

/* QR Code Box */
.qr-box {
  width: 176px;
  height: 176px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-box img,
.qr-box canvas {
  max-width: 100%;
  height: auto;
}

/* Public Online Booking Slots Grid */
.pub-slots-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.pub-slot-btn {
  border: 1.5px solid var(--free-border);
  background: var(--free-bg);
  color: var(--free-accent);
  font-weight: 700;
  border-radius: 12px;
  padding: 0.65rem 0.5rem;
  font-size: 0.9rem;
  transition: all 0.14s ease;
}

.pub-slot-btn.selected {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.pub-slot-btn.disabled,
.pub-slot-btn:disabled {
  background: #f3f4f6;
  border-color: #e5e7eb;
  color: #9ca3af;
  text-decoration: line-through;
  cursor: not-allowed;
}

.seg-btn {
  border: 0;
  background: transparent;
  padding: 0.45rem 0.5rem;
  border-radius: 9px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.16s ease;
}

.seg-btn.active {
  background: #ffffff;
  color: var(--text-main);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* Reschedule Banner */
.reschedule-banner {
  position: sticky;
  top: 0;
  z-index: 1035;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  padding: 0.65rem 1rem;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
}

/* ========================================================================= */
/* DAY VIEW — CUSTOM 2-HOUR SQUARE CSS GRID (1-HOUR INTERNAL STEP)           */
/* ========================================================================= */
.day-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.slot-block {
  aspect-ratio: 1 / 1;
  min-height: 176px;
  border-radius: 18px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1.5px solid var(--border-subtle);
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.slot-block.block-free {
  background: var(--free-bg);
  border-color: var(--free-border);
}

.slot-block.block-partial {
  background: var(--partial-bg);
  border-color: var(--partial-border);
}

.slot-block.block-full {
  background: var(--full-bg);
  border-color: var(--full-border);
}

.slot-block.block-closed {
  background: var(--closed-bg);
  border-color: var(--closed-border);
}

.slot-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 6px;
  padding: 0 2px;
  color: var(--text-muted);
}

.block-free .slot-block-header { color: var(--free-accent); }
.block-partial .slot-block-header { color: var(--partial-accent); }
.block-full .slot-block-header { color: var(--full-accent); }

.slot-halves {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 6px;
  flex: 1;
  min-height: 0;
}

.slot-halves.merged {
  grid-template-rows: 1fr;
}

.slot-halves.single-hour {
  grid-template-rows: 1fr;
}

/* Free 1-hour half with "+" button */
.slot-half-free {
  position: relative;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid #d1fae5;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  cursor: pointer;
  min-height: 0;
  padding: 4px;
  transition: background-color 0.14s ease, transform 0.1s ease;
}

.slot-half-free:active {
  transform: scale(0.97);
  background: #dcfce7;
}

.reschedule-active .slot-half-free {
  border: 2px dashed #2563eb;
  background: #eff6ff;
}

.slot-half-time {
  position: absolute;
  top: 4px;
  left: 7px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--free-accent);
}

.slot-plus-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #dcfce7;
  color: var(--free-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
}

.reschedule-active .slot-plus-icon {
  background: #2563eb;
  color: #fff;
}

.slot-lock-btn {
  position: absolute;
  top: 3px;
  right: 4px;
  border: 0;
  background: transparent;
  color: #9ca3af;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  padding: 0;
}

.slot-lock-btn:hover,
.slot-lock-btn:active {
  background: rgba(0, 0, 0, 0.06);
  color: #374151;
}

/* Closed / Blocked 1-hour half */
.slot-half-closed {
  position: relative;
  border-radius: 12px;
  background: repeating-linear-gradient(
    -45deg,
    #f3f4f6,
    #f3f4f6 6px,
    #e5e7eb 6px,
    #e5e7eb 12px
  );
  border: 1px solid #d1d5db;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  cursor: pointer;
  color: #6b7280;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 4px;
}

/* Booked Appointment Card inside a half or full 2-hour block */
.slot-half-booked {
  position: relative;
  border-radius: 12px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  min-height: 0;
  background: #fee2e2;
  border: 1.5px solid #f87171;
  color: #7f1d1d;
  transition: transform 0.1s ease;
}

.slot-half-booked:active {
  transform: scale(0.98);
}

/* Partially busy block: give 1-hour booked card a clear warm/saturated highlight */
.block-partial .slot-half-booked {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #78350f;
}

/* Completed appointment styling */
.slot-half-booked.status-completed {
  background: #ffe4e6;
  border-color: #e11d48;
  color: #881337;
}

/* Pending confirmation (`new`): MANDATORY DASHED BORDER */
.slot-half-booked.status-new {
  border-style: dashed !important;
  border-width: 2px !important;
  border-color: var(--new-dashed) !important;
  background: #fff1f2 !important;
  color: #9f1239 !important;
}

.appt-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-size: 0.67rem;
  font-weight: 700;
  line-height: 1.1;
}

.appt-card-client {
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  margin-top: 2px;
}

.appt-card-service {
  font-size: 0.68rem;
  opacity: 0.88;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.appt-card-price {
  font-size: 0.72rem;
  font-weight: 700;
  margin-top: 4px;
}

/* ========================================================================= */
/* WEEK VIEW & MONTH VIEW                                                    */
/* ========================================================================= */
.week-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.week-day-card {
  background: var(--surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: 16px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.14s ease, transform 0.1s ease;
}

.week-day-card:active {
  transform: scale(0.99);
}

.week-day-card.is-today {
  border-color: var(--brand);
  box-shadow: 0 2px 10px rgba(194, 24, 91, 0.08);
}

.week-hour-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(22px, 1fr));
  gap: 4px;
  margin-top: 8px;
}

.week-hour-pill {
  height: 22px;
  border-radius: 6px;
  font-size: 0.62rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.week-hour-pill.free { background: var(--free-bg); color: var(--free-accent); border: 1px solid var(--free-border); }
.week-hour-pill.busy { background: #fee2e2; color: #b91c1c; border: 1px solid #f87171; }
.week-hour-pill.new { background: #fff1f2; color: #be123c; border: 1.5px dashed #e11d48; }
.week-hour-pill.closed { background: #e5e7eb; color: #6b7280; }

/* Month CSS Grid */
.month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.month-cell {
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  background: var(--surface);
  border: 1.5px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 2px;
  position: relative;
}

.month-cell.outside {
  opacity: 0.32;
}

.month-cell.is-today {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}

.month-cell.state-free { background: var(--free-bg); border-color: var(--free-border); }
.month-cell.state-partial { background: var(--partial-bg); border-color: var(--partial-border); }
.month-cell.state-full { background: var(--full-bg); border-color: var(--full-border); }
.month-cell.state-off { background: var(--closed-bg); border-color: var(--closed-border); color: #9ca3af; }
.month-cell.has-new { border-style: dashed !important; border-width: 2px !important; }

.month-day-num {
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
}

.month-day-count {
  font-size: 0.62rem;
  font-weight: 600;
  margin-top: 3px;
  color: var(--text-muted);
}

/* ========================================================================= */
/* LEGEND, WHATSAPP, PICKERS, MODALS                                         */
/* ========================================================================= */
.legend-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 4px;
  display: inline-block;
}

.dot-free { background: var(--free-bg); border: 1.5px solid var(--free-border); }
.dot-partial { background: var(--partial-bg); border: 1.5px solid var(--partial-border); }
.dot-full { background: var(--full-bg); border: 1.5px solid var(--full-border); }
.dot-new { background: #fff1f2; border: 1.5px dashed var(--new-dashed); }

.whatsapp-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 14px;
}

.btn-whatsapp {
  background: #25d366;
  border-color: #25d366;
  color: #fff;
  border-radius: 12px;
  padding: 0.65rem 1rem;
}

.btn-whatsapp:hover,
.btn-whatsapp:focus {
  background: #1ebe5b;
  border-color: #1ebe5b;
  color: #fff;
}

.client-picker-list {
  max-height: 170px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.client-picker-item {
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 8px 12px;
  background: #fff;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.client-picker-item:hover,
.client-picker-item:active {
  background: var(--brand-soft);
  border-color: var(--brand);
}

.selected-client-pill {
  background: var(--brand-soft);
  border: 1.5px solid var(--brand);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.service-option-card {
  border: 1.5px solid var(--border-subtle);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
}

.service-option-card.selected {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.promo-preview-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
}

.avatar-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

/* Bottom Sheet feel on mobile modals */
@media (max-width: 576px) {
  .modal-bottom-sheet {
    margin: 0;
    align-items: flex-end;
    min-height: 100%;
  }
  .modal-bottom-sheet .modal-content {
    border-radius: 22px 22px 0 0;
    max-height: 92vh;
  }
}

@media (min-width: 577px) {
  .modal-bottom-sheet .modal-content {
    border-radius: 20px;
  }
}

/* ========================================================================= */
/* FIXED NATIVE-STYLE BOTTOM NAVIGATION                                      */
/* ========================================================================= */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 1030;
  box-shadow: 0 -4px 18px rgba(15, 23, 42, 0.05);
}

.nav-item-btn {
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #6b7280;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 6px 4px;
  transition: color 0.14s ease;
}

.nav-item-btn i {
  font-size: 1.3rem;
  line-height: 1;
}

.nav-item-btn.active {
  color: var(--brand);
}
