/**
 * Sabattus Community Resource Network — Senior-Friendly, Mobile-First WCAG 2.1 AA Stylesheet
 *
 * UX Design Specialist Architecture ("Maximum 1 Bordered Card Depth"):
 * 1. Zero Concentric/Nested Boxes:
 *    - Outer sections (`.panel`) are flat, borderless page sections on mobile separated
 *      by clean horizontal dividers (matching `Homepage_Mobile_Mockup.png`), reclaiming
 *      70px–130px of horizontal screen width on 320px–430px smartphones.
 *    - Individual items (`.need-card`, `.phonebook-card`, `.sub-box`) are the ONLY
 *      4-sided bordered cards on the page.
 *    - Any form, callout, or preview inside a card (`.inline-drawer`, `.card-callout`,
 *      `.party-split`, or nested `.sub-box`) automatically flattens to a borderless
 *      top-rule divider (`border-top: 2px dashed #94A3B8`) instead of drawing a box inside a box.
 * 2. Minimum base font size: 18px (1.125rem), line-height 1.6
 * 3. Minimum interactive touch target size: 48px x 48px (`min-height: 48px; min-width: 48px`)
 * 4. Contrast ratios exceed WCAG 2.1 AA (> 10:1 on primary actions and text)
 */

:root {
  --bg-page: #F4F7FA;
  --bg-surface: #FFFFFF;
  --bg-header-band: #DCEBFA;
  --bg-muted: #F1F5F9;
  --text-primary: #0F172A;
  --text-secondary: #1E293B;
  --border-strong: #0F172A;
  --border-soft: #94A3B8;
  --action-primary: #0B3B60;
  --action-primary-hover: #072842;
  --urgent-bg: #FEF3C7;
  --urgent-text: #451A03;
  --urgent-border: #92400E;
  --success-bg: #DCFCE7;
  --success-text: #064E3B;
  --success-border: #166534;
  --offline-bg: #FEF2F2;
  --offline-text: #7F1D1D;
  --offline-border: #991B1B;
  --focus-ring: #D97706;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    Oxygen, Ubuntu, Cantarell, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 18px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

/* Skip to main content link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 1000;
  background: var(--action-primary);
  color: #FFFFFF;
  padding: 12px 20px;
  font-weight: 700;
  font-size: 1rem;
  min-height: 48px;
  min-width: 48px;
  border: 2px solid var(--border-strong);
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

:focus-visible {
  outline: 3px solid var(--focus-ring) !important;
  outline-offset: 2px !important;
}

/* Enforce 48x48px minimum touch target across all interactive elements */
button,
a.btn,
a.nav-link,
input,
select,
textarea,
.touch-target,
.checkbox-tile {
  min-height: 48px;
  min-width: 48px;
  font-family: inherit;
  font-size: 1rem;
}

input[type='text'],
input[type='tel'],
input[type='email'],
input[type='search'],
input[type='file'],
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border-strong);
  border-radius: 8px;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-size: 1rem;
  line-height: 1.4;
}

label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.field-group {
  margin-bottom: 16px;
}

.field-hint {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Clean, Uncluttered Site Header & Structured 2-Column Mobile Nav Grid */
.site-header {
  background-color: var(--bg-surface);
  border-bottom: 3px solid var(--border-strong);
  padding: 12px 14px;
}

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

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
}

.brand-icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg-header-band);
  font-size: 1.5rem;
}

.brand-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.2;
}

.brand-subtitle {
  margin: 2px 0 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.primary-nav {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  width: 100%;
}

@media (min-width: 768px) {
  .primary-nav {
    display: flex;
    flex-wrap: wrap;
    width: auto;
  }
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 2px solid var(--border-strong);
  border-radius: 8px;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.nav-btn[aria-current='page'],
.nav-btn.active {
  background-color: var(--action-primary);
  color: #FFFFFF;
}

/* Offline Status Banner (Key Directive 4) */
.offline-banner {
  background-color: var(--offline-bg);
  color: var(--offline-text);
  border-bottom: 3px solid var(--offline-border);
  padding: 14px 16px;
  font-weight: 700;
}

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

/* Main Container — Full width on mobile, spacious on desktop */
.main-container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 12px 48px;
}

@media (min-width: 768px) {
  .main-container {
    padding: 28px 20px 60px;
  }
}

.homepage-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

@media (min-width: 880px) {
  .homepage-grid {
    grid-template-columns: 1fr 1fr;
    gap: 28px;
  }
}

/*
 * FLAT SECTIONS ON MOBILE (Eliminates Outer Box Border on Phones)
 * On phones (< 768px), `.panel` is a flat, unbordered section separated by a clean
 * top/bottom rule, giving 100% of the viewport width to cards and buttons.
 * On desktop (>= 768px), `.panel` displays as a clean framed section.
 */
.panel {
  background-color: transparent;
  border: none;
  border-radius: 0;
  margin-bottom: 24px;
}

.panel-header {
  background-color: transparent;
  border-bottom: 3px solid var(--border-strong);
  padding: 8px 4px 10px 4px;
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--text-primary);
}

