/* ================================================================
   عيادة القلب التخصصية - التصميم الكامل
   Royal Heart Clinic - Full RTL Design System
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800;900&display=swap');

/* ── Variables ── */
:root {
  --navy:      #0d1b3e;
  --navy-mid:  #162555;
  --navy-light:#1e3a7b;
  --gold:      #c9a84c;
  --gold-light:#e8c96b;
  --crimson:   #8b1a2f;
  --crimson-l: #c0293f;
  --bg:        #f0f4f8;
  --card:      #ffffff;
  --border:    #e2e8f0;
  --text:      #1a202c;
  --text-muted:#64748b;
  --text-light:#94a3b8;
  --success:   #16a34a;
  --warning:   #d97706;
  --danger:    #dc2626;
  --info:      #0ea5e9;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 2px 12px rgba(0,0,0,.08);
  --shadow-md: 0 4px 24px rgba(0,0,0,.12);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.18);
  --trans:     all .2s ease;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Tajawal', sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
  line-height: 1.6;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--navy-light); border-radius: 3px; }

/* ================================================================
   LOGIN PAGE
   ================================================================ */
#login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #132752 0%, #0d1b3e 60%, #081026 100%);
  position: relative;
  overflow: hidden;
}

/* Background ECG Wave Lines */
.ecg-bg-container {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0.25;
  z-index: 0;
}
.ecg-wave-svg {
  width: 100%;
  height: 240px;
}
.ecg-line-bg {
  fill: none;
  stroke: rgba(201,168,76, 0.2);
  stroke-width: 2;
}
.ecg-line-pulse {
  fill: none;
  stroke: url(#ecgGlow);
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1400;
  stroke-dashoffset: 1400;
  animation: ecgDash 2.5s cubic-bezier(0.1, 0, 0.3, 1) infinite, ecgBeating 1.2s ease-in-out infinite;
  filter: drop-shadow(0 0 16px #ff3b5c) drop-shadow(0 0 8px #c9a84c);
}

@keyframes ecgDash {
  0% { stroke-dashoffset: 1400; }
  100% { stroke-dashoffset: 0; }
}

@keyframes ecgBeating {
  0%   { stroke-width: 3.5px; opacity: 0.75; filter: drop-shadow(0 0 10px #ff3b5c); }
  14%  { stroke-width: 7px; opacity: 1; filter: drop-shadow(0 0 24px #ff3b5c) drop-shadow(0 0 12px #c9a84c); }
  28%  { stroke-width: 4px; opacity: 0.8; filter: drop-shadow(0 0 12px #ff3b5c); }
  42%  { stroke-width: 8px; opacity: 1; filter: drop-shadow(0 0 28px #ff3b5c) drop-shadow(0 0 16px #c9a84c); }
  70%  { stroke-width: 3.5px; opacity: 0.75; filter: drop-shadow(0 0 10px #ff3b5c); }
  100% { stroke-width: 3.5px; opacity: 0.75; filter: drop-shadow(0 0 10px #ff3b5c); }
}

/* Pulse Rings and Heartbeat */
.heart-pulse-wrapper {
  position: relative;
  width: 84px;
  height: 84px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.heart-pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(139,26,47,0.3);
  animation: ringPulse 2s ease-out infinite;
}
.heart-pulse-ring.ring-2 {
  animation-delay: 0.6s;
}

@keyframes ringPulse {
  0% { transform: scale(0.8); opacity: 0.8; }
  100% { transform: scale(2.2); opacity: 0; }
}

.login-logo .heart-icon.pulsating-heart {
  width: 76px; height: 76px;
  background: linear-gradient(135deg, var(--crimson), #e62e4a);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 30px rgba(139,26,47,0.5), 0 0 0 4px rgba(201,168,76,0.3);
  animation: heartBeating 1.2s ease-in-out infinite;
  position: relative;
  z-index: 2;
}

@keyframes heartBeating {
  0%   { transform: scale(1); box-shadow: 0 8px 30px rgba(139,26,47,0.5), 0 0 0 4px rgba(201,168,76,0.3); }
  14%  { transform: scale(1.16); box-shadow: 0 12px 40px rgba(139,26,47,0.8), 0 0 0 8px rgba(201,168,76,0.5); }
  28%  { transform: scale(1.02); box-shadow: 0 8px 30px rgba(139,26,47,0.5), 0 0 0 4px rgba(201,168,76,0.3); }
  42%  { transform: scale(1.22); box-shadow: 0 14px 45px rgba(229,46,74,0.9), 0 0 0 10px rgba(201,168,76,0.6); }
  70%  { transform: scale(1); box-shadow: 0 8px 30px rgba(139,26,47,0.5), 0 0 0 4px rgba(201,168,76,0.3); }
  100% { transform: scale(1); box-shadow: 0 8px 30px rgba(139,26,47,0.5), 0 0 0 4px rgba(201,168,76,0.3); }
}

.login-logo .heart-icon svg { width: 40px; height: 40px; fill: white; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); }

.ecg-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(13,27,62,0.06);
  border: 1px solid rgba(201,168,76,0.3);
  border-radius: 20px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--crimson);
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}
.ecg-status-badge .pulse-dot {
  width: 7px;
  height: 7px;
  background: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 8px #22c55e;
  animation: dotBlink 1.2s ease-in-out infinite;
}

@keyframes dotBlink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.login-card {
  background: rgba(255,255,255,0.96);
  border-radius: 28px;
  padding: 44px 40px;
  width: 430px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35), 0 0 0 1px rgba(201,168,76,0.4);
  position: relative;
  z-index: 10;
  backdrop-filter: blur(16px);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-sub-motto {
  color: var(--navy-light);
  font-size: .84rem;
  font-weight: 500;
  margin-top: 6px;
  font-style: italic;
}
.login-gold-bar {
  width: 70px; height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), var(--gold-light), transparent);
  border-radius: 2px;
  margin: 12px auto 0;
}

/* Cardiac Ambient Grid & Floating Particles */
.cardiac-ambient-bg {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  overflow: hidden;
}
.cardiac-grid-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: 
    linear-gradient(rgba(201,168,76,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201,168,76,0.05) 1px, transparent 1px);
  background-size: 30px 30px;
}

.cardiac-particle {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(229,46,74,0.6) 0%, transparent 70%);
  filter: blur(2px);
  animation: floatParticle 8s ease-in-out infinite alternate;
}
.particle-1 { width: 140px; height: 140px; top: 10%; right: 15%; animation-duration: 9s; }
.particle-2 { width: 220px; height: 220px; bottom: 8%; left: 10%; animation-duration: 12s; }
.particle-3 { width: 90px; height: 90px; top: 60%; right: 25%; animation-duration: 7s; }
.particle-4 { width: 160px; height: 160px; top: 20%; left: 20%; animation-duration: 11s; }

@keyframes floatParticle {
  0% { transform: translateY(0) scale(1); opacity: 0.3; }
  100% { transform: translateY(-30px) scale(1.2); opacity: 0.7; }
}

/* Inputs with Icons */
.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}
.input-with-icon .input-icon {
  position: absolute;
  right: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
  transition: var(--trans);
}
.input-with-icon .form-control {
  padding-right: 42px;
}
.input-with-icon .form-control:focus + .input-icon,
.input-with-icon:focus-within .input-icon {
  color: var(--crimson);
}

/* Glowing Submit Button */
.glowing-submit-btn {
  width: 100%;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--crimson), #c0293f);
  box-shadow: 0 6px 20px rgba(139,26,47,0.4), 0 0 0 1px rgba(201,168,76,0.3);
  transition: var(--trans);
}
.glowing-submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(139,26,47,0.6), 0 0 12px rgba(201,168,76,0.5);
}

/* Quick Login Chips */
.quick-login-chips {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed rgba(13,27,62,0.12);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.quick-login-chips .chip-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-left: 4px;
}
.login-chip {
  background: rgba(13,27,62,0.04);
  border: 1px solid rgba(13,27,62,0.1);
  padding: 4px 10px;
  border-radius: 16px;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
  transition: var(--trans);
}
.login-chip:hover {
  background: var(--crimson);
  color: white;
  border-color: var(--crimson);
  transform: scale(1.04);
}

/* ================================================================
   APP LAYOUT
   ================================================================ */
#app {
  display: flex;
  min-height: 100vh;
}
.hidden { display: none !important; }

/* ── Sidebar ── */
.sidebar {
  width: 260px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-mid) 100%);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  z-index: 100;
  box-shadow: -4px 0 24px rgba(0,0,0,.25);
  transition: var(--trans);
}
.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-logo {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--crimson), var(--crimson-l));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(139,26,47,.4);
}
.sidebar-logo svg { width: 24px; height: 24px; fill: white; }
.sidebar-title { color: white; }
.sidebar-title h2 { font-size: .95rem; font-weight: 700; line-height: 1.2; }
.sidebar-title p  { font-size: .72rem; color: var(--gold-light); margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-section { margin-bottom: 8px; }
.nav-section-label {
  font-size: .7rem; font-weight: 700;
  color: rgba(255,255,255,.35);
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 8px 12px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.7);
  font-size: .92rem;
  font-weight: 500;
  transition: var(--trans);
  cursor: pointer;
  margin-bottom: 2px;
  position: relative;
}
.nav-item:hover {
  background: rgba(255,255,255,.08);
  color: white;
}
.nav-item.active {
  background: linear-gradient(135deg, var(--crimson), rgba(139,26,47,.8));
  color: white;
  box-shadow: 0 4px 12px rgba(139,26,47,.3);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  right: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--gold);
  border-radius: 2px 0 0 2px;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge {
  margin-right: auto;
  background: var(--crimson-l);
  color: white;
  font-size: .7rem;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 700;
}
.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: rgba(255,255,255,.07);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .85rem;
  color: var(--navy);
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-info .name { color: white; font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .role { color: var(--gold-light); font-size: .72rem; }

/* ── Main Content ── */
.main {
  margin-right: 260px;
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 8px rgba(0,0,0,.06);
}
.topbar-title { font-size: 1.2rem; font-weight: 700; color: var(--navy); }
.topbar-subtitle { font-size: .82rem; color: var(--text-muted); margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.content { flex: 1; padding: 28px; }

/* ================================================================
   COMPONENTS
   ================================================================ */

/* ── Cards ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: 1rem; font-weight: 700; color: var(--navy); display: flex; align-items: center; gap: 8px; }
.card-title svg { width: 18px; height: 18px; color: var(--crimson); }
.card-body { padding: 24px; }

/* ── Stat Cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 28px; }
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--trans);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.stat-card.navy::before  { background: linear-gradient(90deg, var(--navy), var(--navy-light)); }
.stat-card.crimson::before { background: linear-gradient(90deg, var(--crimson), var(--crimson-l)); }
.stat-card.gold::before  { background: linear-gradient(90deg, var(--gold), var(--gold-light)); }
.stat-card.green::before { background: linear-gradient(90deg, #16a34a, #22c55e); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon.navy   { background: rgba(13,27,62,.1); color: var(--navy-light); }
.stat-icon.crimson{ background: rgba(139,26,47,.1); color: var(--crimson-l); }
.stat-icon.gold   { background: rgba(201,168,76,.15); color: var(--gold); }
.stat-icon.green  { background: rgba(22,163,74,.1); color: #16a34a; }
.stat-icon svg { width: 26px; height: 26px; }
.stat-info { flex: 1; }
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--navy); line-height: 1; }
.stat-label { font-size: .82rem; color: var(--text-muted); margin-top: 4px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 600;
  border: none;
  transition: var(--trans);
  white-space: nowrap;
  cursor: pointer;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: linear-gradient(135deg, var(--navy), var(--navy-light)); color: white; box-shadow: 0 4px 12px rgba(13,27,62,.3); }
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-crimson { background: linear-gradient(135deg, var(--crimson), var(--crimson-l)); color: white; box-shadow: 0 4px 12px rgba(139,26,47,.3); }
.btn-crimson:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-gold { background: linear-gradient(135deg, var(--gold), var(--gold-light)); color: var(--navy); box-shadow: 0 4px 12px rgba(201,168,76,.3); }
.btn-gold:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-success { background: linear-gradient(135deg, #16a34a, #22c55e); color: white; box-shadow: 0 4px 12px rgba(22,163,74,.3); }
.btn-success:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--navy); background: rgba(13,27,62,.04); }
.btn-danger { background: linear-gradient(135deg, #dc2626, #ef4444); color: white; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-sm { padding: 7px 14px; font-size: .82rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn-icon { padding: 8px; border-radius: 8px; }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none !important; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .88rem; font-weight: 600; color: var(--text); margin-bottom: 7px; }
.form-label .required { color: var(--crimson-l); }
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Tajawal', sans-serif;
  font-size: .92rem;
  color: var(--text);
  background: #fff;
  transition: var(--trans);
  outline: none;
}
.form-control:focus { border-color: var(--navy-light); box-shadow: 0 0 0 3px rgba(30,58,123,.1); }
.form-control::placeholder { color: var(--text-light); }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2364748b'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  background-size: 18px;
  padding-left: 36px;
}
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }

/* ── Tables ── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--navy);
  color: white;
  font-weight: 600;
  font-size: .85rem;
  padding: 13px 16px;
  text-align: right;
  white-space: nowrap;
}
thead th:first-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
thead th:last-child  { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
tbody tr { border-bottom: 1px solid var(--border); transition: background .15s; }
tbody tr:last-child { border: none; }
tbody tr:hover { background: rgba(13,27,62,.03); }
tbody td { padding: 13px 16px; font-size: .9rem; color: var(--text); vertical-align: middle; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
}
.badge-navy    { background: rgba(13,27,62,.1); color: var(--navy); }
.badge-crimson { background: rgba(139,26,47,.1); color: var(--crimson-l); }
.badge-gold    { background: rgba(201,168,76,.15); color: #92720a; }
.badge-success { background: rgba(22,163,74,.1); color: #16a34a; }
.badge-warning { background: rgba(217,119,6,.1); color: var(--warning); }
.badge-info    { background: rgba(14,165,233,.1); color: var(--info); }
.badge-danger  { background: rgba(220,38,38,.1); color: var(--danger); }

/* ── Search Bar ── */
.search-bar {
  position: relative;
  flex: 1;
  max-width: 400px;
}
.search-bar input {
  width: 100%;
  padding: 10px 44px 10px 16px;
  border: 1.5px solid var(--border);
  border-radius: 50px;
  font-size: .9rem;
  font-family: 'Tajawal', sans-serif;
  outline: none;
  transition: var(--trans);
  background: var(--bg);
}
.search-bar input:focus { border-color: var(--navy-light); background: white; box-shadow: 0 0 0 3px rgba(30,58,123,.08); }
.search-bar .search-icon {
  position: absolute;
  right: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.search-bar .search-icon svg { width: 18px; height: 18px; }
.search-results-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0; left: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 200;
  max-height: 340px;
  overflow-y: auto;
}
.search-result-item {
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer;
  transition: background .15s;
  border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border: none; }
.search-result-item:hover { background: rgba(13,27,62,.04); }
.search-result-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem;
  flex-shrink: 0;
}

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  animation: fadeIn .2s ease;
}
.modal {
  background: var(--card);
  border-radius: 18px;
  width: 100%; max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp .25s ease;
}
.modal-lg { max-width: 860px; }
.modal-xl { max-width: 1100px; }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: white; z-index: 1;
  border-radius: 18px 18px 0 0;
}
.modal-title { font-size: 1.05rem; font-weight: 700; color: var(--navy); display: flex; align-items: center; gap: 10px; }
.modal-title svg { width: 20px; height: 20px; color: var(--crimson); }
.modal-close { width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--bg); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: var(--trans); }
.modal-close:hover { background: var(--border); }
.modal-close svg { width: 16px; height: 16px; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 12px; justify-content: flex-start; }

