/* custom.css — ECMN Property Database
   Sprint 1A audit pass: rules superseded by theme.css have been removed.
   The surviving rules style the legacy survey form modules
   (vitality, property conditions, financial), score badges, archetype
   chips, and parish-profile / report internals. They reference the
   theme.css tokens where possible; legacy hex values are kept where
   the existing forms still depend on them so this sprint does not
   silently change form styling.

   See shiny-app/www/theme.css for the canonical color, type, space,
   and radius tokens (Sprint 1A theme system).
*/

/* ========== TYPE ==========
   The theme's Inter (sans) + EB Garamond (serif), loaded via Google Fonts in
   ui_main.R, provide all type. The legacy Cambon/Larsseit @font-face blocks and
   their woff files were removed (the @font-face path had been broken, so they
   already fell back); the few references now use the Inter/EB Garamond stacks. */

/* ========== ECMN FORM DESIGN SYSTEM (legacy classes used by survey modules) ==========
   These classes are still referenced by modules/vitality_form.R,
   modules/property_conditions_form.R, and modules/financial_form.R.
   Until Sprint 4 rewrites the forms, the classes stay in place but
   pull from the token system. */

button.ecmn-submit-btn,
.btn.ecmn-submit-btn,
button.btn.ecmn-submit-btn,
#vitality-submit,
#conditions-submit,
.action-button.ecmn-submit-btn {
  background-color: var(--ecmn-blue) !important;
  border-color: var(--ecmn-blue-dark) !important;
  color: #FFFFFF !important;
  padding: 10px 30px !important;
  font-size: var(--text-base) !important;
  font-weight: 600 !important;
  margin-top: 20px !important;
  border-radius: var(--radius-sm) !important;
}

button.ecmn-submit-btn:hover,
.btn.ecmn-submit-btn:hover,
button.btn.ecmn-submit-btn:hover,
#vitality-submit:hover,
#conditions-submit:hover,
.action-button.ecmn-submit-btn:hover {
  background-color: var(--ecmn-blue-dark) !important;
  border-color: var(--ecmn-blue-dark) !important;
  color: #FFFFFF !important;
}

button.ecmn-submit-btn:active,
button.ecmn-submit-btn:focus,
.btn.ecmn-submit-btn:active,
.btn.ecmn-submit-btn:focus {
  background-color: var(--ecmn-blue-dark) !important;
  box-shadow: 0 0 0 0.2rem var(--ecmn-blue-tint) !important;
  color: #FFFFFF !important;
}

/* Section panels sit a step deeper than the page (--neutral-50) so the
   three-level hierarchy reads clearly: page (lightest) → section (mid grey)
   → white question cards. */
.ecmn-form-section {
  background-color: var(--neutral-100) !important;
  border: 1px solid var(--neutral-200) !important;
  border-radius: var(--radius-md) !important;
  padding: var(--space-6) !important;
  margin-bottom: var(--space-6) !important;
}

/* Section headers are a serif (EB Garamond) with a smaller x-height, so they
   need a larger point size than the sans-serif question text to read as
   clearly larger. --text-2xl (28px) sits a comfortable step above the 16px
   question prompts. */
.ecmn-section-header {
  color: var(--neutral-900) !important;
  font-family: var(--font-display) !important;
  font-size: var(--text-2xl) !important;
  font-weight: 600 !important;
  /* Zero the default h3 top margin so the header sits at the top of the section
     box instead of floating down inside its padding. */
  margin-top: 0 !important;
  margin-bottom: var(--space-4) !important;
  padding-bottom: var(--space-2) !important;
}

/* Section-header icon: scales with the header and picks up the brand blue. */
.ecmn-section-header .fa,
.ecmn-section-header .fas,
.ecmn-section-header .far,
.ecmn-section-header svg {
  color: var(--ecmn-blue) !important;
  font-size: 1.15em !important;
  margin-right: var(--space-2) !important;
}

/* Question prompt (direct-child label only — not the radio/checkbox option
   labels nested below): slightly larger and clearer. */
.ecmn-question > label {
  font-size: var(--text-base) !important;
  font-weight: 600 !important;
  color: var(--neutral-900) !important;
  display: block;
  margin-bottom: var(--space-2) !important;
}

.ecmn-info-box {
  background-color: var(--ecmn-blue-tint) !important;
  border: 1px solid var(--ecmn-blue) !important;
  color: var(--ecmn-blue-dark) !important;
  padding: var(--space-4) !important;
  margin-bottom: var(--space-6) !important;
  border-radius: var(--radius-sm) !important;
}

