/* Presentation only: named routes, forms, document orientation and domain
   authorization remain owned by the existing Laravel views/controllers. */
html {
  accent-color: var(--rd-primary);
  text-size-adjust: 100%;
}
/* Avoid mixing old surfaces and new text colors during a theme swap. Normal
   hover and drawer motion resumes after the new palette has been painted. */
html.rd-theme-changing body[data-brand] * {
  transition: none !important;
}
html body[data-brand="royadarman"] {
  background: var(--rd-canvas);
  color: var(--rd-text);
}
body[data-brand] :is(h1, h2, h3, h4) {
  color: var(--rd-heading);
}
body[data-brand]
  :is(.lapis, .auth-aside, .clinic-workspace-hero)
  :is(h1, h2, h3) {
  color: #fff;
}
body[data-brand]
  :is(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--rd-focus);
  outline-offset: 3px;
}
body[data-brand] :is(.btn, .button) {
  min-block-size: 44px;
  border-radius: var(--rd-radius-control);
  color: var(--rd-link);
  background: var(--rd-surface);
  border-color: var(--rd-line);
}
body[data-brand] :is(.btn.primary, .button.primary) {
  background: var(--rd-primary);
  color: var(--rd-primary-text);
  border-color: var(--rd-primary);
}
body[data-brand] :is(.btn.primary, .button.primary):hover {
  background: var(--rd-primary-hover);
}
body[data-brand] :is(.button.secondary, .btn.accent) {
  background: var(--rd-accent);
  color: var(--rd-accent-text);
  border-color: var(--rd-accent);
}
body[data-brand] :is(.btn.danger, .danger-text) {
  color: var(--rd-danger);
}
body[data-brand] :is(input, select, textarea) {
  color: var(--rd-text);
  background: var(--rd-surface);
  border-color: var(--rd-line);
}
body[data-brand] :is(input, textarea)::placeholder {
  color: var(--rd-muted);
  opacity: 1;
}
body[data-brand] :is(.muted, .section-subtitle, .large-copy, .hero-lead) {
  color: var(--rd-muted);
}
body[data-brand] :is(.notice, .alert, .status) {
  color: var(--rd-text);
  background: var(--rd-surface-soft);
  border-color: var(--rd-line);
}
body[data-brand] :is(.notice.error, .notice.danger, .errors, .alert.error) {
  color: var(--rd-danger);
  background: var(--rd-danger-surface);
  border-color: var(--rd-danger);
}
body[data-brand] :is(.notice.success, .alert.ok) {
  color: var(--rd-success);
  background: var(--rd-success-surface);
  border-color: var(--rd-success);
}

