/* ============================================================================
   components.css — shared UI PRIMITIVES (single source of truth).

   Loaded by BOTH portals (main.ejs + admin.ejs) AFTER base-tokens.css and the
   per-portal token file, BEFORE the big per-portal stylesheet — so a portal
   can still override a primitive if it truly must, but both sides get the
   same component by default.

   ── .btn ──────────────────────────────────────────────────────────────────
   SIZE and COLOUR are separate, so any treatment can be any size:
     • size:       (default) small  ·  .btn--lg  large (modal / hero rows)
     • treatment:  .btn--primary  dark ink fill        (admin workhorse / neutral)
                   .btn--cta      teal brand gradient  (the main action — patient hero)
                   .btn--secondary light-grey outline  (alt action: Cancel / Done)
                   .btn--ghost    transparent + quiet  (tertiary / dismiss)
                   .btn--danger   red fill             (destructive)
   `:disabled` greys any button out.

   Patient note: the brand primary is TEAL, so most patient main-actions use
   .btn--cta. Dark .btn--primary is the neutral button (e.g. the cookie banner)
   and the admin workhorse.
   ============================================================================ */
.btn {

  font: inherit;
  font-size: 13px;
  font-weight: var(--weight-semibold);
  padding: 9px var(--space-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s, color 0.12s;

}

.btn:disabled {
 background: #ccc; border-color: #ccc; color: #fff; cursor: not-allowed; box-shadow: none; transform: none; 
}


/* ── Size ─────────────────────────────────────────────────────────────── */
.btn--lg {
 padding: 13px 22px; font-size: 15px; border-radius: 10px; 
}


/* ── Treatments (colour only — size-agnostic) ─────────────────────────── */
.btn--primary {
 background: #2b3039; color: #fff; border-color: #2b3039; 
}

.btn--primary:hover {
 transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26, 43, 60, 0.20); 
}


.btn--cta {
 background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #fff; border: none; 
}


/* Secondary = the app's dominant "alt action": a quiet light-grey outline. */
.btn--secondary {
 background: transparent; color: #5A6B7C; border-color: #e0ddd8; 
}

.btn--secondary:hover {
 background: var(--page-bg); color: #2b3039; border-color: #c9c4bd; 
}


.btn--ghost {
 background: transparent; color: var(--text-secondary); padding: 9px 10px; 
}

.btn--ghost:hover {
 color: #2b3039; 
}


/* Inverse — for buttons sitting ON a coloured (teal) hero panel, where the
   normal teal fill would vanish. .btn--inverse = white fill / teal text (the
   main action); .btn--inverse-outline = transparent / white outline (alt). */
.btn--inverse {
 background: #fff; color: var(--primary); border-color: #fff; 
}

.btn--inverse:hover {
 transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.20); 
}

.btn--inverse-outline {
 background: transparent; color: #fff; border-color: #fff; 
}

.btn--inverse-outline:hover {
 background: rgba(255, 255, 255, 0.12); 
}


/* ── Shape modifier ───────────────────────────────────────────────────── */
.btn--pill {
 border-radius: var(--radius-full); 
}

.btn--danger {
  background: #C0392B; color: #fff; border-color: #C0392B;
}

.btn--danger:hover {
  background: #A93226; border-color: #A93226; box-shadow: 0 4px 12px rgba(192, 57, 43, 0.20);
}


/* ============================================================================
   .authm — shared passwordless auth modal (full-screen overlay, 6-digit OTP).
   Loaded on both portals. Teal resolves via --primary on patient and the
   #2D8B7A fallback on admin; serif title via --font-display fallback.
   ============================================================================ */
.authm {
 position: fixed; inset: 0; z-index: var(--z-modal, 9100); display: flex; align-items: center; justify-content: center; padding: 20px; 
}

.authm[hidden] {
 display: none; 
}

.authm__backdrop {
 position: absolute; inset: 0; background: rgba(20, 22, 26, 0.55); backdrop-filter: blur(3px); 
}

.authm__panel {

  position: relative;
  width: 100%; max-width: 420px;
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: 0 24px 64px rgba(20, 22, 26, 0.22);
  animation: authmIn 180ms cubic-bezier(0.16, 1, 0.3, 1);

}

@keyframes authmIn {
 from {
 opacity: 0; transform: translateY(12px) scale(0.98); 
}
 to {
 opacity: 1; transform: none; 
}
 
}

.authm__x {

  position: absolute; top: 18px; right: 18px;
  width: 32px; height: 32px; border: 0; border-radius: 50%; padding: 0;
  background: transparent; color: var(--text-secondary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s, color 0.12s;

}

.authm__x svg {
 display: block; 
}

.authm__x:hover {
 background: rgba(20,22,26,0.06); color: #2b3039; 
}

.authm__title {
 font-family: var(--font-body); font-size: 24px; line-height: 1.25; font-weight: 600; color: #2b3039; margin: 0 0 8px; letter-spacing: -0.02em; padding-right: 28px; text-align: left !important;
}

.authm__sub {
 font-size: 14.5px; line-height: 1.55; color: var(--text-secondary); margin: 0 0 22px; 
}

.authm__input {

  width: 100%; box-sizing: border-box;
  padding: 13px 15px; margin: 0 0 12px;
  border: 1.5px solid #e0ddd8; border-radius: 8px;
  font: inherit; font-size: 15px; color: #2b3039;
  transition: border-color 0.12s, box-shadow 0.12s;

}

.authm__input:focus {
 outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent); 
}

