/* Smart DMA — styles.css */

/* =========================================================================
   GROUP 1 — Typography and spacing
   ========================================================================= */

body {
  font-family: 'Arial', sans-serif;
  line-height: 1.6;
  color: #212529;
}

/* Consistent card padding via BS5 custom properties */
.card {
  --bs-card-spacer-x: 1.25rem;
  --bs-card-spacer-y: 1rem;
  --bs-card-color: #212529;
  --bs-card-bg: #fff;
  color: #212529;
}

/* Card headers: consistent weight, dark text on light background */
.card-header {
  font-weight: 600;
  background-color: #f8f9fa;
  color: #212529;
}

/* Ensure all card body text is dark */
.card-body {
  color: #212529;
}
.card-body p, .card-body div, .card-body li,
.card-body strong, .card-body span {
  color: inherit;
}

/* Force dark text globally — Flatly theme override safety net */
h1, h2, h3, h4, h5, h6, p, li, span, div, label, strong, em, td, th {
  color: inherit;
}
.btn-default, .btn-default:hover, .btn-default:focus {
  color: #212529;
}

/* Primary/secondary buttons: white text on dark backgrounds */
.btn-primary, .btn-primary:hover, .btn-primary:focus,
.btn-primary:active, .btn-primary:visited {
  color: #ffffff !important;
}
.btn-outline-secondary {
  color: #212529;
}

/* Section heading weight consistency */
h4 {
  font-weight: 600;
}

/* =========================================================================
   GROUP 5 — Global polish (placed early: max-width wrapper, navbar, tabs)
   ========================================================================= */

/* Page max-width wrapper */
.container-fluid {
  max-width: 1200px;
}

/* Top banner: white text on dark Flatly navbar */
.navbar-brand {
  color: #ffffff !important;
  font-weight: 700;
  font-size: 20px;
}

/* Subtitle below brand */
.navbar-subtitle {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  margin-left: 8px;
  font-weight: 400;
}

/* Navbar top-level nav links: white on dark background */
.navbar .navbar-nav .nav-link {
  color: rgba(255, 255, 255, 0.85) !important;
  border-bottom: none !important;
}
.navbar .navbar-nav .nav-link:hover {
  color: #ffffff !important;
}
.navbar .navbar-nav .nav-link.active {
  color: #ffffff !important;
  font-weight: 600;
  border-bottom: none !important;
  background: transparent !important;
}

/* Tab navigation inside page body: brand blue underline */
.nav-tabs .nav-link.active,
.nav-underline .nav-link.active {
  color: #1A5276 !important;
  border-bottom-color: #1A5276 !important;
  border-bottom-width: 3px;
  font-weight: 600;
}
.nav-tabs .nav-link,
.nav-underline .nav-link {
  color: #495057;
  transition: color 0.15s;
}
.nav-tabs .nav-link:hover,
.nav-underline .nav-link:hover {
  color: #1A5276;
}

/* =========================================================================
   GROUP 2 — Classification and symptom screens
   ========================================================================= */

/* Classification radio tiles */
.choice-tile .radio label,
.choice-tile .shiny-input-radiogroup label.radio-inline {
  display: block;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  padding: 12px 16px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: border-color 0.15s, background 0.15s;
  font-size: 15px;
  color: #212529;
}
.choice-tile .radio label:hover,
.choice-tile .shiny-input-radiogroup label.radio-inline:hover {
  border-color: #2980B9;
  background: #EBF5FB;
}
.choice-tile input[type="radio"] {
  display: none;
}
.choice-tile input[type="radio"]:checked + span,
.choice-tile .radio input[type="radio"]:checked ~ span {
  /* handled by parent label border change */
}
.choice-tile .radio label:has(input:checked),
.choice-tile label.radio-inline:has(input:checked) {
  border-color: #1A5276;
  background: #EBF5FB;
}

/* Also hide checkbox circles in choice-tile multi_choice */
.choice-tile .shiny-input-checkboxgroup .checkbox label {
  display: block;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  padding: 12px 16px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: border-color 0.15s, background 0.15s;
  font-size: 15px;
}
.choice-tile .shiny-input-checkboxgroup .checkbox label:hover {
  border-color: #2980B9;
  background: #EBF5FB;
}
.choice-tile .shiny-input-checkboxgroup input[type="checkbox"] {
  display: none;
}
.choice-tile .shiny-input-checkboxgroup .checkbox label:has(input:checked) {
  border-color: #1A5276;
  background: #EBF5FB;
}

/* Symptom card tiles (actionButtons — override Flatly .btn styles) */
.symptom-card,
.symptom-card.btn,
.symptom-card.btn-default {
  border: 2px solid #dee2e6;
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.15s;
  background: white !important;
  color: #212529 !important;
  text-align: left;
  min-height: 80px;
  display: flex;
  align-items: center;
}
.symptom-card:hover,
.symptom-card.btn:hover {
  border-color: #2980B9;
  background: #EBF5FB !important;
  color: #212529 !important;
}
.symptom-card.selected,
.symptom-card.btn.selected {
  border-color: #2d9e6b;
  background: #f0faf5 !important;
  color: #212529 !important;
}
.symptom-card:focus,
.symptom-card.btn:focus {
  color: #212529 !important;
}