/* ── Animations ── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }

/* ── Toast ── */
#toast-container {
  position: fixed; top: 24px; left: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  border-left: 4px solid;
  min-width: 300px;
  max-width: 420px;
  animation: slideToast .3s ease;
}
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }
.toast.info    { border-color: var(--info); }
.toast-icon svg { width: 20px; height: 20px; }
.toast.success .toast-icon { color: var(--success); }
.toast.error   .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info    .toast-icon { color: var(--info); }
.toast-message { flex: 1; font-size: .9rem; font-weight: 500; color: var(--text); }
@keyframes slideToast { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: none; } }

/* ── Loading ── */
.loader { width: 20px; height: 20px; border: 2.5px solid rgba(255,255,255,.3); border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; }
.page-loader {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.9);
  z-index: 9998;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
}
.page-loader .big-loader {
  width: 48px; height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--crimson);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* ── Patient Card ── */
.patient-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: var(--trans);
  display: flex; align-items: center; gap: 16px;
}
.patient-card:hover { border-color: var(--navy-light); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.patient-avatar-lg {
  width: 54px; height: 54px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.1rem;
  flex-shrink: 0;
}
.patient-avatar-lg.male   { background: rgba(13,27,62,.1); color: var(--navy); }
.patient-avatar-lg.female { background: rgba(139,26,47,.1); color: var(--crimson-l); }
.patient-info { flex: 1; min-width: 0; }
.patient-name { font-weight: 700; font-size: .98rem; color: var(--navy); margin-bottom: 4px; }
.patient-meta { font-size: .82rem; color: var(--text-muted); display: flex; gap: 12px; flex-wrap: wrap; }

/* ── Visit Timeline ── */
.timeline { position: relative; }
.timeline::before {
  content: '';
  position: absolute;
  right: 21px; top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--navy-light), var(--border));
}
.timeline-item { display: flex; gap: 16px; margin-bottom: 24px; position: relative; }
.timeline-dot {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--crimson), var(--crimson-l));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  z-index: 1;
  box-shadow: 0 3px 10px rgba(139,26,47,.3);
}
.timeline-dot svg { width: 20px; height: 20px; fill: white; }
.timeline-card {
  flex: 1;
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--trans);
}
.timeline-card:hover { border-color: var(--navy-light); box-shadow: var(--shadow); }
.timeline-date { font-size: .8rem; color: var(--text-muted); margin-bottom: 6px; }
.timeline-complaint { font-weight: 600; font-size: .95rem; color: var(--navy); margin-bottom: 4px; }
.timeline-diagnosis { font-size: .85rem; color: var(--text-muted); }