/* The sidebar starts at the locale's reading edge; imagery/charts are intact. */
html body[data-brand] .app-shell {
  direction: inherit;
  grid-template-columns: var(--rd-sidebar-width) minmax(0, 1fr);
  grid-template-areas: "sidebar main";
}
html body[data-brand] .app-sidebar {
  grid-area: sidebar;
}
html body[data-brand] .app-main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  min-inline-size: 0;
}
html[dir="rtl"] body[data-brand] :is(.app-sidebar, .app-main) {
  direction: rtl;
}
html[dir="ltr"] body[data-brand] :is(.app-sidebar, .app-main) {
  direction: ltr;
}
html body[data-brand] .app-sidebar {
  background: var(--rd-surface);
  color: var(--rd-text);
  border: 0;
  border-inline-end: 1px solid var(--rd-line);
  padding: 28px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--rd-line) transparent;
  scrollbar-width: thin;
}
html body[data-brand] .app-brand {
  padding-block-end: 22px;
  border-block-end: 1px solid var(--rd-line);
}
html body[data-brand] .app-brand img {
  inline-size: 48px;
  block-size: 48px;
  flex-basis: 48px;
  object-fit: contain;
  padding: 4px;
  border-radius: 14px;
  background: #fff;
}
html body[data-brand] .app-brand strong {
  color: var(--rd-heading);
}
html body[data-brand] .app-role {
  color: var(--rd-muted);
  font-size: 0.76rem;
}
html body[data-brand] .app-nav {
  gap: 6px;
}
html body[data-brand] .app-nav a {
  position: relative;
  color: var(--rd-muted);
  border: 1px solid transparent;
  min-block-size: 46px;
  line-height: 1.65;
  font-weight: 600;
}
html body[data-brand] .app-nav a:hover {
  color: var(--rd-heading);
  background: var(--rd-surface-raised);
}
html body[data-brand] .app-nav a:is(.active, [aria-current="page"]) {
  color: var(--rd-link);
  background: var(--rd-surface-soft);
  border-color: var(--rd-line);
  box-shadow: inset -3px 0 var(--rd-link);
}
html body[data-brand] .app-nav .nav-sep {
  background: var(--rd-line);
}
html body[data-brand] .app-sidebar-foot .btn {
  color: var(--rd-link);
  background: var(--rd-surface-raised);
  border-color: var(--rd-line);
}
html body[data-brand] .app-topbar {
  background: var(--rd-surface);
  border-color: var(--rd-line);
  box-shadow: none;
  min-block-size: 88px;
  gap: 16px;
  flex-wrap: wrap;
}
html body[data-brand] .app-topbar h1 {
  flex: 1 1 170px;
  line-height: 1.7;
  min-inline-size: 0;
}
html body[data-brand] .app-content {
  flex: 1;
  inline-size: 100%;
  max-inline-size: 1480px;
  padding: clamp(20px, 3vw, 40px);
  min-inline-size: 0;
}
html body[data-brand] :is(.hero-panel, .card, .metric, .stat) {
  background: var(--rd-surface);
  border-color: var(--rd-line);
  box-shadow: var(--rd-shadow);
}
html body[data-brand] .hero-panel {
  padding: clamp(22px, 3vw, 36px);
}
html body[data-brand] .hero-panel p {
  color: var(--rd-muted);
}
html body[data-brand] :is(.metric, .stat) {
  border-block-start: 3px solid var(--rd-link);
}
html body[data-brand] :is(.metric strong, .stat .num) {
  color: var(--rd-heading);
  font-variant-numeric: tabular-nums;
}
html body[data-brand] :is(.card-head, thead th) {
  color: var(--rd-muted);
  background: var(--rd-surface-raised);
  border-color: var(--rd-line);
}
html body[data-brand] :is(th, td) {
  border-color: var(--rd-line);
}
html body[data-brand] tbody tr:hover {
  background: var(--rd-surface-raised);
}
html body[data-brand] .table-wrap {
  max-inline-size: 100%;
  overscroll-behavior-inline: contain;
}
html body[data-brand] .topbar-search {
  min-inline-size: 180px;
  max-inline-size: 360px;
  flex: 1 1 230px;
}
html body[data-brand] .topbar-search :is(input, button) {
  color: var(--rd-link);
  background: var(--rd-surface-raised);
}
html body[data-brand] .topbar-search input {
  color: var(--rd-text);
}

