/* =====================================================
  VARIABLES GLOBALES DE DISEÑO
  Centralizan colores y facilitan mantenimiento
===================================================== */
:root {
  --primary: #1F6FB2;
  --light: #EAF2FB;
  --bg: #F5F7FA;
  --text: #2E2E2E;

  /* Estados de riesgo / feedback */
  --success: #4CAF50;
  --warning: #FF9800;
  --danger: #F44336;

  /* Fondo específico para score REBA */
  --score-bg: #EAF2FB;
}

/* =====================================================
  RESET BÁSICO Y TIPOGRAFÍA
===================================================== */
* {
  box-sizing: border-box;
  font-family: 'Segoe UI', sans-serif;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

/* =====================================================
  LAYOUT GENERAL
===================================================== */
.layout {
  display: flex;
}

/* Sidebar lateral */
.sidebar {
  width: 220px;
  background: var(--primary);
  color: white;
  min-height: 100vh;
  padding: 20px;
}

.sidebar nav a {
  display: block;
  color: white;
  padding: 10px 0;
  opacity: .8;
  cursor: pointer;
}

.sidebar nav a.active,
.sidebar nav a:hover {
  opacity: 1;
}

/* Contenido principal */
.content {
  flex: 1;
  padding: 30px;
}

/* Barra superior */
.topbar {
  margin-bottom: 20px;
}

/* =====================================================
  COMPONENTES REUTILIZABLES
===================================================== */

/* Tarjetas */
.card {
  background: white;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;

  /* Sombra ligera para jerarquía visual */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Grid flexible */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

/* Botones */
.btn-primary,
.btn-secondary {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 6px;
  text-decoration: none;
  border: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-secondary {
  background: var(--light);
  color: var(--primary);
}

/* Inputs */
.input {
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #ccc;
}

/* =====================================================
  FILAS DE CHECKBOX Y RADIO
===================================================== */
.check-row,
.radio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 14px;
}

/* =====================================================
  VISTA DE RESULTADOS REBA
===================================================== */

/* Encabezado del score */
.score-header {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid #eee;
}

/* Valor principal REBA */
.score-value {
  font-size: 40px;
  font-weight: 700;
  color: var(--primary);
  background: var(--score-bg);
  border-radius: 8px;
  padding: 10px 20px;
  margin-right: 20px;
  min-width: 80px;
  text-align: center;
}

/* Barra de niveles de riesgo */
.risk-level-bar {
  flex-grow: 1;
  display: flex;
  height: 20px;
  border-radius: 10px;
  overflow: hidden;
  background: #eee;
}

/* Segmentos de la barra */
.risk-level-segment {
  height: 100%;
  font-size: 10px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

/* Distribución visual REBA */
.segment-success {
  background-color: var(--success);
  width: 30%;
}

.segment-warning {
  background-color: var(--warning);
  width: 20%;
}

.segment-danger {
  background-color: var(--danger);
  width: 15%;
}

.segment-primary {
  background-color: var(--primary);
  width: 35%;
}

/* =====================================================
  TABLA DE RIESGO REBA
===================================================== */
.risk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 15px;
}

.risk-table th,
.risk-table td {
  padding: 10px 12px;
  border: 1px solid #eee;
  text-align: left;
}

.risk-table th {
  background-color: var(--light);
  color: var(--primary);
  font-weight: 600;
}

/* Columna nivel destacada */
.risk-table td.level-cell {
  font-weight: 600;
  text-align: center;
}

/* Colores por nivel REBA (lectura semántica) */
.risk-table tr.level-0 {
  background-color: #e8f5e9;
}

/* Inapreciable */
.risk-table tr.level-1 {
  background-color: #f1f8e9;
}

/* Bajo */
.risk-table tr.level-2 {
  background-color: #fffde7;
}

/* Medio */
.risk-table tr.level-3 {
  background-color: #fff3e0;
}

/* Alto */
.risk-table tr.level-4 {
  background-color: #fdecea;
}

/* Muy alto */

/* =====================================================
  TITULOS Y BLOQUES INFORMATIVOS
===================================================== */
.section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 15px;
  color: var(--primary);
  border-left: 4px solid var(--primary);
  padding-left: 10px;
}

/* Bloques informativos (ej: enlaces, avisos) */
.user-results-link {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 15px;
  background: var(--light);
  border-radius: 6px;
  text-align: center;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
}

.user-results-link span {
  margin-left: 8px;
}


/* ==========================
   ICONOS Y HEADERS DE CARD
========================== */

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.icon-primary {
  font-size: 20px;
  color: var(--primary);
}

/* ==========================
   CARD IA
========================== */

.card-ia {
  background: linear-gradient(135deg, #ffffff, #f0f6ff);
  border-left: 5px solid var(--primary);
}

.card-desc {
  margin-bottom: 15px;
  font-size: 14px;
}

/* ==========================
   BOTÓN CON ICONO
========================== */

.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* ==========================
   OPCIONES CON ICONOS
========================== */

.options-icons {
  display: flex;
  gap: 15px;
  margin-top: 10px;
}

.option-card {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 15px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-card i {
  font-size: 22px;
  color: var(--primary);
}

.option-card input {
  display: none;
}

.option-card.active,
.option-card:hover {
  border-color: var(--primary);
  background-color: #f0f6ff;
}

/* ==========================
   CARDS DE GRUPOS REBA
========================== */

.card-group {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-group:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
}

/* Grupo de botones (izq / der) */
.btn-group {
  display: flex;
  gap: 10px;
}

/* Asegurar alineación visual */
.card-group .btn-secondary {
  width: 100%;
  justify-content: center;
}

.textarea-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.textarea-label {
  font-weight: 600;
  font-size: 14px;
}

.textarea-main {
  width: 100%;
  min-height: 240px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid #ddd;
  resize: vertical;
  font-size: 14px;
}

.textarea-main:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(31,111,178,.1);
}

.textarea-helper {
  font-size: 12px;
  color: #666;
}
