/* ==========================================================================
   Design system for the Online Visit flow, the patient portal and the staff
   panel.

   Scoped to .ov-scope so it can never leak into the existing themed homepage.
   Colour tokens mirror the site's skin-1 palette so the new screens read as
   part of the same brand.
   ========================================================================== */

.ov-scope,
.ov-scope *,
.ov-scope *::before,
.ov-scope *::after {
  /* The themed public pages get this from style.css, but the staff panel does
     not load the theme -- without it every width:100% control overflows its
     container by its own padding and border. */
  box-sizing: border-box;
}

.ov-scope {
  /* Brand */
  --ov-primary: #00bde0;
  --ov-primary-strong: #009cbb;
  --ov-primary-ink: #00647a;
  --ov-primary-tint: #e6f9fd;
  --ov-navy: #031b4e;
  --ov-navy-soft: #1c3163;

  /* Neutrals */
  --ov-ink: #0f1e3d;
  --ov-body: #566593;
  --ov-muted: #8593b8;
  --ov-line: #e2e9f5;
  --ov-surface: #ffffff;
  --ov-canvas: #f5f8fd;

  /* Status */
  --ov-success: #0f9d6b;
  --ov-success-tint: #e6f7f0;
  --ov-warning: #b7791f;
  --ov-warning-tint: #fdf6e3;
  --ov-danger: #d64550;
  --ov-danger-tint: #fdecee;
  --ov-info-tint: #eef3ff;

  /* Scale */
  --ov-radius: 14px;
  --ov-radius-lg: 22px;
  --ov-radius-sm: 9px;
  --ov-shadow: 0 1px 2px rgba(3, 27, 78, 0.06), 0 8px 24px rgba(3, 27, 78, 0.07);
  --ov-shadow-lg: 0 18px 48px rgba(3, 27, 78, 0.13);
  --ov-space: 1rem;

  color: var(--ov-body);
  font-family: "iransans-light", "Vazirmatn", Tahoma, sans-serif;
  line-height: 1.85;
  direction: rtl;
  text-align: right;
}

@media (prefers-reduced-motion: reduce) {
  .ov-scope *,
  .ov-scope *::before,
  .ov-scope *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- Layout ------------------------------------------------------------- */

.ov-page {
  background: var(--ov-canvas);
  padding: clamp(1.5rem, 4vw, 4rem) 0 clamp(3rem, 6vw, 5rem);
}

.ov-container {
  width: min(1160px, 100% - 2rem);
  margin-inline: auto;
}

.ov-container--narrow {
  width: min(760px, 100% - 2rem);
}

.ov-stack > * + * {
  margin-top: var(--ov-space);
}

.ov-grid {
  display: grid;
  gap: clamp(1rem, 2vw, 1.75rem);
}

@media (min-width: 768px) {
  .ov-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .ov-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ov-grid--sidebar { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
}

/* --- Typography --------------------------------------------------------- */

.ov-scope h1,
.ov-scope h2,
.ov-scope h3,
.ov-scope h4 {
  color: var(--ov-navy);
  font-weight: 700;
  line-height: 1.4;
  margin: 0;
}

.ov-title { font-size: clamp(1.65rem, 3.4vw, 2.6rem); }
.ov-subtitle { font-size: clamp(1.15rem, 2vw, 1.5rem); }
.ov-lead { font-size: clamp(1rem, 1.6vw, 1.15rem); color: var(--ov-body); }

.ov-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  background: var(--ov-primary-tint);
  color: var(--ov-primary-ink);
  font-size: 0.85rem;
  font-weight: 700;
}

.ov-muted { color: var(--ov-muted); }
.ov-small { font-size: 0.875rem; }
.ov-center { text-align: center; }

/* --- Cards -------------------------------------------------------------- */

.ov-card {
  background: var(--ov-surface);
  border: 1px solid var(--ov-line);
  border-radius: var(--ov-radius-lg);
  padding: clamp(1.15rem, 2.4vw, 2rem);
  box-shadow: var(--ov-shadow);
}

.ov-card--flat { box-shadow: none; }

.ov-card__header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--ov-line);
}

/* --- Buttons ------------------------------------------------------------ */

.ov-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.7rem 1.6rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.ov-btn:hover { transform: translateY(-1px); }
.ov-btn:active { transform: translateY(0); }

.ov-btn:focus-visible,
.ov-scope a:focus-visible,
.ov-scope input:focus-visible,
.ov-scope select:focus-visible,
.ov-scope textarea:focus-visible,
.ov-scope button:focus-visible {
  outline: 3px solid var(--ov-primary-strong);
  outline-offset: 2px;
}

