/* ==========================================================================
   Demo patient portal (login, sign up, booking, receipt, status)
   Opens as a modal <dialog> on top of any page.
   ========================================================================== */

.portal {
  width: min(100% - 2rem, 62rem);
  max-width: none;
  height: min(100% - 2rem, 52rem);
  max-height: none;
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius-l);
  background: var(--enamel);
  color: var(--midnight);
  box-shadow: 0 40px 90px -30px rgb(10 30 66 / 0.6);
  overflow: hidden;
}

.portal[open] {
  animation: portal-in 320ms var(--ease);
}

.portal::backdrop {
  background: rgb(10 30 66 / 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

@keyframes portal-in {
  from {
    opacity: 0;
    transform: translateY(1.25rem) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Full screen on phones */
@media (max-width: 47.99em) {
  .portal {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
}

.portal__shell {
  display: grid;
  grid-template-rows: auto auto 1fr;
  height: 100%;
}

.portal__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem clamp(1rem, 3vw, 1.75rem);
  background: var(--navy);
  color: var(--white);
}

.portal__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.portal__logo {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.6rem;
}

.portal__title {
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: 600;
  line-height: 1.2;
}

.portal__demo {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--gold-soft);
}

.portal__demo .icon {
  width: 1em;
  height: 1em;
}

.portal__close {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid rgb(255 255 255 / 0.25);
  border-radius: 0.75rem;
  background: rgb(255 255 255 / 0.06);
  color: var(--white);
  transition: background-color var(--dur) var(--ease);
}

.portal__close:hover {
  background: rgb(255 255 255 / 0.16);
}

.portal__tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem clamp(0.75rem, 3vw, 1.5rem);
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: var(--white);
  scrollbar-width: none;
}

.portal__tabs::-webkit-scrollbar {
  display: none;
}

.portal__tabs[hidden] {
  display: none;
}

.portal__tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex: none;
  min-height: 2.75rem;
  padding: 0.5rem 0.9rem;
  border: 0;
  border-radius: 0.7rem;
  background: none;
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--slate);
  transition:
    background-color var(--dur) var(--ease),
    color var(--dur) var(--ease);
}

.portal__tab:hover {
  background: var(--enamel);
  color: var(--midnight);
}

.portal__tab[aria-current="page"] {
  background: var(--ice);
  color: var(--navy);
  font-weight: 600;
}

.portal__tab--logout {
  margin-left: auto;
}

.portal__body {
  overflow-y: auto;
  padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1rem, 4vw, 2.5rem) clamp(2rem, 5vw, 3rem);
  overscroll-behavior: contain;
}

/* View layout ------------------------------------------------------------- */
.pview {
  display: grid;
  gap: var(--space-m);
  animation: rise 320ms var(--ease) both;
}

.pview__head {
  display: grid;
  gap: 0.35rem;
}

.pview__title {
  font-size: var(--step-2);
}

.pview__title:focus {
  outline: none;
}

.pview__text {
  color: var(--slate);
}

.pview__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--navy);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.link-btn:hover {
  color: var(--midnight);
}

/* Auth */
.pview--auth {
  justify-items: center;
}

.auth {
  display: grid;
  gap: var(--space-m);
  width: min(100%, 26rem);
}

.auth--wide {
  width: min(100%, 38rem);
}

.auth__demo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px dashed var(--mist);
  border-radius: var(--radius);
  background: var(--white);
  font-size: var(--step--1);
}

.auth__demo span {
  color: var(--slate);
}

.auth__switch {
  text-align: center;
  color: var(--slate);
}

/* Dashboard */
.next-card {
  display: grid;
  gap: var(--space-m);
  padding: var(--space-m);
  border-radius: var(--radius-l);
  border-top: 3px solid var(--gold);
  background: var(--navy);
  color: var(--white);
}

@media (min-width: 36em) {
  .next-card {
    grid-template-columns: auto 1fr;
    align-items: center;
  }
}

.next-card__count {
  display: grid;
  place-content: center;
  justify-items: center;
  min-width: 7.5rem;
  padding: 1rem;
  border: 1px solid rgb(250 192 7 / 0.5);
  border-radius: var(--radius);
  text-align: center;
}

.next-card__num {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 2rem + 2vw, 3.25rem);
  font-weight: 600;
  line-height: 1;
  color: var(--gold);
}

.next-card__num--word {
  font-size: var(--step-2);
}

.next-card__label {
  font-size: var(--step--1);
  color: var(--mist);
}

.next-card__info {
  display: grid;
  gap: 0.2rem;
}

.next-card__info h3 {
  font-size: var(--step-2);
}

.next-card__info p {
  color: var(--mist);
}

.next-card__eyebrow {
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-soft) !important;
}

.next-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12.5rem), 1fr));
  gap: 0.75rem;
}

.dash-tile {
  display: grid;
  align-content: start;
  gap: 0.3rem;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--midnight);
  font-size: var(--step--1);
  text-align: left;
  text-decoration: none;
  transition:
    transform var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}

