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

:root {
  --bg-deep: #08111f;
  --bg-panel: #101f35;
  --bg-panel-2: #14263f;
  --border-soft: rgba(255, 255, 255, 0.08);
  --text-main: #eef2f7;
  --text-dim: #93a3b8;
  --gold: #d4af37;
  --gold-soft: #e9cf7a;
  --purple: #6c4fa1;
  --green: #1e7d5a;
  --blue: #1f6fb2;
  --amber: #b8862c;
  --teal: #157b74;
  --ok: #33c17a;
  --warn: #e0a530;
  --radius-lg: 16px;
  --radius-md: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: 'Tajawal', sans-serif;
  direction: rtl;
}

body {
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at top, rgba(212, 175, 55, 0.06), transparent 60%),
    linear-gradient(180deg, #060d18 0%, #0a1727 100%);
}

a { color: inherit; text-decoration: none; }

/* ---------- شريط علوي ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: linear-gradient(180deg, #0c1a2c, #0a1626);
  border-bottom: 1px solid var(--border-soft);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand .logo {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #2c4a6e, #0d1c30);
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  overflow: hidden;
}

.brand .logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.brand .names h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.brand .names p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-dim);
}

.topbar .banner {
  flex: 1;
  text-align: center;
  font-size: 22px;
  font-weight: 900;
  color: var(--gold-soft);
  letter-spacing: 0.5px;
}

.topbar .meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.meta .chip {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 13px;
  text-align: center;
  min-width: 110px;
}

.meta .chip .big {
  font-size: 16px;
  font-weight: 700;
}

.sidebar-toggle-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  color: var(--gold-soft);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-toggle-btn:hover {
  border-color: var(--gold);
}

.layout.sidebar-hidden {
  grid-template-columns: 1fr;
}

.sidebar.hidden {
  display: none;
}

/* خلفية معتّمة خلف درج القائمة، تظهر بالموبايل فقط */
.sidebar-backdrop {
  display: none;
}

/* ---------- تخطيط الصفحة ---------- */
/*
  بلا min-height: لو كان المحتوى أقصر من الشاشة، كان التخطيط يتمدد لطول الشاشة
  ويصير فراغ فارغ تحت الكاردات، وكارت الـ QR (margin-top:auto) ينزل لآخر هذا
  الفراغ فيبين غير محاذي. الآن الطول = طول المحتوى، فيصير أسفل الـ QR بمستوى
  أسفل آخر صف كاردات.
*/
.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
}

.sidebar {
  background: #0b1930;
  border-left: 1px solid var(--border-soft);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
}

.sidebar .nav-item.active {
  background: linear-gradient(90deg, #1c3a5e, #163049);
  color: #fff;
  border: 1px solid rgba(212, 175, 55, 0.35);
}

.sidebar .qr-box {
  margin-top: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

.sidebar .qr-box .qr-img {
  width: 100%;
  aspect-ratio: 1;
  background: #fff;
  border-radius: 6px;
  margin-bottom: 8px;
  display: block;
  padding: 6px;
  object-fit: contain;
}

.main {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------- بطاقات عامة ---------- */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--gold-soft);
}

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

/* ---------- أوقات الصلاة ---------- */
.prayer-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  text-align: center;
}

.prayer-cell {
  background: var(--bg-panel-2);
  border-radius: var(--radius-md);
  padding: 12px 8px;
}

.prayer-cell .label { font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.prayer-cell .icon { font-size: 20px; margin-bottom: 6px; }
.prayer-cell .time { font-weight: 700; font-size: 14px; }

.prayer-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: left;
}

/* ---------- بطاقات الإحصائيات ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
}

.stat-card {
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
  color: #fff;
}

.stat-card .icon { font-size: 26px; margin-bottom: 8px; }
.stat-card .value { font-size: 26px; font-weight: 900; margin: 4px 0; }
.stat-card .label { font-size: 12.5px; opacity: 0.9; }

.stat-card.purple { background: linear-gradient(160deg, #7a5cc0, #4c3480); }
.stat-card.green { background: linear-gradient(160deg, #2a9d6f, #1a5c40); }
.stat-card.blue { background: linear-gradient(160deg, #2f8fd6, #175f96); }
.stat-card.gold { background: linear-gradient(160deg, #cf9a3c, #96691f); }
.stat-card.teal { background: linear-gradient(160deg, #1f9e94, #115a53); }

/* ---------- جداول النقل ---------- */
table.transport {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.transport th {
  text-align: right;
  color: var(--text-dim);
  font-weight: 500;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border-soft);
}

table.transport td {
  padding: 10px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
}

.status-dot::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}