/* ── Image Gallery ── */
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.image-item {
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: var(--trans);
  position: relative;
  aspect-ratio: 1;
  background: var(--bg);
}
.image-item:hover { border-color: var(--navy-light); transform: scale(1.03); }
.image-item img { width: 100%; height: 100%; object-fit: cover; }
.image-item .pdf-icon { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: rgba(220,38,38,.08); }
.image-item .pdf-icon svg { width: 40px; height: 40px; color: var(--danger); }
.image-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  opacity: 0; transition: var(--trans);
}
.image-item:hover .image-overlay { opacity: 1; }

/* ── Upload Zone ── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: var(--trans);
  background: var(--bg);
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--navy-light); background: rgba(13,27,62,.03); }
.upload-zone svg { width: 48px; height: 48px; color: var(--text-muted); margin-bottom: 12px; }
.upload-zone p  { font-size: .9rem; color: var(--text-muted); }
.upload-zone strong { color: var(--navy-light); }

/* ── Print Styles ── */
@media print {
  .sidebar, .topbar, .btn, .modal-backdrop { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  .print-report { padding: 20px; }
}
.print-header { border-bottom: 3px solid var(--navy); padding-bottom: 16px; margin-bottom: 20px; }
.print-clinic-name { font-size: 1.5rem; font-weight: 900; color: var(--navy); }
.print-section { margin-bottom: 16px; }
.print-section h3 { font-size: .95rem; font-weight: 700; color: var(--crimson); border-bottom: 1px solid var(--border); padding-bottom: 6px; margin-bottom: 10px; }

/* ── Vital Signs ── */
.vitals-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.vital-item {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  border: 1px solid var(--border);
}
.vital-label { font-size: .75rem; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; }
.vital-value { font-size: 1.1rem; font-weight: 800; color: var(--navy); }
.vital-unit  { font-size: .75rem; color: var(--text-muted); }

/* ── Prescription ── */
.medication-row {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  position: relative;
}
.medication-row .remove-med {
  position: absolute; top: 8px; left: 8px;
  background: none; border: none;
  color: var(--danger); cursor: pointer;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* ── Tabs ── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.tab {
  padding: 12px 24px;
  font-size: .92rem; font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--trans);
}
.tab:hover { color: var(--navy); }
.tab.active { color: var(--navy); border-bottom-color: var(--crimson-l); }

/* ── Profile Header ── */
.profile-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 50%, var(--crimson) 100%);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  color: white;
  position: relative;
  overflow: hidden;
}
.profile-header::before {
  content: '';
  position: absolute;
  top: -40px; left: -40px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(201,168,76,.2) 0%, transparent 70%);
  border-radius: 50%;
}
.profile-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  border: 3px solid rgba(255,255,255,.3);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 1.8rem;
  flex-shrink: 0;
}
.profile-name { font-size: 1.4rem; font-weight: 800; margin-bottom: 6px; }
.profile-meta { display: flex; gap: 20px; flex-wrap: wrap; }
.profile-meta span { font-size: .85rem; opacity: .85; display: flex; align-items: center; gap: 6px; }
.profile-meta svg { width: 15px; height: 15px; }
.profile-file-num {
  margin-right: auto;
  background: rgba(201,168,76,.25);
  border: 1px solid rgba(201,168,76,.4);
  padding: 8px 16px;
  border-radius: 8px;
  text-align: center;
}
.profile-file-num .label { font-size: .75rem; opacity: .75; }
.profile-file-num .num { font-size: 1.1rem; font-weight: 800; color: var(--gold-light); }