.dash-tile .icon {
  width: 1.5rem;
  height: 1.5rem;
  margin-bottom: 0.3rem;
  color: var(--navy);
}

.dash-tile strong {
  font-family: var(--font-display);
  font-size: var(--step-0);
}

.dash-tile span {
  color: var(--slate);
}

button.dash-tile:hover,
a.dash-tile:hover {
  transform: translateY(-3px);
  border-color: var(--mist);
  box-shadow: var(--shadow-m);
}

.empty {
  display: grid;
  justify-items: center;
  gap: 0.6rem;
  padding: var(--space-l) var(--space-m);
  border: 1px dashed var(--mist);
  border-radius: var(--radius-l);
  background: var(--white);
  text-align: center;
}

.empty__icon {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  background: var(--ice);
  color: var(--navy);
}

.empty__icon .icon {
  width: 1.5rem;
  height: 1.5rem;
}

.empty h3 {
  font-size: var(--step-1);
}

.empty p {
  margin-bottom: 0.5rem;
  color: var(--slate);
}

/* Booking stepper */
.stepper {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
  list-style: none;
}

.stepper li {
  height: 0.35rem;
  border-radius: var(--pill);
  background: var(--line);
  transition: background-color 300ms var(--ease);
}

.stepper li span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.stepper .is-done {
  background: var(--navy);
}

.stepper .is-current {
  background: var(--gold);
}

.booking {
  display: grid;
  gap: var(--space-s);
}

.booking__nav {
  position: sticky;
  bottom: calc(-1 * clamp(2rem, 5vw, 3rem));
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-inline: calc(-1 * clamp(1rem, 4vw, 2.5rem));
  margin-bottom: calc(-1 * clamp(2rem, 5vw, 3rem));
  padding: 0.9rem clamp(1rem, 4vw, 2.5rem) 1.1rem;
  border-top: 1px solid var(--line);
  background: rgb(246 248 252 / 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.booking__hint,
.booking__context {
  font-size: var(--step--1);
  color: var(--slate);
}

.booking__context {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--midnight);
}

.booking__context .icon {
  color: var(--navy);
}

/* Radio "choice" cards */
.choice-set {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr));
  gap: 0.65rem;
}

.choice-grid--doctors {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
}

.choice {
  position: relative;
  display: block;
  cursor: pointer;
}

.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice__box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 100%;
  padding: 0.9rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    background-color var(--dur) var(--ease),
    transform 90ms var(--ease);
}

.choice:hover .choice__box {
  border-color: var(--mist);
}

.choice:active .choice__box {
  transform: scale(0.98);
}

.choice input:checked + .choice__box {
  border-color: var(--navy);
  background: var(--ice);
  box-shadow: inset 0 0 0 1px var(--navy);
}

.choice input:focus-visible + .choice__box {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.choice.is-disabled {
  cursor: not-allowed;
}

.choice.is-disabled .choice__box {
  border-style: dashed;
  background: transparent;
  color: #8b97ad;
  text-decoration: line-through;
}

.choice__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.7rem;
  background: var(--ice);
  color: var(--navy);
}

.choice input:checked + .choice__box .choice__icon {
  background: var(--navy);
  color: var(--gold);
}

.choice__title {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.25;
}

.choice__sub {
  display: block;
  font-size: var(--step--1);
  color: var(--slate);
}

.choice__avatar {
  flex: none;
  width: 3.5rem;
  height: 3.5rem;
  overflow: hidden;
  border-radius: 50%;
  background: var(--ice);
}

.choice__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.choice__monogram {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  background: var(--navy);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
}

/* Date picker */
.day-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
  gap: 0.5rem;
}

.choice--day .choice__box {
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.7rem 0.4rem;
  text-align: center;
}

.choice__dow {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate);
}

.choice__day {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.1;
}

.choice__mon {
  font-size: 0.85rem;
}

.choice__hours {
  margin-top: 0.2rem;
  font-size: 0.7rem;
  color: var(--slate);
  white-space: nowrap;
}

/* Time slots */
.slot-group {
  display: grid;
  gap: 0.5rem;
}

.slot-group__label {
  padding: 0;
  margin-bottom: 0.5rem;
  font-family: var(--font-display);
  font-weight: 600;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.25rem, 1fr));
  gap: 0.5rem;
}

.choice--slot .choice__box {
  justify-content: center;
  padding: 0.65rem 0.5rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Review */
.review {
  display: grid;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--white);
  overflow: hidden;
}

.review div {
  display: grid;
  grid-template-columns: minmax(6rem, 0.4fr) 1fr;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line);
}

.review div:last-child {
  border-bottom: 0;
}

.review dt {
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--slate);
}

.review dd {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin: 0;
  font-weight: 500;
}