/* Sortable rank-list items */
.rank-list-item {
  color: #212529 !important;
  background: #fff;
}
.rank-list-container .rank-list-item {
  color: #212529 !important;
}

/* Symptom card grid: 2-column above 480px */
.symptom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
@media (max-width: 480px) {
  .symptom-grid {
    grid-template-columns: 1fr;
  }
}

/* Confirm button styling */
.btn-confirm {
  margin-top: 16px;
  width: 100%;
  background-color: #1A5276;
  border-color: #1A5276;
  color: white;
}
.btn-confirm:hover {
  background-color: #154360;
  border-color: #154360;
  color: white;
}

/* =========================================================================
   GROUP 3 — Questionnaire screen
   ========================================================================= */

/* Question fade-in animation */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.question-fade-in {
  animation: fadeIn 200ms ease-out;
}

/* Progress indicator */
.stage-progress {
  font-size: 13px;
  color: #6c757d;
  text-align: right;
  margin-bottom: 24px;
}
.stage-progress-green {
  color: #2d9e6b;
  font-weight: 600;
}

/* Rating table styling */
.table-rating {
  width: 100%;
  margin-top: 12px;
}
.table-rating thead th {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 4px;
  border-bottom: 2px solid #dee2e6;
}
.table-rating tbody tr:nth-child(odd) {
  background: #F8F9FA;
}
.table-rating tbody tr:nth-child(even) {
  background: white;
}
.table-rating tbody td {
  padding: 8px 12px;
  font-size: 14px;
  vertical-align: middle;
}
.table-rating tbody td:not(:first-child) {
  text-align: center;
  padding: 4px 8px;
}

/* Screen centring */
.screen-narrow {
  max-width: 580px;
  margin: 0 auto;
  padding-top: 32px;
}

/* =========================================================================
   GROUP 4 — Output screens
   ========================================================================= */

/* Output A max width */
.output-sme { max-width: 780px; margin: 0 auto; }
.output-sme h4 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #212529;
}

/* Output A cards */
.output-sme .card {
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Impact cards in A2 */
.impact-card-styled {
  border-left: 4px solid #1A5276;
  background: #F8F9FA;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  color: #212529;
}
.impact-card-styled .card-body {
  color: #212529;
}

/* Action plan phase cards */
.plan-card-week   { border-left: 4px solid #2d9e6b; background: #fff; color: #212529; }
.plan-card-month  { border-left: 4px solid #e8a020; background: #fff; color: #212529; }
.plan-card-year   { border-left: 4px solid #2196f3; background: #fff; color: #212529; }

.plan-card-week .card-body,
.plan-card-month .card-body,
.plan-card-year .card-body {
  padding: 16px 20px;
  color: #212529;
}

/* Accordion inside plan cards */
.plan-card-month .accordion {
  --bs-accordion-border-color: #dee2e6;
  --bs-accordion-btn-color: #212529;
  --bs-accordion-body-color: #212529;
  --bs-accordion-bg: #fff;
}
.plan-card-month .accordion-button {
  font-size: 14px;
  padding: 10px 16px;
  color: #212529;
  background-color: #fff;
}
.plan-card-month .accordion-button:not(.collapsed) {
  color: #212529;
  background-color: #f8f9fa;
}
.plan-card-month .accordion-body {
  color: #212529;
}

/* Tool download buttons */
.output-sme .btn-outline-secondary.btn-sm {
  white-space: nowrap;
  min-width: 90px;
}

/* Digital twin container: thin border + shadow */
.js-plotly-plot {
  border: 1px solid #dee2e6;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* Output B — Advisor view */
.output-advisor { max-width: 960px; margin: 0 auto; }
.output-advisor h4 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #212529;
}
.output-advisor .card {
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.output-advisor .badge { font-size: 12px; font-weight: 500; }
.output-advisor .gt_table { font-size: 13px; }
.output-advisor .dataTable { font-size: 13px; }

/* B2 evidence: confidence badge */
.badge.bg-danger { background-color: #c94040 !important; }

/* Global accordion text fix (Flatly theme override) */
.accordion-button {
  color: #212529;
}
.accordion-button:not(.collapsed) {
  color: #212529;
}
.accordion-body {
  color: #212529;
}

/* Narrative text below analysis plots */
.narrative-text {
  font-size: 14px;
  color: #495057;
  font-style: italic;
  margin-top: 0.75rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

/* Loading screen */
.loading-message {
  font-size: 18px;
  color: #495057;
  min-height: 28px;
}

/* Digital twin static container */
.twin-plot { width: 100%; height: 380px; }

/* =========================================================================
   Responsive breakpoints
   ========================================================================= */

@media (max-width: 768px) {
  .output-sme  { max-width: 100%; padding: 0 12px; }
  .output-advisor { max-width: 100%; padding: 0 12px; }
  .screen-narrow { max-width: 100%; padding: 12px; }
}

@media (max-width: 1024px) {
  .output-advisor { max-width: 100%; }
}