.authm__input--code {
 text-align: center; font-size: 26px; letter-spacing: 0.4em; font-weight: 600; padding-left: 0.4em; 
}

.authm__btn {

  width: 100%; box-sizing: border-box;
  padding: 14px 20px; margin-top: 0;
  background: var(--primary); color: #fff;
  border: 0; border-radius: 8px;
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: filter 0.12s, opacity 0.12s;

}

.authm__btn:hover {
 filter: brightness(1.04); 
}

.authm__btn:disabled {
 opacity: 0.55; cursor: progress; 
}

.authm__err {
 font-size: 13px; color: #C0392B; margin: -4px 0 12px; line-height: 1.4; 
}

.authm__link {
 background: 0; border: 0; padding: 0; font: inherit; font-size: inherit; color: var(--primary); font-weight: 600; cursor: pointer; text-decoration: none; 
}

.authm__link:hover {
 text-decoration: underline; 
}

.authm__link:disabled {
 color: #9a9a95; cursor: default; text-decoration: none; 
}

.authm__resend {
 font-size: 13px; color: var(--text-secondary); margin: 16px 0 0; text-align: center; 
}

.authm__alt {
 font-size: 13px; color: var(--text-secondary); margin: 16px 0 0; text-align: center; 
}

.authm__alt a {
 color: var(--primary); font-weight: 600; text-decoration: none; 
}

.authm__alt a:hover {
 text-decoration: underline; 
}

.authm__countdown {
 color: #9a9a95; 
}

.authm__check {
 display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; line-height: 1.5; color: #5a5a55; margin: 0 0 12px; cursor: pointer; 
}

.authm__check input {
 margin-top: 2px; flex: 0 0 auto; accent-color: var(--primary); width: 16px; height: 16px; 
}

.authm__check a {
 color: var(--primary); 
}

.authm__tick {
 width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 50%; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); display: flex; align-items: center; justify-content: center; 
}

.authm [data-authm-step] {
 text-align: left; 
}

.authm [data-authm-step="success"] {
 text-align: center; 
}


/* Mobile: full-width sheet pinned to the bottom for thumb reach. */
@media (max-width: 520px) {

  .authm {
 padding: 0; align-items: flex-end;
 /* The modal is pinned to the visual viewport in JS (auth-modal.js pinViewport)
    so it stays above the iOS soft keyboard — see that comment for the why. */
}

  .authm__panel {
 max-width: none; border-radius: 16px 16px 0 0; padding: 30px 22px calc(24px + env(safe-area-inset-bottom)); 
}

  @keyframes authmIn {
 from {
 opacity: 0; transform: translateY(100%); 
}
 to {
 opacity: 1; transform: none; 
}
 
}


}


/* ============================================================================
   .toast — shared toast notification primitive (success/error/warning).
   Used by Toast helper in core/components.js across both client and admin.
   ============================================================================ */
.toast-container {

  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: var(--z-toast, 10000);
  pointer-events: none;
  max-width: 360px;
  width: calc(100% - 48px);

}


.toast {

  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
  color: var(--text, #2b3039);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.05);
  font-family: var(--font-body, inherit);
  font-size: 13.5px;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transition: opacity 0.3s, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);

}


.toast.show {

  opacity: 1;
  transform: translateY(0) scale(1);

}


.toast-message {

  flex: 1;
  font-weight: var(--weight-medium, 500);

}