.ov-btn--primary {
  background: var(--ov-primary-strong);
  color: #fff;
  box-shadow: 0 8px 20px rgba(0, 156, 187, 0.28);
}
.ov-btn--primary:hover { background: var(--ov-primary-ink); color: #fff; }

.ov-btn--ghost {
  background: transparent;
  border-color: var(--ov-line);
  color: var(--ov-navy);
}
.ov-btn--ghost:hover { background: var(--ov-canvas); }

.ov-btn--danger { background: var(--ov-danger); color: #fff; }
.ov-btn--block { width: 100%; }
.ov-btn--sm { min-height: 38px; padding: 0.35rem 1rem; font-size: 0.875rem; }

.ov-btn[disabled],
.ov-btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.ov-btn.is-loading { pointer-events: none; opacity: 0.75; }
.ov-btn.is-loading::before {
  content: "";
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: ov-spin 0.7s linear infinite;
}

@keyframes ov-spin { to { transform: rotate(360deg); } }

/* --- Forms -------------------------------------------------------------- */

.ov-field { display: block; margin-bottom: 1.1rem; }

.ov-field__label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--ov-navy);
  font-weight: 700;
  font-size: 0.95rem;
}

.ov-field__label .ov-req { color: var(--ov-danger); margin-inline-start: 0.15rem; }

.ov-field__input,
.ov-scope input[type="text"],
.ov-scope input[type="tel"],
.ov-scope input[type="number"],
.ov-scope input[type="date"],
.ov-scope input[type="time"],
.ov-scope input[type="password"],
.ov-scope input[type="file"],
.ov-scope input[type="url"],
.ov-scope input[type="email"],
.ov-scope input[type="search"],
.ov-scope select,
.ov-scope textarea {
  width: 100%;
  max-width: 100%;
  min-height: 50px;
  padding: 0.7rem 1rem;
  border: 1.5px solid var(--ov-line);
  border-radius: var(--ov-radius-sm);
  background: #fff;
  color: var(--ov-ink);
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ov-scope textarea {
  min-height: 120px;
  max-height: 60vh;
  resize: vertical;
  line-height: 1.9;
  /* vertical only: horizontal resizing lets a textarea escape its card */
}

/* A pasted URL or token must wrap instead of widening the layout. */
.ov-scope .ov-card,
.ov-scope .ov-field { min-width: 0; }
.ov-scope .ov-field__help,
.ov-scope .ov-field__error { overflow-wrap: anywhere; }

.ov-scope input:focus,
.ov-scope select:focus,
.ov-scope textarea:focus {
  border-color: var(--ov-primary);
  box-shadow: 0 0 0 4px var(--ov-primary-tint);
}

.ov-field--error .ov-field__input,
.ov-scope input[aria-invalid="true"],
.ov-scope textarea[aria-invalid="true"],
.ov-scope select[aria-invalid="true"] {
  border-color: var(--ov-danger);
  background: var(--ov-danger-tint);
}

.ov-field__error {
  display: block;
  margin-top: 0.35rem;
  color: var(--ov-danger);
  font-size: 0.85rem;
  font-weight: 700;
}

.ov-field__help { display: block; margin-top: 0.35rem; color: var(--ov-muted); font-size: 0.85rem; }

.ov-choice {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.ov-choice label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 48px;
  padding: 0.4rem 1.1rem;
  border: 1.5px solid var(--ov-line);
  border-radius: 999px;
  cursor: pointer;
  background: #fff;
}

.ov-choice input { accent-color: var(--ov-primary-strong); width: auto; min-height: 0; }
.ov-choice label:hover { border-color: var(--ov-primary); }

.ov-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border: 1.5px solid var(--ov-line);
  border-radius: var(--ov-radius-sm);
  background: #fff;
  cursor: pointer;
}

.ov-checkbox input { width: auto; min-height: 0; margin-top: 0.4rem; accent-color: var(--ov-primary-strong); }

/* --- Steps -------------------------------------------------------------- */

.ov-steps {
  display: flex;
  gap: 0.5rem;
  list-style: none;
  margin: 0 0 2rem;
  padding: 0;
  counter-reset: ov-step;
}

.ov-steps li {
  flex: 1;
  padding-top: 0.85rem;
  border-top: 4px solid var(--ov-line);
  color: var(--ov-muted);
  font-size: 0.85rem;
  font-weight: 700;
  counter-increment: ov-step;
}

.ov-steps li::before {
  content: counter(ov-step) ". ";
}

.ov-steps li[aria-current="step"] { border-top-color: var(--ov-primary); color: var(--ov-navy); }
.ov-steps li.is-done { border-top-color: var(--ov-success); color: var(--ov-success); }

/* --- Badges ------------------------------------------------------------- */