.rd-appearance-controls {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
}
.rd-appearance-controls label {
  color: var(--rd-muted);
  font-size: 0.78rem;
  font-weight: 600;
}
.rd-appearance-options {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--rd-surface-sunken, var(--rd-surface-raised));
  border: 1px solid var(--rd-border, rgb(0 0 0 / 0.12));
}
.rd-appearance-option {
  display: grid;
  place-items: center;
  inline-size: 40px;
  block-size: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--rd-muted);
  cursor: pointer;
}
.rd-appearance-option svg {
  inline-size: 19px;
  block-size: 19px;
}
.rd-appearance-option[aria-checked="true"] {
  background: var(--rd-surface-raised);
  color: var(--rd-text);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.18);
}
.rd-appearance-option:disabled {
  cursor: default;
  opacity: 0.55;
}
.rd-appearance-option:focus-visible {
  outline: 2px solid var(--rd-link);
  outline-offset: 2px;
}
.rd-appearance-feedback {
  flex-basis: 100%;
  margin: 0;
  font-size: 0.75rem;
  color: var(--rd-muted);
}
.rd-appearance-feedback:empty {
  display: none;
}
.rd-appearance-controls [data-appearance-retry] {
  font-size: 0.75rem;
  padding: 6px 10px;
}
.rd-appearance-block {
  display: grid;
  gap: 4px;
  justify-items: start;
  max-inline-size: 100%;
}
.rd-workspace-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  padding: 28px clamp(20px, 3vw, 40px);
  border-block-start: 1px solid var(--rd-line);
  background: var(--rd-surface);
  color: var(--rd-muted);
  font-size: 0.79rem;
}
.rd-workspace-footer strong {
  color: var(--rd-heading);
  display: block;
}
.rd-workspace-footer p {
  margin: 4px 0 0;
}
.rd-workspace-footer nav {
  display: flex;
  align-items: center;
  gap: 8px 22px;
  flex-wrap: wrap;
}
.rd-workspace-footer a {
  min-block-size: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--rd-link);
}
.rd-auth-appearance {
  display: flex;
  justify-content: end;
  margin-block-end: 18px;
}
html body[data-brand].auth-body {
  background: var(--rd-canvas);
}
html body[data-brand].auth-body > .rd-workspace-footer {
  inline-size: min(1040px, 100%);
  border-radius: 18px;
}
html body[data-brand] :is(.auth-shell, .auth-main) {
  background: var(--rd-surface);
  border-color: var(--rd-line);
}
html body[data-brand] .auth-aside {
  background: #005b59;
}
html body[data-brand] .auth-aside :is(h2, p, .auth-point) {
  color: #fff;
}
html body[data-brand] .auth-card h1 {
  color: var(--rd-heading);
}
html body[data-brand] .auth-card .secondary {
  color: var(--rd-link);
}

/* Public content, clinical images and the real discovery map are retained. */
body[data-brand]
  :is(
    .site-header,
    .public-home-path,
    .public-home-service,
    .care-map,
    .service-link,
    .faq-item,
    .language summary,
    .language > div
  ) {
  background: var(--rd-surface);
  border-color: var(--rd-line);
  color: var(--rd-text);
}
body[data-brand] :is(.public-home-hero, .hero-home) {
  background: var(--rd-canvas);
  border-color: var(--rd-line);
}
body[data-brand]
  :is(.public-home-eyebrow, .directory-eyebrow, .text-link, .case-link) {
  color: var(--rd-link);
}
body[data-brand]
  :is(.public-home-intake, .public-home-hero p, .public-home-section p) {
  color: var(--rd-muted);
}
body[data-brand] :is(.public-home-hero h1, .public-home-hero h2) {
  color: var(--rd-heading);
}

