/* ===== IMPORTS - DEBE SER LA PRIMERA LÍNEA ===== */
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');

/* ===== RESET Y CONFIGURACIÓN GENERAL ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: Arial, sans-serif;
}

/* Layout principal */
body {
  background: #f5f7fa;
  color: #333;
}

/* ===== HEADER Y MENÚ ===== */
.main-header {
  background: #fff;
  padding: 15px 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  gap: 15px;
}

.main-header h1 {
  font-size: 24px;
  text-align: center;
  margin: 0;
  flex: 1;
}

.menu-toggle {
  background: #007bff;
  color: white;
  border: none;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s;
}

.menu-toggle:hover {
  background: #0056b3;
}

/* Menú lateral */
.sidebar {
  position: fixed;
  left: -300px;
  top: 0;
  width: 250px;
  background: #ddd;
  padding: 20px;
  height: 100%;
  transition: left 0.3s;
  z-index: 1000;
  box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}

.sidebar.active {
  left: 0;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #ccc;
}

.close-menu {
  background: #dc3545;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s;
}

.close-menu:hover {
  background: #c82333;
}

.sidebar h2 {
  margin-bottom: 15px;
}

.sidebar ul {
  list-style: none;
}

.sidebar ul li {
  margin-bottom: 10px;
}

.sidebar ul li a {
  text-decoration: none;
  color: #000;
  background: #fff;
  padding: 10px 15px;
  display: block;
  border-radius: 6px;
  transition: 0.3s;
}

.sidebar ul li a:hover {
  background: #bbb;
}

.sidebar ul li a i,
.submenu li i {
  width: 20px;
  margin-right: 10px;
}

.submenu {
  display: none;
  list-style: disc;
  padding-left: 20px;
  margin-top: 5px;
}

.submenu li {
  padding: 5px 0;
}

#toggleIntegrantes:checked + .submenu-label + .submenu {
  display: block;
}

.submenu-label {
  display: block;
  cursor: pointer;
  padding: 10px 15px;
  background: #fff;
  border-radius: 6px;
  color: #000;
  text-decoration: none;
}

.submenu-label:hover {
  background: #bbb;
}

/* ===== CONTENIDO PRINCIPAL ===== */
.content {
  padding: 20px;
}

/* ===== TARJETAS Y FORMULARIOS ===== */
.card {
  background: #fff;
  padding: 20px;
  margin-bottom: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.card h2, .card h3 {
  margin-bottom: 10px;
}

.card .subtitle {
  color: #666;
  font-size: 14px;
  margin-bottom: 15px;
}

/* Inputs - CORREGIDOS CON ID Y NAME */
input[type="text"] {
  width: 100%;
  padding: 8px;
  margin: 8px 0 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
}

.datos input[type="text"] {
  border: 2px solid #ddd;
  transition: border-color 0.3s;
  font-size: 14px;
}

.datos input[type="text"]:focus {
  border-color: #007bff;
  outline: none;
  box-shadow: 0 0 5px rgba(0, 123, 255, 0.3);
}

/* Botones de optimización */
.optimization-type {
  margin-bottom: 20px;
}

.optimization-buttons {
  display: flex;
  gap: 10px;
  margin: 10px 0;
}

.opt-btn {
  flex: 1;
  padding: 12px;
  border: 2px solid #007bff;
  background: white;
  color: #007bff;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.opt-btn.active {
  background: #007bff;
  color: white;
}

.opt-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

/* Botones de restricciones */
.restriction-item {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  align-items: center;
}

.restriction-item input {
  flex: 1;
  margin: 0;
}

.btn-remove-restriction {
  padding: 8px 12px;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-remove-restriction:hover {
  background: #c82333;
  transform: scale(1.05);
}

.btn-add-restriction {
  width: 100%;
  padding: 12px;
  background: #28a745;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-add-restriction:hover {
  background: #218838;
  transform: translateY(-2px);
}

.restriction-buttons {
  margin: 15px 0;
}

/* Botón resolver */
.btn-resolver {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, #007bff, #0056b3);
  color: #fff;
  font-weight: bold;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 16px;
}

.btn-resolver:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(0, 123, 255, 0.4);
}

/* ===== RESULTADOS Y GRÁFICOS ===== */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.tab-buttons {
  display: flex;
  gap: 10px;
}

.tab-btn {
  padding: 8px 16px;
  border: 2px solid #007bff;
  background: white;
  color: #007bff;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
}

.tab-btn.active {
  background: #007bff;
  color: white;
}

.tab-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

/* Resultados numéricos */
.numeric-results {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  border-left: 4px solid #007bff;
}

.numeric-results p {
  margin: 8px 0;
  font-size: 15px;
}

/* Contenedores de gráficos */
.plot-container {
  text-align: center;
  margin-top: 20px;
  animation: fadeIn 0.5s ease-in;
}

.export-image {
  max-width: 100%;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin: 15px 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Botones de exportación */
.btn-export {
  padding: 12px 24px;
  background: linear-gradient(135deg, #28a745, #20c997);
  color: white;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-export:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

/* ===== GRÁFICOS INTERACTIVOS (PLOTLY) - CORREGIDO ===== */
#plotly-container {
  width: 100%;
  min-height: 700px;
  max-height: 100%;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  overflow: auto; /* Cambiado de hidden a auto */
  margin: 15px 0;
  background: white;
  display: flex;
  justify-content: flex;
  align-items: flex-start;
  padding: 8px;
}

/* CONTROLES SIMPLIFICADOS PARA PLOTLY */
#plotly-container .plotly-graph-div {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  /*transform: scale(0.85); /* ← REDUCE EL TAMAÑO */
  transform-origin: center;
}

/* SVG dentro de Plotly */
#plotly-container .svg-container {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
}
#plotly-container .js-plotly-plot {
  width: 100% !important;
  height: 100% !important;
}

