/* ============================================================
   360 Med Booking Widget  –  widget.css
   Scoped entirely under #apt-widget-shell to avoid conflicts.
   ============================================================ */

#apt-widget-shell *,
#apt-widget-shell *::before,
#apt-widget-shell *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

#apt-widget-shell {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0 12px;
  width: 100%;
  font-family: 'DM Sans', 'Open Sans', sans-serif;
  position: relative;
  z-index: 1;

  /* ── Design tokens ── */
  --tmed-green:        #0d5c45;
  --tmed-green-light:  #e6f4ef;
  --tmed-green-mid:    #1a7a5e;
  --tmed-amber:        #92400e;
  --tmed-amber-light:  #fef3c7;
  --tmed-amber-bg:     #fffbeb;
  --tmed-slate:        #0f172a;
  --tmed-slate-mid:    #475569;
  --tmed-slate-light:  #94a3b8;
  --tmed-border:       #e2e8f0;
  --tmed-bg:           #f8fafc;
  --tmed-white:        #ffffff;
  --tmed-radius:       16px;
  --tmed-widget-h:     500px;
}

/* ── Widget shell ───────────────────────────────────────────── */
#apt-widget-shell .widget {
  width: 100%;
  max-width: 540px;
  height: var(--tmed-widget-h);
  background: var(--tmed-white);
  border-radius: 24px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.10);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────────── */
#apt-widget-shell .widget-header {
  background: linear-gradient(135deg, var(--tmed-green) 0%, var(--tmed-green-mid) 100%);
  padding: 26px 28px 22px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.2s ease;
  max-height: 200px;
  opacity: 1;
}
#apt-widget-shell .widget-header.hidden {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  pointer-events: none;
}
#apt-widget-shell .widget-header::before {
  content: '';
  position: absolute;
  right: -30px;
  top: -30px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
}
#apt-widget-shell .widget-header::after {
  content: '';
  position: absolute;
  right: 40px;
  top: 50px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
}

#apt-widget-shell .header-title {
  font-family: 'DM Serif Display', serif;
  font-size: 26px;
  color: #fff;
  line-height: 1.2;
  position: relative;
  z-index: 1;
}

/* ── Hours banner ───────────────────────────────────────────── */
#apt-widget-shell .hours-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 9px 14px;
  position: relative;
  z-index: 1;
}

#apt-widget-shell .hours-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  animation: tmed-pulse 2s infinite;
}
#apt-widget-shell .hours-dot.dot-green { background: #4ade80; }
#apt-widget-shell .hours-dot.dot-amber { background: #fbbf24; }

@keyframes tmed-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.7; transform: scale(1.2); }
}

#apt-widget-shell .hours-text {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
  line-height: 1.4;
}
#apt-widget-shell .hours-text strong { color: #fff; }

/* ── Body ───────────────────────────────────────────────────── */
#apt-widget-shell .widget-body {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── Step bar ───────────────────────────────────────────────── */
#apt-widget-shell .steps {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
}
#apt-widget-shell .step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--tmed-slate-light);
  font-weight: 500;
}
#apt-widget-shell .step.active { color: var(--tmed-green); font-weight: 600; }
#apt-widget-shell .step.done   { color: var(--tmed-slate-mid); }

#apt-widget-shell .step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--tmed-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--tmed-slate-light);
  flex-shrink: 0;
}
#apt-widget-shell .step.active .step-num { background: var(--tmed-green); color: #fff; }
#apt-widget-shell .step.done   .step-num { background: var(--tmed-green-light); color: var(--tmed-green); }

#apt-widget-shell .step-sep {
  flex: 1;
  height: 1px;
  background: var(--tmed-border);
}

/* ── Fade-up animation ──────────────────────────────────────── */
@keyframes tmed-fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
#apt-widget-shell .anim { animation: tmed-fadeUp 0.22s ease both; }

/* ── Section label ──────────────────────────────────────────── */
#apt-widget-shell .section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tmed-slate-light);
  margin-bottom: 10px;
}

/* ── Type cards (Step 1) ────────────────────────────────────── */
#apt-widget-shell .type-grid { display: flex; flex-direction: column; gap: 9px; }

#apt-widget-shell .type-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 16px;
  border-radius: var(--tmed-radius);
  border: 2px solid var(--tmed-border);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s, box-shadow 0.2s;
  background: var(--tmed-white);
  position: relative;
  overflow: hidden;
  /* Accessibility: make div keyboard-focusable */
  outline-offset: 2px;
}
#apt-widget-shell .type-card:focus-visible {
  outline: 2px solid var(--tmed-green);
}
#apt-widget-shell .type-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: 4px 0 0 4px;
  background: var(--tmed-green);
  opacity: 0;
  transition: opacity 0.2s;
}
#apt-widget-shell .type-card:hover,
#apt-widget-shell .type-card:focus-visible {
  border-color: var(--tmed-green);
  background: var(--tmed-green-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(13, 92, 69, 0.12);
}
#apt-widget-shell .type-card:hover::before,
#apt-widget-shell .type-card:focus-visible::before { opacity: 1; }
#apt-widget-shell .type-card:active { transform: scale(0.98); }