/* Explicit legacy surfaces keep status semantics; no CSS filters on imagery. */
html[data-theme="dark"]
  body[data-brand]
  :is(
    .empty,
    .card-body,
    .dashboard-shortcuts a,
    .rd-dialog,
    .search-result-card,
    .support-message,
    .task-card,
    .kanban-column,
    .kanban-head,
    .launch-status,
    .launch-gate,
    .calendar-month,
    .calendar-day,
    .calendar-event,
    .policy-locale-card,
    .policy-content-preview,
    .profile-section,
    .profile-affiliation,
    .profile-empty,
    .profile-code,
    .directory-tabs,
    .directory-person-card,
    .directory-clinic-choice,
    .directory-choice,
    .directory-photo-card,
    .clinic-card,
    .reception-card,
    .patient-case-section,
    .patient-portal-card,
    .clinic-workspace-card,
    .workspace-role-card
  ) {
  background: var(--rd-surface);
  color: var(--rd-text);
  border-color: var(--rd-line);
}
html[data-theme="dark"]
  body[data-brand]
  :is(
    .calendar-day-head,
    .directory-initial,
    .directory-avatar-empty,
    .launch-detail,
    .profile-avatar,
    .directory-tabs a:hover,
    .directory-tabs a[aria-current="page"],
    .search-result-type,
    .white,
    .profile-section-nav a
  ) {
  background: var(--rd-surface-soft);
  color: var(--rd-link);
  border-color: var(--rd-line);
}
html[data-theme="dark"]
  body[data-brand]
  :is(
    .directory-workspace label,
    .directory-heading h2,
    .directory-person-card h3,
    .profile-heading h2
  ) {
  color: var(--rd-heading);
}
html[data-theme="dark"]
  body[data-brand]
  :is(
    .directory-person-card p,
    .directory-workspace dt,
    .directory-clinic-choice small,
    .directory-affiliation-row small,
    .calendar-event small,
    .calendar-event-time,
    .support-message-meta
  ) {
  color: var(--rd-muted);
}
html[data-theme="dark"]
  body[data-brand]
  :is(
    .directory-workspace input,
    .directory-workspace select,
    .directory-workspace textarea
  ) {
  background: var(--rd-surface);
  color: var(--rd-text);
  border-color: var(--rd-line);
}
html[data-theme="dark"] body[data-brand] :is(.badge, .gate-chip) {
  background: var(--rd-surface-soft);
  color: var(--rd-text);
}
html[data-theme="dark"]
  body[data-brand]
  :is(
    .badge.published,
    .badge.completed,
    .badge.verified,
    .badge.resolved,
    .gate-chip.ok,
    .launch-status.ready
  ) {
  background: var(--rd-success-surface);
  color: var(--rd-success);
}
html[data-theme="dark"]
  body[data-brand]
  :is(
    .badge.in_review,
    .badge.awaiting_patient,
    .badge.coordinator_review,
    .badge.proposed,
    .support-message.internal-note,
    .row-attention,
    .offline-banner
  ) {
  background: var(--rd-warning-surface);
  color: var(--rd-warning);
}
html[data-theme="dark"]
  body[data-brand]
  :is(
    .badge.cancelled,
    .badge.unverified,
    .badge.open,
    .badge.archived,
    .gate-chip.blocked,
    .launch-status.blocked
  ) {
  background: var(--rd-danger-surface);
  color: var(--rd-danger);
}
html[data-theme="dark"]
  body[data-brand]
  :is(.patient-case, .clinician-case, .clinic-workspace) {
  color: var(--rd-text);
}
html[data-theme="dark"]
  body[data-brand]
  :is(
    .patient-case-hero,
    .patient-case-card,
    .patient-case-document,
    .patient-case-referral,
    .patient-case-review,
    .patient-case-empty,
    .clinician-case-hero,
    .clinician-case-card,
    .clinician-case-draft,
    .clinician-case-empty,
    .clinic-scope-card,
    .clinic-panel,
    .clinic-metric,
    .clinic-request-card,
    .clinic-empty,
    .clinician-case-documents li
  ) {
  background: var(--rd-surface);
  color: var(--rd-text);
  border-color: var(--rd-line);
}
html[data-theme="dark"]
  body[data-brand]
  :is(
    .patient-case-review header,
    .patient-case-review-meta,
    .clinician-case-draft header,
    .clinician-case-draft-meta,
    .clinic-event,
    .clinic-count,
    .clinic-schedule-status,
    .clinic-chip
  ) {
  background: var(--rd-surface-soft);
  color: var(--rd-text);
  border-color: var(--rd-line);
}
html[data-theme="dark"]
  body[data-brand]
  :is(.patient-case, .clinician-case)
  :is(p, dd, label, small) {
  color: var(--rd-text);
}
html[data-theme="dark"]
  body[data-brand]
  :is(.patient-case, .clinician-case)
  :is(dt, a:not(.btn), .clinician-case-eyebrow, .patient-case-eyebrow) {
  color: var(--rd-link);
}
html[data-theme="dark"]
  body[data-brand]
  :is(
    .clinic-scope-identity span,
    .clinic-workspace-switch span,
    .clinic-metric span,
    .clinic-request-meta,
    .clinic-profile-card p,
    .clinic-form-field span,
    .clinic-event small
  ) {
  color: var(--rd-muted);
}
html[data-theme="dark"]
  body[data-brand]
  :is(
    .clinic-metric strong,
    .patient-case-review h3,
    .clinician-case-draft h3
  ) {
  color: var(--rd-heading);
}
html[data-theme="dark"]
  body[data-brand]
  :is(
    .clinician-case #review-form select,
    .clinician-case #review-form textarea,
    .clinic-workspace-switch select,
    .clinic-schedule-form input,
    .clinic-schedule-form select,
    .clinic-decline-panel select,
    .clinic-decline-panel textarea,
    .profile-workspace input[readonly]
  ) {
  background: var(--rd-surface);
  color: var(--rd-text);
  border-color: var(--rd-line);
}

