/* ============================================
   نظام إدارة العيادات المتكامل - الأنماط الرئيسية
   Clinic CRM - Main Stylesheet
   Direction: RTL | Arabic
============================================ */

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

:root {
  /* Primary Palette */
  --navy: #1a3a4a;
  --navy-dark: #0f2535;
  --navy-mid: #1e4a5e;
  --navy-light: #2a5f7a;

  /* Green Sidebar Palette */
  --sidebar-bg: #e8f5f0;
  --sidebar-bg-dark: #d4ede5;
  --sidebar-accent: #2e8b6e;
  --sidebar-accent-light: #3aab88;
  --sidebar-active-bg: rgba(46, 139, 110, 0.15);
  --sidebar-text: #1a3a2e;

  /* Main Colors */
  --primary: #1a3a4a;
  --primary-hover: #0f2535;
  --accent-green: #2e8b6e;
  --accent-green-light: #3aab88;
  --accent-gold: #c9973a;
  --accent-coral: #e05c5c;

  /* Background & Surface */
  --bg: #f7faf9;
  --surface: #ffffff;
  --surface-2: #f0f7f4;
  --border: #d8eae4;
  --border-light: #e8f4f0;

  /* Text */
  --text: #1a2e28;
  --text-secondary: #4a6b60;
  --text-muted: #8aada3;
  --text-light: #b0cbc4;

  /* Status */
  --success: #2e8b6e;
  --success-bg: #e8f5f0;
  --warning: #c9973a;
  --warning-bg: #fdf4e3;
  --danger: #e05c5c;
  --danger-bg: #fdeaea;
  --info: #2a7ab5;
  --info-bg: #e3f0fb;

  /* Spacing */
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);

  /* Transitions */
  --trans: 0.22s ease;
}

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

/* ============================================
   LAYOUT
============================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ============================================
   SIDEBAR
============================================ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-left: 1px solid var(--sidebar-bg-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--trans);
}

.sidebar-logo {
  padding: 22px 20px 16px;
  border-bottom: 1px solid var(--sidebar-bg-dark);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo .logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo .logo-icon svg {
  width: 22px;
  height: 22px;
  fill: white;
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
}

.sidebar-logo-text .brand {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.2;
}

.sidebar-logo-text .brand-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* User Info in Sidebar */
.sidebar-user {
  padding: 14px 16px;
  margin: 12px;
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user .avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-green), var(--accent-green-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-info .user-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-info .user-role {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 8px;
}

.nav-section {
  margin-bottom: 6px;
}

.nav-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 12px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 0.87rem;
  font-weight: 600;
  transition: all var(--trans);
  cursor: pointer;
  margin-bottom: 1px;
  position: relative;
}

.nav-item:hover {
  background: rgba(46,139,110,0.1);
  color: var(--accent-green);
}

.nav-item.active {
  background: var(--accent-green);
  color: white;
  box-shadow: 0 4px 12px rgba(46,139,110,0.3);
}

.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-item .nav-badge {
  margin-right: auto;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.nav-item.active .nav-badge {
  background: rgba(255,255,255,0.3);
}

/* Sidebar Bottom */
.sidebar-bottom {
  padding: 12px;
  border-top: 1px solid var(--sidebar-bg-dark);
}

.sidebar-bottom .nav-item {
  color: var(--danger);
}

.sidebar-bottom .nav-item:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ============================================
   TOPBAR
============================================ */
.topbar {
  position: fixed;
  top: 0;
  right: var(--sidebar-w);
  left: 0;
  height: var(--topbar-h);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  z-index: 90;
  box-shadow: var(--shadow);
}

.topbar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  padding: 8px;
  border-radius: var(--radius-sm);
}

.topbar-search {
  flex: 1;
  max-width: 340px;
  position: relative;
}

.topbar-search input {
  width: 100%;
  padding: 8px 36px 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: 50px;
  background: var(--surface-2);
  font-size: 0.84rem;
  color: var(--text);
  outline: none;
  transition: border-color var(--trans);
  direction: rtl;
}