/* ── Mobile Sidebar Overlay & Toggle ── */
.mobile-menu-btn {
  display: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  color: var(--navy);
  cursor: pointer;
  transition: var(--trans);
  flex-shrink: 0;
}
.mobile-menu-btn:hover { background: var(--border); }

.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(13, 27, 62, 0.65);
  backdrop-filter: blur(4px);
  z-index: 99;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
}
.sidebar-overlay.active {
  opacity: 1; pointer-events: auto;
}

/* ── Responsive Media Queries ── */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .vitals-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 992px) {
  .mobile-menu-btn { display: flex; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; right: 0;
    width: 270px;
    z-index: 100;
    transform: translateX(100%);
    box-shadow: -4px 0 25px rgba(0,0,0,0.2);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-right: 0 !important; width: 100% !important; }
  .topbar { padding: 12px 16px; gap: 12px; }
  .topbar-actions { gap: 8px; }
  .search-bar { max-width: 200px !important; width: auto !important; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .vitals-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .topbar-actions { justify-content: space-between; width: 100%; }
  .search-bar { max-width: 100% !important; width: 100% !important; flex: 1; }
  .stats-grid { grid-template-columns: 1fr; }
  .vitals-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; gap: 12px; }
  .content { padding: 14px 12px; }
  .card-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .card-actions { width: 100%; justify-content: flex-start; }
  .patient-card { flex-direction: column; align-items: flex-start; }
  .profile-header { flex-direction: column; align-items: flex-start; }
  .profile-file-num { margin-right: 0; width: 100%; margin-top: 10px; }
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; display: block; }
  table { min-width: 620px; }
  .modal { width: 95vw; max-height: 92vh; padding: 16px; border-radius: 12px; }
  .login-card { width: 94vw; padding: 28px 18px; }
}

