:root {
  --ink: #263c3a;
  --muted: #56635f;
  --line: #e7e6df;
  --soft-line: #eeede7;
  --accent: #1d5f91;
  --accent-dark: #0e5570;
  --accent-soft: #eef7fa;
  --surface: #ffffff;
  --bg: #f7f5f0;
  --error: #a93434;
  --success: #23633c;
}

* {
  box-sizing: border-box;
}

html {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

main {
  width: min(1000px, calc(100% - 24px));
  margin: 20px auto;
}

.booking-shell {
  display: grid;
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr);
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 46px rgba(38, 60, 58, 0.11);
}

.intro {
  min-width: 0;
  padding: 28px;
  background: var(--bg);
  border-right: 1px solid var(--soft-line);
}

.eyebrow {
  width: fit-content;
  margin-bottom: 14px;
  border: 1px solid rgba(29, 95, 145, 0.26);
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.details-list {
  display: grid;
  gap: 12px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.detail-item {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  align-items: start;
}

.detail-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 700;
}

.detail-title {
  margin: 0 0 2px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.detail-copy {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.form-panel {
  min-width: 0;
  padding: 28px;
}

h1 {
  color: var(--accent);
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: 0;
}

p {
  margin: 0 0 18px;
  color: var(--muted);
}

.field-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

form {
  display: grid;
  gap: 15px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label,
legend {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
  color: var(--ink);
}

fieldset {
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 13px;
  font: inherit;
  color: var(--ink);
  background: #fff;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(29, 95, 145, 0.16);
}

.patient-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  position: relative;
}

.patient-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.patient-options label {
  min-height: 46px;
  display: grid;
  place-items: center;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.patient-options input:focus+label {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 95, 145, 0.16);
}

.patient-options input:checked+label {
  border-color: rgba(29, 95, 145, 0.45);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.hidden-field {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

button {
  width: fit-content;
  min-height: 44px;
  border: 1px solid var(--accent-dark);
  border-radius: 6px;
  padding: 11px 20px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.message {
  display: none;
  min-height: 48px;
  border-radius: 6px;
  padding: 12px 14px;
  font-weight: 700;
}

.message.success {
  display: block;
  border: 1px solid rgba(35, 99, 60, 0.35);
  background: rgba(35, 99, 60, 0.08);
  color: var(--success);
}

.message.error {
  display: block;
  border: 1px solid rgba(169, 52, 52, 0.35);
  background: rgba(169, 52, 52, 0.08);
  color: var(--error);
}

/* Calendar Widget styles */
.calendar-container {
  display: grid;
  gap: 12px;
  margin-top: 5px;
  margin-bottom: 5px;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.calendar-header label {
  margin: 0;
}

.week-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.week-range-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-dark);
  min-width: 120px;
  text-align: center;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: all 160ms ease;
  line-height: 1;
}

.nav-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: var(--line);
  background: var(--bg);
  color: var(--muted);
}

.week-selector {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.day-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 66px;
  padding: 10px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  user-select: none;
  transition: all 160ms ease;
}

.day-card:hover:not(.disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.day-card.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.day-card.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: var(--bg);
  color: var(--ink);
}

.day-card .day-name {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: bold;
  color: var(--muted);
  margin-bottom: 2px;
}

.day-card.active .day-name {
  color: rgba(255, 255, 255, 0.85);
}

.day-card .day-date {
  font-size: 14px;
  font-weight: bold;
}

.time-slots-header {
  font-weight: 700;
  color: var(--ink);
  font-size: 14px;
  margin-top: 8px;
}

.time-slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
  min-height: 100px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Custom scrollbar for time slots */
.time-slots-grid::-webkit-scrollbar {
  width: 6px;
}
.time-slots-grid::-webkit-scrollbar-track {
  background: var(--soft-line);
  border-radius: 4px;
}
.time-slots-grid::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

.time-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 38px;
  padding: 7px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: all 160ms ease;
}

.time-slot:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.time-slot.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.hidden-inputs {
  display: none;
}

@media (max-width: 820px) {
  .booking-shell {
    grid-template-columns: 1fr;
  }

  .intro {
    border-right: 0;
    border-bottom: 1px solid var(--soft-line);
  }

  .details-list {
    display: none;
  }
}

/* Compact phone layout: retain readable inputs and comfortable touch targets. */
@media (max-width: 640px) {
  main {
    width: calc(100% - 12px);
    margin: 6px auto;
  }

  .intro { padding: 12px; }
  .form-panel { padding: 12px; }
  h1 { margin: 0; font-size: 20px; line-height: 1.25; }
  body.in-iframe .intro { padding-right: 48px; }

  .intro .eyebrow,
  .intro>p { display: none; }

  form { gap: 10px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid > div { min-width: 0; }
  label, legend { margin-bottom: 4px; font-size: 14px; }

  .grid input {
    min-width: 0;
    max-width: 100%;
    height: 44px;
    padding: 8px;
    font-size: 16px;
  }

  /* Keep Safari's native date control inside its grid column. */
  input[type="date"] { min-inline-size: 0; }
  input[type="date"]::-webkit-date-and-time-value { min-width: 0; text-align: left; }

  .patient-options { gap: 8px; }
  .patient-options label { min-height: 44px; padding: 6px; font-size: 14px; }
  button { width: 100%; }

  .calendar-container { gap: 8px; margin: 0; }
  .calendar-header { gap: 4px; margin-bottom: 0; }
  .week-nav { gap: 8px; }
  .nav-btn { width: 44px; height: 44px; min-height: 44px; }
  .week-selector { gap: 6px; }
  .day-card { min-height: 52px; padding: 6px 2px; }
  .day-card .day-date { font-size: 13px; }

  .time-slots-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    min-height: 0;
    align-content: start;
  }
  .time-slot { min-height: 44px; font-size: 12px; padding: 6px 2px; }
  #submit-button { min-height: 44px; padding: 8px 14px; }
}

@media (max-width: 359px) {
  .grid { grid-template-columns: 1fr; }
  .time-slots-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Checkbox styling */
.checkbox-group {
  display: grid;
  gap: 12px;
  margin-top: 5px;
  margin-bottom: 5px;
}

.checkbox-item {
  display: flex;
  align-items: start;
  gap: 10px;
}

.checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 3px 0 0 0;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.checkbox-item label {
  font-size: 13px;
  font-weight: normal;
  color: var(--muted);
  line-height: 1.4;
  margin: 0;
  cursor: pointer;
  user-select: none;
}

.checkbox-item label a {
  color: var(--accent);
  text-decoration: underline;
  font-weight: 600;
}

.checkbox-item label a:hover {
  color: var(--accent-dark);
}

body.in-iframe {
  background: var(--bg) !important;
}

body.in-iframe main {
  margin: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
}

body.in-iframe .booking-shell {
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

body.in-iframe .intro {
  background: var(--bg) !important;
  border-right: 1px solid var(--line) !important;
}
