* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
  background: #f4f6f8;
  color: #1f2937;
  direction: rtl;
}
a { color: #2563eb; text-decoration: none; }

.topnav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #111827;
  color: #fff;
  padding: 14px 24px;
}
.topnav-title { font-weight: 600; font-size: 16px; }

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.back-link { display: inline-block; margin-bottom: 12px; font-size: 14px; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-header h1 { margin: 0 0 4px; font-size: 22px; }

.muted { color: #6b7280; font-size: 14px; }

.card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 20px;
}
.card-title { margin-top: 0; font-size: 17px; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: right;
  padding: 10px 8px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 14px;
}
.table th { color: #6b7280; font-weight: 600; font-size: 13px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.empty-state { text-align: center; padding: 24px 0; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-green { background: #dcfce7; color: #15803d; }
.badge-gray { background: #f3f4f6; color: #4b5563; }

.btn {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #1f2937;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { background: #f9fafb; }
.btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { color: #dc2626; border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-small { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 10px; }
.btn-link { background: none; border: none; color: #cbd5e1; cursor: pointer; font-size: 14px; }
.btn-link:hover { color: #fff; }

.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.alert-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* تسجيل الدخول */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: #fff;
  padding: 32px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  width: 100%;
  max-width: 360px;
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }

/* نماذج */
form label {
  display: block;
  font-size: 13px;
  color: #374151;
  margin: 12px 0 6px;
  font-weight: 600;
}
form input[type="text"],
form input[type="number"],
form input[type="password"],
form input[type="time"],
form select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
}

/* نافذة منبثقة */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}
.modal {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
}
.modal h2 { margin-top: 0; font-size: 18px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* محرر القالب الأسبوعي */
.template-grid { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.template-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
  flex-wrap: wrap;
  gap: 10px;
}
.template-row.active { background: #eff6ff; border-color: #bfdbfe; }
.day-toggle { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 110px; margin: 0; }
.day-toggle input { width: 18px; height: 18px; }
.time-inputs { display: flex; align-items: center; gap: 8px; }
.time-inputs input { width: 130px; }


/* إصلاح: إخفاء النافذة المنبثقة فعليًا عند وجود خاصية hidden */
.modal-overlay[hidden] {
  display: none;
}

/* شاشة المواعيد الفعلية المولّدة */
.schedule-date-title { font-size: 15px; margin-bottom: 10px; }
.slot-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.slot-chip {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
}
.slot-available { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.slot-booked { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

/* استثناءات الجدول: مواعيد محظورة، وتنقل فرعي بين شاشات الطبيب */
.slot-blocked { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; text-decoration: line-through; }
.subnav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.exceptions-table td, .exceptions-table th { vertical-align: middle; }
.radio-group { display: flex; gap: 18px; margin: 8px 0 4px; }
.radio-group label { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; color: #374151; margin: 0; }
.radio-group input { width: 16px; height: 16px; }
.conflict-list { margin: 8px 0 0; padding-inline-start: 20px; font-size: 13px; }
.badge-red { background: #fef2f2; color: #b91c1c; }
