/* =====================================================================
   MasjidTimeTable — shared.css
   Design tokens + base layout shared by every page. Colors, spacing and
   component shapes are taken directly from the Android app's composables
   (Color(0x..) literals scattered through HomeScreen.kt, SettingsScreen.kt,
   MasjidDetailScreen.kt, the *TaqweemScreen.kt files, etc).
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:wght@400;600;700&display=swap');

:root {
  color-scheme: light only;

  /* ---- palette, ported 1:1 from the app's Color(0xFF..) literals ---- */
  --teal-topbar:   #009688; /* TopAppBar background everywhere */
  --page-navy:     #05242C; /* Settings / dialog card background */
  --green-accent:  #84D02C; /* primary buttons, switches */
  --green-alt:     #8BC34A; /* taqweem-year headers, gold slider thumbs */
  --gold:          #C9A84C; /* dialog titles (Rate app / What's New) */
  --gold-star:     #FDD835; /* favourite star, RAMADAN_YELLOW dot */
  --red-dot:       #E53935; /* TODAY_RED */
  --green-dot:     #43A047; /* TOMORROW_GREEN */
  --whatsapp:      #25D366;
  --maps-blue:     #1565C0;
  --jumuah-bg:     #0B3D2E;
  --dark-bg:       #121212; /* taqweem-year / livestreams background */
  --card-dark:     #1E1E1E;
  --glass:         rgba(255,255,255,0.14);
  --glass-border:  rgba(255,255,255,0.30);
  --white:         #ffffff;

  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --arch-radius: 24px;

  --font: 'Titillium Web', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* appearance-settings overridable sizes (kept in sync by shared.js) */
  --f-slides: 24px;
  --f-detail: 28px;
  --f-taqweem: 28px;
  --f-menu: 20px;
  --f-header: 24px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* touch-action:manipulation drops the browser's double-tap-zoom delay and,
   more importantly, stops it delaying/cancelling Pointer Events while it
   decides whether a touch might be a scroll/zoom gesture instead — without
   it, tap and long-press detection (the star, the taqweem clock, …) can
   silently misfire on real touchscreens even though it works fine with a
   mouse. `manipulation` still allows panning, so scrollable containers
   are unaffected. */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
html, body { margin: 0; padding: 0; height: 100%; }
html { color-scheme: light only; }

/* The app never shows a scroll track (native mobile scrolling), so every
   scrollable region here — the shell itself, slide lists, popups, the
   taqweem-year table, … — scrolls but stays trackless. */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* Global <hr> reset — every divider in the app is a thin 0.5dp line, never
   the browser's default 2px grooved rule. Page-specific rules below only
   need to touch color/width, never thickness. */
hr { border: none; height: 0.5px; background: rgba(0,0,0,0.15); margin: 0; }

body {
  font-family: var(--font);
  background: #dfe7e6;
  color: #111;
  -webkit-font-smoothing: antialiased;
  height: 100%;
  overflow: hidden;
}

/* Centers the phone-width app on desktop, full width on mobile. The shell
   itself is the scrolling viewport (fixed to the device height) so inner
   flex:1 + overflow-y:auto regions (slide lists, settings body, the
   taqweem-year table, …) get a real bound to scroll within — and so their
   position:sticky headers have something to stick to. */
.app-shell {
  max-width: 500px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--white);
  position: relative;
  box-shadow: 0 0 40px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
}
@media (min-width: 501px) {
  body { padding: 0; }
}

.app-shell.bg-page   { background: var(--page-navy); }
.app-shell.bg-dark    { background: var(--dark-bg); }
.app-shell.bg-jumuah  { background: var(--jumuah-bg); }
.app-shell.bg-white   { background: var(--white); }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------------------------------------------------------------------
   Top bar — TopAppBar(containerColor = Color(0xFF009688)) everywhere
   --------------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  padding: var(--safe-top) 4px 0 4px;
  background: var(--teal-topbar);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar .title {
  flex: 1;
  color: var(--white);
  font-size: 18px;
  font-weight: 600;
  padding: 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar.center .title { text-align: center; }

.icon-btn {
  width: 48px;
  height: 48px;
  min-width: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--white);
  cursor: pointer;
  padding: 0;
}
.icon-btn:active { background: rgba(255,255,255,0.15); }
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }
.icon-btn.gold { color: var(--gold-star); }
.icon-btn[disabled] { opacity: 0.4; pointer-events: none; }

.topbar-search {
  flex: 1;
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.12);
  border-radius: 10px;
  height: 40px;
  padding: 0 8px;
}
.topbar-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--white);
  font-size: 16px;
  font-family: inherit;
}
.topbar-search input::placeholder { color: rgba(255,255,255,0.6); }

/* ---------------------------------------------------------------------
   Dot indicators — DotIndicator.kt (coloured LED with a thin white ring)
   --------------------------------------------------------------------- */
.mtt-dot {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  box-shadow: 0 0 0 1.4px rgba(255,255,255,0.9), inset 2px 2px 2px rgba(255,255,255,0.35);
  flex-shrink: 0;
}

