/* Copra Clinic: RTL Hebrew UI */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #94a3b8;
  --line: #e2e8f0;
  --brand: #1a2b63;
  --brand-600: #111d47;
  --brand-50: #eef1f9;
  --brand-100: #d9dff0;
  --sidebar: #111d47;
  --accent: #d3122f;
  --accent-600: #b00e27;
  --accent-50: #fdecee;
  --sidebar-2: #1a2b63;
  --danger: #dc2626;
  --danger-50: #fef2f2;
  --warn: #d97706;
  --warn-50: #fffbeb;
  --ok: #16a34a;
  --ok-50: #f0fdf4;
  --indigo: #4f46e5;
  --indigo-50: #eef2ff;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .05);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Heebo", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand); }
.icon { flex-shrink: 0; vertical-align: middle; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, #0a1330 100%);
  color: #cbd5e1;
  padding: 22px 16px;
  display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 19px; padding: 4px 10px 22px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, #d3122f, #1a2b63); color: #fff; box-shadow: 0 4px 14px rgba(211, 18, 47, .4); }
.brand small { display: block; font-size: 12px; font-weight: 400; color: #aab3d1; }
.nav-label { font-size: 11.5px; color: #8793b8; padding: 12px 12px 6px; letter-spacing: .02em; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: #cbd5e1; font-weight: 500; transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.active { background: rgba(211, 18, 47, .18); color: #fff; box-shadow: inset -3px 0 0 #e8384f; }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 14px; }
.me { display: flex; align-items: center; gap: 10px; padding: 6px 8px 12px; }
.me strong { color: #fff; display: block; font-size: 14px; }
.me span { font-size: 12.5px; color: #aab3d1; }

.main { min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 26px 36px 8px;
}
.topbar h1 { margin: 0; font-size: 25px; font-weight: 700; letter-spacing: -.01em; }
.topbar .sub { color: var(--text-2); font-size: 14px; margin-top: 2px; }
.content { padding: 16px 36px 48px; max-width: 1280px; }

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h2, .card h2 { margin: 0; font-size: 17px; font-weight: 700; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush .card-head { padding: 18px 22px 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  background: var(--brand); color: #fff; font: inherit; font-weight: 600; font-size: 14.5px;
  cursor: pointer; white-space: nowrap; transition: background .15s, box-shadow .15s, transform .05s;
  box-shadow: 0 1px 2px rgba(26, 43, 99, .3);
}
.btn:hover { background: var(--brand-600); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--line); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: #cbd5e1; }
.btn-soft { background: var(--brand-50); color: var(--brand-600); box-shadow: none; }
.btn-soft:hover { background: var(--brand-100); color: var(--brand-600); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: #fecaca; box-shadow: none; }
.btn-danger:hover { background: var(--danger-50); color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 13.5px; border-radius: 8px; }
.btn-icon { padding: 8px; }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.req { color: var(--danger); }
input, select, textarea {
  width: 100%; padding: 10px 13px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid #cbd5e1; border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(26, 43, 99, .14); }
textarea { min-height: 96px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--brand); margin: 3px 0 0; flex-shrink: 0; }
input[type="date"], input[type="datetime-local"], input[type="tel"], input[type="email"] { direction: ltr; text-align: right; }

.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > .grow { flex: 1 1 220px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.section-title { font-size: 15px; font-weight: 700; margin: 26px 0 14px; padding-top: 20px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; color: var(--text); }

/* Search bar */
.search-hero { position: relative; }
.search-hero .icon { position: absolute; top: 50%; right: 16px; transform: translateY(-50%); color: var(--muted); }
.search-hero input { padding: 14px 48px 14px 16px; font-size: 16px; border-radius: 12px; }

/* Stats */
.stat { display: flex; align-items: center; gap: 14px; padding: 18px 20px; }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); }
.stat-icon.indigo { background: var(--indigo-50); color: var(--indigo); }
.stat-icon.warn { background: var(--warn-50); color: var(--warn); }
.stat-icon.ok { background: var(--ok-50); color: var(--ok); }
.stat-value { font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat-label { color: var(--text-2); font-size: 13.5px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: right; font-size: 12.5px; font-weight: 600; color: var(--text-2); background: var(--surface-2); padding: 11px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: #fafcfd; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }

/* Person cell */
.person { display: flex; align-items: center; gap: 12px; }
.person-name { font-weight: 600; color: var(--text); }
.person-meta { color: var(--muted); font-size: 13px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.tone-1 { background: #d9dff0; color: #1a2b63; }
.tone-2 { background: #e0e7ff; color: #4338ca; }
.tone-3 { background: #fce7f3; color: #be185d; }
.tone-4 { background: #fef3c7; color: #b45309; }
.tone-5 { background: #dbeafe; color: #1d4ed8; }
.tone-6 { background: #ede9fe; color: #6d28d9; }
.sidebar .avatar { background: rgba(255, 255, 255, .12); color: #fff; }

/* Badges & chips */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--brand-50); color: var(--brand-600); white-space: nowrap; }
.badge.scheduled { background: var(--brand-50); color: var(--brand-600); }
.badge.completed { background: var(--ok-50); color: var(--ok); }
.badge.cancelled { background: var(--danger-50); color: var(--danger); }
.badge.gray { background: #f1f5f9; color: var(--text-2); }
.badge.family { background: var(--indigo-50); color: var(--indigo); }
.badge.danger { background: var(--danger-50); color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; }
.chip a { color: var(--text); font-weight: 500; }
.chip .role { color: var(--muted); font-size: 12px; }
.chip form { display: inline-flex; }
.chip-x { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; display: inline-flex; }
.chip-x:hover { color: var(--danger); }

/* Alerts */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 13px 16px; border-radius: 12px; margin-bottom: 18px; font-weight: 500; }
.alert.ok { background: var(--ok-50); color: #166534; border: 1px solid #bbf7d0; }
.alert.err { background: var(--danger-50); color: #991b1b; border: 1px solid #fecaca; }

/* Agent log */
.agent { background: linear-gradient(135deg, #0f172a, #1a2b63); color: #e2e8f0; border-radius: var(--radius); padding: 16px 20px; margin-bottom: 20px; box-shadow: var(--shadow-lg); }
.agent-head { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #fff; margin-bottom: 10px; }
.agent-head .pulse { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: rgba(232, 56, 79, .2); color: #ff8a99; }
.agent ol { margin: 0; padding: 0 22px 0 0; font-size: 14px; }
.agent li { padding: 3px 0; }
.agent li::marker { color: #ff8a99; font-weight: 700; }

/* Schedule */
.timeline { display: flex; flex-direction: column; gap: 14px; }
.appt { display: grid; grid-template-columns: 96px 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.appt-time { background: var(--brand-50); color: var(--brand-600); padding: 16px 12px; text-align: center; border-left: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center; }
.appt-time strong { font-size: 20px; font-weight: 800; direction: ltr; }
.appt-time span { font-size: 12.5px; direction: ltr; }
.appt-body { padding: 16px 20px; min-width: 0; }
.appt-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.appt-title { font-size: 16.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.appt-meta { color: var(--text-2); font-size: 13.5px; display: flex; gap: 14px; flex-wrap: wrap; margin-top: 3px; }
.appt-meta span { display: inline-flex; align-items: center; gap: 5px; }
.appt.is-family .appt-time { background: var(--indigo-50); color: var(--indigo); }
.appt.completed .appt-time { background: var(--ok-50); color: var(--ok); }
.appt.cancelled { opacity: .6; }
.appt.cancelled .appt-time { background: var(--danger-50); color: var(--danger); }
.appt.highlight { box-shadow: 0 0 0 3px rgba(26, 43, 99, .35), var(--shadow-lg); }

.date-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Empty state */
.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty .empty-icon { width: 60px; height: 60px; border-radius: 16px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); }
.empty h3 { margin: 0 0 6px; color: var(--text); font-size: 17px; }

/* Profile */
.profile-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.profile-head h2 { font-size: 22px; margin: 0; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 12px 16px; margin: 0; }
.kv dt { color: var(--text-2); font-size: 13.5px; }
.kv dd { margin: 0; font-weight: 500; }
.allergy { display: flex; gap: 10px; align-items: center; background: var(--danger-50); color: #991b1b; border: 1px solid #fecaca; padding: 11px 14px; border-radius: 10px; font-weight: 600; margin-top: 16px; }
.history-item { position: relative; padding: 0 22px 18px 0; border-right: 2px solid var(--line); margin-right: 6px; }
.history-item:last-child { padding-bottom: 0; }
.history-item::before { content: ""; position: absolute; right: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); border: 2px solid var(--surface); box-shadow: 0 0 0 2px var(--brand-100); }
.history-date { color: var(--muted); font-size: 12.5px; }

/* Member picker */
.member-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.member-pick label { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--surface); transition: border-color .15s, background .15s; }
.member-pick label:hover { border-color: var(--brand); }
.member-pick label:has(input:checked) { border-color: var(--brand); background: var(--brand-50); }
.option-box { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); cursor: pointer; }
.option-box strong { display: block; }
.option-box span { color: var(--text-2); font-size: 13.5px; }

/* Login */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: linear-gradient(150deg, #111d47, #1a2b63); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side::after { content: ""; position: absolute; width: 420px; height: 420px; border-radius: 50%; background: rgba(255, 255, 255, .06); left: -120px; bottom: -120px; }
.auth-side h2 { font-size: 34px; line-height: 1.25; margin: 0 0 14px; font-weight: 800; }
.auth-side p { color: #d9dff0; font-size: 16px; max-width: 420px; margin: 0; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.auth-points li { display: flex; align-items: center; gap: 10px; color: #eef1f9; }
.auth-form { display: grid; place-items: center; padding: 32px 20px; background: var(--surface); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 26px; margin: 0 0 6px; }
.auth-card .sub { color: var(--text-2); margin: 0 0 28px; }

.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.mt-0 { margin-top: 0; }
.nowrap { white-space: nowrap; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .shell > *, .sidebar, .nav { min-width: 0; max-width: 100vw; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; gap: 4px; }
  .brand { padding: 0 4px; font-size: 17px; margin-left: auto; }
  .brand small, .nav-label, .me { display: none; }
  .nav { display: flex; gap: 2px; order: 3; width: 100%; overflow-x: auto; }
  .nav a { padding: 8px 12px; white-space: nowrap; }
  .nav a.active { box-shadow: inset 0 -2px 0 #e8384f; }
  .sidebar-foot { margin: 0; border: 0; padding: 0; }
  .topbar { padding: 20px 16px 4px; }
  .topbar h1 { font-size: 21px; }
  .content { padding: 12px 16px 40px; }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .appt { grid-template-columns: 76px 1fr; }
  .kv { grid-template-columns: 110px 1fr; }
  .card { padding: 18px; }
}
@media (max-width: 520px) {
  .cols-4 { grid-template-columns: 1fr 1fr; }
  .stat { padding: 14px; }
  .stat-icon { width: 38px; height: 38px; }
  .stat-value { font-size: 21px; }
}

/* ---------- Cobra Ambulance brand ---------- */
.brand-logo { width: 46px; height: 46px; border-radius: 50%; background: #fff; object-fit: cover; box-shadow: 0 0 0 3px rgba(255, 255, 255, .12), 0 4px 14px rgba(0, 0, 0, .3); flex-shrink: 0; }
.brand-name { line-height: 1.15; letter-spacing: .02em; }
.brand-name b { display: block; font-size: 18px; font-weight: 800; color: #fff; }
.brand-name b span { color: var(--accent); }
.brand-name small { font-size: 11px; white-space: nowrap; }
.sidebar { border-left: 3px solid var(--accent); }
.nav a.active { background: rgba(255, 255, 255, .08); box-shadow: inset -3px 0 0 var(--accent); }
.btn-accent { background: var(--accent); box-shadow: 0 1px 2px rgba(211, 18, 47, .35); }
.btn-accent:hover { background: var(--accent-600); }
.agent { background: linear-gradient(135deg, #0a1330, #1a2b63); border-right: 4px solid var(--accent); }
.agent-head .pulse { background: rgba(211, 18, 47, .25); color: #ff8a99; }
.appt-time { background: var(--brand-50); color: var(--brand); }
.appt.is-family .appt-time { background: var(--accent-50); color: var(--accent); }
.badge.family { background: var(--accent-50); color: var(--accent); }
.history-item::before { background: var(--accent); box-shadow: 0 0 0 2px var(--accent-50); }
.auth-side { background: linear-gradient(150deg, #0a1330 0%, #1a2b63 70%, #2a3d80 100%); }
.auth-side::before { content: ""; position: absolute; inset: auto 0 0 0; height: 6px; background: var(--accent); }
.auth-logo { width: 150px; height: 150px; border-radius: 50%; background: #fff; box-shadow: 0 12px 40px rgba(0, 0, 0, .35); margin-bottom: 26px; }
.auth-card .login-logo { width: 88px; height: 88px; border-radius: 50%; display: block; margin-bottom: 18px; box-shadow: var(--shadow); }
.ecg { display: block; width: 100%; max-width: 360px; height: 34px; color: var(--accent); margin: 18px 0 0; }
@media (max-width: 860px) {
  .sidebar { border-left: 0; border-bottom: 3px solid var(--accent); }
  .brand-logo { width: 38px; height: 38px; }
  .brand-name b { font-size: 16px; }
  .nav a.active { box-shadow: inset 0 -2px 0 var(--accent); }
}

/* Structured medical record */
.step { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 11.5px; font-weight: 700; margin-left: 6px; vertical-align: 1px; }
.note-diagnosis { display: inline-block; margin: 6px 0 4px; padding: 3px 12px; border-radius: 8px; background: var(--accent-50); color: var(--accent-600); font-weight: 700; }
.note-sections { display: grid; grid-template-columns: 110px 1fr; gap: 6px 14px; margin: 8px 0 0; font-size: 14.5px; }
.note-sections dt { color: var(--text-2); font-weight: 600; font-size: 13.5px; }
.note-sections dd { margin: 0; }
@media (max-width: 520px) { .note-sections { grid-template-columns: 1fr; gap: 2px; } .note-sections dd { margin-bottom: 8px; } }