.topbar-search input:focus {
  border-color: var(--accent-green);
  background: white;
}

.topbar-search .search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: auto;
}

.topbar-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all var(--trans);
}

.topbar-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.topbar-btn .badge {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid white;
}

.topbar-clinic {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all var(--trans);
}

.topbar-clinic:hover { border-color: var(--accent-green); }

.topbar-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

/* ============================================
   MAIN CONTENT
============================================ */
.main-content {
  margin-right: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 24px;
  min-height: calc(100vh - var(--topbar-h));
}

/* ============================================
   PAGE HEADER
============================================ */
.page-header {
  margin-bottom: 22px;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-header p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 3px;
}

/* ============================================
   CARDS
============================================ */
.card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Stat Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  transition: transform var(--trans), box-shadow var(--trans);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.3rem;
}

.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.navy { background: #e3edf3; color: var(--navy); }
.stat-icon.gold { background: var(--warning-bg); color: var(--warning); }
.stat-icon.coral { background: var(--danger-bg); color: var(--danger); }
.stat-icon.info { background: var(--info-bg); color: var(--info); }
.stat-icon.purple { background: #f0e8fb; color: #7c3aed; }

.stat-body {}
.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 2px;
}
.stat-change {
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 4px;
}
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ============================================
   BUTTONS
============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all var(--trans);
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
}
.btn-primary:hover { background: var(--navy-dark); border-color: var(--navy-dark); }

.btn-success {
  background: var(--accent-green);
  color: white;
  border-color: var(--accent-green);
}
.btn-success:hover { background: var(--sidebar-accent); }

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover { border-color: var(--navy); color: var(--navy); background: var(--surface-2); }

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover { background: #c94444; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.btn-lg { padding: 12px 24px; font-size: 0.95rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { width: 36px; height: 36px; padding: 0; justify-content: center; }

/* ============================================
   BADGES
============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-navy { background: #e3edf3; color: var(--navy); }
.badge-gray { background: var(--surface-2); color: var(--text-muted); }

/* ============================================
   FORMS
============================================ */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.form-label span { color: var(--danger); }

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--text);
  font-size: 0.88rem;
  font-family: inherit;
  direction: rtl;
  outline: none;
  transition: border-color var(--trans), box-shadow var(--trans);
}

.form-control:focus {
  border-color: var(--accent-green);
  box-shadow: 0 0 0 3px rgba(46,139,110,0.1);
}

.form-control.error { border-color: var(--danger); }

.form-control-icon {
  position: relative;
}

.form-control-icon .form-control {
  padding-right: 38px;
}

.form-control-icon .icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

.form-error {
  color: var(--danger);
  font-size: 0.76rem;
  font-weight: 600;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.form-hint {
  color: var(--text-muted);
  font-size: 0.76rem;
  margin-top: 4px;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input { opacity:0; width:0; height:0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 50px;
  cursor: pointer;
  transition: var(--trans);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  right: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--trans);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider { background: var(--accent-green); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(-20px); }

/* ============================================
   TABLE
============================================ */
.table-responsive { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.table th {
  padding: 11px 14px;
  text-align: right;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--surface-2); }

/* ============================================
   MODAL
============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--trans);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.97);
  transition: transform var(--trans);
}

.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  background: var(--surface-2);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--trans);
  flex-shrink: 0;
}

.modal-close:hover { background: var(--danger-bg); color: var(--danger); }

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ============================================
   TOAST NOTIFICATIONS
============================================ */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
}

.toast {
  background: white;
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  border-right: 4px solid var(--accent-green);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toastIn 0.3s ease forwards;
}

.toast.error { border-right-color: var(--danger); }
.toast.warning { border-right-color: var(--warning); }
.toast.info { border-right-color: var(--info); }

@keyframes toastIn {
  from { transform: translateX(-20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast-icon { color: var(--accent-green); flex-shrink: 0; }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--info); }

.toast-body { flex: 1; }
.toast-title { font-size: 0.84rem; font-weight: 700; color: var(--text); }
.toast-msg { font-size: 0.78rem; color: var(--text-muted); margin-top: 1px; }

/* ============================================
   EMPTY STATE
============================================ */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.6;
}

.empty-state h3 { font-size: 1rem; font-weight: 700; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 0.84rem; }

/* ============================================
   TABS
============================================ */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  width: fit-content;
  margin-bottom: 20px;
}