.status-dot.waiting::before { background: var(--warn); }
.status-dot.stopped::before { background: #e05353; }

.transport-footer {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------- خدمات الموكب ---------- */
.services-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.service-chip {
  background: var(--bg-panel-2);
  border-radius: var(--radius-md);
  padding: 14px 8px;
  text-align: center;
  font-size: 13px;
}

.service-chip .icon { font-size: 20px; margin-bottom: 6px; }

/* ---------- الطقس ---------- */
.weather-main {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.weather-main .temp { font-size: 40px; font-weight: 900; }
.weather-main .cond { color: var(--text-dim); font-size: 14px; }

.weather-details { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.weather-details .item { display: flex; justify-content: space-between; color: var(--text-dim); }
.weather-details .item b { color: var(--text-main); }

/* ---------- الموقع ---------- */
.map-embed-wrap {
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 10px;
  flex: 1;
  min-height: 0;
}

.location-panel {
  display: flex;
  flex-direction: column;
}

.map-embed {
  width: 100%;
  height: 100%;
  min-height: 200px;
  border: 0;
  display: block;
}

.map-placeholder {
  background: #142338;
  border-radius: var(--radius-md);
  min-height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
  padding: 10px;
}

.map-point { font-size: 12.5px; }

.maps-btn {
  display: block;
  text-align: center;
  background: #1a5fb4;
  color: #fff;
  padding: 10px;
  border-radius: var(--radius-md);
  margin-top: 10px;
  font-size: 13.5px;
  font-weight: 700;
}

/* ---------- أرقام التواصل ---------- */
.contact-list { display: flex; flex-direction: column; gap: 10px; }
.contact-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-panel-2);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 14px;
}

/* ---------- الإعلانات ---------- */
.ad-slide {
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  min-height: 150px;
  background: linear-gradient(160deg, #2b2410, #4a3a12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  padding: 16px;
}

.ad-slide .title { font-size: 22px; font-weight: 900; color: var(--gold-soft); }
.ad-slide .subtitle { font-size: 14px; }
.ad-slide .footer { font-size: 12px; color: var(--text-dim); margin-top: 8px; }

/* ---------- تذييل الصفحة ---------- */
.site-footer {
  padding: 16px 24px;
  background: #0b1930;
  border-top: 1px solid var(--border-soft);
  text-align: center;
  font-size: 13px;
  line-height: 1.9;
  color: var(--text-dim);
}

.site-footer .org {
  color: var(--gold-soft);
  font-weight: 500;
}

/* ---------- عناصر مساعدة ---------- */
.muted { color: var(--text-dim); }
.center { text-align: center; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }

  /*
    الشريط الجانبي ما يختفي بالموبايل، يصير درجاً ينزلق فوق المحتوى بزر ☰.
    نتجاهل هنا حالة .hidden المحفوظة من سطح المكتب حتى لا تخفي الدرج.
  */
  .sidebar,
  .sidebar.hidden {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 264px;
    max-width: 84vw;
    z-index: 60;
    overflow-y: auto;
    border-left: none;
    border-right: 1px solid var(--border-soft);
    box-shadow: -10px 0 26px rgba(0, 0, 0, 0.5);
    transform: translateX(101%);
    transition: transform 0.25s ease;
  }

  .sidebar.drawer-open { transform: translateX(0); }

  /* بالدرج الشاشة كاملة، فيبقى الكارت بالأسفل مثل ما هو */
  .sidebar .qr-box { margin-top: auto; }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(3, 8, 16, 0.6);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
  }

  .sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
  }

  .row-2, .row-3, .row-4 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .prayer-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- الهواتف: الشريط العلوي ينزل بأسطر بدل ما يمدّ الصفحة ---------- */
@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 14px;
  }

  .topbar .brand { flex: 1 1 100%; }
  .brand .names h1 { font-size: 16px; }
  .brand .names p { font-size: 12px; }

  .topbar .banner {
    flex: 1 1 100%;
    font-size: 17px;
  }

  .topbar .meta {
    flex: 1 1 100%;
    justify-content: center;
  }

  /* الشريحتان تتقاسمان السطر بدل عرض ثابت يمدّ الصفحة */
  .meta .chip {
    flex: 1 1 0;
    min-width: 0;
  }

  /* حشو أقل على الشاشات الصغيرة ليتسع الجدول بدل ما يمدّ الصفحة */
  .main { padding: 16px 14px; }
  .panel { padding: 14px 12px; }

  /* لو ضاقت الشاشة أكثر من اللازم، يتمرّر الجدول داخل بطاقته فقط */
  .panel:has(> .transport) { overflow-x: auto; }
}

/* =========================================================
   لوحة التحكم (Admin)
   ========================================================= */
.admin-body { padding: 24px; max-width: 1100px; margin: 0 auto; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-card h1 { margin: 0 0 6px; font-size: 20px; }
.login-card p.sub { color: var(--text-dim); font-size: 13px; margin-bottom: 20px; }

.field { margin-bottom: 14px; text-align: right; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: #0c1a2c;
  color: var(--text-main);
  font-family: 'Tajawal', sans-serif;
  font-size: 14px;
}

.field textarea { resize: vertical; min-height: 60px; }

.btn {
  display: inline-block;
  border: none;
  cursor: pointer;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-family: 'Tajawal', sans-serif;
  font-size: 14px;
  font-weight: 700;
}

.btn-primary { background: linear-gradient(160deg, #d4af37, #a9812a); color: #1a1200; width: 100%; }
.btn-secondary { background: var(--bg-panel-2); color: var(--text-main); border: 1px solid var(--border-soft); }
.btn-danger { background: #7a2b2b; color: #fff; }
.btn-small { padding: 6px 12px; font-size: 12.5px; }

.error-msg { color: #e05353; font-size: 13px; margin-top: 10px; min-height: 16px; }
.success-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e7d5a;
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}
.success-toast.show { opacity: 1; }

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

.admin-header h1 { margin: 0; font-size: 20px; }

.admin-section {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 18px;
}

.admin-section h2 {
  margin: 0 0 14px;
  font-size: 16px;
  color: var(--gold-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.grid-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-fields.two { grid-template-columns: repeat(2, 1fr); }

.dyn-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
  padding: 10px;
  background: var(--bg-panel-2);
  border-radius: var(--radius-md);
}

.dyn-row.cols-2 { grid-template-columns: 1fr 1fr auto; }
.dyn-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr auto; }

.add-row-btn { margin-top: 4px; }

@media (max-width: 800px) {
  .grid-fields, .grid-fields.two { grid-template-columns: 1fr; }
  .dyn-row, .dyn-row.cols-2, .dyn-row.cols-4 { grid-template-columns: 1fr; }
}
