/* Base + Bootstrap 5.3 theme in the TV palette (tokens in colors.css).
   Pages keep using normal Bootstrap classes; this file recolours them. */
:root,
[data-bs-theme="light"] {
    --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
    --bs-body-bg: var(--parchment-100);
    --bs-body-color: var(--slate);
    --bs-emphasis-color: var(--ink);
    --bs-heading-color: var(--ink);
    --bs-secondary-color: var(--muted);
    --bs-border-color: var(--parchment-300);
    --bs-border-radius: var(--radius-sm);
    --bs-link-color: var(--azure-600);
    --bs-link-color-rgb: 5, 113, 200;
    --bs-link-hover-color: var(--azure-800);
    --bs-link-hover-color-rgb: 5, 86, 163;
    --bs-primary: var(--azure-600);
    --bs-primary-rgb: 5, 113, 200;
    --bs-primary-bg-subtle: var(--azure-50);
    --bs-primary-text-emphasis: var(--azure-800);
    --bs-success: var(--emerald-700);
    --bs-success-rgb: 4, 122, 85;
    --bs-success-bg-subtle: var(--emerald-50);
    --bs-danger: var(--danger);
    --bs-danger-rgb: 194, 54, 43;
    --bs-warning-text-emphasis: var(--warning);
    --bs-info: var(--azure-500);
    --bs-info-rgb: 7, 129, 214;
    --bs-dark-rgb: 3, 58, 100;
    --bs-focus-ring-color: rgba(5, 113, 200, .3);
}

/* Urdu/Arabic: fields whose contents are always left-to-right (emails, numbers, dates, times)
   still sit on the right like the rest of the form; text fields are handled by js/field_dir.js */
html[dir="rtl"] :is(input[type=email], input[type=url], input[type=number], input[type=tel], input[type=date],
    input[type=time], input[type=datetime-local], input.num):not(.text-center) { text-align: right; }

html[dir="rtl"] body {
    font-family: "Noto Naskh Arabic", var(--bs-body-font-family);
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--parchment-100);
}

a { text-decoration: none; }

/* Times, dates and numbers stay left-to-right inside Urdu text */
.num { direction: ltr; unicode-bidi: isolate; }

:focus-visible {
    outline: 2px solid var(--gold-500);
    outline-offset: 2px;
}