.tab-btn {
  padding: 7px 16px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--trans);
  font-family: inherit;
}

.tab-btn.active {
  background: white;
  color: var(--navy);
  box-shadow: var(--shadow);
}

/* ============================================
   DROPDOWN
============================================ */
.dropdown { position: relative; }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: all var(--trans);
}

.dropdown-menu.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 0.84rem;
  color: var(--text);
  cursor: pointer;
  transition: background var(--trans);
}

.dropdown-item:hover { background: var(--surface-2); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-bg); }
.dropdown-divider { border-top: 1px solid var(--border); margin: 4px 0; }

/* ============================================
   SEARCH BAR
============================================ */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  transition: border-color var(--trans);
}

.search-bar:focus-within { border-color: var(--accent-green); background: white; }

.search-bar input {
  border: none;
  background: transparent;
  flex: 1;
  font-size: 0.86rem;
  color: var(--text);
  outline: none;
  direction: rtl;
  font-family: inherit;
}

.search-bar input::placeholder { color: var(--text-muted); }

/* ============================================
   APPOINTMENT CARD
============================================ */
.appt-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all var(--trans);
  cursor: pointer;
  margin-bottom: 10px;
}

.appt-card:hover { border-color: var(--accent-green); box-shadow: var(--shadow); }

.appt-time {
  text-align: center;
  min-width: 60px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
}

.appt-time .hour { font-size: 1rem; font-weight: 800; color: var(--navy); line-height: 1; }
.appt-time .period { font-size: 0.7rem; color: var(--text-muted); }

.appt-info { flex: 1; min-width: 0; }
.appt-name { font-weight: 700; font-size: 0.9rem; color: var(--text); margin-bottom: 2px; }
.appt-meta { font-size: 0.75rem; color: var(--text-muted); display: flex; gap: 10px; flex-wrap: wrap; }

.appt-status { margin-right: auto; }

/* ============================================
   PATIENT CARD
============================================ */
.patient-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--trans);
}

.patient-row:hover { border-color: var(--accent-green); box-shadow: var(--shadow); }

.patient-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.patient-info { flex: 1; min-width: 0; }
.patient-name { font-weight: 700; font-size: 0.9rem; color: var(--text); margin-bottom: 2px; }
.patient-meta { font-size: 0.75rem; color: var(--text-muted); display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================================
   CALENDAR
============================================ */
.mini-calendar {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.cal-header {
  background: var(--navy);
  color: white;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
}

.cal-nav { background: none; border: none; color: white; cursor: pointer; padding: 4px; opacity: 0.8; }
.cal-nav:hover { opacity: 1; }

.cal-grid {
  padding: 12px;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  margin-bottom: 6px;
}

.cal-weekday {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 4px;
}

.cal-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}

.cal-day {
  padding: 6px 2px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--trans);
  color: var(--text);
}

.cal-day:hover { background: var(--surface-2); }
.cal-day.other-month { color: var(--text-light); }
.cal-day.today { background: var(--accent-green); color: white; font-weight: 700; }
.cal-day.selected { background: var(--navy); color: white; }
.cal-day.has-appt { position: relative; }
.cal-day.has-appt::after {
  content: '';
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent-gold);
}

/* ============================================
   QUICK ACTIONS
============================================ */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.quick-action-btn {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
  cursor: pointer;
  transition: all var(--trans);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.quick-action-btn:hover {
  border-color: var(--navy);
  background: var(--surface-2);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.quick-action-btn .qa-icon {
  font-size: 1.5rem;
}

.quick-action-btn .qa-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
}

/* ============================================
   PROGRESS / STATS
============================================ */
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 50px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 50px;
  background: var(--accent-green);
  transition: width 0.5s ease;
}

