/* ════════════════════════════════════════════════
   موعد — CSS لوحة الإدارة
   Mobile-First | RTL | Cairo Font
   ════════════════════════════════════════════════ */

/* ─── 1. متغيرات ──────────────────────────────── */
:root {
  --primary:        #1B6B5A;
  --primary-light:  #2A8A75;
  --primary-xlight: #E8F4F1;
  --secondary:      #C9A84C;
  --bg:             #F4F7F6;
  --bg-card:        #FFFFFF;
  --sidebar-bg:     #0F3D2F;
  --sidebar-hover:  rgba(255,255,255,.07);
  --sidebar-active: rgba(27,107,90,.55);
  --text:           #1A2E25;
  --text-muted:     #6B8070;
  --border:         #E0EDE8;
  --shadow:         rgba(27,107,90,.08);
  --shadow-md:      rgba(27,107,90,.15);
  --danger:         #E53E3E;
  --success:        #38A169;
  --warning:        #D69E2E;
  --info:           #3182CE;
  --radius:         12px;
  --radius-lg:      18px;
  --trans:          .2s ease;
  --sidebar-w:      240px;
}

/* ─── 2. Reset ────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html  { scroll-behavior: smooth; }
body  {
  font-family: 'Cairo', sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
}
a       { color: inherit; text-decoration: none; }
button  { cursor: pointer; border: none; background: none; font-family: inherit; }
ul      { list-style: none; }

/* ─── 3. Buttons ──────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .6rem 1.4rem;
  border-radius: var(--radius);
  font-family: 'Cairo', sans-serif;
  font-size: .92rem;
  font-weight: 600;
  transition: all var(--trans);
  white-space: nowrap;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); transform: translateY(-1px);
                     box-shadow: 0 5px 16px var(--shadow-md); }
.btn-outline { background: transparent; color: var(--primary);
               border: 2px solid var(--primary); }
.btn-outline:hover { background: var(--primary-xlight); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #c53030; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #2f855a; }
.btn-large   { padding: .85rem 2rem; font-size: 1rem; }
.btn-full    { width: 100%; }
.btn-sm      { padding: .35rem .9rem; font-size: .82rem; }
.btn:disabled{ opacity: .5; cursor: not-allowed; transform: none !important; }

/* ─── 4. صفحة تسجيل الدخول ──────────────────── */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(140deg, #0C3D30 0%, #1B6B5A 100%);
  padding: 1.5rem;
}
.auth-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.auth-logo-icon  { font-size: 2.75rem; display: block; margin-bottom: .5rem; }
.auth-logo-title { font-size: 1.75rem; font-weight: 800; color: var(--primary); }
.auth-logo-sub   { color: var(--text-muted); font-size: .88rem; margin-top: .2rem; }
.auth-error {
  background: rgba(229,62,62,.08);
  border: 1px solid rgba(229,62,62,.3);
  color: var(--danger);
  padding: .55rem .9rem;
  border-radius: var(--radius);
  font-size: .85rem;
  margin-bottom: 1rem;
}

/* ─── 5. تخطيط لوحة الإدارة ─────────────────── */
.admin-layout {
  display: flex;
  min-height: 100vh;
  direction: rtl;
}

/* ─── 6. Sidebar ──────────────────────────────── */
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 200;
  transition: transform var(--trans);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand-icon { font-size: 1.75rem; }
.sidebar-brand-name { font-size: 1rem; font-weight: 700; }
.sidebar-brand-sub  { font-size: .72rem; opacity: .6; }