/* Status pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.7rem;
  border-radius: var(--pill);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
}

.pill--confirmed {
  background: var(--success-bg);
  color: var(--success);
}

.pill--cancelled {
  background: var(--error-bg);
  color: var(--error);
}

.pill--past {
  background: var(--ice);
  color: var(--slate);
}

/* Receipt */
.receipt {
  position: relative;
  display: grid;
  gap: var(--space-s);
  width: min(100%, 40rem);
  padding: clamp(1.25rem, 4vw, 2.25rem);
  border: 1px solid var(--line);
  border-top: 6px solid var(--gold);
  border-radius: var(--radius-l);
  background: var(--white);
  box-shadow: var(--shadow-m);
  overflow: hidden;
  animation: rise 420ms var(--ease) both;
}

.receipt__watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  font-family: var(--font-display);
  font-size: clamp(4rem, 3rem + 8vw, 8rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: rgb(1 53 126 / 0.05);
  transform: translate(-50%, -50%) rotate(-18deg);
  pointer-events: none;
}

.receipt__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem;
}

.receipt__head > div {
  flex: 1;
  min-width: 12rem;
}

.receipt__logo {
  width: 3rem;
  height: 3rem;
  border-radius: 0.7rem;
}

.receipt__clinic {
  font-family: var(--font-display);
  font-weight: 600;
}

.receipt__ar {
  font-family: var(--font-ar);
  font-size: var(--step--1);
  color: var(--slate);
  text-align: left;
}

.receipt__ref {
  display: grid;
  gap: 0.15rem;
  padding: 0.9rem 1rem;
  border: 1px dashed var(--mist);
  border-radius: var(--radius);
  background: var(--enamel);
}

.receipt__ref span {
  font-size: var(--step--1);
  color: var(--slate);
}

.receipt__ref strong {
  font-family: var(--font-display);
  font-size: var(--step-2);
  letter-spacing: 0.06em;
  color: var(--navy);
}

.receipt__list {
  display: grid;
  margin: 0;
}

.receipt__list div {
  display: grid;
  grid-template-columns: minmax(5.5rem, 0.4fr) 1fr;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}

.receipt__list dt {
  font-size: var(--step--1);
  color: var(--slate);
}

.receipt__list dd {
  margin: 0;
  font-weight: 500;
}

.receipt__note {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  background: #fff8e1;
  font-size: var(--step--1);
  color: #5c4300;
}

.receipt__note .icon {
  margin-top: 0.15em;
}

/* Appointment status */
.status-hero {
  display: grid;
  gap: var(--space-s);
  align-items: center;
  padding: var(--space-m);
  border-radius: var(--radius-l);
  background: var(--navy);
  color: var(--white);
}

@media (min-width: 36em) {
  .status-hero {
    grid-template-columns: auto 1fr;
  }
}

.status-hero__count {
  display: grid;
  justify-items: center;
  min-width: 7.5rem;
  padding: 0.9rem;
  border-radius: var(--radius);
  background: var(--gold);
  color: var(--midnight);
  text-align: center;
}

.status-hero__count strong {
  font-family: var(--font-display);
  font-size: clamp(2rem, 1.6rem + 2vw, 3rem);
  line-height: 1;
}

.status-hero__count span {
  font-size: var(--step--1);
  font-weight: 600;
}

.status-hero h3 {
  font-size: var(--step-2);
}

.status-hero p {
  color: var(--mist);
}

.status-hero__eyebrow {
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-soft) !important;
}

.appt-list {
  display: grid;
  gap: 0.75rem;
  list-style: none;
}

.appt {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.9rem 1rem;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}

@media (min-width: 40em) {
  .appt {
    grid-template-columns: auto 1fr auto;
  }
}

.appt__date {
  display: grid;
  justify-items: center;
  width: 3.75rem;
  padding: 0.45rem 0;
  border-radius: 0.75rem;
  background: var(--ice);
  color: var(--navy);
  line-height: 1.1;
}

.appt__date span {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.appt__date strong {
  font-family: var(--font-display);
  font-size: 1.5rem;
}

.appt__info {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.appt__info h4 {
  font-size: var(--step-0);
}

.appt__info p {
  font-size: var(--step--1);
  color: var(--slate);
}

.appt__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
  margin-top: 0.2rem;
}

.appt__count {
  font-weight: 600;
  color: var(--midnight);
}

.appt__ref {
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}

.appt__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  grid-column: 1 / -1;
}

@media (min-width: 40em) {
  .appt__actions {
    grid-column: auto;
  }
}

.appt__cancel {
  --btn-bg: transparent;
  --btn-fg: var(--error);
  --btn-border: rgb(180 35 24 / 0.3);
}

.appt__cancel:hover {
  --btn-bg: var(--error-bg);
}

/* Printing a receipt: only the receipt is printed */
@media print {
  .portal-open body > *:not(.portal),
  .portal__top,
  .portal__tabs,
  .pview__head,
  .pview__actions,
  .form-alert {
    display: none !important;
  }

  .portal {
    position: static;
    width: auto;
    height: auto;
    box-shadow: none;
    overflow: visible;
  }

  .portal::backdrop {
    display: none;
  }

  .portal__body {
    overflow: visible;
    padding: 0;
  }

  .receipt {
    box-shadow: none;
  }
}
