/* ==========================================================================
   JAMAA'AH CONNECT — PRODUCTION STYLESHEET (LTR + RTL + A4 PRINT)
   ========================================================================== */
:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #475569;
  --primary: #065f46;
  --primary-hover: #047857;
  --primary-soft: #ecfdf5;
  --accent-gold: #b45309;
  --accent-gold-bg: #fffbeb;
  --clock-bg: #090d16;
  --clock-red: #ef4444;
  --clock-red-glow: rgba(239, 68, 68, 0.45);
  --radius: 14px;
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

/* RTL Typography & Script Protection (Arabic & Urdu) */
[dir="rtl"] body,
[dir="rtl"] {
  line-height: 1.78;
  letter-spacing: 0 !important;
}

[dir="rtl"] * {
  letter-spacing: 0 !important;
}

.ltr-keep {
  direction: ltr !important;
  unicode-bidi: isolate;
}

.hidden {
  display: none !important;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

/* TOP HEADER */
.topbar {
  background: linear-gradient(135deg, #064e3b 0%, #065f46 100%);
  color: #ffffff;
  padding: 14px 0;
  border-bottom: 3px solid #d97706;
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.brand-crest {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fde68a;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
}

.brand-sub {
  font-size: 0.78rem;
  color: #d1fae5;
}

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

.lang-switcher,
.role-switcher {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.25);
  padding: 3px;
  border-radius: 9px;
  gap: 3px;
}

.lang-btn,
.role-btn {
  border: none;
  background: transparent;
  color: #e2e8f0;
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s ease;
}

.lang-btn.active,
.role-btn.active {
  background: #ffffff;
  color: #064e3b;
  font-weight: 700;
}

.role-switcher-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.demo-badge {
  font-size: 0.75rem;
  color: #fde68a;
  font-weight: 600;
}

/* LOCATION BAR */
.location-strip {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}

.location-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.location-pills {
  display: inline-flex;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}

.loc-pill {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.loc-pill.active {
  background: var(--primary);
  color: #ffffff;
}

.location-status-box {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.active-loc-readout {
  display: flex;
  flex-direction: column;
}

.coords-tag {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.btn-save-loc {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.loc-drawer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.loc-search-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.loc-input {
  flex: 1;
  min-width: 240px;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.92rem;
}

.quick-cities {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.quick-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.chip-btn {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
}

.chip-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.saved-list-panel {
  margin-top: 10px;
  padding: 10px;
  background: var(--surface-alt);
  border-radius: 8px;
}

.saved-header {
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.saved-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.loc-feedback {
  margin-top: 6px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--primary);
}

/* NAVIGATION TABS */
.main-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.nav-scroll {
  display: flex;
  overflow-x: auto;
  gap: 6px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.nav-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.nav-tab.active {
  background: var(--primary-soft);
  color: var(--primary);
}

/* MAIN WORKSPACE & CARDS */
.main-content {
  padding-top: 20px;
  padding-bottom: 40px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
}

.card-sub {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* HERO CARD & RED DIGITAL COUNTDOWN CLOCK */
.hero-card {
  background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 20px;
  align-items: center;
}

@media (max-width: 820px) {
  .hero-card {
    grid-template-columns: 1fr;
  }
}

.pure-badge {
  display: inline-block;
  background: #dcfce7;
  color: #166534;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.hero-dates {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 600;
}

.hijri-accent {
  color: var(--accent-gold);
  font-weight: 700;
}

.dot-sep {
  margin: 0 6px;
}

.hero-waqt-title {
  margin: 6px 0 4px;
  font-size: 1.65rem;
  font-weight: 900;
}

.waqt-highlight-name {
  color: var(--primary);
}

.hero-waqt-sub {
  margin: 0 0 14px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.madhhab-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.toggle-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toggle-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
}

.seg-control {
  display: inline-flex;
  background: #e2e8f0;
  padding: 3px;
  border-radius: 8px;
  gap: 3px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--primary);
  color: #ffffff;
}

.high-lat-note {
  margin-top: 10px;
  font-size: 0.8rem;
  color: #92400e;
  background: #fef3c7;
  padding: 6px 10px;
  border-radius: 8px;
  font-weight: 600;
}

/* DEDICATED RED DIGITAL CLOCK */
.countdown-box {
  background: var(--clock-bg);
  color: #ffffff;
  border-radius: 14px;
  padding: 18px 16px;
  text-align: center;
  border: 2px solid #1e293b;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.25);
}

.countdown-heading {
  font-size: 0.88rem;
  font-weight: 700;
  color: #cbd5e1;
  margin-bottom: 10px;
}

.digital-clock {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #020617;
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid #334155;
}

.clock-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.clock-digits {
  font-family: "Courier New", Courier, monospace;
  font-size: 2.15rem;
  font-weight: 900;
  color: var(--clock-red);
  text-shadow: 0 0 14px var(--clock-red-glow);
  line-height: 1;
}

.clock-sub {
  font-size: 0.65rem;
  font-weight: 700;
  color: #94a3b8;
  margin-top: 4px;
}

.clock-colon {
  font-family: "Courier New", Courier, monospace;
  font-size: 1.9rem;
  font-weight: 900;
  color: var(--clock-red);
  margin-top: -12px;
}

.countdown-next-note {
  margin-top: 10px;
  font-size: 0.78rem;
  color: #94a3b8;
}

/* DAILY PRAYER ROWS */
.daily-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prayer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  gap: 10px;
}

.prayer-row.active-waqt {
  background: #ecfdf5;
  border: 2px solid #059669;
}

.prayer-name-col {
  display: flex;
  align-items: center;
  gap: 10px;
}

.prayer-title {
  font-weight: 800;
  font-size: 1rem;
}

.active-pill {
  background: #059669;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}

.prayer-time-col {
  display: flex;
  align-items: center;
  gap: 14px;
}

.prayer-time-val {
  font-size: 1.15rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.prayer-end-note {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.row-mini-clock {
  width: 100%;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed #a7f3d0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-clock-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #065f46;
}

.mini-red-clock {
  background: #090d16;
  color: #ef4444;
  font-family: "Courier New", Courier, monospace;
  font-weight: 900;
  font-size: 1.05rem;
  padding: 4px 12px;
  border-radius: 6px;
  letter-spacing: 1px;
}

/* MONTHLY TIMETABLE */
.month-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.month-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 8px;
}

.btn-icon {
  border: none;
  background: transparent;
  font-weight: 800;
  cursor: pointer;
  padding: 4px 6px;
}

.month-label {
  font-weight: 800;
  font-size: 0.9rem;
  min-width: 120px;
  text-align: center;
}

.table-wrap {
  overflow-x: auto;
}

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

.timetable th,
.timetable td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  white-space: nowrap;
}

.timetable th {
  background: var(--surface-alt);
  font-weight: 800;
  color: var(--text);
}

.timetable tr.today-row {
  background: #ecfdf5;
  font-weight: 800;
}

/* BUTTONS */
.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-outline {
  background: #ffffff;
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
}

.btn-outline:hover {
  background: var(--primary-soft);
}

/* QIBLA FINDER */
.qibla-bearing-pill {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #a7f3d0;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.88rem;
}

.qibla-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: center;
}

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

.qibla-svg {
  width: 100%;
  max-width: 390px;
  display: block;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 16px;
}

.qibla-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-tile {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.tile-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

.tile-val {
  font-size: 1rem;
  font-weight: 800;
  margin-top: 2px;
}

.accent-green {
  color: var(--primary);
}

.tile-note {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* MASAJID DIRECTORY & FEED */
.search-compact {
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  min-width: 240px;
}

.masjid-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 14px;
}

.masjid-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: var(--surface-alt);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.badge-verified {
  display: inline-block;
  background: #dcfce7;
  color: #166534;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
}

.badge-personal {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
}

.jamaah-mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  font-size: 0.78rem;
  background: #ffffff;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.feed-stack,
.janazah-stack,
.super-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feed-item,
.janazah-card,
.super-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: var(--surface-alt);
}

/* JANAZAH 30-JUZ KHATAM */
.khatam-cycle-badge {
  background: var(--accent-gold-bg);
  color: var(--accent-gold);
  border: 1px solid #fde68a;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.82rem;
}

.juz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.juz-btn {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  padding: 6px 4px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

.juz-btn.claimed {
  background: #059669;
  color: #ffffff;
  border-color: #059669;
}

/* ADMIN FORMS & AQEEDAH ENGINE */
.role-pill-badge {
  display: inline-block;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 0.74rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.role-pill-badge.super {
  background: #fef3c7;
  color: #92400e;
}

.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (max-width: 720px) {
  .admin-form-grid {
    grid-template-columns: 1fr;
  }
}

.full-span {
  grid-column: 1 / -1;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 700;
}

.form-group input[type="text"],
.form-group input[type="time"] {
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.gate-results {
  margin-top: 14px;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* FOOTER */
.site-footer {
  background: #0f172a;
  color: #cbd5e1;
  padding: 18px 0;
  font-size: 0.82rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}

/* A4 PDF PRINT RULES */
.print-only-banner {
  display: none;
}

@media print {
  .no-print {
    display: none !important;
  }
  body {
    background: #ffffff;
    font-size: 11px;
  }
  .card {
    box-shadow: none;
    border: none;
    padding: 0;
  }
  .print-only-banner {
    display: block;
    margin-bottom: 10px;
    border-bottom: 2px solid #065f46;
    padding-bottom: 6px;
  }
  .timetable th,
  .timetable td {
    padding: 4px 6px;
    border: 1px solid #94a3b8;
  }
  @page {
    size: A4 portrait;
    margin: 12mm;
  }
}
