/* ==========================================================================
   Melida's Cleaning — Calendar Wizard UI (scoped)
   Scope selector: .mcw
   Sections: Modal, Header/Steps, Panels, Calendar, Slots, Details Form,
             Review, Payment, Utilities, Responsiveness, Motion
   Each property is on its own line for clarity.
   ========================================================================== */


/* ===== Modal root ===== */

.mcw {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 9999;
  /* Prevent background scroll on iOS when the modal is open */
  overscroll-behavior: contain;
}

.mcw[aria-hidden="false"] {
  display: block;
}


/* ===== Backdrop ===== */

.mcw__overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 24, 35, 0.55);
  backdrop-filter: blur(3px);
}


/* ===== Dialog container ===== */

.mcw__dialog {
  position: relative;
  z-index: 2;
  width: min(980px, 94vw);
  max-width: 980px;
  margin: 4vh auto;
  background: #ffffff;
  border: 1px solid #e7eef2;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(8, 36, 48, 0.25);
  display: flex;
  flex-direction: column;
  /* Keep header/footer visible and let body scroll */
  max-height: calc(100dvh - 8vh);
  overflow: hidden;
}


/* ===== Header ===== */

.mcw__header {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 18px 20px 12px;
  background: #fbfdff;
  border-bottom: 1px solid #edf3f7;
}

.mcw__title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mcw__title {
  margin: 0;
  color: #0e2430;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-weight: 600;
  font-size: 20px;
  line-height: 1.2;
}

.mcw__close {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: #48606b;
  font-size: 18px;
  cursor: pointer;
}

.mcw__close:hover {
  color: #0e2430;
}


/* ===== Stepper ===== */

.mcw__steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 0 0;
  margin: 0;
}

.mcw__steps li {
  position: relative;
  padding: 10px 0;
  text-align: center;
  background: #f2f7fb;
  color: #6d8590;
  border-radius: 10px;
  user-select: none;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-weight: 600;
  font-size: 12px;
  line-height: 1;
}

.mcw__steps li.is-active {
  background: #e7f3ff;
  color: #0e2430;
}

.mcw__steps li::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -6px;
  height: 4px;
  border-radius: 4px;
  background: transparent;
}

.mcw__steps li.is-active::after {
  background: #2b7cff;
}


/* ===== Panels / body ===== */

.mcw__body {
  position: relative;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  /* Scroll only the body area */
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  /* Reserve space for footer inside max-height */
  max-height: calc(100dvh - 8vh - 72px - 60px);
  /* 8vh margins + ~72px header + ~60px footer (approx) */
}

.mcw__panel {
  display: block;
}

.mcw__panel.is-hidden {
  display: none;
}

.mcw__h3 {
  margin: 0 0 8px;
  color: #0e2430;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-weight: 700;
  font-size: 18px;
  line-height: 1.25;
}

.mcw__hint {
  margin: 0 0 14px;
  color: #55707d;
  font-size: 14px;
}

.mcw__note {
  margin-top: 6px;
  color: #aa2a2a;
  font-size: 14px;
}

.mcw__tag {
  display: inline-block;
  padding: 6px 10px;
  background: #eef6ff;
  color: #1c4d7a;
  border-radius: 10px;
  font-size: 13px;
}


/* ===== Footer (navigation) ===== */

.mcw__footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: #fbfdff;
  border-top: 1px solid #edf3f7;
}

.mcw__spacer {
  flex: 1 1 auto;
}


/* ===== Buttons ===== */

.mcw-btn {
  appearance: none;
  padding: 10px 16px;
  border: 1px solid #c9d8e2;
  border-radius: 12px;
  background: #0f6efd;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.08);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
}

.mcw-btn:hover {
  filter: brightness(0.97);
}

.mcw-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.mcw-btn--primary {
  background: #0f6efd;
  border-color: #0f6efd;
  color: #ffffff;
}

.mcw-btn--ghost {
  background: #ffffff;
  border: 1px solid #ccdde7;
  color: #13303d;
}

.mcw-btn--ghost:hover {
  background: #f6fbff;
}


/* ==========================================================================
   STEP 1 — Calendar
   ========================================================================== */

.mcw-cal {
  background: #ffffff;
  border: 1px solid #e7eef2;
  border-radius: 16px;
  padding: 10px;
}

.mcw-cal__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px;
}

.mcw-cal__label {
  color: #0e2430;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-weight: 600;
  font-size: 15px;
  line-height: 1;
}

/* grid wrapper for headers + days */
.mcw-cal__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 6px;
  padding: 8px 6px 12px;
}

/* day-of-week headers */
.mcw-cal__dow {
  display: grid;
  place-items: center;
  height: 28px;
  color: #5d7681;
  border-radius: 8px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-weight: 600;
  font-size: 12px;
  line-height: 1;
}

/* days grid follows in full row */
.mcw-cal__days {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

/* individual day cell */
.mcw-day {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  background: #ffffff;
  border: 1px solid #e7eef2;
  border-radius: 10px;
  color: #0e2430;
  cursor: pointer;
  user-select: none;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
}

.mcw-day:hover {
  background: #f3f9ff;
}

.mcw-day[aria-disabled="true"] {
  color: #9aaab3;
  background: #f6f9fb;
  cursor: not-allowed;
  opacity: 0.7;
}

.mcw-day.is-today {
  border-color: #b6d6ff;
}

.mcw-day.is-selected {
  background: #0f6efd;
  color: #ffffff;
  border-color: #0f6efd;
}


/* ==========================================================================
   STEP 2 — Time slots
   ========================================================================== */

.mcw-slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.mcw-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: #ffffff;
  border: 1px solid #dce8ef;
  border-radius: 12px;
  color: #15323f;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
}