.panel-body {
  padding: 0;
}

@media (min-width: 768px) {
  .panel {
    background-color: var(--bg-surface);
    border: 2px solid var(--border-strong);
    border-radius: 12px;
    overflow: hidden;
  }

  .panel-header {
    background-color: var(--bg-header-band);
    border-bottom: 2px solid var(--border-strong);
    padding: 14px 20px;
    margin-bottom: 0;
  }

  .panel-body {
    padding: 22px;
  }
}

/*
 * SINGLE-LEVEL CARDS & ZERO NESTED BOXES RULE:
 * - A top-level `.sub-box`, `.need-card`, or `.phonebook-card` has a clean 2px border.
 * - ANY `.sub-box` or `.inline-drawer` placed INSIDE another `.sub-box`, `.need-card`,
 *   or `.phonebook-card` NEVER draws a second 4-sided box! Instead, it flattens into
 *   a clean top divider (`border-top: 2px dashed var(--border-soft)`) with 0 side padding!
 */
.sub-box {
  border: 2px solid var(--border-strong);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  background-color: var(--bg-surface);
}

.sub-box:last-child {
  margin-bottom: 0;
}

/* Automatic de-nesting for any box inside a card or box */
.sub-box .sub-box,
.need-card .sub-box,
.phonebook-card .sub-box,
.inline-drawer {
  border: none !important;
  border-top: 2px dashed var(--border-soft) !important;
  border-radius: 0 !important;
  padding: 16px 0 4px 0 !important;
  margin-top: 14px !important;
  margin-bottom: 0 !important;
  background-color: transparent !important;
}

/* Flat Callout Strip inside a card (no 4-sided box; uses a left accent bar) */
.card-callout {
  border: none;
  border-left: 4px solid var(--urgent-border);
  background-color: var(--urgent-bg);
  color: var(--urgent-text);
  padding: 10px 14px;
  margin-top: 12px;
  border-radius: 0 6px 6px 0;
  font-size: 0.95rem;
}

/* Flat Section Group Header (for Moderator Queue & Wellness sections — no outer box!) */
.section-group {
  margin-bottom: 28px;
}

.section-group-header {
  border-bottom: 2px solid var(--border-strong);
  padding-bottom: 8px;
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

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

/* Two-Party Split inside a Claim Card (Divider line instead of 2 nested boxes) */
.party-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 14px 0;
  margin: 12px 0;
  border-top: 2px dashed var(--border-soft);
  border-bottom: 2px dashed var(--border-soft);
}

@media (min-width: 720px) {
  .party-split {
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }
}

/* Mobile-First Big Easy Action Buttons (Matching Mobile Mockup) */
.quick-action-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.big-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 76px;
  padding: 14px 16px;
  border: 2px solid var(--border-strong);
  border-radius: 10px;
  background-color: var(--action-primary);
  color: #FFFFFF;
  cursor: pointer;
  text-align: center;
}

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

.big-action-btn.secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
}

.big-action-btn.secondary:hover {
  background-color: var(--bg-header-band);
}

.big-action-title {
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.25;
}

.big-action-sub {
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 4px;
  opacity: 0.95;
}

/* Standard Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 18px;
  background-color: var(--action-primary);
  color: #FFFFFF;
  border: 2px solid var(--border-strong);
  border-radius: 8px;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  text-align: center;
}

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

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 2px solid var(--border-strong);
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn-secondary:hover {
  background-color: var(--bg-header-band);
}

/* Voluntary Priority Checkboxes (No outer fieldset box border) */
.checkbox-fieldset {
  border: none;
  padding: 0;
  margin: 0 0 16px 0;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 8px;
}

.checkbox-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 2px solid var(--border-strong);
  border-radius: 8px;
  background-color: var(--bg-surface);
  cursor: pointer;
  font-weight: 600;
}

.checkbox-tile input[type='checkbox'] {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  margin: 0;
  accent-color: var(--action-primary);
}

/* 6-Tile Resource Directory Category Grid */
.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 14px 0;
}

@media (min-width: 540px) {
  .category-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
}