.sidebar-nav {
  flex: 1;
  padding: .75rem 0;
  overflow-y: auto;
}
.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .75rem 1rem;
  font-size: .9rem;
  font-weight: 600;
  color: rgba(255,255,255,.75);
  transition: all var(--trans);
  text-align: right;
  border-right: 3px solid transparent;
  position: relative;
}
.nav-btn:hover  { background: var(--sidebar-hover); color: #fff; }
.nav-btn.active {
  background: var(--sidebar-active);
  color: #fff;
  border-right-color: var(--secondary);
}
.nav-btn-icon { font-size: 1.05rem; flex-shrink: 0; }
.nav-badge {
  margin-right: auto;
  background: var(--danger);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 50px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: .9rem 1rem;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
  opacity: .6;
  margin-bottom: .6rem;
  overflow: hidden;
}
.sidebar-user-email { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem .75rem;
  background: rgba(229,62,62,.12);
  color: rgba(255,255,255,.8);
  border-radius: var(--radius);
  font-size: .87rem;
  font-weight: 600;
  transition: all var(--trans);
}
.logout-btn:hover { background: rgba(229,62,62,.25); color: #fff; }

/* ─── 7. المحتوى الرئيسي ─────────────────────── */
.admin-content {
  flex: 1;
  margin-right: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ─── 8. Topbar ───────────────────────────────── */
.admin-topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: .85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px var(--shadow);
}
.mobile-menu-btn {
  font-size: 1.25rem;
  color: var(--text-muted);
  display: none;
}
.topbar-title  { font-size: 1.05rem; font-weight: 700; flex: 1; }
.topbar-right  { display: flex; align-items: center; gap: .75rem; }
.topbar-clinic { font-size: .82rem; color: var(--text-muted); }

/* ─── 9. صفحات ───────────────────────────────── */
.admin-page {
  display: none;
  padding: 1.75rem 1.5rem;
  flex: 1;
}
.admin-page.active { display: block; }

/* ─── 10. بطاقات الإحصاء ────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px,1fr));
  gap: 1.1rem;
  margin-bottom: 1.75rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 2px 10px var(--shadow);
}
.stat-icon-wrap {
  width: 52px; height: 52px;
  border-radius: var(--radius);
  background: var(--primary-xlight);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.stat-icon--blue   { background: rgba(49,130,206,.1); }
.stat-icon--yellow { background: rgba(214,158,46,.1); }
.stat-icon--green  { background: rgba(56,161,105,.1); }
.stat-label { font-size: .8rem; color: var(--text-muted); font-weight: 500; margin-bottom: .2rem; }
.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--primary); line-height: 1; }

/* ─── 11. بطاقات الإدارة ────────────────────── */
.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 2px 12px var(--shadow);
  margin-bottom: 1.5rem;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.card-title { font-size: 1.05rem; font-weight: 700; margin-bottom: .4rem; }
.card-desc  { color: var(--text-muted); font-size: .87rem; margin-bottom: 1.25rem; }

/* ─── 12. فلاتر ───────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
}
.filter-tab {
  padding: .35rem .9rem;
  border-radius: 50px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  transition: all var(--trans);
  font-family: 'Cairo', sans-serif;
}
.filter-tab:hover  { border-color: var(--primary); color: var(--primary); }
.filter-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ─── 13. جدول الحجوزات ─────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.bookings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .86rem;
  min-width: 700px;
}
.bookings-table th {
  background: var(--bg);
  padding: .75rem 1rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.bookings-table td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.bookings-table tr:last-child td { border-bottom: none; }
.bookings-table tr:hover td { background: var(--bg); }

/* الصف المعالج */
.bookings-table tr.handled td {
  color: var(--text-muted);
  text-decoration: line-through;
  background: rgba(0,0,0,.015);
}
.bookings-table tr.handled:hover td { background: rgba(0,0,0,.025); }

/* شارة الحالة في الجدول */
.status-pill {
  display: inline-block;
  padding: .2rem .7rem;
  border-radius: 50px;
  font-size: .78rem;
  font-weight: 700;
}
.status-pill.pending { background: rgba(214,158,46,.12); color: var(--warning); }
.status-pill.handled { background: rgba(56,161,105,.1);  color: var(--success); }

/* زر المعالجة */
.handle-btn {
  padding: .3rem .8rem;
  border-radius: var(--radius);
  font-size: .8rem;
  font-weight: 600;
  background: var(--primary-xlight);
  color: var(--primary);
  border: 1px solid var(--border);
  transition: all var(--trans);
  font-family: 'Cairo', sans-serif;
  cursor: pointer;
  white-space: nowrap;
}
.handle-btn:hover { background: var(--primary); color: #fff; }

/* حالة فارغة */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
  font-size: .9rem;
}

/* ─── 14. إدارة حالة العيادة ────────────────── */
.mode-selector {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.mode-opt { cursor: pointer; }
.mode-opt input { display: none; }
.mode-opt-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  padding: 1rem 1.5rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  transition: all var(--trans);
  min-width: 100px;
}
.mode-opt:has(input:checked) .mode-opt-body {
  border-color: var(--primary);
  background: var(--primary-xlight);
}
.mode-opt-icon  { font-size: 1.5rem; }
.mode-opt-label { font-size: .85rem; font-weight: 700; color: var(--text); }

.mode-panel { margin-bottom: 1.25rem; }
.panel-hint { color: var(--text-muted); font-size: .88rem; margin-bottom: 1rem; }

.manual-btns {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* جدول الجلسات */
.sessions-config { display: flex; flex-direction: column; gap: .75rem; margin-bottom: 1.25rem; }
.session-row     { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.session-row-label {
  font-size: .88rem;
  font-weight: 600;
  min-width: 170px;
  flex-shrink: 0;
}
.session-row-label small { color: var(--text-muted); font-weight: 400; }
.time-pair   { display: flex; align-items: center; gap: .5rem; }
.time-field  { width: 115px; text-align: center; }
.time-sep    { color: var(--text-muted); font-size: .85rem; flex-shrink: 0; }

/* أيام العمل */
.days-selector { display: flex; gap: .5rem; flex-wrap: wrap; }
.day-opt {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .4rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: 50px;
  font-size: .83rem;
  font-weight: 600;
  transition: all var(--trans);
  user-select: none;
}
.day-opt:has(input:checked) {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.day-opt input { display: none; }

/* العطلة */
.vacation-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ملاحظة الحفظ */
.card-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1.25rem; }
.save-feedback {
  font-size: .85rem;
  font-weight: 600;
  transition: opacity .3s;
}
.save-feedback.success { color: var(--success); }
.save-feedback.error   { color: var(--danger); }

/* ─── 15. حقول ────────────────────────────────── */
.field-group    { margin-bottom: 1.1rem; }
.field-label    { display: block; font-size: .88rem; font-weight: 600; margin-bottom: .38rem; }
.field-input,
.field-textarea {
  width: 100%;
  padding: .6rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Cairo', sans-serif;
  font-size: .9rem;
  color: var(--text);
  background: var(--bg);
  direction: rtl;
  transition: border-color var(--trans);
}
.field-input:focus,
.field-textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-card);
}
.field-textarea { resize: vertical; min-height: 100px; line-height: 1.65; }

/* ─── 16. Modal ──────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.52);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(4px);
}
.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 88vh;
  overflow-y: auto;
  animation: fadeIn .22s ease;
}
@keyframes fadeIn {
  from { transform: scale(.96); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--bg-card);
}
.modal-title     { font-size: 1.05rem; font-weight: 700; }
.modal-close-btn { font-size: 1.1rem; color: var(--text-muted); padding: .2rem .4rem; }
.modal-close-btn:hover { color: var(--danger); }
.modal-body      { padding: 1.5rem; }

/* تفاصيل الحجز في المودال */
.detail-row {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  padding: .65rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-key   { color: var(--text-muted); font-weight: 600; min-width: 130px; flex-shrink: 0; }
.detail-val   { font-weight: 600; }

/* ─── 17. شريط PWA ────────────────────────────── */
.pwa-bar {
  position: fixed;
  bottom: 0; right: 0; left: 0;
  z-index: 200;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: .7rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  box-shadow: 0 -4px 20px var(--shadow);
}
.pwa-close-btn { color: var(--text-muted); font-size: 1rem; }
.pwa-close-btn:hover { color: var(--danger); }

/* ─── 18. Responsive ──────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 260px; }
  .admin-sidebar {
    transform: translateX(100%);
  }
  .admin-sidebar.open {
    transform: translateX(0);
    box-shadow: -8px 0 40px rgba(0,0,0,.25);
  }
  .admin-content    { margin-right: 0; }
  .mobile-menu-btn  { display: block; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .vacation-grid { grid-template-columns: 1fr; }
  .session-row  { flex-direction: column; align-items: flex-start; }
  .mode-selector { flex-direction: row; }
  .admin-page   { padding: 1.25rem 1rem; }
}

/* ─── 19. عناصر المرحلة 4 ──────────────────── */

/* آخر الحجوزات في الداشبورد */
.recent-booking-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--trans);
  border-radius: var(--radius);
}
.recent-booking-row:last-child { border-bottom: none; }
.recent-booking-row:hover { background: var(--bg); }

.rb-num {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary);
  min-width: 36px;
  text-align: center;
  background: var(--primary-xlight);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.rb-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .1rem;
  min-width: 0;
}
.rb-name    { font-weight: 700; font-size: .9rem;
              white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rb-service { font-size: .78rem; color: var(--text-muted); }
.rb-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .2rem;
  flex-shrink: 0;
}
.rb-date { font-size: .72rem; color: var(--text-muted); }

/* جدول الحجوزات — صف المعالَج */
.bookings-table tr.handled td {
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-color: rgba(107,128,112,.4);
}
.bookings-table tr.handled:hover td { background: rgba(0,0,0,.02); }

/* علامة الإنجاز */
.done-check {
  color: var(--success);
  font-size: .85rem;
  font-weight: 600;
}

/* روابط الهاتف في الجدول */
.bookings-table a {
  color: var(--primary);
  font-weight: 600;
}
.bookings-table a:hover { text-decoration: underline; }

/* مودال التفاصيل */
.detail-row {
  display: flex;
  gap: 1rem;
  padding: .7rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
  align-items: flex-start;
}
.detail-row:last-of-type { border-bottom: none; }
.detail-key {
  color: var(--text-muted);
  font-weight: 600;
  min-width: 140px;
  flex-shrink: 0;
  font-size: .85rem;
}
.detail-val { font-weight: 600; flex: 1; }
