/* Application styles built on tokens.css. */
body {
  font-family: var(--fp-font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1 0 auto; }

.fp-container { max-width: var(--fp-container-max); }

.fp-skip-link {
  position: absolute;
  top: var(--fp-space-2);
  left: var(--fp-space-2);
  z-index: 1000;
  padding: var(--fp-space-2) var(--fp-space-4);
  background: var(--fp-gray-0);
  border-radius: var(--fp-radius-sm);
}

:focus-visible {
  outline: 2px solid var(--fp-brand-primary);
  outline-offset: 2px;
}

.fp-brand {
  font-weight: 700;
  font-size: var(--fp-fs-lg);
  color: var(--fp-gray-900);
  min-height: var(--fp-touch-target);
  display: inline-flex;
  align-items: center;
}

.fp-title {
  font-weight: 700;
  font-size: clamp(var(--fp-fs-xl), 4vw, var(--fp-fs-2xl));
}

.fp-hero { max-width: 48rem; }

.fp-status-list li {
  display: flex;
  align-items: center;
  gap: var(--fp-space-2);
  padding: var(--fp-space-2) 0;
}

.fp-error-code {
  font-size: var(--fp-fs-2xl);
  font-weight: 600;
  margin-bottom: 0;
}

.fp-debug pre {
  white-space: pre-wrap;
  font-size: var(--fp-fs-xs);
  background: var(--fp-gray-50);
  padding: var(--fp-space-4);
  border-radius: var(--fp-radius-sm);
}

/* ---------------------------------------------------------------------------
 * Icons
 * ------------------------------------------------------------------------- */
.fp-icon { width: 1.1em; height: 1.1em; vertical-align: -0.15em; flex-shrink: 0; }
.fp-icon-lg { width: 2rem; height: 2rem; }
.fp-touch, .fp-icon-btn { min-height: var(--fp-touch-target); min-width: var(--fp-touch-target); }

/* ---------------------------------------------------------------------------
 * Brand colour applied to Bootstrap primary components
 * ------------------------------------------------------------------------- */
.btn-primary {
  --bs-btn-bg: var(--fp-brand-primary);
  --bs-btn-border-color: var(--fp-brand-primary);
  --bs-btn-hover-bg: color-mix(in srgb, var(--fp-brand-primary) 85%, black);
  --bs-btn-hover-border-color: color-mix(in srgb, var(--fp-brand-primary) 85%, black);
  --bs-btn-active-bg: color-mix(in srgb, var(--fp-brand-primary) 75%, black);
  --bs-btn-disabled-bg: var(--fp-brand-primary);
  --bs-btn-disabled-border-color: var(--fp-brand-primary);
}
.btn-outline-primary {
  --bs-btn-color: var(--fp-brand-primary);
  --bs-btn-border-color: var(--fp-brand-primary);
  --bs-btn-hover-bg: var(--fp-brand-primary);
  --bs-btn-hover-border-color: var(--fp-brand-primary);
}
a { color: var(--fp-brand-primary); }
.text-bg-primary { background-color: var(--fp-brand-primary) !important; }

/* ---------------------------------------------------------------------------
 * Auth pages
 * ------------------------------------------------------------------------- */
.fp-auth-body { background: var(--fp-gray-50); }
.fp-auth-main { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--fp-space-4); }
.fp-auth-card { width: 100%; max-width: 28rem; border-radius: var(--fp-radius-lg); }

/* ---------------------------------------------------------------------------
 * Portal shell
 * ------------------------------------------------------------------------- */
.fp-portal { background: var(--fp-gray-50); display: block; }
.fp-topbar { background: var(--fp-gray-0); position: sticky; top: 0; z-index: 1020; }
.fp-shell { display: flex; min-height: calc(100vh - 57px); }
.fp-sidebar { background: var(--fp-gray-0); }
@media (min-width: 992px) {
  .fp-sidebar { width: 15rem; flex-shrink: 0; }
}
.fp-nav-link {
  display: flex; align-items: center; gap: var(--fp-space-2);
  min-height: var(--fp-touch-target);
  color: var(--fp-gray-900);
  border-radius: var(--fp-radius-sm);
}
.fp-nav-link:hover { background: var(--fp-gray-100); color: var(--fp-gray-900); }
.fp-nav-link.active { background: color-mix(in srgb, var(--fp-brand-primary) 12%, white); color: var(--fp-gray-900); font-weight: 600; }
.fp-content { flex: 1 1 auto; min-width: 0; padding: var(--fp-space-6) var(--fp-space-4); }
@media (min-width: 992px) {
  .fp-content { padding: var(--fp-space-8); }
}
.fp-form-card { max-width: 40rem; }
.fp-wrap { white-space: pre-wrap; word-break: break-word; }