/* ============================================
   TIMELINE
============================================ */
.timeline {
  position: relative;
  padding-right: 20px;
}

.timeline::before {
  content: '';
  position: absolute;
  right: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding: 0 20px 20px 0;
}

.timeline-item::before {
  content: '';
  position: absolute;
  right: -14px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-green);
  border: 2px solid white;
  box-shadow: 0 0 0 2px var(--accent-green);
}

.timeline-time { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; margin-bottom: 2px; }
.timeline-content { font-size: 0.84rem; color: var(--text); }

/* ============================================
   LOGIN PAGE
============================================ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f2535 0%, #1a3a4a 40%, #1e5c4a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.login-bg-decoration {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.login-bg-decoration .circle {
  position: absolute;
  border-radius: 50%;
  opacity: 0.08;
  background: white;
}

.login-bg-decoration .circle-1 { width: 400px; height: 400px; top: -100px; right: -100px; }
.login-bg-decoration .circle-2 { width: 300px; height: 300px; bottom: -80px; left: -80px; }
.login-bg-decoration .circle-3 { width: 200px; height: 200px; top: 40%; left: 10%; }

.login-card {
  background: white;
  border-radius: 20px;
  padding: 36px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo .logo-mark {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--navy), var(--accent-green));
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  box-shadow: 0 8px 24px rgba(26,58,74,0.3);
}

.login-logo .logo-mark svg { width: 32px; height: 32px; fill: white; }

.login-logo h1 {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--navy);
  margin-bottom: 4px;
}

.login-logo p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Role Switcher */
.role-switcher {
  display: flex;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 20px;
  gap: 3px;
}

.role-btn {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--trans);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
}

.role-btn.active {
  background: var(--navy);
  color: white;
  box-shadow: var(--shadow);
}

.login-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

/* ============================================
   ALERT / BANNER
============================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 0.84rem;
}

.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success); }
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning); }
.alert-info { background: var(--info-bg); color: var(--info); border: 1px solid var(--info); }

.alert-title { font-weight: 700; margin-bottom: 2px; }
.alert p { margin: 0; }

/* ============================================
   SECTION TABS / CONTENT
============================================ */
.content-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  gap: 0;
}

.content-tab {
  padding: 10px 18px;
  border: none;
  background: transparent;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--trans);
}

.content-tab.active {
  color: var(--accent-green);
  border-bottom-color: var(--accent-green);
  font-weight: 700;
}

.content-tab:hover:not(.active) { color: var(--text); }

/* ============================================
   SIDEBAR OVERLAY (mobile)
============================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}

/* ============================================
   SCROLLBAR
============================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 50px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ============================================
   UTILITIES
============================================ */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 700; }
.text-sm { font-size: 0.82rem; }
.text-xs { font-size: 0.74rem; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.rounded { border-radius: var(--radius-sm); }
.rounded-full { border-radius: 50px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ============================================
   RESPONSIVE
============================================ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(100%);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .sidebar-overlay { display: block; }
  .main-content {
    margin-right: 0;
    padding: 16px;
  }
  .topbar {
    right: 0;
  }
  .topbar-toggle { display: flex; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 24px 20px; }
  .modal { padding: 20px; }
  .topbar-date { display: none; }
  .topbar-search { display: none; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: 1fr 1fr; }
}

/* ============================================
   PRINT
============================================ */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-content { margin: 0; padding: 0; }
}

/* ============================================
   ANIMATIONS
============================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-in { animation: fadeIn 0.3s ease forwards; }
.animate-slide { animation: slideIn 0.3s ease forwards; }

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border-light) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Color swatch items */
.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.color-dot.green { background: var(--accent-green); }
.color-dot.navy { background: var(--navy); }
.color-dot.gold { background: var(--accent-gold); }
.color-dot.coral { background: var(--accent-coral); }