/* ── Lightbox ── */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.95);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .2s ease;
}
.lightbox img { max-width: 90vw; max-height: 90vh; object-fit: contain; border-radius: 8px; }
.lightbox-close {
  position: absolute; top: 20px; right: 20px;
  width: 44px; height: 44px;
  background: rgba(255,255,255,.15);
  border: none; border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 20px;
  transition: var(--trans);
}
.lightbox-close:hover { background: rgba(255,255,255,.25); }

/* ── Audit Log ── */
.audit-action {
  font-family: monospace; font-size: .8rem;
  background: var(--bg); padding: 3px 8px;
  border-radius: 4px; color: var(--navy);
}

/* ── Diagnosis Suggestions ── */
.diagnosis-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: rgba(14,165,233,.1);
  border: 1px solid rgba(14,165,233,.3);
  border-radius: 20px;
  font-size: .82rem;
  cursor: pointer;
  transition: var(--trans);
  color: var(--info);
}
.diagnosis-chip:hover { background: var(--info); color: white; border-color: var(--info); }

/* ── Empty State ── */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: .4; }
.empty-state h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.empty-state p  { font-size: .9rem; }

/* ================================================================
   NEW OFFICIAL LOGO & BRANDING STYLES
   ================================================================ */
.login-brand-badge-wrapper {
  position: relative;
  width: 110px;
  height: 110px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-brand-badge {
  width: 96px;
  height: 96px;
  border-radius: 24px;
  overflow: hidden;
  background: #07132b;
  border: 2.5px solid var(--gold);
  box-shadow: 0 8px 32px rgba(13,27,62,0.4), 0 0 16px rgba(201,168,76,0.3);
  position: relative;
  z-index: 2;
  transition: var(--trans);
}
.login-brand-badge:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 40px rgba(139,26,47,0.5), 0 0 24px rgba(201,168,76,0.5);
}
.login-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sidebar-logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  overflow: hidden;
  background: #07132b;
  border: 1.5px solid var(--gold);
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ================================================================
   ECHOCARDIOGRAPHY MODULE STYLES
   ================================================================ */