/* ---- Buttons: azure for actions, emerald-700 for success/confirm ---------- */
.btn-primary {
    --bs-btn-bg: var(--azure-600);
    --bs-btn-border-color: var(--azure-600);
    --bs-btn-hover-bg: var(--azure-700);
    --bs-btn-hover-border-color: var(--azure-700);
    --bs-btn-active-bg: var(--azure-800);
    --bs-btn-active-border-color: var(--azure-800);
    --bs-btn-disabled-bg: var(--azure-600);
    --bs-btn-disabled-border-color: var(--azure-600);
}
.btn-outline-primary {
    --bs-btn-color: var(--azure-600);
    --bs-btn-border-color: var(--azure-600);
    --bs-btn-hover-bg: var(--azure-600);
    --bs-btn-hover-border-color: var(--azure-600);
    --bs-btn-active-bg: var(--azure-700);
}
.btn-success {
    --bs-btn-bg: var(--emerald-700);
    --bs-btn-border-color: var(--emerald-700);
    --bs-btn-hover-bg: #036646;
    --bs-btn-hover-border-color: #036646;
    --bs-btn-active-bg: #02573C;
}
.btn-danger {
    --bs-btn-bg: var(--danger);
    --bs-btn-border-color: var(--danger);
    --bs-btn-hover-bg: #A82D23;
    --bs-btn-hover-border-color: #A82D23;
}
/* Bootstrap's info/warning buttons use dark text on light fills; keep them readable */
.btn-info { --bs-btn-bg: var(--azure-500); --bs-btn-border-color: var(--azure-500); --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--azure-700); }
.btn-warning { --bs-btn-bg: var(--gold-300); --bs-btn-border-color: var(--gold-300); --bs-btn-color: var(--ink); --bs-btn-hover-bg: #D8AE58; }

/* ---- Surfaces ------------------------------------------------------------ */
.card {
    --bs-card-bg: #fff;
    --bs-card-border-color: var(--parchment-300);
    --bs-card-border-radius: var(--radius-md);
    --bs-card-cap-bg: var(--parchment-50);
    box-shadow: var(--shadow);
}
.table {
    --bs-table-bg: #fff;
    --bs-table-border-color: var(--parchment-300);
}
.table > thead th,
.table-dark {
    --bs-table-bg: var(--navy-800);
    --bs-table-color: #fff;
    --bs-table-border-color: var(--navy-700);
    background-color: var(--navy-800);
    color: #fff;
}
.table-light { --bs-table-bg: var(--parchment-200); --bs-table-color: var(--ink); }
.alert-success { --bs-alert-bg: var(--emerald-50); --bs-alert-color: #03543B; --bs-alert-border-color: #B5E6CF; }
.alert-info { --bs-alert-bg: var(--azure-50); --bs-alert-color: var(--azure-800); --bs-alert-border-color: #C3DCF4; }

/* "Now": current prayer / countdown, same as the TV screen */
.is-now,
.table tr.is-now > * {
    background: var(--emerald-400) !important;
    color: var(--on-emerald) !important;
    font-weight: 700;
}

/* ---- App bar (public and logged-in pages) -------------------------------- */
.site-bar {
    position: relative; z-index: 1020; /* its blur makes a layer: keep its dropdowns above the page */
    background: linear-gradient(180deg, var(--navy-800), var(--navy-950));
    color: #fff;
    border-bottom: 3px solid var(--azure-600);
}
.site-bar .navbar { --bs-navbar-padding-x: .75rem; }
.site-bar .navbar-brand { color: #fff; display: flex; align-items: center; gap: .6rem; }
.site-bar .brand-logo { width: 42px; height: 42px; border-radius: 10px; background: #fff; object-fit: contain; padding: 2px; }
.site-bar .brand-name { font-weight: 800; font-size: 1.15rem; line-height: 1.1; display: block; }
.site-bar .brand-tagline { font-size: .75rem; color: #A9C1D9; display: block; }
.site-bar .nav-link { color: #D6E4F2; border-radius: var(--radius-sm); padding: .45rem .75rem; }
.site-bar .nav-link:hover,
.site-bar .nav-link:focus { color: #fff; background: rgba(255, 255, 255, .08); }
.site-bar .nav-link.active { color: #fff; background: var(--azure-600); }
.site-bar .dropdown-menu { --bs-dropdown-link-active-bg: var(--azure-600); }
.site-bar .dropdown-menu .nav-link { color: var(--slate); }
.site-bar .dropdown-menu .nav-link:hover { color: var(--ink); background: var(--parchment-200); }
.site-bar .dropdown-menu .nav-link.active { color: #fff; background: var(--azure-600); }
.site-bar .greeting { color: #A9C1D9; font-size: .85rem; }
.site-bar .greeting b { color: var(--gold-300); font-weight: 600; }
.lang-switch {
    color: #fff; background: transparent; /* it is a <button> now (language dropdown) */
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 999px;
    padding: .25rem .8rem;
    font-size: .9rem;
}
.lang-switch:hover, .lang-switch.show { background: rgba(255, 255, 255, .1); color: #fff; }

.list-group { --bs-list-group-bg: #fff; --bs-list-group-border-color: var(--parchment-300); }
html[dir="rtl"] .bi-arrow-right-short, html[dir="rtl"] .bi-arrow-right { display: inline-block; transform: scaleX(-1); }

main.page { flex: 1 0 auto; padding-block: 1.25rem 2rem; }

.site-footer {
    border-top: 1px solid var(--parchment-300);
    color: var(--muted);
    font-size: .875rem;
    padding: 1.25rem 1rem;
    text-align: center;
}
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--azure-700); }
.site-footer .app-get { margin-bottom: .75rem; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .35rem; }
.site-footer .app-get .btn, .site-footer .app-get .btn:hover { color: #fff; }

/* ---- Next-prayer card (public home, dashboard): same look as the TV -------- */
.next-card {
    background: linear-gradient(160deg, var(--azure-600) 0%, var(--navy-800) 55%, var(--navy-950) 100%);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}
.next-card .next-label { font-size: .85rem; color: #A9C1D9; }
.next-card .next-name { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.next-card .countdown {
    display: inline-block;
    background: var(--emerald-400);
    color: var(--on-emerald);
    font-weight: 800;
    font-size: 1.5rem;
    font-variant-numeric: tabular-nums;
    border-radius: var(--radius-sm);
    padding: .15rem .6rem;
}
.next-card .next-at { font-size: .85rem; color: #D6E4F2; margin-top: .25rem; }
.next-card .next-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: .25rem 1rem;
    margin-top: 1rem;
    padding-top: .75rem;
    border-top: 1px solid rgba(255, 255, 255, .15);
    font-size: .875rem;
    color: #D6E4F2;
}
.list-group-item.is-now { border-color: var(--emerald-400); }

.slide-thumb { height: 180px; object-fit: cover; background: var(--parchment-200); }
.slide-item[draggable="true"] { cursor: grab; }

.page-tabs .nav-link { color: var(--slate); background: #fff; border: 1px solid var(--parchment-300); }
.page-tabs .nav-link.active { background: var(--azure-600); border-color: var(--azure-600); color: #fff; }

/* ---- App shell (logged-in pages): sidebar, top bar, phone tab bar ---------- */
:root { --side-w: 250px; }
.app-side { --bs-offcanvas-width: var(--side-w); --bs-offcanvas-bg: var(--navy-900); color: #D6E4F2; }
.app-side-inner {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: linear-gradient(180deg, var(--navy-800), var(--navy-950));
}
.side-brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 800; font-size: 1.1rem; }
.side-brand .brand-logo, .app-top .brand-logo { width: 38px; height: 38px; border-radius: 9px; background: #fff; object-fit: contain; padding: 2px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; padding: .5rem .75rem 1.5rem; }
.side-link {
    display: flex; align-items: center; gap: .7rem;
    padding: .55rem .75rem; border-radius: var(--radius-sm);
    color: #D6E4F2; font-weight: 500;
}
.side-link i { font-size: 1.05rem; width: 1.25rem; text-align: center; }
.side-link:hover, .side-link:focus-visible { color: #fff; background: rgba(255, 255, 255, .08); }
.side-link.active { background: var(--azure-600); color: #fff; font-weight: 700; }
.side-sep {
    margin: 1rem .75rem .25rem; font-size: .7rem; font-weight: 700;
    letter-spacing: .12em; text-transform: uppercase; color: var(--gold-300);
}
/* Sidebar always visible from tablet/PC width up (768px); drawer + tab bar only on phones */
@media (min-width: 768px) and (max-width: 991.98px) { :root { --side-w: 220px; } }
@media (min-width: 768px) {
    body.app { padding-inline-start: var(--side-w); }
    .app-side { position: fixed; inset-block: 0; inset-inline-start: 0; width: var(--side-w); z-index: 1030; }
}
.app-col { min-height: 100vh; display: flex; flex-direction: column; }
.app-col > main.page { flex: 1 0 auto; }
.app-top {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: .75rem;
    padding: .6rem 1rem;
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--parchment-300);
    backdrop-filter: blur(8px);
}
.min-w-0 { min-width: 0; }
.chip {
    display: inline-flex; align-items: center; gap: .25rem;
    font-size: .85rem; font-weight: 600; white-space: nowrap;
    padding: .3rem .75rem; border-radius: 999px;
    border: 1px solid var(--parchment-300); background: #fff; color: var(--ink);
}
a.chip:hover { border-color: var(--azure-600); color: var(--azure-700); }

.tabbar {
    position: fixed; inset-inline: 0; bottom: 0; z-index: 1030;
    display: flex; justify-content: space-around;
    padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom, 0px));
    background: #fff; border-top: 1px solid var(--parchment-300);
    box-shadow: 0 -4px 16px rgba(2, 26, 55, .06);
}
.tab-link {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: .25rem 0; border: 0; background: none;
    font-size: .72rem; font-weight: 600; color: var(--muted);
}
.tab-link i { font-size: 1.25rem; }
.tab-link.active { color: var(--azure-600); font-weight: 800; }
@media (max-width: 767.98px) { body.app { padding-bottom: 4.5rem; } }

/* ---- Dashboard (masjid.php) --------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
@media (max-width: 575.98px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: #fff; border: 1px solid var(--parchment-300); border-radius: var(--radius-md); padding: .75rem 1rem; box-shadow: var(--shadow); min-width: 0; }
.kpi small { display: block; font-size: .78rem; color: var(--muted); }
.kpi b { display: block; font-size: 1.35rem; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi.is-now small, .kpi.is-now b { color: var(--on-emerald) !important; }
a.kpi { color: inherit; transition: border-color var(--transition); }
a.kpi:hover { border-color: var(--azure-600); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.panel-head h2 { font-size: 1rem; margin: 0; }
.panel-head a { font-size: .85rem; font-weight: 600; }
.qa-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.qa {
    display: flex; flex-direction: column; gap: 2px;
    padding: .7rem; border: 1px dashed var(--parchment-300); border-radius: var(--radius-sm);
    color: var(--ink); font-weight: 700; font-size: .9rem;
}
.qa i { color: var(--azure-600); font-size: 1.1rem; }
.qa span { font-weight: 400; font-size: .78rem; color: var(--muted); }
.qa:hover { border-color: var(--azure-600); border-style: solid; color: var(--ink); }
.thumbs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .4rem; }
.thumbs img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; border: 1px solid var(--parchment-300); background: var(--parchment-200); }

.prayer-ico { color: var(--gold-500); font-size: 1.05em; margin-inline-end: .35rem; }
.is-now .prayer-ico { color: var(--on-emerald); }

/* ---- Feature tiles (masjid page) ----------------------------------------- */
.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: .75rem;
}
.tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 110px;
    padding: 1rem .75rem;
    text-align: center;
    background: #fff;
    border: 1px solid var(--parchment-300);
    border-radius: var(--radius-md);
    color: var(--ink);
    font-weight: 600;
    box-shadow: var(--shadow);
    transition: border-color var(--transition), transform var(--transition);
}
.tile i { font-size: 1.6rem; color: var(--azure-600); }
.tile:hover { border-color: var(--azure-600); color: var(--ink); transform: translateY(-2px); }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* Page loader (js/loader.js): circular spinner over the page while it loads */
.page-loader {
    position: fixed; inset: 0; z-index: 2100;
    display: grid; place-items: center;
    background: rgb(251 248 240 / .55); /* --parchment-50, see-through */
}
.page-loader[hidden] { display: none; }
.page-loader .spinner-border { width: 3.25rem; height: 3.25rem; border-width: .3rem; color: var(--azure-600); }
@media (prefers-reduced-motion: reduce) { .page-loader .spinner-border { animation-duration: 1.5s; } }

/* ---- Today's prayer times list (part_prayer_today.php + js/prayer_card.js) ----
   Grouped (Farz, then solar & prohibited times) or Timeline (the day's order). */
.pt-card .card-header { background: var(--parchment-50); padding: .9rem 1.25rem; }
.pt-title-ico { color: var(--emerald-700); }
.pt-toggle { display: inline-flex; background: var(--parchment-200); border-radius: 999px; padding: 3px; }
.pt-toggle button {
    border: 0; background: transparent; color: var(--muted); font-size: .85rem; font-weight: 600;
    border-radius: 999px; padding: .3rem .85rem;
}
.pt-toggle button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(11, 36, 64, .15); }
.pt-toggle button:focus-visible { outline: 2px solid var(--azure-600); outline-offset: 1px; }

.pt-list .pt-item {
    display: flex; justify-content: space-between; align-items: center; gap: .75rem;
    padding: .8rem 1.25rem; color: var(--ink);
}
.pt-list .pt-name { display: inline-flex; align-items: center; flex-wrap: wrap; gap: .35rem .5rem; }
.pt-list .pt-time { font-weight: 600; white-space: nowrap; }
.pt-list .pt-head {
    padding: .7rem 1.25rem .45rem; font-size: .75rem; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; color: var(--muted); background: transparent;
}
.pt-head .pt-head-farz { color: var(--azure-600); }
.pt-head .pt-head-solar { color: var(--gold-500); }
.pt-list[data-view="grouped"] .pt-head ~ .pt-head { border-top: 1px solid var(--parchment-300); }
.pt-list[data-view="grouped"] .pt-other { background: var(--parchment-50); color: var(--muted); }
.pt-list[data-view="grouped"] .pt-badge-solar { display: none; } /* the section heading says it */
.pt-next .pt-time { font-weight: 700; }
.pt-done, .pt-done .pt-time, .pt-done .prayer-ico { color: #9AA6B2 !important; font-weight: 500; }
.pt-now { background: var(--emerald-50) !important; color: #03543B; font-weight: 700; box-shadow: inset 4px 0 0 var(--emerald-400); }
.pt-now .pt-time, .pt-now .prayer-ico { color: #03543B; font-weight: 800; }
html[dir="rtl"] .pt-now { box-shadow: inset -4px 0 0 var(--emerald-400); }

.pt-badge {
    font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    border-radius: 999px; padding: .15rem .55rem; line-height: 1.4; border: 1px solid transparent;
}
.pt-badge-done { background: #F1F3F5; color: #8A96A3; border-color: #E2E6EA; }
.pt-badge-now { background: var(--emerald-400); color: var(--on-emerald); }
.pt-badge-solar { background: #FDF3D7; color: var(--gold-700); border-color: var(--gold-300); }

/* ---- "Our other apps": sidebar footer + popup (menu_top.php, DYNASOL_APPS in config.php) ---- */
.side-foot { margin-top: auto; padding: 1rem .75rem 1rem; border-top: 1px solid rgba(255, 255, 255, .1); }
.side-by { font-size: .72rem; color: #8FA7C0; text-align: center; margin-bottom: .5rem; }
.side-apps-btn {
    width: 100%; display: flex; align-items: center; justify-content: center; gap: .4rem;
    border: 0; border-radius: var(--radius-sm); padding: .55rem .75rem;
    background: var(--azure-600); color: #fff; font-weight: 600; font-size: .9rem;
}
.side-apps-btn:hover { background: var(--azure-700); }
.side-apps-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.apps-modal { border-radius: var(--radius-lg); }
.app-card { display: flex; flex-direction: column; gap: .5rem; color: var(--ink); text-align: center; height: 100%; }
.app-card-img {
    display: grid; place-items: center; aspect-ratio: 1; overflow: hidden; /* square: Play Store icons */
    border: 1px solid var(--parchment-300); border-radius: 14px; background: var(--parchment-50);
    transition: transform .15s, box-shadow .15s, border-color .15s;
}
.app-card-img img { width: 100%; height: 100%; object-fit: cover; }
.app-card-img .bi { font-size: 2.5rem; color: var(--azure-600); opacity: .55; }
.app-card-name { font-weight: 700; font-size: .95rem; }
.app-card:hover .app-card-img, .app-card:focus-visible .app-card-img {
    border-color: var(--azure-600); box-shadow: 0 6px 18px rgba(11, 36, 64, .12); transform: translateY(-2px);
}
.app-card:hover .app-card-name { color: var(--azure-700); }

/* ---- Sign up (signup.php): role cards + searchable masjid list ---------------- */
.role-card { border-width: 2px; }
.btn-check:checked + .role-card { color: #fff; }
.masjid-pick { max-height: 300px; overflow-y: auto; background: #fff; }
.masjid-pick.is-invalid { border-color: var(--bs-danger) !important; }
.masjid-pick-head { position: sticky; top: 0; z-index: 1; padding: .4rem .9rem; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--parchment-100); }
.masjid-pick-row { display: flex; gap: .65rem; align-items: flex-start; padding: .6rem .9rem; border-top: 1px solid var(--parchment-300); cursor: pointer; }
.masjid-pick-row:hover { background: var(--parchment-50); }
.masjid-pick-row:has(input:checked) { background: var(--azure-50); }
.masjid-pick-row .form-check-input { margin-top: .25rem; flex-shrink: 0; }


/* Upload: "Choose File" source sheet on phones (upload_new_content.php) */
.pick-sheet.offcanvas-bottom { height: auto; border-top-left-radius: var(--radius-lg); border-top-right-radius: var(--radius-lg); }

/* Pull down to refresh on touch screens (js/pull_refresh.js) */
.pull-refresh {
    position: fixed; top: .5rem; left: 50%; z-index: 2050;
    width: 2.5rem; height: 2.5rem; display: grid; place-items: center;
    border-radius: 50%; background: #fff; color: var(--azure-600); box-shadow: 0 2px 8px rgba(11, 36, 64, .25);
    transform: translate(-50%, 0); opacity: 0; pointer-events: none;
    transition: transform .2s, opacity .2s;
}
.pull-refresh.is-pulling { transition: none; }
.pull-refresh .bi { font-size: 1.2rem; }
/* our pull-to-refresh replaces the browser's own, so it behaves the same in browsers and the app */
@media (pointer: coarse) { html, body { overscroll-behavior-y: contain; } }