#apt-widget-shell .type-icon {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: var(--tmed-green-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#apt-widget-shell .type-info  { flex: 1; }
#apt-widget-shell .type-name  { font-size: 14px; font-weight: 600; color: var(--tmed-slate); }
#apt-widget-shell .type-desc  { font-size: 12px; color: var(--tmed-slate-mid); margin-top: 2px; }
#apt-widget-shell .type-arrow {
  color: var(--tmed-slate-light);
  font-size: 20px;
  transition: transform 0.2s, color 0.2s;
}
#apt-widget-shell .type-card:hover .type-arrow,
#apt-widget-shell .type-card:focus-visible .type-arrow {
  transform: translateX(3px);
  color: var(--tmed-green);
}

/* ── Back button ────────────────────────────────────────────── */
#apt-widget-shell .back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--tmed-green);
  cursor: pointer;
  margin-bottom: 12px;
  padding: 5px 10px;
  border-radius: 8px;
  transition: background 0.15s;
  width: fit-content;
  flex-shrink: 0;
  border: none;
  background: transparent;
}
#apt-widget-shell .back-btn:hover,
#apt-widget-shell .back-btn:focus-visible { background: var(--tmed-green-light); outline: none; }

/* ── Chosen label ───────────────────────────────────────────── */
#apt-widget-shell .chosen-label {
  font-size: 13px;
  color: var(--tmed-slate-mid);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}
#apt-widget-shell .chosen-label strong { color: var(--tmed-slate); }

/* ── Hour options (Step 2) ──────────────────────────────────── */
#apt-widget-shell .hours-choice { display: flex; flex-direction: column; gap: 10px; }

#apt-widget-shell .hour-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: var(--tmed-radius);
  border: 2px solid var(--tmed-border);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s, box-shadow 0.2s;
  background: var(--tmed-white);
  position: relative;
  outline-offset: 2px;
}
#apt-widget-shell .hour-option:hover  { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.1); }
#apt-widget-shell .hour-option:active { transform: scale(0.98); }
#apt-widget-shell .hour-option:focus-visible { outline: 2px solid var(--tmed-green); }

#apt-widget-shell .hour-option.opt-in  { border-color: rgba(13, 92, 69, 0.3); }
#apt-widget-shell .hour-option.opt-in:hover,
#apt-widget-shell .hour-option.opt-in:focus-visible  { border-color: var(--tmed-green); background: var(--tmed-green-light); }

#apt-widget-shell .hour-option.opt-out { border-color: rgba(180, 83, 9, 0.25); }
#apt-widget-shell .hour-option.opt-out:hover,
#apt-widget-shell .hour-option.opt-out:focus-visible { border-color: #b45309; background: var(--tmed-amber-bg); }

#apt-widget-shell .rec-badge {
  position: absolute;
  top: -1px;
  right: 14px;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 0 0 8px 8px;
}
#apt-widget-shell .rec-badge.rec-green { background: var(--tmed-green); }
#apt-widget-shell .rec-badge.rec-amber { background: #b45309; }

#apt-widget-shell .hour-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#apt-widget-shell .opt-in  .hour-icon { background: var(--tmed-green-light); }
#apt-widget-shell .opt-out .hour-icon { background: var(--tmed-amber-light); }

#apt-widget-shell .hour-info { flex: 1; }
#apt-widget-shell .hour-name { font-size: 15px; font-weight: 700; }
#apt-widget-shell .opt-in  .hour-name { color: var(--tmed-green); }
#apt-widget-shell .opt-out .hour-name { color: var(--tmed-amber); }
#apt-widget-shell .hour-time { font-size: 12px; color: var(--tmed-slate-mid); margin-top: 3px; line-height: 1.5; }
#apt-widget-shell .hour-arrow { font-size: 20px; color: var(--tmed-slate-light); }
#apt-widget-shell .opt-in:hover  .hour-arrow { color: var(--tmed-green); }
#apt-widget-shell .opt-out:hover .hour-arrow { color: #b45309; }

/* ── Content / scroll areas ─────────────────────────────────── */
#apt-widget-shell .content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: visible;
  padding-bottom: 20px;
  min-height: 0;
}
#apt-widget-shell .content-area.step3-mode {
  overflow: hidden;
  padding-bottom: 0;
}
#apt-widget-shell .scroll-inner {
  flex: 1;
  overflow: visible;
  padding-right: 2px;
  -webkit-overflow-scrolling: touch;
}

/* ── iFrame (Step 3) ────────────────────────────────────────── */
#apt-widget-shell .iframe-outer {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#apt-widget-shell .iframe-wrap {
  flex: 1;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--tmed-border);
}
#apt-widget-shell .iframe-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 520px) {
  #apt-widget-shell { padding: 0; }
  #apt-widget-shell .widget { height: auto; border-radius: 0; box-shadow: none; overflow: visible; }
  #apt-widget-shell .widget-header { padding: 20px 16px 18px; }
  #apt-widget-shell .header-title  { font-size: 22px; }
  #apt-widget-shell .widget-body   { padding: 16px 16px 24px; }
  #apt-widget-shell .content-area  { height: auto; overflow: visible; padding-bottom: 16px; min-height: unset; }
  #apt-widget-shell .scroll-inner  { overflow: visible; height: auto; }
  #apt-widget-shell .type-card,
  #apt-widget-shell .hour-option   { padding: 13px; }
  #apt-widget-shell .iframe-wrap   { flex: none; height: 70vh; }
  #apt-widget-shell .iframe-outer  { flex: none; }
}

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #apt-widget-shell .anim,
  #apt-widget-shell .hours-dot { animation: none; }
  #apt-widget-shell .type-card,
  #apt-widget-shell .hour-option { transition: none; }
}