/* ---------------------------------------------------------------------
   Generic buttons
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 18px;
  border-radius: 999px; /* Compose M3 Button() default shape is fully rounded (pill) */
  border: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--white);
  cursor: pointer;
  background: var(--teal-topbar);
}
.btn svg { width: 22px; height: 22px; fill: currentColor; flex-shrink: 0; }
.btn.whatsapp { background: var(--whatsapp); }
.btn.maps     { background: var(--maps-blue); }
.btn.green    { background: var(--green-accent); }
.btn.round    { width: 48px; height: 48px; padding: 0; border-radius: 50%; }
.btn.block    { width: 100%; }
.btn:active   { filter: brightness(0.92); }
.btn[disabled]{ opacity: 0.5; pointer-events: none; }

.btn-outline {
  border: 1px solid rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.06);
  color: var(--white);
  height: 46px;
  border-radius: 999px; /* Compose M3 OutlinedButton() default shape is fully rounded (pill) */
  font-family: inherit;
  font-size: 15px;
  width: 100%;
  cursor: pointer;
}

/* ---------------------------------------------------------------------
   Modal / dialog primitives — matches the glass Surface() dialogs used
   throughout: Color.White.copy(alpha=0.22f) frosted glass on capable
   devices (Build.VERSION.SDK_INT >= S in the app), Color(0xFF1A3A3A)
   solid fallback otherwise. backdrop-filter is our "glass"; the
   @supports fallback keeps old/unsupporting browsers on the solid card.
   --------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal-card {
  width: 100%;
  max-width: 460px;
  max-height: 82vh;
  background: #1A3A3A; /* solid fallback */
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .modal-card {
    background: rgba(255,255,255,0.22);
    -webkit-backdrop-filter: blur(22px) saturate(1.4);
    backdrop-filter: blur(22px) saturate(1.4);
  }
  .modal-card.light { background: rgba(255,255,255,0.5); }
}
.modal-card.narrow { max-width: 300px; }
.modal-card .modal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.08);
  color: var(--white);
  font-weight: 700;
  font-size: 18px;
}
.modal-card .modal-body {
  padding: 16px;
  overflow-y: auto;
  color: var(--white);
  flex: 1;
}
.modal-card .modal-foot {
  padding: 14px;
  text-align: center;
  background: rgba(255,255,255,0.18);
  color: var(--white);
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
}

/* Simple centered card dialog (Rate app / What's New style) */
.dialog-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: none; align-items: center; justify-content: center; z-index: 120; padding: 20px;
}
.dialog-overlay.open { display: flex; }
.dialog-card {
  background: var(--page-navy);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 340px;
  width: 100%;
  text-align: center;
}
.dialog-card h3 { color: var(--gold); font-size: 20px; margin: 0 0 12px; }
.dialog-card p { color: var(--white); font-size: 15px; line-height: 22px; margin: 0 0 20px; white-space: pre-line; }

/* Simple dropdown menu list used inside modal-card bodies */
.menu-item {
  padding: 16px 20px;
  color: var(--white);
  font-size: var(--f-menu);
  cursor: pointer;
}
.menu-item:active { background: rgba(255,255,255,0.08); }
.menu-hr { background: rgba(255,255,255,0.15); }

/* ---------------------------------------------------------------------
   Loading / empty states
   --------------------------------------------------------------------- */
.loading-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px;
  text-align: center;
}
.spinner {
  width: 34px; height: 34px;
  border: 3px solid rgba(0,0,0,0.15);
  border-top-color: #111;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner.light { border-color: rgba(255,255,255,0.25); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-wrap .hint { color: rgba(0,0,0,0.7); font-size: 13px; line-height: 18px; }
.loading-wrap.on-dark .hint { color: rgba(255,255,255,0.7); }
.loading-wrap.on-dark p { color: var(--white); }

/* ---------------------------------------------------------------------
   Misc utility
   --------------------------------------------------------------------- */
.hr { height: 0.5px; background: rgba(255,255,255,0.3); border: none; margin: 0; }
.hr.dark { background: rgba(0,0,0,0.15); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.safe-bottom { padding-bottom: var(--safe-bottom); }
.center { display: flex; align-items: center; justify-content: center; }
.grow { flex: 1; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: rgba(0,0,0,0.85); color: #fff; padding: 10px 18px; border-radius: 24px;
  font-size: 14px; z-index: 200; opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.toast.show { opacity: 1; }

/* Icon helper — hydrateIcons() swaps <span class="icon" data-icon="..."></span>
   into an inline <svg>. Color/size are set per-context (.icon-btn svg,
   .tile svg, .picker-row svg, …) below and in pages.css; this just makes
   sure a modifier class landing on the SPAN (icon-btn.gold, .fav, etc.)
   still reaches the svg's fill via currentColor inheritance. */
.icon { display: inline-flex; color: inherit; }
.icon svg { fill: currentColor; }

/* ---------------------------------------------------------------------
   Pager prev/next arrows — desktop/tablet only (no touch swipe there).
   Hidden by default; pages that have a swipeable pager opt in with the
   .pager-arrows wrapper and toggle via JS (disabled at the ends).
   --------------------------------------------------------------------- */
.pager-arrow {
  display: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.35);
  color: #fff;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 8;
}
.pager-arrow svg { width: 22px; height: 22px; fill: currentColor; }
.pager-arrow.prev { left: 6px; }
.pager-arrow.next { right: 6px; }
.pager-arrow:hover { background: rgba(0,0,0,0.55); }
.pager-arrow[disabled] { opacity: 0.25; pointer-events: none; }
@media (min-width: 640px) {
  .pager-arrow { display: flex; }
}