.echo-measurements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.echo-param-card {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: var(--trans);
  position: relative;
}
.echo-param-card:focus-within {
  border-color: var(--navy);
  background: white;
  box-shadow: 0 4px 16px rgba(13,27,62,0.08);
}
.echo-param-card.param-ef {
  border-color: rgba(139,26,47,0.4);
  background: #fffafa;
}
.echo-param-card.param-ef:focus-within {
  border-color: var(--crimson);
  box-shadow: 0 4px 16px rgba(139,26,47,0.15);
}
.echo-param-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.echo-param-name {
  font-weight: 800;
  font-size: .95rem;
  color: var(--navy);
  font-family: 'Cinzel', 'Tajawal', sans-serif;
  letter-spacing: .5px;
  direction: ltr;
}
.echo-param-ref {
  font-size: .72rem;
  font-weight: 700;
  color: #64748b;
  background: rgba(100,116,139,0.1);
  padding: 2px 7px;
  border-radius: 12px;
  direction: ltr;
}
.echo-param-card.param-ef .echo-param-ref {
  background: rgba(139,26,47,0.1);
  color: var(--crimson);
}
.echo-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}
.echo-input-wrapper .form-control {
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
  direction: ltr;
}
.echo-unit {
  font-size: .8rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 32px;
  direction: ltr;
}