.category-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 8px;
  min-height: 92px;
  border: 2px solid var(--border-strong);
  border-radius: 10px;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 800;
  text-align: center;
  cursor: pointer;
}

.category-tile:hover {
  background-color: var(--bg-header-band);
}

.category-tile[aria-pressed='true'] {
  background-color: var(--action-primary);
  color: #FFFFFF;
}

.category-icon {
  font-size: 1.7rem;
  line-height: 1;
}

.category-subtext {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  opacity: 0.9;
}

@media (max-width: 620px) {
  .category-subtext {
    display: none;
  }
}

/* Senior-Friendly Zero-Scroll 2-Column Topic Filter Grid (4 columns on desktop) */
.topic-pill-bar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

@media (min-width: 768px) {
  .topic-pill-bar {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }
}

.topic-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  min-height: 48px;
  border: 2px solid var(--border-strong);
  border-radius: 8px;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 800;
  font-size: 0.92rem;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}

.topic-pill:hover {
  background-color: var(--bg-header-band);
}

.topic-pill[aria-pressed='true'] {
  background-color: var(--action-primary);
  color: #FFFFFF;
}

/* Single-Layer Cards for Needs, Phonebook, Wellness & Moderation */
.phonebook-card,
.need-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  margin-bottom: 14px;
  border: 2px solid var(--border-strong);
  border-radius: 10px;
  background-color: var(--bg-surface);
}

.need-card--urgent {
  border-left: 8px solid var(--urgent-border);
}

@media (min-width: 720px) {
  .phonebook-card,
  .need-card {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    padding: 20px;
    gap: 20px;
  }
}

.phonebook-card-main,
.need-card-main {
  flex: 1 1 420px;
  min-width: 0;
}

.need-card-action {
  width: 100%;
}

@media (min-width: 720px) {
  .need-card-action {
    width: auto;
    min-width: 200px;
    flex-shrink: 0;
  }
}

.phonebook-card-title {
  margin: 4px 0 6px 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
}

.phonebook-card-meta {
  margin: 4px 0 0 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.phonebook-call-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 12px 18px;
  background-color: var(--action-primary);
  color: #FFFFFF;
  border: 2px solid var(--border-strong);
  border-radius: 8px;
  font-size: 1.05rem;
  font-weight: 800;
  text-decoration: none;
  text-align: center;
}

@media (min-width: 720px) {
  .phonebook-call-btn {
    width: auto;
    min-width: 220px;
  }
}

.phonebook-call-btn:hover {
  background-color: var(--action-primary-hover);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 800;
  border: 2px solid var(--border-strong);
}

.badge-high {
  background-color: var(--urgent-bg);
  color: var(--urgent-text);
  border-color: var(--urgent-border);
}

.badge-standard {
  background-color: var(--bg-muted);
  color: var(--text-primary);
}

.badge-approved,
.badge-completed {
  background-color: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-border);
}

/* Responsive Tables fallback */
.needs-table {
  width: 100%;
  border-collapse: collapse;
}

.needs-table th,
.needs-table td {
  border: 2px solid var(--border-strong);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

.needs-table th {
  background-color: var(--bg-header-band);
  font-weight: 800;
}

/* Convert tables into stacked mobile cards on < 720px phones */
@media (max-width: 719px) {
  .needs-table,
  .needs-table thead,
  .needs-table tbody,
  .needs-table th,
  .needs-table td,
  .needs-table tr {
    display: block;
    width: 100%;
  }

  .needs-table thead {
    display: none;
  }

  .needs-table tr {
    border: 2px solid var(--border-strong);
    border-radius: 10px;
    margin-bottom: 12px;
    padding: 12px;
    background: var(--bg-surface);
  }

  .needs-table td {
    border: none;
    border-bottom: 1px solid var(--border-soft);
    padding: 6px 0;
  }

  .needs-table td:last-child {
    border-bottom: none;
  }
}

.status-toast {
  padding: 14px 16px;
  margin-bottom: 16px;
  border: 2px solid var(--success-border);
  background-color: var(--success-bg);
  color: var(--success-text);
  font-weight: 700;
  border-radius: 8px;
}

.error-toast {
  padding: 14px 16px;
  margin-bottom: 16px;
  border: 2px solid var(--offline-border);
  background-color: var(--offline-bg);
  color: var(--offline-text);
  font-weight: 700;
  border-radius: 8px;
}

/* Subtle Footer Utility Bar for Staff Login & Offline Testing */
.utility-bar {
  background-color: var(--bg-muted);
  border-top: 2px solid var(--border-soft);
  padding: 16px 14px;
}

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