/* ====== ESTILOS PRINCIPALES - VERSIÓN COMPACTA ====== */

/* Contenedor principal */
.rep-cotizador-root {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  max-width: 1400px; /* Limitar ancho máximo y centrar */
  margin: 0 auto;
  padding: 10px 20px;
  line-height: 1.4;
  font-size: 14px;
}

/* Cada caja de formulario */
.rep-box {
  border: 1px solid #e5e7eb;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 15px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  box-sizing: border-box;
  transition: box-shadow 0.2s ease;
}

.rep-box:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Fila principal que contiene todos los elementos: ahora es una tarjeta por cotización
   Dentro de .rep-row tenemos .rep-row-card que contiene dos filas:
   .rep-row-top (Categoría, Material, Domiciliario, Peligroso)
   .rep-row-bottom (Peso, Cantidad, Toneladas) */
.rep-row {
  width: 100%;
  margin-bottom: 14px;
}

.rep-row-card {
  border: 1px solid #eef2f6;
  background: #ffffff;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15,23,42,0.03);
}

.rep-row-top,
.rep-row-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 12px; /* separación balanceada entre columnas */
  align-items: flex-end;
  justify-content: flex-start;
  width: 100%;
}

.rep-row-sep {
  height: 8px;
  width: 100%;
}

/* Columnas individuales */
.rep-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 100px;
  flex: 1;
  padding: 0 2px; /* reducir padding horizontal para menos separación */
}

/* Columnas pequeñas para los dropdowns de Sí/No */
.rep-col--sm {
  min-width: 200px;
  flex: 0 0 200px;
}

/* Columnas medianas para Categoría y Material - Más grandes para aprovechar espacio */
.rep-col--categoria,
.rep-col--material {
  min-width: 300px;
  flex: 0 0 300px;
}

/* Campo de grasa con el mismo tamaño que Domiciliario y Peligroso */
.rep-grasa-field {
  flex: 0 0 200px;
  min-width: 200px;
  position: relative;
  z-index: 3;
}

select.repGrasa {
  width: 100% !important;
  padding: 8px 10px;
  height: 40px;
  max-width: 100%;
  box-sizing: border-box;
}

/* Estilos reducidos para selects tipo Sí/No: menos padding, menor altura y tamaño de fuente */
.rep-col.rep-col--sm select,
.rep-col.rep-col--sm input {
  padding: 8px 10px;
  height: 36px;
  font-size: 13px;
}

/* Columnas más anchas para campos específicos */
.rep-col--md {
  min-width: 140px;
  flex: 0 0 140px;
}

.rep-col--line {
  flex: 0 0 30px;
  min-width: 30px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
}

/* Etiquetas */
.rep-col label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 4px;
  white-space: nowrap;
}

/* Inputs y selects */
.rep-col input,
.rep-col select {
  padding: 12px 14px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #ffffff;
  font-size: 16px;
  transition: border-color 0.2s ease;
  height: 45px;
  box-sizing: border-box;
}

.rep-col input:focus,
.rep-col select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.1);
}

.rep-col input:disabled,
.rep-col select:disabled {
  background: #f9fafb;
  color: #9ca3af;
  cursor: not-allowed;
}