.ecmn-info-box h4 {
  color: var(--ecmn-blue-dark) !important;
  font-weight: 600 !important;
  margin-top: 0 !important;
}

.ecmn-question {
  background-color: #FFFFFF !important;
  padding: var(--space-4) !important;
  margin-bottom: var(--space-4) !important;
  border: 1px solid var(--neutral-200) !important;
  border-radius: var(--radius-sm) !important;
}

/* ========== FLOATING PROGRESS INDICATOR ========== */
.ecmn-floating-progress {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: #FFFFFF !important;
  color: var(--neutral-700) !important;
  padding: 15px !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-card-hover) !important;
  z-index: 1000;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ecmn-floating-progress h5 {
  margin: 0 !important;
  color: var(--ecmn-blue) !important;
  font-size: var(--text-base) !important;
}

.ecmn-floating-progress .fa {
  color: var(--ecmn-blue) !important;
  margin-right: 5px;
}

.ecmn-floating-progress .progress,
[style*="position: fixed"][style*="bottom: 20px"][style*="right: 20px"] .progress {
  height: 25px !important;
  width: 200px !important;
  background-color: var(--neutral-100) !important;
  margin-bottom: 0 !important;
  border-radius: var(--radius-sm) !important;
  overflow: hidden;
}

.ecmn-floating-progress .progress-bar,
[style*="position: fixed"][style*="bottom: 20px"][style*="right: 20px"] .progress-bar {
  font-size: 12px !important;
  font-weight: 600 !important;
  color: #FFFFFF !important;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: width 0.3s ease;
}

.progress-bar.bg-danger  { background-color: var(--score-challenge) !important; color: #FFFFFF !important; }
.progress-bar.bg-warning { background-color: var(--score-moderate)  !important; color: var(--neutral-900) !important; }
.progress-bar.bg-success { background-color: var(--score-asset)     !important; color: #FFFFFF !important; }

[style*="position: fixed"][style*="bottom: 20px"][style*="right: 20px"] h5 {
  margin: 0 0 10px 0 !important;
  color: var(--ecmn-blue) !important;
  font-size: var(--text-base) !important;
  font-weight: 600 !important;
}

[style*="position: fixed"][style*="bottom: 20px"][style*="right: 20px"] h5 .fa {
  color: var(--ecmn-blue) !important;
  margin-right: 5px;
}

.ecmn-form-input {
  background-color: #FFFFFF !important;
  border: 1px solid var(--neutral-200) !important;
  border-radius: var(--radius-sm) !important;
}

.ecmn-form-input:focus {
  border-color: var(--ecmn-blue) !important;
  box-shadow: 0 0 0 0.2rem var(--ecmn-blue-tint) !important;
}

.ecmn-secondary-btn {
  background-color: #FFFFFF !important;
  border: 2px solid var(--ecmn-blue) !important;
  color: var(--ecmn-blue) !important;
  padding: 10px 30px !important;
  font-size: var(--text-base) !important;
  font-weight: 600 !important;
  margin-top: 20px !important;
  border-radius: var(--radius-sm) !important;
}

.ecmn-secondary-btn:hover {
  background-color: var(--neutral-100) !important;
  border-color: var(--ecmn-blue-dark) !important;
  color: var(--ecmn-blue-dark) !important;
}

/* ========== MONEY / COUNT INPUTS ==========
   Shared by the Financial Survey and the Property Conditions Survey's Q37b
   cost estimate, so a dollar field looks the same wherever one is asked for.
   A visible "$" addon sits flush against a numeric-only field; the amount is
   right-aligned with tabular figures so digits line up down a column. */

.ecmn-money-group {
  display: flex;
  max-width: 260px;
}

.ecmn-money-addon {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  background-color: var(--neutral-100) !important;
  border: 1px solid var(--neutral-200) !important;
  border-right: none !important;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm) !important;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--neutral-700) !important;
}

