/**
 * biomarker-components.css — Estilos compartidos para paneles de biomarcadores
 * 
 * Antes duplicados en 5 archivos *_component.php (~70 líneas cada uno).
 * Ahora centralizado aquí. Se carga una sola vez.
 */

/* --- Barra de rango clínico --- */
.bar-container,
.barra-container {
  position: relative;
  width: 100%;
  max-width: 80%;
  height: 12px;
  background: linear-gradient(to right,
    var(--color-deficiency-bg, #ebbcbe) 0%,
    var(--color-deficiency-bg, #ebbcbe) calc(var(--minPorcentaje) * 1%),
    var(--color-excess-bg, #a5dfb4) calc(var(--minPorcentaje) * 1%),
    var(--color-excess-bg, #a5dfb4) calc(var(--maxPorcentaje) * 1%),
    var(--color-deficiency-bg, #ebbcbe) calc(var(--maxPorcentaje) * 1%),
    var(--color-deficiency-bg, #ebbcbe) 100%);
  border-radius: 6px;
  margin: 20px 0;
}

.bar-container .bubble,
.barra-container .burbuja {
  position: absolute;
  top: -30px;
  transform: translateX(-50%);
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: bold;
  color: white;
  white-space: nowrap;
  cursor: pointer;
}

/* --- Severity badges (usa clases de app-colors.css) --- */
.badge.green-item { color: var(--color-excess-text, #034c11) !important; font-weight: 600; }
.badge.red-item   { color: var(--color-deficiency-text, #6b030f) !important; font-weight: 600; }
.badge.yellow-item { color: var(--color-yellow-text, #84732c) !important; font-weight: 600; }
.badge.blue-item  { color: var(--color-info, #1e40af) !important; font-weight: 600; }
.badge.gray-item  { color: var(--color-gray-dark, #374151) !important; }

/* --- Description labels --- */
.barra-valor {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--color-gray-dark);
}

.barra-valor b {
  color: #1e293b;
  font-weight: 600;
}

/* --- Empty state --- */
.biomarker-empty {
  padding: 12px 16px;
  color: #9ca3af;
  font-style: italic;
  font-size: 13px;
}

/* --- Semáforo categórico unificado (renal) --- */
.semaforo-wrapper {
  width: 100%;
}

.semaforo-grid-unified {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
  align-items: start;
}

.semaforo-col {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 6px;
}

.semaforo-label {
  min-height: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  font-size: 12px;
  font-weight: 700;
  color: #374151;
  text-align: center;
  line-height: 1.2;
}

.semaforo-label small {
  font-size: 9px;
  font-weight: 400;
  color: #6b7280;
}

.semaforo-label small {
  font-size: 9px;
  font-weight: 400;
  color: #6b7280;
}

.semaforo-cell {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  transition: outline 0.15s ease;
}

.semaforo-active {
  outline: 3px solid var(--color-gray-dark, #374151);
  outline-offset: 3px;
}

/* Albumin cells */
.alb-n  { background: #adbaa4; }
.alb-1  { background: #9fb8a9; }
.alb-2  { background: #92b7b1; }
.alb-3  { background: #79abaf; }

/* Creatinine cells */
.cr-1   { background: #a8aa80; }
.cr-2   { background: #92a07e; }
.cr-3   { background: #74846a; }

/* --- Accordion custom --- */
.custom-accordion .accordion-header {
  margin: 0 !important;
}

.custom-accordion h2.accordion-header,
.custom-accordion h5.accordion-header {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

.custom-accordion .accordion-button:not(.collapsed) {
  background: #f8fafc;
  color: #1e293b;
  font-weight: 600;
}

.custom-accordion .accordion-button:focus {
  box-shadow: none;
  border-color: #e2e8f0;
}

/* --- Comments section --- */
.comment-section .comment-text {
  font-size: 13px;
  line-height: 1.5;
}

/* --- Component view spacing (mobile scroll for floating AI button) --- */
.biomarker-component-view {
  padding-bottom: 80px;
}

/* ============================================
   Range Bar Advanced — 5-segment bidirectional
   ============================================ */

.range-bar-advanced {
  position: relative;
  width: 100%;
  --seg-critical: var(--color-deficiency-bg, #ebbcbe);
  --seg-low: var(--color-yellow-bg, #ede7c8);
  --seg-normal: var(--color-excess-bg, #a5dfb4);
  --seg-elevated: var(--color-yellow-bg, #ede7c8);
  --bar-height: 14px;
  --bubble-gap: 8px;
  margin-top: 32px;
}

/* 5-segment flex row */
.range-segments {
  display: flex;
  flex-direction: row;
  height: var(--bar-height);
  border-radius: 7px;
  overflow: hidden;
}

.range-segment {
  min-width: 0;
}

.range-segment.seg-critical-low  { background-color: var(--seg-critical); }
.range-segment.seg-low           { background-color: var(--seg-low); }
.range-segment.seg-normal        { background-color: var(--seg-normal); }
.range-segment.seg-elevated      { background-color: var(--seg-elevated); }
.range-segment.seg-critical-high { background-color: var(--seg-critical); }

/* Floating bubble + triangle */
.range-bubble-wrapper {
  position: absolute;
  top: calc(-1 * (var(--bubble-gap) + 28px));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.range-bubble {
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.2;
}

.range-bubble.red-item,
.range-bubble.green-item,
.range-bubble.yellow-item {
  font-size: 12px;
  padding: 4px 10px;
}

.range-bubble-triangle {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--color-deficiency-text);
  margin-top: -1px;
}

.range-bubble-wrapper:has(.green-item) .range-bubble-triangle  { border-top-color: var(--color-excess-text); }
.range-bubble-wrapper:has(.yellow-item) .range-bubble-triangle { border-top-color: var(--color-yellow-text); }

/* Segment labels */
.range-labels {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 10px;
  color: var(--color-gray-dark);
}

.range-label {
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 18%;
  white-space: nowrap;
}

/* Interpretation alert */
.interpretation-alert {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  border-left: 4px solid var(--alert-color);
  background: var(--alert-bg);
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.5;
}

.interpretation-alert .alert-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.interpretation-alert.alert-critical  { --alert-color: var(--color-deficiency-text); --alert-bg: #fce0e2; }
.interpretation-alert.alert-high     { --alert-color: var(--color-deficiency-text); --alert-bg: #f5d5d8; }
.interpretation-alert.alert-warning  { --alert-color: var(--color-yellow-text);   --alert-bg: #f8f4e0; }
.interpretation-alert.alert-elevated { --alert-color: var(--color-yellow-text);   --alert-bg: #f8f4e0; }
.interpretation-alert.alert-normal   { --alert-color: var(--color-excess-text);   --alert-bg: #d3f4d9; }

/* Mobile responsive */
@media (max-width: 767px) {
  .range-label {
    font-size: 9px;
  }
  .range-bubble {
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .range-bar-advanced {
    --bar-height: 10px;
  }
  .range-labels {
    flex-wrap: wrap;
    gap: 2px;
  }
  .range-label {
    max-width: 48%;
    font-size: 9px;
  }
  .range-bubble {
    font-size: 10px;
    padding: 3px 8px;
  }
  .interpretation-alert {
    font-size: 12px;
    padding: 8px;
  }
}

/* ============================================
   BP Summary Card — 3-column (Blood Pressure only)
   ============================================ */

.bp-summary-card .card-body {
  padding: 20px 24px;
}

.bp-summary-reading {
  margin-bottom: 4px;
}

.bp-summary-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-gray-dark, #212121);
}

.bp-summary-unit {
  font-size: 13px;
  margin-left: 2px;
}

@media (max-width: 576px) {
  .bp-summary-card .row > .col {
    border-right: 0 !important;
    border-bottom: 1px solid var(--color-gray-light, #e5e7eb);
    padding: 10px 0;
  }
  .bp-summary-card .row > .col:last-child {
    border-bottom: 0;
  }
  .bp-summary-value {
    font-size: 20px;
  }
}

/* ============================================
   Generic Summary Card — reusable across panel types
   Derived from .bp-summary-card
   ============================================ */

.summary-card {
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border-radius: 8px;
  border: 0;
  margin-bottom: 24px;
}

.summary-card .card-body {
  padding: 20px 24px;
}

.summary-card-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  text-align: center;
  align-items: center;
}

.summary-card-col {
  flex: 1;
  min-width: 80px;
  padding: 0 12px;
}

.summary-card-col + .summary-card-col {
  border-left: 1px solid var(--color-gray-light, #e5e7eb);
}

.summary-card-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-gray-dark, #212121);
  line-height: 1.2;
}

.summary-card-label {
  display: block;
  font-size: 11px;
  color: var(--color-gray-dark, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.summary-card-unit {
  font-size: 13px;
  margin-left: 2px;
  color: var(--color-gray-dark, #6b7280);
}

.summary-card-meta {
  font-size: 12px;
  color: var(--color-gray-dark, #6b7280);
  padding-top: 8px;
  border-top: 1px solid var(--color-gray-light, #e5e7eb);
  text-align: center;
  margin-top: 8px;
}

.summary-card-context {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  font-size: 11px;
}

.summary-card-context .badge {
  font-weight: 500;
  padding: 4px 10px;
}

.summary-card-symptoms {
  font-size: 11px;
  color: var(--color-gray-dark, #6b7280);
  margin-top: 6px;
  text-align: center;
  line-height: 1.4;
}

.summary-card-symptoms .symptom-tag {
  display: inline-block;
  background: #f3f4f6;
  border-radius: 12px;
  padding: 2px 8px;
  margin: 2px;
  font-size: 10px;
}

@media (max-width: 576px) {
  .summary-card-col {
    border-left: 0 !important;
    border-bottom: 1px solid var(--color-gray-light, #e5e7eb);
    padding: 10px 0;
    min-width: 100%;
  }
  .summary-card-col:last-child {
    border-bottom: 0;
  }
  .summary-card-value {
    font-size: 20px;
  }
}
