/* Seva Sankalp Abhiyan - base styles. Mobile-first, high contrast for sunlight. */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #16202a;
  --muted: #5a6b7b;
  --brand: #0b5cab;
  --brand-dark: #084a8c;
  --accent: #f26522;
  --ok: #1a8f4a;
  --warn: #c47f00;
  --err: #c0392b;
  --border: #d7dee5;
  --radius: 12px;
  --tap: 48px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

img { max-width: 100%; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: var(--brand);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-header .title { font-weight: 700; font-size: 1rem; }
.app-header .user-email { font-size: 0.8rem; opacity: 0.9; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: #eef2f6; color: var(--text); border: 1px solid var(--border); }
.btn.block { width: 100%; }

.btn-google {
  background: #fff;
  color: #1f2933;
  border: 1px solid var(--border);
}
.btn-google:hover { background: #f4f6f8; }

.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hidden { display: none !important; }

.signin-wrap {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
}
.signin-wrap h1 { font-size: 1.4rem; margin: 0; }
.brand-logo { font-size: 2rem; }

.status-line { min-height: 1.4em; margin-top: 8px; }
.status-line.err { color: var(--err); }
.status-line.ok { color: var(--ok); }

.spinner {
  width: 22px; height: 22px;
  border: 3px solid rgba(0,0,0,0.15);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Header links */
.header-brand { display: flex; align-items: center; gap: 10px; }
.header-right { display: flex; align-items: center; gap: 10px; }
.back-link { color: #fff; text-decoration: none; font-weight: 600; font-size: 0.9rem; }
.btn.tiny { min-height: 32px; padding: 0 10px; font-size: 0.8rem; border-radius: 6px; }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 0.9rem; }
.btn.warn { background: var(--warn); color: #fff; }

/* Admin Container & Tabs */
.admin-container { max-width: 960px; }
.admin-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
  padding-bottom: 2px;
}
.admin-tabs .tab-btn {
  background: none;
  border: none;
  padding: 10px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.admin-tabs .tab-btn.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}
.admin-tabs .tab-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Cards & Layout */
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-header h3 { margin: 0; font-size: 1.1rem; }
.card-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 768px) {
  .card-grid { grid-template-columns: 1fr 1fr; }
}

/* Tables */
.table-wrap { overflow-x: auto; margin-top: 8px; }
.table-wrap.max-h-200 { max-height: 220px; overflow-y: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}
.data-table th, .data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.data-table th { background: #eef2f6; font-weight: 600; }
.data-table tbody tr:hover { background: #fafbfc; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-ok { background: #e6f4ea; color: var(--ok); }
.badge-muted { background: #eef2f6; color: var(--muted); }
.badge-warn { background: #fef3d6; color: var(--warn); }
/* Scoped to the .badge family on purpose: a bare .badge-err further down styles
   the solid-colour GPS pills, which would leave dark text on a dark red chip. */
.badge.badge-err { background: #fdecea; color: #c0392b; }

/* Forms & Controls */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group label { font-weight: 600; font-size: 0.9rem; }
.form-control {
  min-height: var(--tap);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}
.form-control:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.actions-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-select, .inline-input { min-height: 38px; font-size: 0.85rem; padding: 4px 8px; }

.toggle-label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.toggle-label input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brand); }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
/* A nested two-up row (Start Time / End Time) that stays two-up on phones. */
.form-grid.two-col { grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
@media (min-width: 600px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .full-width { grid-column: span 2; }
}
.border-top { border-top: 1px solid var(--border); }

/* Modals */
.app-modal {
  border: 0;
  border-radius: var(--radius);
  padding: 20px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.app-modal::backdrop { background: rgba(0,0,0,0.5); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* Progress Bar */
.progress-bar {
  display: flex;
  justify-content: space-between;
  background: #eef2f6;
  border-radius: var(--radius);
  padding: 6px 12px;
  margin-bottom: 16px;
}
.progress-bar .step {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}
.progress-bar .step.active {
  color: var(--brand);
}

/* Field errors & input error state */
.field-error {
  font-size: 0.8rem;
  color: var(--err);
  min-height: 1.2em;
}
.form-control.invalid {
  border-color: var(--err);
  background-color: #fff8f8;
}

/* Quota badge & Claim list */
.quota-badge {
  background: #e6f4ea;
  color: var(--ok);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 700;
  display: inline-block;
}

.inst-list-wrap {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
/* After an office is picked the list shows a single row, so it must not reserve
   the scroll height that pushed the confirm button off a phone screen. */
.inst-list-collapsed {
  max-height: none;
  overflow-y: visible;
}
.inst-list-collapsed .inst-item { border-bottom: 0; }
.inst-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.inst-item:last-child { border-bottom: none; }
.inst-item:hover:not(.disabled) { background: #eef2f6; }
.inst-item.disabled {
  opacity: 0.6;
  background: #fafbfc;
  cursor: not-allowed;
}
/* Chosen institute: unmistakable highlight + check, so the user knows it registered. */
.inst-item.selected {
  background: #e6f4ea;
  box-shadow: inset 4px 0 0 var(--ok);
  border-bottom-color: var(--ok);
}
.inst-item.selected strong { color: var(--ok); }
.inst-item .inst-check {
  color: var(--ok);
  font-weight: 800;
  font-size: 1.25rem;
  flex: 0 0 auto;
  padding-left: 10px;
}
.claim-selection-summary {
  margin-top: 10px;
  padding: 10px 12px;
  background: #e6f4ea;
  border: 1px solid var(--ok);
  border-radius: 8px;
  font-size: 0.9rem;
  color: #14532d;
}

.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.text-right { text-align: right; }

/* Camera Overlay */
.camera-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #000;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.camera-overlay video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0; left: 0;
}
.camera-top-bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent);
}
.camera-bottom-bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 24px 16px;
  background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
}
.camera-icon-btn {
  background: rgba(255,255,255,0.25);
  border: 0;
  color: #fff;
  width: 44px; height: 44px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.shutter-btn {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 5px solid #fff;
  background: var(--brand);
  cursor: pointer;
  box-shadow: 0 0 12px rgba(0,0,0,0.4);
}
.shutter-btn:disabled {
  background: #666;
  opacity: 0.5;
  cursor: not-allowed;
}

.gps-badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
}
.badge-green { background: #1a8f4a; }
.badge-amber { background: #c47f00; }
.badge-err, .badge-red { background: #c0392b; }

.camera-msg {
  position: relative;
  z-index: 10;
  color: #fff;
  text-align: center;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* Photo Cards Grid */
.photo-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.photo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.photo-card-preview {
  width: 100%;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-card-preview canvas {
  width: 100%;
  height: auto;
  display: block;
}
.photo-card-body {
  padding: 12px 14px;
}

.sticky-actions-bar {
  position: sticky;
  bottom: 12px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 10px 14px;
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  z-index: 100;
  border: 1px solid var(--border);
}

/* Permission help panel overlay (must sit above the camera overlay, z-index 9999) */
.app-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

/* Roster builders (teams / team members / office bearers) */
.roster-block {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}
.team-block {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  background: #fff;
}
.team-block .team-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.roster-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.roster-row .roster-index {
  flex: 0 0 auto;
  font-size: 0.8rem;
  color: var(--muted, #667085);
  min-width: 1.6em;
  text-align: right;
}
.roster-row .form-control {
  flex: 1 1 auto;
  min-width: 0;
}
.field-warn {
  display: block;
  font-size: 0.82rem;
  color: #92400e;
  background: #fffbe6;
  border-left: 3px solid var(--accent);
  padding: 6px 8px;
  margin-top: 4px;
  border-radius: 4px;
}
.field-warn:empty {
  display: none;
}

/* Attention pulse for the "Add Photo" button when a photo is now required */
@keyframes attention-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(242,101,34,0.55); transform: scale(1); }
  70%  { box-shadow: 0 0 0 14px rgba(242,101,34,0); transform: scale(1.04); }
  100% { box-shadow: 0 0 0 0 rgba(242,101,34,0); transform: scale(1); }
}
.pulse-attention {
  animation: attention-pulse 1.4s ease-out infinite;
  background: var(--accent) !important;
  color: #fff !important;
}

/* Prominent toast (was too faint at the top) */
.app-toast-strong {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  max-width: 92vw;
  margin-top: 12px;
  padding: 14px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.35;
  box-shadow: 0 8px 24px rgba(0,0,0,0.28);
  text-align: center;
}
.app-toast-strong.ok  { background: var(--ok);  color: #fff; }
.app-toast-strong.err { background: var(--err); color: #fff; }
.app-toast-strong.info{ background: var(--brand); color: #fff; }

/* Dashboard reference card after a submission */
.dash-ref {
  text-align: left;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin: 12px 0;
}
.dash-ref h4 { margin: 0 0 8px 0; }
.dash-ref .row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: 0.9rem; }
.dash-ref .row span:first-child { color: var(--muted); }
.dash-ref .roster { font-size: 0.85rem; color: var(--muted); margin-top: 6px; }

/* Caption across the camera viewfinder: which half of the Before/After pair. */
.camera-caption {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  max-width: 86%;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(11, 92, 171, 0.92);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
}

/* Before / After clean-up photo pairs */
.pair-block {
  border: 1px solid var(--line, #d7dee5);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 14px;
  background: #fff;
}
.pair-block > .flex-between { margin-bottom: 8px; }
.pair-slots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.pair-slot {
  border: 1px dashed var(--line, #d7dee5);
  border-radius: 8px;
  padding: 10px;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pair-slot.filled { border-style: solid; }
.pair-slot-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.pair-slot-label.before { color: #b26a00; }
.pair-slot-label.after { color: #1a8f4a; }
.pair-slot-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted, #5a6b7b);
}
.pair-slot canvas { width: 100%; height: auto; border-radius: 6px; display: block; }
.pair-incomplete-note {
  font-size: 0.82rem;
  color: #b26a00;
  margin-top: 6px;
}
@media (max-width: 520px) {
  .pair-slots { grid-template-columns: 1fr; }
}

/* Superadmin photo viewer (before/after clean-up, auth-fetched blobs) */
.photo-viewer { max-width: 900px; width: 94vw; }
.photo-viewer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.pv-cell { border: 1px solid var(--line, #d7dee5); border-radius: 8px; padding: 8px; background: #fff; }
.pv-label { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; margin-bottom: 6px; }
.pv-label.before { color: #b26a00; }
.pv-label.after { color: #1a8f4a; }
.pv-imgwrap { min-height: 140px; display: flex; align-items: center; justify-content: center; background: #f4f6f8; border-radius: 6px; }
.pv-imgwrap img { width: 100%; height: auto; border-radius: 6px; display: block; }
.pv-meta { margin-top: 6px; line-height: 1.35; }
.warn-text { color: #c62828; }
@media (max-width: 560px) { .photo-viewer-grid { grid-template-columns: 1fr; } }