.toast-close {

  background: none;
  border: none;
  color: var(--text-faint, #9a9a95);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.12s;

}

.toast-close:hover {

  color: var(--text, #2b3039);

}


/* On mobile, center the toasts at the bottom */
@media (max-width: 520px) {

  .toast-container {

    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    right: auto;
    width: calc(100% - 32px);
  
}


}


/* Prevent iOS Safari auto-zoom on focus by forcing 16px font-size on mobile inputs */
@media (max-width: 768px) {

  input[type="text"], input[type="email"], input[type="tel"], input[type="search"], input[type="password"], input[type="number"], textarea, select {

    font-size: 16px !important;
  
}


}


/* ============================================================================
   .inner-page-header — shared header pattern for public pages (single source of truth).
   Standardises headings, labels, margins, and descriptions for inner pages
   (help, contact, why-join, faqs, blog, how-it-works).
   ============================================================================ */
.inner-page-header {

  text-align: center;
  padding: var(--space-2xl) 0 var(--space-xl);
  max-width: 800px;
  margin: 0 auto var(--space-lg);
  display: flex;
  flex-direction: column;
  align-items: center;

}


.inner-page-header .section-label {

  margin-bottom: var(--space-sm) !important;

}


.inner-page-header h1 {

  font-family: var(--font-display) !important;
  font-size: clamp(2.25rem, 5vw, 3.25rem) !important;
  font-weight: 800 !important;
  line-height: 1.15 !important;
  letter-spacing: -0.02em !important;
  color: var(--text-primary, #2b3039) !important;
  margin: var(--space-xs) 0 var(--space-md) !important;
  -webkit-background-clip: initial !important;
  background-clip: initial !important;
  -webkit-text-fill-color: initial !important;
  background: none !important;

}


.inner-page-header p, .inner-page-header .inner-page-subtitle {

  font-size: 1.0625rem !important;
  color: var(--text-secondary) !important;
  max-width: 650px !important;
  margin: var(--space-xs) auto 0 !important;
  line-height: 1.7 !important;

}


/* Shared Conversation Input/Composer */
.conversation-input-area {

    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-light);
    background: var(--surface);
    flex-shrink: 0;
    margin-bottom: var(--space-md);

}


.conv-input-wrapper {

    display: flex;
    align-items: flex-end;
    gap: var(--space-sm);
    background: var(--bg-warm);
    border-radius: var(--radius-lg);
    padding: var(--space-sm);

}


.conv-attach-btn {

    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition);

}


.conv-attach-btn:hover {

    color: var(--primary);
    background: var(--primary-subtle);

}


.conv-input {

    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.9375rem;
    color: var(--text);
    resize: none;
    padding: var(--space-sm) 0;
    max-height: 120px;
    line-height: 1.5;

}


.conv-input::placeholder {

    color: var(--text-muted);

}


.conv-send-btn {

    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--primary);
    border: none;
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition);

}


.conv-send-btn:disabled {

    background: var(--border);
    color: var(--text-muted);
    cursor: not-allowed;

}


.conv-send-btn:not(:disabled):hover {

    background: var(--primary-dark);

}


/* Conversation messages */
.conversation-messages {

    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    min-height: 0;
    background: var(--bg-warm) !important;

}


.date-separator {

    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md) 0;

}


.date-separator span {

    padding: var(--space-xs) var(--space-md);
    background: var(--bg-warm);
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    border-radius: var(--radius-full);

}


.conv-message {

    display: flex;
    gap: var(--space-sm);
    max-width: 85%;

}


.conv-message.clinic {

    align-self: flex-start;

}


.conv-message.user {

    align-self: flex-end;
    flex-direction: row-reverse;

}


.conv-msg-avatar {

    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    object-fit: cover;
    flex-shrink: 0;

}


.conv-message.user .conv-msg-avatar {

    display: none;

}


.conv-msg-content {

    background: #FFFFFF !important;
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: var(--radius-sm);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);

}


.conv-message.user .conv-msg-content {

    /* Darker teal than --primary so white bubble text meets WCAG AA (4.5:1):
       white on --primary (#2D8B7A) was only 4.12:1. --primary-dark gives 6.3:1. */
    background: var(--primary-dark, #1F6B5F) !important;
    color: var(--text-inverse) !important;
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-sm);
    box-shadow: none;

}


.conv-msg-content p {

    font-size: 0.9375rem;
    line-height: 1.5;
    margin-bottom: var(--space-xs);

}


.conv-msg-content p:last-of-type {

    margin-bottom: var(--space-sm);

}


.conv-msg-time {

    display: block;
    font-size: 0.6875rem;
    color: var(--text-muted);

}


.conv-message.user .conv-msg-time {

    color: rgba(255,255,255,0.9);

}


.conv-msg-status {

    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.6875rem;
    color: rgba(255,255,255,0.9);
    margin-top: 2px;

}

/* ── Confirm Modal & Transitions ────────────────────────────────────────── */
.confirm-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.confirm-modal-panel {
  background: #fff;
  border-radius: 20px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  font-family: inherit;
}

html[data-theme="dark"] .confirm-modal-panel {
  background: #1C1C1E;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .confirm-modal-panel h3 {
  color: #fff !important;
}

html[data-theme="dark"] .confirm-modal-panel p {
  color: #aaa !important;
}

/* Spring Entry Animation for Modals on Desktop */
@keyframes modalSpringIn {
  from { opacity: 0; transform: scale(0.92) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@media (min-width: 768px) {
  .modal-container,
  .authm__panel,
  .confirm-modal-panel {
    animation: modalSpringIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }
}

/* Global Micro-Haptic Scale Transition (Tactile Press Feedback) */
.btn,
.nav-icon,
.cs-card,
.sl-card,
.dropdown-item,
.help-popover__link,
.cs-drawer__link,
.cs-drawer__bottom-link {
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.btn:active,
.nav-icon:active,
.cs-card:active,
.sl-card:active,
.dropdown-item:active,
.help-popover__link:active,
.cs-drawer__link:active,
.cs-drawer__bottom-link:active {
  transform: scale(0.96) !important;
}

/* Hard hidden rules to prevent WebKit scroll compositing layers from leaking through */
.hidden,
[hidden],
.hidden *,
[hidden] * {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  transform: none !important;
  animation: none !important;
  transition: none !important;
  pointer-events: none !important;
}