/* Tables become stacked cards on small screens (docs/UI-UX-DESIGN.md §3). */
@media (max-width: 767.98px) {
  .fp-table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .fp-table-stack tr { display: block; border: 1px solid var(--bs-border-color); border-radius: var(--fp-radius-md); margin-bottom: var(--fp-space-3); background: var(--fp-gray-0); }
  .fp-table-stack td { display: flex; justify-content: space-between; gap: var(--fp-space-3); border: 0; }
  .fp-table-stack td::before { content: attr(data-label); font-weight: 600; color: var(--fp-gray-600); }
}

/* Maps (Phase 2) */
.fp-map { height: 320px; border-radius: var(--fp-radius-md); border: 1px solid var(--bs-border-color); }
.fp-map-lg { height: 440px; }
.fp-map:focus-visible { outline: 2px solid var(--fp-brand-primary); outline-offset: 2px; }
.fp-checklist { max-height: 28rem; overflow-y: auto; }

/* Page viewer (OpenSeadragon) */
.fp-viewer { height: 70vh; min-height: 360px; background: var(--bs-tertiary-bg); border-radius: var(--fp-radius-md); border: 1px solid var(--bs-border-color); }
.fp-viewer:focus-visible { outline: 2px solid var(--fp-brand-primary); outline-offset: 2px; }

/* Bootstrap's secondary grey (#6c757d) is 4.41:1 on the page background (--fp-gray-50); outline
   secondary buttons use the darker token so their text meets WCAG 1.4.3 (axe, Phase 4 slice 5). */
.btn-outline-secondary {
  --bs-btn-color: var(--fp-gray-600);
  --bs-btn-border-color: var(--fp-gray-600);
  --bs-btn-hover-bg: var(--fp-gray-600);
  --bs-btn-hover-border-color: var(--fp-gray-600);
  --bs-btn-active-bg: var(--fp-gray-600);
  --bs-btn-active-border-color: var(--fp-gray-600);
  --bs-btn-disabled-color: var(--fp-gray-600);
  --bs-btn-disabled-border-color: var(--fp-gray-600);
}

/* Offers workspace (retailer portal, PHASE-5-PLAN slice 2). Regions are positioned in % of the
   page (rules in a nonce'd <style> block, or by offer-editor.js), so they stay aligned at any
   width and zoom. */
.fp-oe-scroll {
  overflow: auto;
  max-height: 80vh;
  background: var(--fp-gray-100);
  border: 1px solid var(--fp-gray-200, #dee2e6);
  border-radius: var(--fp-radius-sm);
}
.fp-oe-stage { position: relative; width: 100%; touch-action: none; }
.fp-oe-zoom-150 { width: 150%; }
.fp-oe-zoom-200 { width: 200%; }
.fp-oe-zoom-300 { width: 300%; }
.fp-oe-stage img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.fp-oe-region {
  position: absolute;
  display: block;
  border: 2px solid #b35c00;
  background: rgb(255 159 28 / .12);
  border-radius: 2px;
  text-decoration: none;
}
/* Other offers' regions are pictures; clicks on them are handled by offer-editor.js. */
.fp-oe-region:not(.is-current) { pointer-events: none; }
.fp-oe-region.status-approved { border-color: #1f7a4d; background: rgb(31 122 77 / .10); }
.fp-oe-region.status-rejected { border-style: dashed; border-color: var(--fp-gray-600); background: transparent; }
.fp-oe-region.is-current { border-color: var(--fp-brand-primary); background: rgb(47 91 234 / .15); z-index: 2; cursor: move; }
.fp-oe-region.is-sketch { border: 2px dashed var(--fp-brand-primary); background: rgb(47 91 234 / .10); z-index: 3; }
.fp-oe-region:focus-visible { outline: 3px solid #111; outline-offset: 2px; }
.fp-oe-region-number {
  position: absolute;
  top: -1px;
  left: -1px;
  min-width: 1.4em;
  padding: 0 .3em;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.4;
  color: #fff;
  background: #b35c00;
}
.fp-oe-region.status-approved .fp-oe-region-number { background: #1f7a4d; }
.fp-oe-region.status-rejected .fp-oe-region-number { background: var(--fp-gray-600); }
.fp-oe-region.is-current .fp-oe-region-number { background: var(--fp-brand-primary); }
.fp-oe-handle {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 16px;
  height: 16px;
  background: var(--fp-brand-primary);
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: nwse-resize;
}
.fp-oe-drawing, .fp-oe-drawing .fp-oe-region { cursor: crosshair; }
.fp-oe-list-number {
  display: inline-block;
  min-width: 1.6em;
  text-align: center;
  font-weight: 600;
  color: var(--fp-gray-600);
}
.fp-oe-list-current { background: rgb(47 91 234 / .06); }

/* A table that scrolls sideways is made focusable by app.js (WCAG 2.1.1, axe scrollable-region-focusable). */
.table-responsive:focus-visible, .fp-oe-scroll:focus-visible { outline: 3px solid var(--fp-brand-primary); outline-offset: 2px; }