.ov-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.8rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.ov-badge--neutral { background: var(--ov-info-tint); color: var(--ov-navy-soft); }
.ov-badge--success { background: var(--ov-success-tint); color: var(--ov-success); }
.ov-badge--warning { background: var(--ov-warning-tint); color: var(--ov-warning); }
.ov-badge--danger { background: var(--ov-danger-tint); color: var(--ov-danger); }
.ov-badge--primary { background: var(--ov-primary-tint); color: var(--ov-primary-ink); }

/* --- Alerts ------------------------------------------------------------- */

.ov-alert {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
  border-radius: var(--ov-radius);
  border: 1px solid transparent;
  font-weight: 600;
}

.ov-alert--success { background: var(--ov-success-tint); border-color: #bfe8d8; color: #0b6b4a; }
.ov-alert--error { background: var(--ov-danger-tint); border-color: #f5c6cb; color: #9b2c36; }
.ov-alert--warning { background: var(--ov-warning-tint); border-color: #f0e0b6; color: #8a5b12; }
.ov-alert--info { background: var(--ov-info-tint); border-color: #d2ddf7; color: var(--ov-navy-soft); }

/* --- Data display ------------------------------------------------------- */

.ov-dl {
  display: grid;
  gap: 0.85rem 1.5rem;
  margin: 0;
}

@media (min-width: 640px) {
  .ov-dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-dl__item--wide { grid-column: 1 / -1; }
}

.ov-dl__item { min-width: 0; }
.ov-dl dt { color: var(--ov-muted); font-size: 0.85rem; margin-bottom: 0.15rem; }
.ov-dl dd { margin: 0; color: var(--ov-ink); font-weight: 600; overflow-wrap: anywhere; }

.ov-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.ov-table {
  width: 100%;
  min-width: 640px;   /* only applies while the table is a table; see panel.css */
  border-collapse: collapse;
  font-size: 0.925rem;
}

.ov-table th,
.ov-table td {
  padding: 0.85rem 0.9rem;
  text-align: right;
  border-bottom: 1px solid var(--ov-line);
  vertical-align: middle;
}

.ov-table th {
  color: var(--ov-muted);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.ov-table tbody tr:hover { background: var(--ov-canvas); }
.ov-table td.ov-num { font-variant-numeric: tabular-nums; }

/* --- Empty / loading states -------------------------------------------- */

.ov-empty {
  padding: clamp(2rem, 6vw, 3.5rem) 1.5rem;
  text-align: center;
  color: var(--ov-muted);
}

.ov-empty__icon {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: var(--ov-primary-tint);
  color: var(--ov-primary-ink);
  font-size: 1.8rem;
}

.ov-skeleton {
  background: linear-gradient(90deg, #eef2f9 25%, #f7fafd 50%, #eef2f9 75%);
  background-size: 200% 100%;
  animation: ov-shimmer 1.4s infinite;
  border-radius: var(--ov-radius-sm);
  min-height: 1rem;
}

@keyframes ov-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* --- Timeline ----------------------------------------------------------- */

.ov-timeline { list-style: none; margin: 0; padding: 0; position: relative; }

.ov-timeline::before {
  content: "";
  position: absolute;
  inset-block: 0.6rem;
  inset-inline-start: 9px;
  width: 2px;
  background: var(--ov-line);
}

.ov-timeline li {
  position: relative;
  padding-inline-start: 2rem;
  padding-bottom: 1.15rem;
}

.ov-timeline li::before {
  content: "";
  position: absolute;
  inset-inline-start: 3px;
  top: 0.55rem;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--ov-primary);
}

.ov-timeline li.is-done::before { border-color: var(--ov-success); background: var(--ov-success); }

/* --- Misc --------------------------------------------------------------- */

.ov-code {
  display: inline-block;
  padding: 0.4rem 1rem;
  border-radius: var(--ov-radius-sm);
  background: var(--ov-navy);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.22em;
  font-variant-numeric: tabular-nums;
}

.ov-price {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  color: var(--ov-navy);
}

.ov-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
}

.ov-thumb {
  display: block;
  aspect-ratio: 1;
  border-radius: var(--ov-radius-sm);
  overflow: hidden;
  border: 1px solid var(--ov-line);
  background: var(--ov-canvas);
}

.ov-thumb img { width: 100%; height: 100%; object-fit: cover; }

.ov-file {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--ov-line);
  border-radius: var(--ov-radius-sm);
  background: #fff;
  text-decoration: none;
  color: var(--ov-ink);
}

.ov-file:hover { border-color: var(--ov-primary); background: var(--ov-primary-tint); }

.ov-scope audio { width: 100%; }

.ov-faq details {
  border: 1px solid var(--ov-line);
  border-radius: var(--ov-radius);
  background: #fff;
  padding: 0.35rem 1.15rem;
}

.ov-faq summary {
  padding: 0.85rem 0;
  cursor: pointer;
  font-weight: 700;
  color: var(--ov-navy);
  list-style: none;
}

.ov-faq summary::-webkit-details-marker { display: none; }
.ov-faq summary::after { content: "＋"; float: left; color: var(--ov-primary-strong); }
.ov-faq details[open] summary::after { content: "－"; }
.ov-faq details p { margin: 0 0 1rem; }

.ov-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media print {
  .ov-no-print { display: none !important; }
  .ov-page { background: #fff; padding: 0; }
  .ov-card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
}

/* ==========================================================================
   Follow-up conversation. Shared by the patient's result page and the staff
   panel, so it lives here rather than in panel.css.
   ========================================================================== */

.chat { display: flex; flex-direction: column; gap: 0.85rem; }

.chat__scroll {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: 460px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-inline-end: 0.3rem;
}

.chat__msg { max-width: min(78%, 560px); }
.chat__msg--patient { align-self: flex-start; }
.chat__msg--doctor { align-self: flex-end; }

.chat__bubble {
  padding: 0.8rem 1rem;
  border-radius: 16px;
  line-height: 1.9;
  font-size: 0.94rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat__msg--patient .chat__bubble {
  background: #fff;
  border: 1px solid var(--ov-line);
  border-start-start-radius: 5px;
  color: var(--ov-ink);
}

.chat__msg--doctor .chat__bubble {
  background: var(--ov-primary-tint);
  border: 1px solid var(--ov-primary);
  border-start-end-radius: 5px;
  color: var(--ov-primary-ink);
}

.chat__meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.3rem;
  font-size: 0.75rem;
  color: var(--ov-muted);
}

.chat__msg--doctor .chat__meta { justify-content: flex-end; }

.chat__unread {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ov-danger);
}

.chat__composer { display: flex; flex-direction: column; gap: 0.6rem; }
.chat__composer textarea { resize: vertical; min-height: 80px; }
.chat__composer .chat__send { align-self: flex-start; }

.chat__empty {
  text-align: center;
  color: var(--ov-muted);
  font-size: 0.9rem;
  padding: 1.5rem 1rem;
}

@media (max-width: 575px) {
  .chat__msg { max-width: 92%; }
  .chat__composer .chat__send { align-self: stretch; }
}

/* ==========================================================================
   Mobile refinements

   Applied across the online visit flow, the patient portal and the panel.
   Everything here is about the hand holding the phone: targets big enough to
   hit, text big enough to read, and nothing that can overflow the viewport.
   ========================================================================== */

/* iOS zooms the page when a focused input is under 16px. Keeping the control
   font at 16px on small screens avoids that jump entirely. */
@media (max-width: 767px) {
  .ov-scope input,
  .ov-scope select,
  .ov-scope textarea {
    font-size: 16px;
  }

  .ov-scope {
    line-height: 1.9;
  }

  /* Comfortable, thumb-sized targets. 44px is the accessibility floor. */
  .ov-scope .ov-btn,
  .ov-scope button,
  .ov-scope summary,
  .ov-scope .ov-chip {
    min-height: 46px;
  }

  .ov-scope .ov-btn--sm { min-height: 42px; }

  /* Stacked buttons read better than a cramped row. */
  .ov-scope .ov-card__header { gap: 0.5rem; }

  /* A grid never becomes multi-column on a phone. */
  .ov-scope .ov-grid--2,
  .ov-scope .ov-grid--3,
  .ov-scope .ov-grid--sidebar { grid-template-columns: 1fr; }

  .ov-scope .ov-title { font-size: clamp(1.5rem, 6vw, 1.9rem); line-height: 1.5; }
  .ov-scope .ov-lead { font-size: 1rem; }
}

/* Nothing may push the page sideways, on any screen. */
.ov-scope,
.ov-scope * { max-width: 100%; }
.ov-scope img,
.ov-scope video,
.ov-scope audio { height: auto; }
.ov-scope pre,
.ov-scope code { overflow-x: auto; }

/* Visible keyboard focus everywhere, not just on inputs. */
.ov-scope a:focus-visible,
.ov-scope button:focus-visible,
.ov-scope summary:focus-visible,
.ov-scope [tabindex]:focus-visible {
  outline: 2px solid var(--ov-primary-strong);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Long unbroken strings -- tracking codes, URLs, national codes -- wrap. */
.ov-scope .ov-dl dd,
.ov-scope .ov-num,
.ov-scope td { overflow-wrap: anywhere; }

/* Loading state on a submitting button, so a slow network still feels alive. */
.ov-scope .ov-btn[aria-busy="true"] {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.ov-scope .ov-btn[aria-busy="true"]::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  color: #fff;
  animation: ov-spin 0.7s linear infinite;
}

@keyframes ov-spin { to { transform: rotate(360deg); } }
