/* ─────────────────────────────────────────────────────────────
   PatriotChat main.css (global) — theme aware + iOS-safe
   ───────────────────────────────────────────────────────────── */

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

/* --- THEME BRIDGE: guarantee Bootstrap vars for both themes --- */
:root[data-bs-theme="light"], [data-bs-theme="light"]{
  --bs-body-bg: #ffffff;
  --bs-body-color: #111827;
  --bs-card-bg: #ffffff;
  --bs-card-border-color: #e5e7eb;
  --bs-dropdown-bg: #ffffff;
  --bs-dropdown-border-color: #e5e7eb;
}

:root[data-bs-theme="dark"], [data-bs-theme="dark"]{
  --bs-body-bg: #0e1624;              /* page surface */
  --bs-body-color: #e5e7eb;
  --bs-card-bg: #111827;
  --bs-card-border-color: #1f2937;
  --bs-dropdown-bg: #0f172a;
  --bs-dropdown-border-color: #1f2937;
}

/* iOS sometimes paints body before vars propagate — force it here too */
[data-bs-theme="light"] body{
  background: var(--bs-body-bg) !important;
  color: var(--bs-body-color) !important;
}
[data-bs-theme="dark"] body{
  background: var(--bs-body-bg) !important;
  color: var(--bs-body-color) !important;
}