.mcw-slot:hover {
  background: #f6fbff;
}

.mcw-slot.is-selected {
  background: #0f6efd;
  color: #ffffff;
  border-color: #0f6efd;
}

.mcw-slot[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}


/* ==========================================================================
   STEP 3 — Customer details
   ========================================================================== */

.mcw-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mcw-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mcw-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mcw-field span {
  color: #183744;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-weight: 600;
  font-size: 13px;
  line-height: 1;
}

.mcw-field input {
  width: 100%;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid #cfe0ea;
  border-radius: 10px;
  color: #0e2430;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.2;
}

.mcw-field textarea {
  width: 100%;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid #cfe0ea;
  border-radius: 10px;
  color: #0e2430;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  resize: vertical;
}

.mcw-field input:focus,
.mcw-field textarea:focus {
  outline: 2px solid #bfe1ff;
  border-color: #8bc6ff;
}

.mcw-error {
  color: #b83232;
  font-size: 12px;
  line-height: 1.2;
  min-height: 14px;
}


/* ==========================================================================
   STEP 4 — Review
   ========================================================================== */

.mcw-review {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}

.mcw-review__card {
  background: #ffffff;
  border: 1px solid #e7eef2;
  border-radius: 14px;
  padding: 12px;
}

.mcw-review__card h4 {
  margin: 0 0 8px;
  color: #0e2430;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}

.mcw-review__card ul {
  margin: 0;
  padding-left: 16px;
  color: #284b58;
  font-size: 14px;
  line-height: 1.5;
}

.mcw-review__total {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #0f6efd;
  color: #ffffff;
  border-radius: 12px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-weight: 600;
  font-size: 16px;
  line-height: 1.2;
}

.mcw-review__pricing {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}

.mcw-review__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid #e7eef2;
  border-radius: 12px;
  color: #123543;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.3;
}

.mcw-review__row strong {
  color: #0e2430;
  font-size: 15px;
}

.mcw-review__row small {
  display: inline-block;
  margin-left: 6px;
  color: #5d7681;
  font-size: 12px;
}


/* ==========================================================================
   STEP 4 — Payment container (Stripe mounts inside)
   ========================================================================== */

.mcw-payment {
  margin-top: 10px;
  padding: 14px;
  background: #ffffff;
  border: 1px solid #e7eef2;
  border-radius: 14px;
}

#payment-element {
  margin-top: 12px;
}

#mcwPayBtn {
  min-width: 180px;
}


/* ===== Utilities ===== */

.is-hidden {
  display: none !important;
}


/* ==========================================================================
   RESPONSIVENESS — small/medium breakpoints and safe areas
   ========================================================================== */

/* Medium screens: keep columns tighter and raise body height */
@media (max-width: 1024px) {
  .mcw__dialog {
    width: 96vw;
    margin: 3vh auto;
    max-height: calc(100dvh - 6vh);
  }

  .mcw__steps {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .mcw-review {
    grid-template-columns: 1fr;
  }
}

/* Small screens: full-screen sheet, safe areas, larger tap targets */
@media (max-width: 720px) {
  .mcw__dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    /* Lock the dialog viewport and let body inside scroll */
    overflow: hidden;
  }

  .mcw__header {
    padding-top: calc(16px + env(safe-area-inset-top));
    padding-right: calc(20px + env(safe-area-inset-right));
    padding-left: calc(20px + env(safe-area-inset-left));
  }

  .mcw__body {
    padding-right: calc(20px + env(safe-area-inset-right));
    padding-left: calc(20px + env(safe-area-inset-left));
    max-height: calc(100dvh - 56px - 64px);
    /* ~56 header + ~64 footer (mobile) */
  }

  .mcw__footer {
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
    padding-right: calc(20px + env(safe-area-inset-right));
    padding-left: calc(20px + env(safe-area-inset-left));
  }

  .mcw__steps {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .mcw__steps li {
    padding: 9px 0;
    font-size: 11px;
  }

  .mcw-grid {
    grid-template-columns: 1fr;
  }

  .mcw-cal__grid {
    gap: 4px;
    padding: 6px 4px 10px;
  }

  .mcw-cal__days {
    gap: 6px;
  }

  .mcw-day {
    height: 42px;
    font-size: 13px;
  }

  .mcw-slot {
    padding: 12px 10px;
    font-size: 14px;
  }
}

/* Ultra-small devices: reduce paddings for more content */
@media (max-width: 360px) {
  .mcw__header {
    padding: 14px 14px 10px;
  }

  .mcw__body {
    padding: 16px;
  }

  .mcw__footer {
    padding: 12px 16px;
  }

  .mcw__title {
    font-size: 18px;
  }
}


/* ==========================================================================
   MOTION & ACCESSIBILITY
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .mcw,
  .mcw * {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* Improve focus visibility for keyboard users */
.mcw :focus-visible {
  outline: 2px solid #8bc6ff;
  outline-offset: 2px;
}

/* Prevent body from scrolling when modal is open (helper class you can toggle on <html> or <body>) */
html.mcw-lock,
body.mcw-lock {
  overflow: hidden;
  touch-action: none;
}