/* Estilos uniformes para los dropdowns pequeños (Sí/No) */
.rep-col.rep-col--sm select.repDomiciliario,
.rep-col.rep-col--sm select.repPeligroso,
.rep-col.rep-col--sm select.repGrasa {
  padding: 9px 12px;
  height: 38px;
  font-size: 14px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

select.repDomiciliario,
select.repPeligroso {
  padding: 9px 12px;
  height: 38px;
  font-size: 14px;
  max-width: 100%;
  box-sizing: border-box;
}

/* Estilos para Categoría y Material - Ligeramente más grandes */
.rep-col--categoria select,
.rep-col--material select {
  padding: 11px 14px;
  height: 42px;
  font-size: 14px;
}

/* Operadores matemáticos */
.rep-op {
  font-weight: 800;
  font-size: 14px;
  color: #1f2937;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 8px;
  min-width: 12px;
}

/* Línea visual */
.rep-line {
  display: block;
  width: 100%;
  height: 2px;
  background: #1f2937;
  border-radius: 1px;
}

/* Resultados */
.rep-results {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  padding: 0 0 10px 0; /* align visually with the '=' operator */
  border: none;
  box-shadow: none;
  min-width: 0;
  justify-content: flex-start;
}

.rep-results span {
  color: #6b7280;
  font-size: 15px;
  font-weight: 700;
}
.rep-results strong {
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
  padding: 0 6px 0 0;
  background: none;
  border: none;
}

.rep-results strong {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  padding: 0;
  background: none;
  border: none;
}

/* Tooltip/info icon next to labels (simple, uses native title attribute) */
.rep-tooltip {
  display: inline-block;
  margin-left: 8px;
  width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 50%;
  background: #eef2f6;
  color: #0f172a;
  font-size: 12px;
  cursor: help;
  box-shadow: 0 1px 0 rgba(0,0,0,0.03) inset;
}
.rep-tooltip:hover { background:#e0f2fe; }

/* Variante del tooltip que se coloca fuera del recuadro de resultados */
.rep-tooltip--outside {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 12px; /* space to the right of the results box */
  margin-right: 0;
  vertical-align: middle;
  background: transparent;
  color: #6b7280;
  width: 20px;
  height: 20px;
  line-height: 20px;
  border-radius: 50%;
}
.rep-tooltip--outside:hover { background: #eef2f6; color: #0f172a; }

/* Acciones */
.rep-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid #e5e7eb;
}

.rep-actions button {
  padding: 8px 16px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.rep-actions .repLimpiar {
  background: #ffffff;
  color: #374151;
  border: 1px solid #d1d5db;
}

.rep-actions .repLimpiar:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.rep-actions .repGenerar {
  background: #3b82f6;
  color: #ffffff;
}

.rep-actions .repGenerar:hover:not(:disabled) {
  background: #2563eb;
}

.rep-actions .repGenerar:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.rep-actions .repDelete {
  background: #ef4444;
  color: #ffffff;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 16px;
  line-height: 1;
  margin-left: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rep-actions .repDelete:hover {
  background: #dc2626;
}

/* Botón agregar formulario */
#rep-add-form {
  margin-top: 8px;
  padding: 10px 16px;
  border-radius: 4px;
  background: #10b981;
  color: #ffffff;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

#rep-add-form:hover {
  background: #059669;
}

/* Tarjetas de radio buttons */
.rep-radioCard {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #ffffff;
  min-width: 90px;
  box-sizing: border-box;
}

.rep-radioCard legend {
  padding: 0 2px;
  font-size: 10px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 1px;
}

.rep-radio {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #374151;
  font-size: 10px;
  cursor: pointer;
}

.rep-radio input[type="radio"] {
  margin: 0;
  accent-color: #3b82f6;
  width: 12px;
  height: 12px;
}

.rep-radio:hover {
  color: #1f2937;
}

/* ====== MODAL STYLES ====== */
.rep-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.rep-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.rep-modal-content {
  position: relative;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  max-width: 900px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideIn 0.3s ease;
}

.rep-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 24px 16px 24px;
  border-bottom: 2px solid #f1f5f9;
}

.rep-modal-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: #1f2937;
}

.rep-modal-close {
  background: none;
  border: none;
  font-size: 28px;
  font-weight: 700;
  color: #9ca3af;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.rep-modal-close:hover {
  background: #f3f4f6;
  color: #374151;
}

.rep-modal-body {
  padding: 24px;
}

.rep-quote-summary h3 {
  margin: 0 0 16px 0;
  font-size: 18px;
  font-weight: 600;
  color: #374151;
}

.rep-quote-item {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.rep-quote-item h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rep-quote-item-number {
  background: #3b82f6;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.rep-quote-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
  margin-bottom: 12px;
}

/* Comparación de gestores por ítem (tarjetas) */
.rep-quote-gestores {
  margin-top: 12px;
}
.rep-quote-gestores-title {
  margin: 6px 0 12px 0;
  color: #0c4a6e;
  font-size: 15px;
  font-weight: 700;
}
.rep-gestor-cards {
  display: flex;
  gap: 12px;
  align-items: stretch;
}
.rep-gestor-card {
  flex: 1 1 0;
  background-color: #ffffff;
  border: 1px solid #e6f2fb;
  border-radius: 10px;
  padding: 12px 14px;
  text-align: center;
  box-shadow: 0 6px 18px rgba(14,165,233,0.04);
}
.rep-gestor-card .rep-gestor-name {
  font-size: 14px;
  color: #0c4a6e;
  font-weight: 700;
  margin-bottom: 8px;
}
.rep-gestor-card .rep-gestor-value {
  font-size: 20px;
  color: #0c4a6e;
  font-weight: 800;
  margin-bottom: 6px;
}
.rep-gestor-card .rep-gestor-uf {
  font-size: 13px;
  color: #64748b;
}

.rep-quote-detail {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rep-quote-detail span {
  color: #6b7280;
  font-size: 14px;
}

.rep-quote-detail strong {
  color: #1f2937;
  font-weight: 600;
}

.rep-quote-totals {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 2px solid #0ea5e9;
  border-radius: 12px;
  padding: 20px;
  margin-top: 20px;
}

.rep-total-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #bae6fd;
}

.rep-total-item:last-child {
  border-bottom: none;
}

.rep-total-final {
  font-size: 18px;
  font-weight: 700;
  color: #0c4a6e;
  padding-top: 16px;
  border-top: 2px solid #0ea5e9;
  margin-top: 8px;
}

.rep-total-item span {
  color: #0369a1;
  font-weight: 600;
}

.rep-total-item strong {
  color: #0c4a6e;
  font-size: 16px;
}

.rep-total-final strong {
  font-size: 20px;
}

.rep-total-uf {
  background-color: #f0f9ff;
  border-radius: 4px;
  padding: 8px 12px;
  margin-top: 8px;
  font-size: 14px;
}

.rep-total-uf span {
  color: #0369a1;
  font-weight: 500;
}

.rep-total-uf strong {
  color: #0c4a6e;
  font-size: 14px;
}

/* Estilos para el texto pequeño de UF */
small {
  color: #64748b;
  font-weight: normal;
  font-size: 12px;
}

/* Estilos para la sección de gestores */
.rep-gestores-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 2px solid #e2e8f0;
}

.rep-gestores-section h4 {
  margin: 0 0 12px 0;
  color: #0c4a6e;
  font-size: 16px;
  font-weight: 600;
}

.rep-gestores-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

.rep-gestor-item {
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.rep-gestor-name {
  display: block;
  font-weight: 600;
  color: #475569;
  font-size: 14px;
  margin-bottom: 8px;
}

.rep-gestor-values strong {
  display: block;
  font-size: 18px;
  color: #0c4a6e;
  font-weight: 700;
  margin-bottom: 4px;
}

.rep-gestor-values small {
  display: block;
  font-size: 12px;
  color: #64748b;
}

.rep-modal-footer {
  padding: 16px 24px 24px 24px;
  border-top: 2px solid #f1f5f9;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.rep-btn {
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rep-btn-primary {
  background: #3b82f6;
  color: #ffffff;
}

.rep-btn-primary:hover {
  background: #2563eb;
}

.rep-btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 2px solid #d1d5db;
}

.rep-btn-secondary:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
}

/* Animaciones */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideIn {
  from { 
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to { 
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Responsive Design */
@media (max-width: 1200px) {
  .rep-row-card {
    padding: 10px 8px;
  }
  
  .rep-col {
    min-width: 90px;
    padding: 0 2px;
  }
  
  .rep-col--categoria,
  .rep-col--material {
    min-width: 220px;
    flex: 0 0 220px;
  }
  
  .rep-col--sm {
    min-width: 160px;
    flex: 0 0 160px;
  }
  
  .rep-col--md {
    min-width: 120px;
    flex: 0 0 120px;
  }
  
  .rep-box {
    padding: 10px;
  }
}

@media (max-width: 900px) {
  .rep-row-top,
  .rep-row-bottom {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  
  .rep-col,
  .rep-col--sm,
  .rep-radioCard {
    min-width: 100%;
    flex: 1;
  }
  
  .rep-col--line {
    display: none;
  }
  
  .rep-op {
    display: none;
  }
  
  .rep-results {
    min-width: 100%;
    margin: 8px 0 0 0;
    order: 10;
  }
  
  .rep-actions {
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
  }
  
  .rep-actions button {
    flex: 1;
    min-width: 80px;
  }
  
  .rep-actions .repDelete {
    flex: none;
    width: 32px;
    height: 32px;
    align-self: center;
  }
}

@media (max-width: 600px) {
  .rep-cotizador-root {
    padding: 8px 0;
  }
  
  .rep-box {
    padding: 12px;
    margin-bottom: 10px;
  }
  
  .rep-col label {
    font-size: 11px;
    margin-bottom: 3px;
  }
  
  .rep-col input,
  .rep-col select {
    padding: 8px;
    font-size: 14px; /* Evita zoom en iOS */
    height: 32px;
  }
  
  .rep-radioCard {
    padding: 8px;
  }
  
  .rep-radioCard legend {
    font-size: 10px;
  }
  
  .rep-radio {
    font-size: 11px;
  }
  
  .rep-results {
    padding: 10px;
  }
  
  .rep-results span {
    font-size: 10px;
  }
  
  .rep-results strong {
    font-size: 12px;
  }

  /* Modal responsive */
  .rep-modal-content {
    width: 95%;
    margin: 10px;
    max-height: calc(100vh - 20px);
  }

  .rep-modal-header {
    padding: 12px;
  }

  .rep-modal-header h2 {
    font-size: 18px;
  }

  .rep-modal-body {
    padding: 12px;
  }

  .rep-quote-details {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .rep-modal-footer {
    padding: 12px;
    flex-direction: column;
  }

  .rep-btn {
    width: 100%;
    justify-content: center;
    padding: 8px 12px;
    font-size: 12px;
  }
}
