/**
 * Idarah platform - styles for auth, wizard, sidebar workspace.
 * platform.css  (builds on style.css tokens)
 */

/* ---- generic helpers ---- */
.pf-center { text-align: center; padding: 32px 16px; }
.pf-spinner {
  width: 32px; height: 32px; margin: 0 auto 12px;
  border: 3px solid var(--border-subtle); border-top-color: var(--primary);
  border-radius: 50%; animation: pf-spin 0.8s linear infinite;
}
@keyframes pf-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .pf-spinner { animation-duration: 3s; } }

.pf-form-error { color: var(--danger); font-weight: 600; font-size: 0.9rem; min-height: 1.2em; margin: 6px 0 10px; }
.pf-field-error { color: var(--danger); font-size: 0.8rem; font-weight: 600; }
.pf-has-error .form-control { border-color: var(--danger); }
.pf-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.pf-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 12px; }
.pf-actions .btn { min-width: 120px; }
.pf-fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.pf-fieldset legend { margin-bottom: 8px; padding: 0; }
.pf-hdr-btn { color: #ffffff; border-color: rgba(255, 255, 255, 0.4); }
.pf-tabs { display: flex; gap: 8px; margin-bottom: 18px; border-bottom: 2px solid var(--border-subtle); }
.pf-tabs .nav-tab-btn { flex: 1; text-align: center; }
.pf-chip { display: inline-block; background: var(--primary-light); color: var(--primary); border-radius: var(--radius-full); padding: 2px 10px; font-size: 0.78rem; font-weight: 700; margin: 2px 0; }
.pf-list { margin: 8px 0 12px; margin-inline-start: 20px; }
.pf-kv th { width: 40%; background: #f8fafc; font-weight: 600; }

.pf-btnrow { display: flex; gap: 8px; flex-wrap: wrap; }
/* tabs rendered as links (same look as the old button tabs) */
a.nav-tab-btn { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
a.nav-tab-btn:focus-visible { outline: 3px solid rgba(4, 120, 87, 0.4); outline-offset: -3px; }
/* link-style buttons need the same box as <button class="btn"> */
a.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; cursor: pointer;
  font-weight: 600; border-radius: var(--radius-md); border: 1px solid transparent; min-height: var(--touch-min-height); padding: 12px 18px;
}
a.btn.btn-sm { min-height: 38px; padding: 6px 12px; font-size: 0.875rem; border-radius: var(--radius-sm); }
a.btn.btn-primary { background-color: var(--primary); color: #fff; }
a.btn.btn-secondary { background-color: #fff; color: var(--primary); border-color: var(--primary); }
a.btn.btn-outline { background-color: transparent; color: var(--text-main); border-color: var(--border-color); }
a.btn.btn-whatsapp { background-color: #25d366; color: #fff; }
.mosque-info-pill { flex-wrap: wrap; }
.pf-subtabs { display: flex; gap: 6px; margin-bottom: 14px; border-bottom: 2px solid var(--border-subtle); }
.pf-subtab {
  padding: 10px 16px; min-height: var(--touch-min-height); display: inline-flex; align-items: center;
  text-decoration: none; font-weight: 700; color: var(--text-muted); border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.pf-subtab.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--primary-light); }
.pf-subtab:focus-visible { outline: 3px solid rgba(4, 120, 87, 0.4); outline-offset: 2px; }

/* ---- phone input with locked +91 ---- */
.pf-phone { display: flex; align-items: stretch; gap: 0; }
.pf-cc {
  display: inline-flex; align-items: center; padding: 0 12px; font-weight: 700;
  background: #f1f5f9; border: 1.5px solid var(--border-color); border-inline-end: 0;
  border-start-start-radius: var(--radius-md); border-end-start-radius: var(--radius-md);
  white-space: nowrap; min-height: var(--touch-min-height);
}
.pf-phone .form-control { border-start-start-radius: 0; border-end-start-radius: 0; }

/* ---- wizard ---- */
.pf-wizard { max-width: 720px; margin-inline: auto; }
.pf-stepper { margin-bottom: 16px; }
.pf-step-label { font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.pf-progress { height: 8px; background: var(--border-subtle); border-radius: var(--radius-full); overflow: hidden; }
.pf-progress span { display: block; height: 100%; background: var(--primary); transition: width 0.25s ease; }
.pf-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.pf-module-card {
  position: relative; display: flex; gap: 12px; align-items: flex-start; cursor: pointer;
  padding: 14px; background: #ffffff; border: 2px solid var(--border-color); border-radius: var(--radius-md);
  text-decoration: none; color: inherit; min-height: var(--touch-min-height);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.pf-module-card:hover { border-color: var(--primary); }
.pf-module-card.selected { border-color: var(--primary); background: var(--primary-light); }
.pf-module-card input[type="checkbox"] { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--primary); flex: none; }
.pf-module-card:focus-within { box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.25); }
.pf-card-icon { font-size: 1.7rem; line-height: 1; flex: none; }
.pf-card-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pf-card-text small { color: var(--text-muted); font-size: 0.8rem; }
.pf-card-text .pf-have { color: var(--gold); font-weight: 600; }
.pf-yesno { display: flex; gap: 12px; }
.pf-yesno label {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; flex: 1;
  border: 1.5px solid var(--border-color); border-radius: var(--radius-md);
  padding: 10px 14px; min-height: var(--touch-min-height); font-weight: 600; background: #ffffff;
}
.pf-yesno input { width: 20px; height: 20px; accent-color: var(--primary); }

/* ---- team / roles ---- */
.pf-roles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.pf-role-opt {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px; cursor: pointer;
  border: 1.5px solid var(--border-subtle); border-radius: var(--radius-md); background: #ffffff;
}
.pf-role-opt input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--primary); flex: none; }
.pf-role-opt small { display: block; color: var(--text-muted); font-size: 0.78rem; }

/* ---- workspace layout: sidebar + main ---- */
.pf-layout { display: flex; align-items: flex-start; max-width: 1280px; margin: 0 auto; width: 100%; flex: 1; }
.pf-sidebar {
  flex: 0 0 260px; position: sticky; top: 64px; align-self: flex-start;
  max-height: calc(100vh - 64px); overflow-y: auto;
  padding: 16px 12px; background: #ffffff; border-inline-end: 1px solid var(--border-subtle); min-height: calc(100vh - 64px);
}
.pf-main { flex: 1; min-width: 0; padding: 16px; outline: none; }
.pf-nav-group { margin: 16px 8px 6px; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-muted); }
.pf-nav-empty { padding: 8px; font-size: 0.85rem; color: var(--text-muted); }
.pf-nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 2px;
  border-radius: var(--radius-md); text-decoration: none; color: var(--text-main);
  min-height: var(--touch-min-height); font-weight: 600; border-inline-start: 4px solid transparent;
}
.pf-nav-item:hover { background: var(--bg-app); }
.pf-nav-item.active { background: var(--primary-light); color: var(--primary); border-inline-start-color: var(--primary); }
.pf-nav-item:focus-visible, .pf-link-card:focus-visible { outline: 3px solid rgba(4, 120, 87, 0.4); outline-offset: 2px; }
.pf-nav-icon { font-size: 1.15rem; flex: none; }
.pf-nav-text { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.pf-nav-text small { color: var(--text-muted); font-weight: 500; font-size: 0.72rem; }
.pf-nav-add { color: var(--primary); }
.pf-switcher { max-width: 220px; text-overflow: ellipsis; }
.pf-user { font-size: 0.85rem; font-weight: 600; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-link-card { cursor: pointer; }

/* header row is allowed to wrap on narrow screens */
.header-controls { flex-wrap: wrap; justify-content: flex-end; }

/* ---- phones: sidebar becomes a horizontal scroll bar ---- */
@media (max-width: 800px) {
  .pf-layout { flex-direction: column; }
  .pf-sidebar {
    position: static; flex: none; width: 100%; max-height: none; min-height: 0;
    display: flex; flex-direction: row; gap: 6px; overflow-x: auto; overflow-y: hidden; padding: 8px;
    border-inline-end: 0; border-bottom: 2px solid var(--border-subtle); -webkit-overflow-scrolling: touch;
  }
  .pf-nav-group { display: none; }
  .pf-nav-empty { white-space: nowrap; }
  .pf-nav-item { flex: none; margin: 0; border-inline-start: 0; border-bottom: 3px solid transparent; white-space: nowrap; }
  .pf-nav-item.active { border-bottom-color: var(--primary); }
  .pf-main { padding: 12px; width: 100%; }
  .pf-switcher { max-width: 100%; flex: 1 1 100%; }
  .pf-user { display: none; }
  .pf-actions .btn { flex: 1; }
}

@media print {
  .pf-sidebar { display: none !important; }
  /* printing a single receipt: show only the receipt box */
  body.pf-printing-receipt #app-root,
  body.pf-printing-receipt .toast-container { display: none !important; }
  body.pf-printing-receipt .modal-overlay { display: block !important; position: static !important; background: none !important; opacity: 1 !important; padding: 0 !important; }
  body.pf-printing-receipt .modal-dialog { box-shadow: none !important; max-height: none !important; padding: 0 !important; transform: none !important; }
  body.pf-printing-receipt .modal-header,
  body.pf-printing-receipt .pf-no-print { display: none !important; }
}

/* ---- language dropdown (top right, next to Log out) + fonts for Hindi, Bengali, Urdu ---- */
.pf-lang { width: auto; min-height: 36px; padding: 2px 8px; font-weight: 700; }
.header-controls { display: flex; align-items: center; gap: 8px; }
html[lang="hi"] body { font-family: "Noto Sans Devanagari", var(--font-sans); }
html[lang="bn"] body { font-family: "Noto Sans Bengali", var(--font-sans); }
html[lang="ur"] body { font-family: var(--font-urdu), var(--font-sans); }