/* Barra de herramientas de Plotly */
.modebar {
  background: rgba(255, 255, 255, 0.95) !important;
  border-radius: 4px !important;
  padding: 3px !important;
  border: 1px solid #e0e0e0 !important;
  font-size: 10px !important;
  /*transform-origin: rigth;*/
}

.modebar-group {
  /*background: transparent !important;*/
}

/* Tooltips de Plotly */
.hovertext {
  background: white !important;
  border: 1px solid #ddd !important;
  border-radius: 6px !important;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
  font-size: 11px !important;
}

/* ===== ESTADOS DE CARGA Y MENSAJES ===== */
.loading-container {
  text-align: center;
  padding: 40px 20px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

.error-container {
  text-align: center;
  padding: 30px 20px;
  background: #fff5f5;
  border: 1px solid #f5c6cb;
  border-radius: 8px;
  color: #721c24;
}

.btn-retry {
  padding: 10px 20px;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  margin-top: 10px;
}

.info-message {
  background: #e3f2fd;
  border-left: 4px solid #2196f3;
  padding: 12px;
  border-radius: 6px;
  margin: 10px 0;
  font-size: 14px;
}

.info-message i {
  color: #2196f3;
  margin-right: 8px;
}

/* Placeholders para gráficos */
.plotly-placeholder {
  text-align: center;
  padding: 60px 20px;
  color: #666;
  font-style: italic;
  background: #f8f9fa;
  border-radius: 8px;
}

.plotly-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: #666;
}

.plotly-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

/* Mensaje cuando no hay gráfico */
.no-chart-message {
  text-align: center;
  color: #666;
  font-style: italic;
  padding: 40px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 2px dashed #dee2e6;
}

/* ===== FOOTER ===== */
footer {
  background: #fff;
  padding: 10px;
  border-top: 1px solid #ddd;
  text-align: center;
}

footer nav {
  display: flex;
  justify-content: space-around;
}

footer nav a {
  margin: 0 15px;
  text-decoration: none;
  color: #333;
  font-weight: bold;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

footer nav a i {
  font-size: 18px;
  margin-bottom: 5px;
}

footer nav a:hover {
  color: #007bff;
}

/* ===== ANIMACIONES ===== */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== RESPONSIVIDAD ===== */
@media (max-width: 768px) {
  .main-header {
    padding: 12px 15px;
  }
  
  .main-header h1 {
    font-size: 16px;
  }
  
  .optimization-buttons {
    flex-direction: column;
  }
  
  .restriction-item {
    flex-direction: column;
    align-items: stretch;
  }
  
  .btn-remove-restriction {
    align-self: flex-end;
  }
  
  .results-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .tab-buttons {
    justify-content: center;
  }
  
  .tab-btn {
    flex: 1;
    text-align: center;
    min-width: 120px;
  }
  
  .btn-export {
    width: 100%;
    justify-content: center;
  }
  
  footer nav {
    flex-wrap: wrap;
  }
  
  footer nav a {
    flex: 1;
    min-width: 80px;
    padding: 8px 5px;
    font-size: 14px;
  }
  
  /* Responsividad para Plotly en tablets */
  #plotly-container {
    min-height: 450px;
    max-height: 500px;
    padding: 5px;
  }
  
  #plotly-container .plotly-graph-div {
    transform: scale(0.6); /* ← MÁS REDUCCIÓN EN MÓVIL */
    height: 450px !important;
  }
  .modebar {
    transform: scale(0.3);
  }
}

@media (max-width: 480px) {
  .tab-btn {
    font-size: 12px;
    padding: 6px 12px;
  }
  
  .numeric-results p {
    font-size: 14px;
  }
  
  /* Responsividad para Plotly en móviles */
  #plotly-container {
    min-height: 400px;
	max-height: 450px;
  }
  
  #plotly-container .plotly-graph-div {
    height: 400px !important;
	transform: scale(0.5); /* ← MÁS REDUCCIÓN EN MÓVIL */
  }
  
  .modebar {
    transform: scale(0.3);
  }
}