@media (max-width: 1100px) {
  html body[data-brand] .app-topbar {
    column-gap: 12px;
  }
  html body[data-brand] .topbar-search {
    order: 4;
    flex-basis: 100%;
    max-inline-size: none;
    margin: 0;
  }
}
@media (max-width: 900px) {
  html body[data-brand] .app-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "main";
  }
  html body[data-brand] .app-sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline: 0 auto;
    inline-size: min(310px, 86vw);
    block-size: 100dvh;
    height: 100dvh;
    transform: translateX(110%);
    z-index: 50;
  }
  html body[data-brand] .app-shell.nav-open .app-sidebar {
    transform: translateX(0);
  }
  html body[data-brand] .app-topbar {
    padding-block: 14px;
    padding-inline: 72px 16px;
  }
  html body[data-brand] .mobile-nav {
    display: inline-flex;
    position: absolute;
    right: auto;
    left: auto;
    inset-inline-start: 16px;
    top: 18px;
    margin: 0;
  }
  html[dir="ltr"] body[data-brand] .app-sidebar {
    transform: translateX(-110%);
  }
  html[dir="ltr"] body[data-brand] .app-shell.nav-open .app-sidebar {
    transform: translateX(0);
  }
  html[dir="ltr"] body[data-brand] .mobile-nav {
    margin-inline-start: 0;
  }
  html[dir="ltr"] body[data-brand] .app-topbar h1 {
    order: 0;
  }
  html[dir="ltr"] body[data-brand] .rd-appearance-block {
    order: 1;
  }
  html body[data-brand] .app-content {
    padding: 20px 16px;
  }
}
@media (max-width: 600px) {
  .rd-appearance-controls {
    gap: 7px;
  }
  .rd-appearance-controls label {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .rd-appearance-controls select {
    max-inline-size: 136px;
  }
  .rd-workspace-footer {
    align-items: start;
    flex-direction: column;
    gap: 12px;
  }
  .rd-workspace-footer nav {
    gap: 6px 18px;
  }
  html body[data-brand] .app-content :is(.two-col, .grid, .field-row) {
    grid-template-columns: minmax(0, 1fr);
  }
  html body[data-brand] .app-content :is(.metric-grid, .stat-grid) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  html body[data-brand] .app-topbar h1 {
    flex-basis: 150px;
    font-size: 0.95rem;
  }
  html body[data-brand] .app-topbar .rd-appearance-block {
    margin-inline-start: auto;
  }
  html body[data-brand] .app-topbar .rd-appearance-feedback {
    max-inline-size: 22ch;
  }
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  body[data-brand] *,
  body[data-brand] *::before,
  body[data-brand] *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
/* Author display rules such as .btn must not override semantic hidden states. */
body[data-brand] [hidden] {
  display: none !important;
}
/* Keep explicit form labels available to assistive technology without taking
   space in compact toolbars. This utility is shared by existing Blade views. */
body[data-brand] .sr-only {
  position: absolute !important;
  inline-size: 1px !important;
  block-size: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap !important;
  border: 0 !important;
}

/* Jalali equivalent shown under native date inputs on Persian pages */
.rd-jalali-hint { display: block; margin-top: .35rem; font-size: .85em; line-height: 1.6; color: var(--rd-muted, #506b70); }
.rd-jalali-hint[hidden] { display: none; }