/* Quick templates & helper chips */
.echo-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.echo-chip {
  background: white;
  border: 1px solid #cbd5e1;
  padding: 3px 10px;
  border-radius: 14px;
  font-size: .76rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: var(--trans);
  user-select: none;
}
.echo-chip:hover {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
  transform: translateY(-1px);
}
.echo-chip.chip-normal {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}
.echo-chip.chip-normal:hover {
  background: #16a34a;
  color: white;
  border-color: #16a34a;
}
.echo-chip.chip-warning {
  border-color: #fde68a;
  background: #fefce8;
  color: #854d0e;
}
.echo-chip.chip-warning:hover {
  background: #d97706;
  color: white;
  border-color: #d97706;
}

/* EF Badges in Table */
.ef-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 16px;
  font-weight: 800;
  font-size: .84rem;
  direction: ltr;
}
.ef-badge.normal {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}
.ef-badge.mild {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fcd34d;
}
.ef-badge.reduced {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

/* Echo Form English / LTR fields */
#echo-form textarea,
#echo-form input[type="text"],
#echo-form .echo-param-card input {
  direction: ltr !important;
  text-align: left !important;
}
#echo-form .echo-param-header {
  direction: ltr !important;
}
#echo-form .form-label {
  direction: ltr !important;
  text-align: left !important;
}

