/* Clinic (عيادتي) — TigrisCare family: Ocean teal primary + gold accent. RTL, Cairo. */
:root {
  --primary: #0f766e;
  --primary-600: #0d5f59;
  --primary-700: #0a4b47;
  --primary-soft: #e3f3f1;
  --gold: #c9a84c;
  --gold-600: #a8872f;
  --gold-soft: #f7efd9;
  --bg: #f3f6f6;
  --card: #ffffff;
  --text: #13262a;
  --muted: #5f7478;
  --line: #dde7e7;
  --ok: #15803d;
  --ok-soft: #e4f5ea;
  --warn: #b45309;
  --warn-soft: #fdf1e1;
  --danger: #b91c1c;
  --danger-soft: #fde8e8;
  --info: #1d4ed8;
  --info-soft: #e5edff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 42, 45, .06), 0 4px 16px rgba(16, 42, 45, .06);
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Cairo", "Segoe UI", Tahoma, sans-serif; line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.35; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.ltr { direction: ltr; unicode-bidi: isolate; text-align: left; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.topbar {
  background: linear-gradient(135deg, var(--primary-700), var(--primary) 70%);
  color: #fff; border-bottom: 3px solid var(--gold);
}
.topbar-in {
  max-width: 1240px; margin: 0 auto; padding: .6rem 1rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 800; font-size: 1.15rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; background: var(--gold); color: var(--primary-700);
  display: grid; place-items: center; font-size: 1.3rem; font-weight: 900;
}
.brand small { display: block; font-weight: 500; font-size: .78rem; opacity: .85; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.nav a {
  color: #e6f4f2; padding: .4rem .9rem; border-radius: 999px; font-weight: 600;
}
.nav a:hover { background: rgba(255, 255, 255, .12); text-decoration: none; }
.nav a.on { background: #fff; color: var(--primary-700); }
.who { margin-inline-start: auto; display: flex; align-items: center; gap: .6rem; font-size: .92rem; }
.who .role { background: rgba(255, 255, 255, .15); padding: .1rem .6rem; border-radius: 999px; }
.who a, .who button { color: #fff; }
.linkbtn { background: none; border: 0; font: inherit; cursor: pointer; padding: 0; }
.linkbtn:hover { text-decoration: underline; }

/* ---------- layout ---------- */
main { max-width: 1240px; margin: 0 auto; padding: 1.4rem 1rem 3rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.page-head p { margin: 0; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.2rem 1.3rem; margin-bottom: 1.1rem;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .8rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.side { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 1.1rem; align-items: start; }

/* ---------- stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .9rem; margin-bottom: 1.1rem; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .9rem 1.1rem; border-inline-start: 5px solid var(--primary);
}
.stat .v { font-size: 1.9rem; font-weight: 800; line-height: 1.2; }
.stat .l { color: var(--muted); font-weight: 600; font-size: .92rem; }
.stat.gold { border-inline-start-color: var(--gold); }
.stat.warn { border-inline-start-color: var(--warn); }
.stat.ok { border-inline-start-color: var(--ok); }
.stat.info { border-inline-start-color: var(--info); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 700; font-size: .95rem; border-radius: 10px; cursor: pointer;
  padding: .5rem 1.1rem; border: 1px solid var(--primary); background: var(--primary); color: #fff;
  white-space: nowrap; min-height: 42px;
}
.btn:hover { background: var(--primary-600); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--primary); }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #2b2206; }
.btn.gold:hover { background: var(--gold-600); color: #fff; }
.btn.danger { background: #fff; color: var(--danger); border-color: #f2c4c4; }
.btn.sm { padding: .25rem .75rem; font-size: .88rem; min-height: 34px; border-radius: 8px; }
.btn.lg { padding: .7rem 1.6rem; font-size: 1.05rem; }
.btns { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; margin: 0; }

/* ---------- forms ---------- */
label { display: block; font-weight: 700; font-size: .92rem; margin-bottom: .25rem; }
.field { margin-bottom: .9rem; }
input[type=text], input[type=password], input[type=search], input[type=number], input[type=date], input[type=tel],
select, textarea {
  width: 100%; font: inherit; font-size: 1rem; color: var(--text); background: #fff;
  border: 1px solid #c9d7d7; border-radius: 10px; padding: .5rem .75rem; min-height: 44px;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.7; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(15, 118, 110, .18); border-color: var(--primary); }
.hint { color: var(--muted); font-size: .85rem; margin-top: .2rem; }
.req { color: var(--danger); }
.radio-row { display: flex; gap: 1.2rem; align-items: center; min-height: 44px; }
.radio-row label { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; margin: 0; }
.searchbar { display: flex; gap: .5rem; }
.searchbar input { flex: 1; font-size: 1.05rem; }

/* toggle switch (checkbox) */
.switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; font-weight: 600; }
.switch input { appearance: none; -webkit-appearance: none; width: 46px; height: 26px; border-radius: 999px;
  background: #c9d4d4; position: relative; cursor: pointer; transition: background .15s; margin: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: inset-inline-start .15s; }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { inset-inline-start: 23px; }

/* paid toggle button (a POST form styled as a switch) */
.paybtn { display: inline-flex; align-items: center; gap: .45rem; background: none; border: 0; font: inherit;
  cursor: pointer; padding: 0; font-weight: 700; font-size: .9rem; color: var(--muted); }
.paybtn .knob { width: 42px; height: 24px; border-radius: 999px; background: #c9d4d4; position: relative; flex: none; }
.paybtn .knob::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.paybtn.on { color: var(--ok); }
.paybtn.on .knob { background: var(--ok); }
.paybtn.on .knob::after { inset-inline-start: 21px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .6rem; text-align: right; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .85rem; color: var(--muted); font-weight: 700; background: #f8fbfb; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.is-with td { background: #f1faf8; }
tr.is-done td, tr.is-cancelled td { color: var(--muted); }
.seq { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 800;
  background: var(--primary-soft); color: var(--primary-700); }
.pname { font-weight: 700; font-size: 1.02rem; }
.fee-form { display: inline-flex; gap: .3rem; align-items: center; }
.fee-form input { width: 105px; min-height: 34px; padding: .2rem .5rem; font-size: .92rem; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: .1rem .65rem; border-radius: 999px; font-size: .82rem; font-weight: 700; white-space: nowrap; }
.b-waiting { background: var(--warn-soft); color: var(--warn); }
.b-with_doctor { background: var(--info-soft); color: var(--info); }
.b-done { background: var(--ok-soft); color: var(--ok); }
.b-cancelled { background: #eef1f1; color: var(--muted); }
.b-booked { background: var(--gold-soft); color: var(--gold-600); }
.b-file { background: var(--gold-soft); color: #7a5f16; }

/* ---------- toasts ---------- */
.toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 50;
  display: grid; gap: .5rem; width: min(560px, calc(100% - 24px)); }
.toast { background: #fff; border: 1px solid var(--line); border-inline-start: 5px solid var(--primary);
  border-radius: 12px; box-shadow: 0 8px 28px rgba(16, 42, 45, .18); padding: .7rem 1rem; font-weight: 600;
  transition: opacity .3s, transform .3s; }
.toast.ok { border-inline-start-color: var(--ok); }
.toast.error { border-inline-start-color: var(--danger); color: var(--danger); }
.toast.hide { opacity: 0; transform: translateY(-8px); }

.alert { border-radius: 12px; padding: .8rem 1rem; margin-bottom: 1rem; font-weight: 600; }
.alert.warn { background: var(--warn-soft); color: #7c3a06; border: 1px solid #f4d3a9; }
.alert.err { background: var(--danger-soft); color: var(--danger); border: 1px solid #f2c4c4; }
.alert.info { background: var(--primary-soft); color: var(--primary-700); border: 1px solid #bfe3de; }

/* ---------- patient page ---------- */
.pcard h1 { font-size: 1.45rem; margin-bottom: .2rem; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: .35rem .75rem; margin: .8rem 0 0; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; }
.timeline { position: relative; padding-inline-start: 22px; }
.timeline::before { content: ""; position: absolute; inset-inline-start: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.visit { position: relative; margin-bottom: 1rem; }
.visit::before { content: ""; position: absolute; inset-inline-start: -21px; top: 22px; width: 14px; height: 14px;
  border-radius: 50%; background: #fff; border: 3px solid var(--primary); }
.visit:first-child::before { border-color: var(--gold); background: var(--gold); }
.visit .card { margin: 0; }
.visit-head { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; align-items: center;
  border-bottom: 1px dashed var(--line); padding-bottom: .55rem; margin-bottom: .6rem; }
.visit-date { font-weight: 800; font-size: 1.05rem; }
.vrow { margin: .25rem 0; }
.vrow b { color: var(--primary-700); }
.dx { background: var(--gold-soft); border-radius: 10px; padding: .4rem .8rem; font-weight: 700; display: inline-block; }
.vitals { display: flex; gap: .5rem; flex-wrap: wrap; margin: .35rem 0; }
.vitals span { background: #f3f7f7; border: 1px solid var(--line); border-radius: 8px; padding: .05rem .6rem; font-size: .9rem; }
.rx-list { direction: ltr; text-align: left; margin: .5rem 0 0; padding: .6rem 1rem .6rem 2.2rem;
  background: #fbfdfd; border: 1px solid var(--line); border-radius: 10px; }
.rx-list li { margin: .15rem 0; }
.rx-list .drug { font-weight: 700; }
.rx-list .rxn { direction: rtl; unicode-bidi: isolate; color: var(--muted); }
.private { background: #fff8e8; border: 1px dashed var(--gold); border-radius: 10px; padding: .4rem .8rem; margin-top: .5rem; }

/* ---------- visit form ---------- */
.vitals-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; }
.rx-table td { padding: .35rem .3rem; border-bottom: 0; }
.rx-table th { background: none; padding: .2rem .3rem; }
.rx-table input { min-height: 40px; }
.rx-table .c-drug { width: 30%; }
.rx-table .c-x { width: 44px; }
.rxhead { display: flex; align-items: center; gap: .6rem; }
.rxsym { font-family: Georgia, serif; font-size: 1.8rem; color: var(--gold-600); font-weight: 700; line-height: 1; }
.sticky-actions { position: sticky; bottom: 0; background: rgba(243, 246, 246, .94); backdrop-filter: blur(4px);
  padding: .8rem 0; border-top: 1px solid var(--line); display: flex; gap: .6rem; flex-wrap: wrap; z-index: 5; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: radial-gradient(circle at 20% 20%, #15948a 0, var(--primary) 35%, var(--primary-700) 100%);
  color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art::after { content: ""; position: absolute; width: 420px; height: 420px; border-radius: 50%;
  border: 60px solid rgba(201, 168, 76, .16); bottom: -160px; left: -140px; }
.login-art h1 { font-size: 2.3rem; font-weight: 900; margin: 0; }
.login-art .tag { font-size: 1.15rem; opacity: .9; max-width: 460px; }
.login-art ul { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .6rem; }
.login-art li { display: flex; gap: .6rem; align-items: center; font-weight: 600; }
.login-art li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); flex: none; }
.login-form { display: grid; place-items: center; padding: 2rem 1rem; }
.login-card { width: min(400px, 100%); }
.login-card .brand-mark { width: 56px; height: 56px; font-size: 1.8rem; margin-bottom: .8rem; }

/* ---------- misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.next-card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  background: linear-gradient(135deg, var(--gold-soft), #fff); border: 1px solid #ecdcae; }
.next-card .who-next { font-size: 1.25rem; font-weight: 800; }
.dup-list { margin: .5rem 0 0; padding-inline-start: 1.2rem; }
.footer-note { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 2rem; }

@media (max-width: 1000px) {
  .side { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  html { font-size: 15px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .vitals-grid { grid-template-columns: 1fr 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { padding: 1.6rem 1.2rem; }
  .login-art ul, .login-art .foot { display: none; }
  .who { margin-inline-start: 0; width: 100%; justify-content: space-between; }
  .hide-sm { display: none; }
  .rx-table thead { display: none; }
  .rx-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem; border: 1px solid var(--line);
    border-radius: 10px; padding: .4rem; margin-bottom: .5rem; }
  .rx-table td { padding: 0; }
  .rx-table td.c-drug { grid-column: 1 / -1; width: auto; }
  .rx-table .c-x { width: auto; }
  .card { padding: 1rem; }
}

td.num, .fee-date { white-space: nowrap; }