.ecmn-money-input {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ecmn-count-input {
  max-width: 160px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* These are amounts to type, not values to nudge — drop the spinner. */
.ecmn-money-input::-webkit-outer-spin-button,
.ecmn-money-input::-webkit-inner-spin-button,
.ecmn-count-input::-webkit-outer-spin-button,
.ecmn-count-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.ecmn-money-input,
.ecmn-count-input {
  -moz-appearance: textfield;
}

/* Live preview of a money amount, rounded to whole dollars and comma-grouped.
   Auto-attached to any .ecmn-money-input by the survey JS, so any dollar field
   using this class (Financial Survey, PCS Q37b, …) gets the preview for free. */
.ecmn-money-preview {
  display: block;
  margin-top: 4px;
  min-height: 1em;
  font-size: 12px;
  color: var(--neutral-500, #8A8A82);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.ecmn-money-preview:empty { display: none; }

/* ========== GENERAL ALERT / WELL / BTN STYLES ========== */

.alert-info {
  background-color: var(--ecmn-blue-tint) !important;
  border: 1px solid var(--ecmn-blue) !important;
  border-bottom: 3px solid var(--ecmn-gold) !important;
  color: var(--ecmn-blue-dark) !important;
  margin-bottom: 20px !important;
}

.alert-info h4 {
  color: var(--ecmn-blue-dark) !important;
  font-weight: 600;
}

.well {
  background-color: var(--neutral-50) !important;
  border: 1px solid var(--neutral-200) !important;
  border-radius: var(--radius-sm) !important;
  padding: var(--space-4) !important;
  margin-bottom: var(--space-4) !important;
}

.btn-primary,
.btn-success {
  background-color: var(--ecmn-blue) !important;
  border-color: var(--ecmn-blue-dark) !important;
  color: #FFFFFF !important;
}

.btn-primary:hover,
.btn-success:hover {
  background-color: var(--ecmn-blue-dark) !important;
  border-color: var(--ecmn-blue-dark) !important;
  color: #FFFFFF !important;
}

.progress-bar { background-color: var(--ecmn-gold) !important; }
.progress     { background-color: var(--neutral-100) !important; }

.form-control {
  background-color: #FFFFFF !important;
  border: 1px solid var(--neutral-200) !important;
}

.form-control:focus {
  border-color: var(--ecmn-blue) !important;
  box-shadow: 0 0 0 0.2rem var(--ecmn-blue-tint) !important;
}

/* =============================================================================
   SCORE / CATEGORY DISPLAYS — used inside dashboards and reports
   ============================================================================= */

.score-large {
  font-size: 2.5em;
  font-weight: bold;
  text-align: center;
  margin: 10px 0;
}

.score-asset     { color: var(--score-asset);     font-weight: bold; }
.score-moderate  { color: var(--score-moderate-ink);  font-weight: bold; }
.score-challenge { color: var(--score-challenge-ink); font-weight: bold; }

.score-display {
  font-size: 2em;
  font-weight: bold;
  margin: 10px 0;
}

.category-asset     { background-color: var(--score-asset);     color: white; }
.category-moderate  { background-color: var(--score-moderate);  color: #333; }
.category-challenge { background-color: var(--score-challenge); color: #1F3A5F; }

/* =============================================================================
   ARCHETYPE STYLES (used in dashboard / report Rmd output)
   ============================================================================= */

.archetype-reimagine { background-color: #003478; color: white; }
.archetype-reinvest  { background-color: var(--ecmn-blue); color: white; }
.archetype-realign   { background-color: var(--score-moderate); color: #333; }
.archetype-respite   { background-color: var(--score-challenge); color: #1F3A5F; }

.archetype-badge {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: bold;
  display: inline-block;
  margin: 5px 0;
}

/* =============================================================================
   WARNING SEVERITY STYLES — used by early-warning panel modules
   ============================================================================= */

.severity-critical {
  background-color: #D6E3F4;
  border-left: 4px solid var(--score-challenge);
}

.severity-warning {
  background-color: #EDF3FB;
  border-left: 4px solid var(--score-moderate);
}

.severity-info {
  background-color: var(--ecmn-blue-tint);
  border-left: 4px solid var(--ecmn-blue);
}

.warning-card {
  padding: 15px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  background: white;
  box-shadow: var(--shadow-card);
}

.warning-card.critical { border-left: 4px solid var(--score-challenge); }
.warning-card.warning  { border-left: 4px solid var(--score-moderate); }
.warning-card.info     { border-left: 4px solid var(--ecmn-blue); }

.warning-critical { border-left: 4px solid var(--score-challenge); }
.warning-warning  { border-left: 4px solid var(--score-moderate); }
.warning-info     { border-left: 4px solid var(--ecmn-blue); }

/* =============================================================================
   INFO CARD STYLES
   ============================================================================= */

.info-card {
  background: white;
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}

/* =============================================================================
   LOADING INDICATOR
   ============================================================================= */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.8);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid var(--neutral-100);
  border-top: 5px solid var(--ecmn-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* =============================================================================
   MAP STYLING
   ============================================================================= */

.leaflet-container {
  border-radius: var(--radius-md);
}

/* =============================================================================
   TABLE HOVER EFFECTS — works on the DT tables in dashboards and reports
   ============================================================================= */

.dataTables_wrapper tbody tr:hover {
  background-color: var(--neutral-50);
  cursor: pointer;
}

/* =============================================================================
   PROGRESS BAR STYLING (for score bars)
   ============================================================================= */

.progress-bar-asset     { background-color: var(--score-asset); }
.progress-bar-moderate  { background-color: var(--score-moderate); }
.progress-bar-challenge { background-color: var(--score-challenge); }

/* =============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================= */

@media (max-width: 768px) {
  .score-large { font-size: 2em; }
  .info-card { padding: 15px; }
}

/* =============================================================================
   PROPERTY TABLE — specific column treatment
   ============================================================================= */

#properties-properties_table {
  font-size: 12px;
}

#properties-properties_table td {
  white-space: normal;
  word-wrap: break-word;
  max-width: 200px;
  line-height: 1.3;
}

#properties-properties_table th {
  font-size: 11px;
  white-space: nowrap;
}

/* =============================================================================
   PARISH PROFILE SNAPSHOT - COMPACT STYLES
   ============================================================================= */

.profile-section {
  background-color: #FFFFFF;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-sm);
  padding: 12px 15px;
  margin-bottom: 10px;
}

.profile-section-header {
  color: var(--neutral-900);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--neutral-200);
}

.profile-section-header .fa,
.profile-section-header .fas {
  margin-right: 6px;
  color: var(--ecmn-blue);
}

.profile-data {
  font-size: 12px;
  line-height: 1.5;
  color: var(--neutral-700);
}

.profile-data-row {
  display: flex;
  padding: 2px 0;
}

.profile-data-label {
  font-weight: 600;
  min-width: 140px;
  flex-shrink: 0;
}

.profile-data-value {
  flex: 1;
  text-align: right;
}

.profile-score-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 12px;
}

.profile-divider {
  border: 0;
  border-top: 1px solid var(--neutral-200);
  margin: 6px 0;
}

/* ========== SHARED REPORT TABLES (.pcr-*) ==========
   Report card + table styling shared by the Property Conditions Report AND the
   Property Adaptability Report. Moved here from ui_property_conditions_report.R
   (Sprint 16): the styles were scoped to the Conditions report's own UI, so the
   Adaptability report — which reuses the same .pcr-* classes — rendered an
   unstyled table. Living in the globally-loaded custom.css, both reports (and
   any future report reusing these classes) pick them up. Row padding + line
   height are a touch more generous than the original to give the table air. */
.pcr-container {
  background: #fff;
  padding: 32px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.pcr-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 3px solid #00449F;
}
.pcr-title {
  font-size: 24px;
  font-weight: 700;
  color: #00449F;
  margin: 0 0 8px 0;
}
.pcr-subtitle {
  font-size: 14px;
  color: #666;
  margin: 0;
  line-height: 1.5;
}
.pcr-logo {
  text-align: right;
  color: #00449F;
  font-weight: 600;
  font-size: 12px;
}
.pcr-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  font-size: 13px;
}
.pcr-table th {
  background: #00449F;
  color: white;
  padding: 11px 14px;
  text-align: left;
  font-weight: 600;
}
.pcr-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #e0e0e0;
  vertical-align: top;
  line-height: 1.5;
}
.pcr-table tr:hover {
  background: #EFF5FC;
}
.pcr-section-header td {
  background: #E1EAF6 !important;
  font-weight: 600;
  color: #00449F;
  padding: 12px 14px;
  font-size: 14px;
}
.pcr-category {
  font-weight: 500;
  color: #333;
  width: 25%;
}
.pcr-data {
  width: 35%;
  color: #1a1a1a;
}
.pcr-definition {
  width: 40%;
  color: #666;
  font-size: 12px;
  font-style: italic;
}
.pcr-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}
.pcr-badge-yes { background: #E1EAF6; color: #00449F; }
.pcr-badge-no { background: #EFF5FC; color: #2B4C6F; }
.pcr-badge-na { background: #f5f5f5; color: #757575; }
.pcr-score-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 13px;
}
.pcr-score-good { background: #E1EAF6; color: #00449F; }
.pcr-score-challenge { background: #E9F0F8; color: #33608F; }
.pcr-score-critical { background: #EFF5FC; color: #2B4C6F; }
.pcr-list { margin: 0; padding-left: 18px; }
.pcr-list li { margin-bottom: 2px; }
.pcr-empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #666;
}
.pcr-empty-state i {
  font-size: 48px;
  color: #ccc;
  margin-bottom: 16px;
}
@media print {
  .pcr-container { box-shadow: none; }
  .no-print { display: none !important; }
}
