/* دليل أبناء السويداء — mobile-first, RTL/LTR via logical properties */

:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --ink: #1d2327;
  --muted: #667076;
  --line: #e3ddd1;
  --brand: #1f2a2e;
  --on-brand: #f4f1ea;
  --on-brand-muted: #b9c2c0;
  --tab-line: #6cc7a0;
  --accent: #2f7a5b;
  --on-accent: #ffffff;
  --accent-soft: #e2efe8;
  --accent-ink: #1f5a42;
  --danger: #b3261e;
  --radius: 14px;
  --font: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  /* Android app: Capacitor injects --safe-area-inset-*; browsers use env() */
  --safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  --safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111618;
    --surface: #1a2023;
    --ink: #ece8e1;
    --muted: #9aa4a9;
    --line: #2b3438;
    --brand: #161d20;
    --accent: #5fb893;
    --on-accent: #0d1a14;
    --accent-soft: #1d362c;
    --accent-ink: #8fd4b4;
    --danger: #f2b8b5;
  }
}

/* قسم الأطباء: طابع طبي أبيض وأزرق. يُفعَّل من app.js عبر <html data-section="doctors">؛
   الشريط العلوي يبقى بلون التطبيق الأساسي. */
[data-section="doctors"] {
  --bg: #f2f6fb;
  --surface: #ffffff;
  --ink: #12263a;
  --muted: #5c6f82;
  --line: #d9e3ee;
  --accent: #1769c7;
  --on-accent: #ffffff;
  --accent-soft: #e4effb;
  --accent-ink: #0f58a8;
  --tab-line: #7db7ff;
  --tag-bg: #0f58a8;
}

@media (prefers-color-scheme: dark) {
  [data-section="doctors"] {
    --bg: #0c151e;
    --surface: #14202c;
    --ink: #e9eff6;
    --muted: #93a5b7;
    --line: #233547;
    --accent: #6db2f7;
    --on-accent: #06213c;
    --accent-soft: #15314d;
    --accent-ink: #9fcdff;
    --tab-line: #6db2f7;
    --tag-bg: #1d4f85;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

/* keeps the area behind the phone's status bar in the brand colour while scrolling */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  height: var(--safe-top);
  background: var(--brand);
}

#app {
  max-width: 520px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding-bottom: var(--safe-bottom);
}

h1,
h2,
p,
dl,
dd {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent-ink);
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.ico {
  width: 20px;
  height: 20px;
  flex: none;
}

[dir="rtl"] .flip {
  transform: scaleX(-1);
}

.flag {
  width: 30px;
  height: 15px;
  flex: none;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(127, 127, 127, 0.35);
}

.missing {
  color: var(--muted);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 0.05em;
}

/* ---------- shared pieces ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.hint {
  color: var(--muted);
  font-size: 0.95rem;
}

.plain-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-outline {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.btn:disabled,
.btn.is-disabled {
  opacity: 0.45;
  cursor: default;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--on-brand);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
}

.input,
.select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.input::placeholder,
.search input::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

.field-label {
  display: block;
  margin-top: 18px;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.95rem;
}

.error {
  margin-top: 10px;
  color: var(--danger);
  font-size: 0.92rem;
  font-weight: 500;
}

/* ---------- pages ---------- */

.page {
  padding: 16px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: calc(8px + var(--safe-top)) 0 6px;
}

.page-head h1 {
  font-size: 1.5rem;
}

.page-head .chip-btn {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.page > .hint {
  margin-bottom: 18px;
}

.row-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 64px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: start;
  font-weight: 600;
  cursor: pointer;
}

.row-main {
  flex: 1;
}

.row-btn .ico,
.doc > .ico {
  color: var(--muted);
}

/* ---------- top bar + section tabs ---------- */

.topbar {
  background: var(--brand);
  color: var(--on-brand);
  padding-top: var(--safe-top);
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 8px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  font-weight: 700;
}

.brand img {
  border-radius: 8px;
  flex: none;
}

.brand span {
  font-size: 0.98rem;
  line-height: 1.25;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.topbar-title {
  flex: 1;
  font-weight: 700;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: none;
  min-height: 46px;
  padding: 0 14px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--on-brand-muted);
  font-weight: 600;
  white-space: nowrap;
}

.tab[aria-selected="true"] {
  color: var(--on-brand);
  border-bottom-color: var(--tab-line);
}

/* ---------- doctors list ---------- */

.page-list {
  padding-top: 0;
}

.filters {
  position: sticky;
  top: var(--safe-top);
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin: 0 -16px;
  padding: 12px 16px 10px;
  background: var(--bg);
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
}

.search:focus-within {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.search input {
  flex: 1;
  min-width: 0;
  height: 46px;
  border: 0;
  outline: 0;
  background: none;
  color: var(--ink);
}

.search input::-webkit-search-cancel-button {
  cursor: pointer;
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

/* 16px at least: iPhone Safari zooms the page in when a smaller field is tapped */
.select {
  min-height: 44px;
  padding-inline: 12px 34px;
  font-size: 1rem;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23808a8f' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 16px;
  background-position: right 12px center;
  text-overflow: ellipsis;
}

[dir="rtl"] .select {
  background-position: left 12px center;
}

.count {
  margin: 4px 2px 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.doc {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 1.15rem;
}

.doc-main {
  display: grid;
  flex: 1;
  min-width: 0;
}

.doc-name {
  font-weight: 700;
}

.doc-spec {
  color: var(--accent-ink);
  font-size: 0.92rem;
  font-weight: 500;
}

.doc-fac {
  color: var(--muted);
  font-size: 0.86rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--muted);
}

.empty .btn {
  margin-top: 14px;
}

.footnote {
  margin: 22px 4px 8px;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

/* ---------- doctor details ---------- */

.detail-head {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 12px 0 18px;
  text-align: center;
}

.detail-head .avatar {
  width: 72px;
  height: 72px;
  margin-bottom: 8px;
  font-size: 1.8rem;
}

.detail-head h1 {
  font-size: 1.35rem;
  line-height: 1.4;
}

.detail-spec {
  color: var(--accent-ink);
  font-weight: 600;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
}

.tag {
  padding: 2px 12px;
  border-radius: 999px;
  background: var(--tag-bg, var(--brand));
  color: var(--on-brand);
  font-size: 0.82rem;
  font-weight: 500;
}

.tag-soft {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.detail-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.info {
  padding: 4px 16px;
}

.info-row {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.info-row:last-child {
  border-bottom: 0;
}

.info-ico {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.info-row > div {
  min-width: 0;
}

.info dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.info dd {
  font-weight: 500;
  overflow-wrap: anywhere;
}

.tel {
  display: block;
  padding: 2px 0;
  font-weight: 600;
  text-decoration: none;
}

.tel-label {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.88rem;
}

/* ---------- wider screens: keep the phone-width column readable ---------- */

@media (min-width: 560px) {
  #app {
    border-inline: 1px solid var(--line);
  }
}

/* ---------- suggestions + add a doctor ("?" button) ---------- */

.form-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  padding: 16px 16px 18px;
}

.form-card + .form-card {
  margin-top: 14px;
}

.form-card h2 {
  font-size: 1.1rem;
}

.form-card .field-label {
  margin-top: 14px;
}

.form-card > .btn {
  margin-top: 16px;
}

textarea.input {
  padding: 10px 14px;
  line-height: 1.6;
  resize: vertical;
}

.status {
  margin: 10px 0 0;
  color: var(--accent-ink);
  font-weight: 500;
  text-align: center;
}

.status:empty {
  display: none;
}

.steps {
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
  padding-inline-start: 22px;
}