/* Base typography & colors (theme-aware) */
html, body{
  margin:0;
  padding:0;
  font-family: Inter, Roboto, sans-serif;
  background: var(--bs-body-bg, #0e1624);
  color: var(--bs-body-color, #e5e7eb);
}

/* Layout helpers */
body.full-height{
  display:flex;
  flex-direction:column;
  min-height:100vh;
}

/* Fixed navbar offset + iOS safe area */
:root{ --nav-height: 56px; }
body{
  padding-top: calc(var(--nav-height) + env(safe-area-inset-top, 0px));
  overflow-x: hidden;
}

/* Main container */
main{
  flex:1;
  width:100%;
  max-width:960px;
  margin:0 auto;
  padding:0.5rem 1rem; /* navbar already provides top offset */
}
main.hero-page{ padding-top: 0; margin-top: 0; }
body.dm-page main{
  max-width:none;
}

/* DM page is an "app" view: lock the viewport so internal panes scroll.
   Without this, the document can grow tall (footer becomes reachable) and the
   DM stream may stop being the scroll container. */
body.dm-page{
  overflow: hidden;
}
body.dm-page main{
  height: calc(var(--dm-vh, 1vh) * 100 - var(--nav-height) - env(safe-area-inset-top, 0px));
  overflow: hidden;
  padding: 0; /* DM view provides its own padding */
}
body.dm-page .site-footer{
  display: none !important;
}


/* Links & buttons */
a{ color:inherit; text-decoration:none; }
button{ font-family:inherit; }
main .btn, .btn-primary{ display:block; margin:1rem auto; text-align:center; }
.btn-primary{ margin:2rem auto; }

/* Content pages (generic) */
.content-page{ padding:3rem 1rem; }
.content-shell{ max-width:1100px; margin:0 auto; }
.content-narrow{ max-width:760px; margin:0 auto; }
.content-page h1{ font-size:2.25rem; margin-bottom:1rem; }
.content-page .lead{ font-size:1.2rem; opacity:.85; }
.content-page p{ line-height:1.6; }

/* Utilities */
.hidden{ display:none!important; }
.text-nowrap{ white-space:nowrap; }

/* Admin settings hub */
.admin-settings-hero{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  padding:20px 24px;
  border-radius:16px;
  background:linear-gradient(135deg, rgba(30,41,59,.7), rgba(15,23,42,.9));
  border:1px solid rgba(148,163,184,.25);
}
.admin-settings-title{
  font-size:1.6rem;
  margin:0 0 6px 0;
}
.admin-settings-sub{
  margin:0;
  color:rgba(226,232,240,.75);
}
.admin-settings-badges{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.admin-pill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 10px;
  border-radius:999px;
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:0.08em;
  border:1px solid rgba(148,163,184,.4);
  background:rgba(30,41,59,.7);
  color:#e2e8f0;
}
.admin-pill-muted{
  border-color:rgba(71,85,105,.6);
  color:rgba(148,163,184,.9);
}
.admin-pill-live{
  border-color:rgba(34,197,94,.55);
  color:#bbf7d0;
  background:rgba(34,197,94,.18);
}
.admin-card-grid{
  display:grid;
  gap:18px;
  grid-template-columns:repeat(auto-fit, minmax(250px, 1fr));
}
.admin-card{
  background:rgba(15,23,42,.85);
  border:1px solid rgba(148,163,184,.25);
  border-radius:16px;
  padding:18px;
  min-height:180px;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  box-shadow:0 10px 30px rgba(0,0,0,.2);
  animation:adminFadeUp .4s ease both;
}
.admin-card.is-primary{
  border-color:rgba(59,130,246,.45);
  box-shadow:0 12px 32px rgba(59,130,246,.12);
}
.admin-card.is-muted{
  opacity:.85;
}
.admin-card-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  margin-bottom:8px;
}
.admin-card-header h3{
  margin:0;
  font-size:1.1rem;
}
.admin-card-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.admin-muted{
  color:rgba(148,163,184,.8);
  font-size:.9rem;
}
.admin-form-grid{
  display:grid;
  gap:20px;
  grid-template-columns:repeat(auto-fit, minmax(240px, 1fr));
}
.admin-status-inline{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}
.admin-empty{
  text-align:center;
  padding:20px;
  border:1px dashed rgba(148,163,184,.3);
  border-radius:12px;
}
.admin-empty-title{
  font-weight:600;
  margin-bottom:6px;
}
@keyframes adminFadeUp{
  from{ opacity:0; transform:translateY(10px); }
  to{ opacity:1; transform:translateY(0); }
}

/* Veteran badge */
.vet-badge{
  display:inline-flex;
  align-items:center;
  gap:4px;
  margin-left:6px;
  padding:2px 6px;
  border-radius:999px;
  font-size:10px;
  font-weight:700;
  letter-spacing:0.04em;
  text-transform:uppercase;
  border:1px solid rgba(56,189,248,.45);
  color:#e2e8f0;
  background:rgba(56,189,248,.18);
}
.vet-badge.vet-branch{
  border-color: rgba(34,197,94,.45);
  background: rgba(34,197,94,.18);
}
.vet-badge.vet-shield{
  border-color: rgba(250,204,21,.55);
  background: rgba(250,204,21,.18);
}

/* Alerts */
.alert{ padding:.75rem 1rem; border-radius:6px; margin-top:1rem; }
.alert-info{    background:#2c3e50; color:#fff;}
.alert-danger{  background:#c0392b; color:#fff;}
.alert-success{ background:#27ae60; color:#fff;}

/* Password strength meter */
.meter{ background:#e5e5e5; border-radius:4px; height:6px; margin-top:6px; }
.meter #fill{ height:100%; width:0; border-radius:4px; transition:width .3s; }

/* Checkbox layout helpers */
.form-group.checkbox > label{
  display:inline-flex; align-items:center; gap:.4rem; margin-bottom:0;
}
.form-group.checkbox input[type="checkbox"]{ flex:0 0 auto; }

/* Registration card */
.register-card,
.step-card,
.card--registration{
  width:100%; max-width:420px; margin:0 auto;
  padding:1.5rem 1.25rem; box-sizing:border-box;
}
@media (max-width:360px){
  .register-card{ padding:1.25rem 1rem; }
  .form-group input, .form-group select{ font-size:1rem; }
}

/* Dashboard grid */
.dashboard .grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap:1.5rem; margin-top:2rem;
}
.dashboard .card{
  background: var(--bs-card-bg, #ffffff);
  border: 1px solid var(--bs-card-border-color, #e5e7eb);
  padding:1.5rem; border-radius:10px;
  box-shadow:0 0 8px rgba(0,0,0,.05);
}

/* CTA helpers */
.page-container{
  padding-top:64px; padding-bottom:1rem;
  max-width:1200px; margin:0 auto;
}
.cta-button-wrapper{ text-align:center; margin-top:1rem; }
.cta .btn-primary{
  display:inline-block; padding:.75rem 1.5rem;
  font-weight:bold; font-size:1.1rem;
}

/* Generic card */
.card{
  border-radius:10px; padding:1.5rem; margin-bottom:1.5rem;
  background: var(--bs-card-bg, #1e1e1e);
  border: 1px solid var(--bs-card-border-color, #333);
}

/* Images / SVG never overflow */
img, svg{ max-width:100%; height:auto; }

/* ===========================================================
   HOME / INDEX POLISH (applies to <main class="hero-page">)
   =========================================================== */
.hero-page .container{
  max-width: 1100px;
  margin-inline: auto;
  padding-inline: 16px;
}

/* Hero section */
.hero{
  padding-block: clamp(28px, 6vw, 72px);
}
.hero h1{
  font-size: clamp(28px, 4.2vw, 44px);
  line-height: 1.18;
  letter-spacing: -0.01em;
  margin: 0 0 12px 0;
}
.hero p{
  margin: 0 0 18px 0;
  color: var(--text-muted, #6b7280);
}
.hero .sticky-cta{
  display:inline-block;
  padding:10px 16px;
  border-radius:12px;
  font-weight:600;
  text-decoration:none;
}
.hero .cta-tagline{
  margin-top:10px;
  color: var(--text-muted, #6b7280);
}

/* Feature grid */
.features{
  padding-block: clamp(24px, 5vw, 56px);
}
.features h2{
  margin: 0 0 14px 0;
  font-size: clamp(22px, 2.4vw, 28px);
}
.features .grid{
  display:grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap:16px;
}
@media (max-width: 992px){
  .features .grid{ grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px){
  .features .grid{ grid-template-columns: 1fr; }
}
.features .feature{
  background: var(--bs-card-bg, #ffffff);
  border: 1px solid var(--bs-card-border-color, #e5e7eb);
  border-radius: 12px;
  padding: 16px;
}

/* Story detail rich media should not overflow */
.story-body img,
.story-body video,
.story-body iframe {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto 1rem auto;
}

.story-body figure {
  max-width: 100%;
  margin: 0 auto 1.5rem auto;
}

.story-actions{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin: 1rem 0;
}
.story-actions .btn,
.story-actions .vp-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius: 999px;
  padding: 8px 12px;
  margin: 0;
}

@media (max-width: 640px){
  .story-actions{
    display:grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .story-actions .btn,
  .story-actions .vp-btn{
    width:100%;
  }
}
.comments{
  margin-top: 1rem;
}
.comments textarea{
  width: 100%;
  min-height: 100px;
  padding: 10px;
  border-radius: 8px;
}

/* Salutes modal */
.salute-overlay{
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.salute-modal{
  background: var(--card-bg, #0f172a);
  color: var(--text, #e5e7eb);
  border: 1px solid var(--card-border, rgba(255,255,255,0.12));
  border-radius: 14px;
  padding: 18px;
  width: min(420px, 92vw);
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
}
.salute-modal h3{ margin: 0 0 8px 0; font-size: 1.1rem; }
.salute-modal .balance{ font-size: 0.95rem; margin-bottom: 10px; color: var(--text-muted, #94a3b8); }
.salute-choices{
  display:flex; flex-wrap:wrap; gap:8px; margin:10px 0;
}
.salute-choices button{
  border-radius: 999px;
  padding: 8px 12px;
}
.salute-actions{
  display:flex; gap:10px; justify-content:flex-end; margin-top:10px;
}
.salute-purchase-hint{
  margin-top:8px;
  font-size:0.85rem;
  color: var(--text-muted, #94a3b8);
}
.salute-purchase-hint a{
  color: #fbbf24;
  text-decoration: none;
}
.salute-purchase-hint a:hover{
  text-decoration: underline;
}

/* Share modal (uses the same overlay/modal shell) */
.pc-share-status{
  display:none;
  margin: 0 0 10px 0;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(148,163,184,.25);
  background: rgba(15,23,42,.55);
  color: rgba(226,232,240,.92);
  font-size: 0.92rem;
}
.pc-share-status.is-error{
  border-color: rgba(239,68,68,.45);
  background: rgba(239,68,68,.12);
  color: #fecaca;
}
.pc-share-open{
  color: #60a5fa;
  text-decoration: none;
  font-weight: 600;
}
.pc-share-open:hover{ text-decoration: underline; }

.pc-share-tabs{
  display:flex;
  gap:8px;
  margin: 6px 0 12px 0;
  flex-wrap: wrap;
}
.pc-share-tab{
  border: 1px solid rgba(148,163,184,.28);
  background: rgba(30,41,59,.35);
  color: rgba(226,232,240,.95);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.9rem;
}
.pc-share-tab.is-active{
  border-color: rgba(59,130,246,.6);
  background: rgba(59,130,246,.18);
}
.pc-share-panel{ display:none; }

.pc-share-section{ margin-top: 10px; }
.pc-share-label{ margin-bottom: 6px; }
.pc-share-hint{
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--text-muted, #94a3b8);
}
.pc-share-search{ margin-top: 2px; }
.pc-share-list{
  margin-top: 10px;
  border: 1px solid rgba(148,163,184,.18);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(15,23,42,.35);
  max-height: 220px;
  overflow-y: auto;
}
.pc-share-item{
  width:100%;
  display:flex;
  gap:10px;
  align-items:center;
  padding: 10px;
  border: 0;
  border-bottom: 1px solid rgba(148,163,184,.12);
  background: transparent;
  color: inherit;
  text-align: left;
}
.pc-share-item:last-child{ border-bottom: 0; }
.pc-share-item:hover{
  background: rgba(148,163,184,.08);
}
.pc-share-avatar{
  width: 34px;
  height: 34px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid rgba(148,163,184,.18);
}
.pc-share-meta{ min-width: 0; }
.pc-share-title{
  font-weight: 650;
  line-height: 1.1;
}
.pc-share-sub{
  font-size: 0.85rem;
  color: var(--text-muted, #94a3b8);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 320px;
}
.pc-share-empty{
  padding: 12px;
  color: var(--text-muted, #94a3b8);
  font-size: 0.9rem;
}
.pc-share-note{ margin-top: 10px; }
.pc-share-selected{ margin: 0 0 6px 0; min-height: 24px; }
.pc-share-selected-pill{
  display:inline-flex;
  align-items:center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(59,130,246,.45);
  background: rgba(59,130,246,.14);
  color: rgba(226,232,240,.96);
  font-size: 0.85rem;
}

/* CTA band */
.cta{
  text-align:center;
  padding: clamp(24px, 5vw, 56px) 16px;
  border-block: 1px solid var(--bs-card-border-color, #1f2937);
}
.cta h2{ margin: 0 0 8px 0; }
.cta .cta-tagline{ margin: 0 0 12px 0; color: var(--text-muted, #6b7280); }
.cta .btn{ padding:10px 18px; border-radius:12px; font-weight:600; }

/* AI teaser */
.ai-teaser{
  padding-block: clamp(20px, 4vw, 48px);
}
.ai-teaser .container{
  max-width: 1100px; margin: 0 auto; padding-inline: 16px;
}

/* -------------------------------------------------------------------------- */
/* Global toast helper (pc_toast.js)                                           */
/* -------------------------------------------------------------------------- */
.pc-toast-stack{
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 9999;
  display: grid;
  gap: 10px;
  max-width: calc(100vw - 28px);
  pointer-events: none;
}
.pc-toast{
  pointer-events: auto;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--bs-toast-border-color, rgba(255,255,255,.12));
  background: var(--bs-toast-bg, rgba(17,24,39,0.96));
  color: var(--bs-toast-color, #e5e7eb);
  box-shadow: var(--menu-shadow, 0 12px 36px rgba(0,0,0,.45));
  transform: translateY(-6px);
  opacity: 0;
  transition: opacity .16s ease, transform .16s ease;
  max-width: 420px;
}
.pc-toast.is-show{
  opacity: 1;
  transform: translateY(0);
}
.pc-toast__text{
  font-size: 13px;
  line-height: 1.25;
  word-break: break-word;
}
.pc-toast__close{
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.pc-toast__close:hover{ background: rgba(255,255,255,0.10); }
.pc-toast--success{ border-color: rgba(34,197,94,0.35); }
.pc-toast--error{ border-color: rgba(239,68,68,0.40); }
.pc-toast--info{ border-color: rgba(96,165,250,0.35); }

/* Minimal progress bar used by XHR uploads (DM + post attachments). */
.pc-progress{
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.12);
  overflow: hidden;
}
html[data-bs-theme="light"] .pc-progress{
  background: rgba(17,24,39,0.06);
  border-color: rgba(17,24,39,0.12);
}
.pc-progress__bar{
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(37,99,235,0.95), rgba(96,165,250,0.95));
  transition: width 80ms linear;
}

/* Accessible focus rings (avoid "where did my focus go?" issues). */
:focus-visible{
  outline: 2px solid rgba(96,165,250,0.90);
  outline-offset: 2px;
}
html[data-bs-theme="light"] :focus-visible{
  outline-color: rgba(37,99,235,0.85);
}

/* -------------------------------------------------------------------------- */
/* Global submit loading helper (pc_submit_loading.js)                         */
/* -------------------------------------------------------------------------- */
.pc-submit-disabled{
  cursor: not-allowed !important;
}
button.pc-is-loading,
input[type="submit"].pc-is-loading{
  position: relative;
}
button.pc-is-loading::after,
input[type="submit"].pc-is-loading::after{
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 8px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 999px;
  vertical-align: -2px;
  animation: pc-spin .8s linear infinite;
}
@keyframes pc-spin{ to { transform: rotate(360deg); } }

/* -------------------------------------------------------------------------- */
/* Empty state component (Wave 2 consistency)                                 */
/* -------------------------------------------------------------------------- */
.pc-empty{
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 14px;
  border: 1px dashed rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.03);
  color: var(--text, #e5e7eb);
}
[data-bs-theme="light"] .pc-empty{
  border-color: rgba(17,24,39,0.14);
  background: rgba(17,24,39,0.03);
  color: var(--text, #111827);
}
.pc-empty__title{
  font-weight: 700;
}
.pc-empty__sub{
  font-size: 13px;
  color: var(--text-muted, #94a3b8);
}
[data-bs-theme="light"] .pc-empty__sub{
  color: var(--text-muted, #6b7280);
}
.pc-empty__actions{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* -------------------------------------------------------------------------- */
/* Global media lightbox (pc_lightbox.js)                                      */
/* -------------------------------------------------------------------------- */
body.lightbox-open{
  overflow:hidden;
}
.pc-lightbox.pc-lightbox--global{
  position:fixed;
  inset:0;
  z-index:2200;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:22px;
}
.pc-lightbox.pc-lightbox--global[hidden]{
  display:none;
}
.pc-lightbox.pc-lightbox--global .pc-lightbox-backdrop{
  position:absolute;
  inset:0;
  background:rgba(4, 8, 20, 0.75);
  backdrop-filter:blur(2px);
}
.pc-lightbox.pc-lightbox--global .pc-lightbox-dialog{
  position:relative;
  z-index:1;
  width:min(980px, 94vw);
  max-height:92vh;
  display:flex;
  flex-direction:column;
  gap:10px;
  padding:14px;
  border-radius:16px;
  border:1px solid rgba(255,255,255,0.14);
  background:rgba(8, 12, 22, 0.96);
  box-shadow:0 20px 60px rgba(0,0,0,0.45);
  outline:none;
}
[data-bs-theme="light"] .pc-lightbox.pc-lightbox--global .pc-lightbox-dialog{
  border-color: rgba(17,24,39,0.14);
  background: rgba(255,255,255,0.96);
}
.pc-lightbox.pc-lightbox--global .pc-lightbox-toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.pc-lightbox.pc-lightbox--global .pc-lightbox-title{
  min-width:0;
  font-size:12px;
  opacity:.75;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.pc-lightbox.pc-lightbox--global .pc-lightbox-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  justify-content:flex-end;
}
.pc-lightbox.pc-lightbox--global .pc-lightbox-stage{
  display:flex;
  align-items:center;
  justify-content:center;
  min-height: 140px;
}
.pc-lightbox.pc-lightbox--global .pc-lightbox-img,
.pc-lightbox.pc-lightbox--global .pc-lightbox-video{
  max-width: 90vw;
  max-height: 76vh;
  object-fit:contain;
  border-radius:12px;
  border:1px solid rgba(255,255,255,0.14);
  background:#0b1220;
}
[data-bs-theme="light"] .pc-lightbox.pc-lightbox--global .pc-lightbox-img,
[data-bs-theme="light"] .pc-lightbox.pc-lightbox--global .pc-lightbox-video{
  border-color: rgba(17,24,39,0.14);
  background: rgba(17,24,39,0.04);
}
.pc-lightbox.pc-lightbox--global .pc-lightbox-nav{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.pc-lightbox.pc-lightbox--global .pc-lightbox-counter{
  font-size:12px;
  opacity:.7;
}
