/* --- ESTILOS ESPECÍFICOS PARA EL ESCÁNER DE CALORÍAS --- */
#initialView {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
#initialView h2 {
  margin-bottom: 10px;
}
#initialView p {
  color: var(--text-secondary-color);
  max-width: 500px;
  margin: 0 auto 30px auto;
}

.scanner-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px auto;
  color: var(--primary-accent);
  flex-shrink: 0; /* Evita que el icono se encoja */
}

.button-group {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 25px;
}

.button-group .control-btn {
  padding: 20px 30px;
  font-size: 1.1em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 240px;
  white-space: nowrap;
}

/* Contenedor de la cámara */
.camera-container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  background-color: #000;
  border: 1px solid var(--border-color);
  aspect-ratio: 16 / 9;
}
#cameraFeed {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.camera-controls {
  margin-top: 20px;
}

/* --- ESTILOS DE RESULTADOS --- */
.product-image {
  max-width: 150px;
  width: 100%;
  border-radius: 16px;
  margin: 0 auto 20px auto;
  display: block;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 15px var(--shadow-color);
}
#resultContent h3 {
  text-align: center;
  font-weight: 700;
  margin-bottom: 10px;
  font-size: 1.5em;
}
#resultContent p {
  text-align: center;
  color: var(--text-secondary-color);
  margin-bottom: 25px;
}

.nutrition-list {
  list-style: none;
  padding: 0;
  margin-top: 20px;
}
.nutrition-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  margin-bottom: 12px;
  border-radius: 16px;
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  transition: transform 0.2s, box-shadow 0.2s;
}
.nutrition-list li:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px var(--shadow-color);
}
.nutrition-list li strong {
  color: var(--text-color);
  font-weight: 600;
}
.nutrition-list li span {
  font-weight: 600;
  background-color: color-mix(in srgb, var(--primary-accent) 15%, transparent);
  color: var(--primary-accent);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 0.9em;
}

.nutrition-list li small {
  display: block;
  color: var(--text-secondary-color);
  font-size: 0.85em;
  margin-top: 4px;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
#cameraView,
#analysisResult {
  animation: fadeInUp 0.6s ease-out forwards;
}

/* --- MODAL DE ESCÁNER DE CÓDIGO DE BARRAS (DISEÑO CORREGIDO Y FINAL) --- */
.scanner-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  overflow: hidden;
}
.scanner-modal.active {
  opacity: 1;
  visibility: visible;
}

.scanner-container {
  background: var(--surface-color);
  padding: 30px;
  border-radius: 24px;
  text-align: center;
  width: 90%;
  max-width: 500px;
  transform: scale(0.95);
  transition: transform 0.3s ease;
  border: 1px solid var(--border-color);
}
.scanner-modal.active .scanner-container {
  transform: scale(1);
}
.scanner-container h3 {
  margin-bottom: 20px;
  font-size: 1.2em;
}
.scanner-viewfinder {
  width: 100%;
  aspect-ratio: 2 / 1;
  margin-bottom: 30px;
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #111;
}
.scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.scanner-reticle {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 3px solid rgba(255, 255, 255, 0.4);
  border-radius: 16px;
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.3);
}
.scanner-reticle::after {
  content: "";
  position: absolute;
  top: 0;
  left: 5%;
  width: 90%;
  height: 3px;
  background: var(--primary-accent);
  box-shadow: 0 0 10px 2px var(--primary-accent);
  border-radius: 3px;
  animation: scanning 2.5s infinite alternate ease-in-out;
}
@keyframes scanning {
  from {
    top: 10%;
  }
  to {
    top: 90%;
  }
}

.loading {
  /* Adaptado para la nueva animación */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--overlay-color);
  backdrop-filter: blur(8px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 9999;
  transition: opacity 0.3s;
}
.loading-spinner {
  width: 70px;
  height: 70px;
  animation: bounce 1s infinite alternate ease-in-out;
}
.loading-spinner svg {
  width: 100%;
  height: 100%;
  animation: spin 3s linear infinite;
}
#loadingText {
  font-size: 1.1em;
  font-weight: 500;
  color: var(--text-secondary-color);
}
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
@keyframes bounce {
  from {
    transform: translateY(0px);
  }
  to {
    transform: translateY(-15px);
  }
}

.toast {
  visibility: hidden;
  min-width: 250px;
  max-width: 80%;
  background-color: var(--error-color);
  color: #fff;
  font-weight: 500;
  text-align: center;
  border-radius: 12px;
  padding: 16px;
  position: fixed;
  z-index: 2001;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.3s, bottom 0.3s, visibility 0.3s;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}
.toast.show {
  visibility: visible;
  opacity: 1;
  bottom: 50px;
}

/* --- NUEVOS ESTILOS PARA RESULTADOS DE ETIQUETA --- */
.verdict-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 25px;
  border-radius: 18px;
  margin-bottom: 25px;
  text-align: center;
}
.verdict-banner span {
  font-size: 2.5em;
  line-height: 1;
  margin-bottom: 10px;
}
.verdict-banner h3 {
  font-size: 1.5em;
  font-weight: 700;
  margin: 0;
  color: var(--text-color);
}
.verdict-good {
  background-color: color-mix(in srgb, var(--success-color) 15%, transparent);
}
.verdict-medium {
  background-color: color-mix(in srgb, #f59e0b 15%, transparent);
}
.verdict-bad {
  background-color: color-mix(in srgb, var(--error-color) 15%, transparent);
}

.product-title {
  margin-bottom: 10px !important;
}
.summary-text {
  font-size: 1.1em;
  max-width: 600px;
  margin: 0 auto 30px auto;
}
.troll-message {
  text-align: center;
}
.troll-message span {
  font-size: 3em;
  display: block;
  margin-bottom: 15px;
}

.pros-cons-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-top: 20px;
}
.pros-cons-card {
  background-color: var(--bg-color);
  padding: 20px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
}
.pros-cons-card h4 {
  font-size: 1.1em;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pros-card h4 {
  color: var(--success-color);
}
.cons-card h4 {
  color: var(--error-color);
}

.pros-cons-list {
  list-style: none;
  padding: 0;
  font-size: 0.95em;
}
.pros-cons-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--text-secondary-color);
  line-height: 1.5;
}
.pros-cons-list li::before {
  content: "";
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: white;
  margin-top: 2px;
}
.pros-list li::before {
  content: "✓";
  background-color: var(--success-color);
}
.cons-list li::before {
  content: "✗";
  background-color: var(--error-color);
}

.learn-more-card {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}
.learn-more-card h4 {
  text-align: center;
  margin-bottom: 20px;
  color: var(--text-secondary-color);
  font-weight: 500;
}
.resource-link {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  text-decoration: none;
  margin-bottom: 12px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.resource-link:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 15px var(--shadow-color);
}
.resource-link .icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 8px;
}
.youtube-icon {
  background-color: #ff0000;
  color: white;
}
.icon svg {
  width: 24px;
  height: 24px;
}
.resource-link div {
  flex-grow: 1;
}
.resource-link strong {
  display: block;
  color: var(--text-color);
  font-weight: 600;
}
.resource-link small {
  color: var(--text-secondary-color);
  font-size: 0.85em;
}

/* --- INICIO DE NUEVOS ESTILOS Y AJUSTES --- */
.results-controls {
  display: flex;
  flex-direction: column;
  gap: 15px; /* Espaciado entre botones */
}

.camera-instruction-title {
  text-align: center;
  margin-bottom: 20px;
}

.camera-instruction-card {
  background: var(--surface-color);
  padding: 20px;
  border-radius: 16px;
  margin: 0 auto 20px auto;
  border: 1px solid var(--border-color);
  max-width: 95%;
}
.camera-instruction-card h4 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
  font-size: 1.1em;
}
.camera-instruction-card p {
  color: var(--text-secondary-color);
  margin-bottom: 10px;
  text-align: left;
}
.camera-instruction-card ul {
  list-style: none;
  padding: 0;
  text-align: left;
  color: var(--text-secondary-color);
  font-size: 0.9em;
}
.camera-instruction-card li {
  margin-bottom: 5px;
}

.guidance-details {
  margin-top: 25px;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  transition: background-color 0.2s;
}
.guidance-details:hover {
  background-color: color-mix(in srgb, var(--primary-accent) 4%, transparent);
}
.guidance-details summary {
  font-weight: 600;
  cursor: pointer;
  padding: 15px 20px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.guidance-details summary::-webkit-details-marker {
  display: none;
}
.guidance-details[open] {
  padding-bottom: 15px;
}
.guidance-details[open] summary {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 15px;
  margin-bottom: 15px;
}
.guidance-content {
  padding: 0 20px;
  font-size: 0.95em;
  color: var(--text-secondary-color);
}
.guidance-content p {
  margin-bottom: 15px;
  text-align: left;
}
.guidance-content strong {
  color: var(--text-color);
}

.single-ingredient-summary {
  text-align: center;
  padding: 20px;
  font-size: 1.1em;
  color: var(--text-secondary-color);
}
.ingredient-card {
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 15px;
}
.ingredient-header {
  margin-bottom: 10px;
}
.ingredient-name {
  font-size: 1.2em;
  font-weight: 600;
  color: var(--text-color);
  margin: 0;
}
.ingredient-category {
  font-size: 0.8em;
  font-weight: 500;
  color: var(--primary-accent);
  background-color: color-mix(in srgb, var(--primary-accent) 15%, transparent);
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-block;
  margin-bottom: 8px;
}
.ingredient-explanation {
  font-size: 0.95em;
  color: var(--text-secondary-color);
  line-height: 1.6;
  margin: 0;
  text-align: left;
}
/* --- Fin de nuevos estilos --- */

@media (min-width: 768px) {
  .button-group {
    flex-direction: row;
    justify-content: center;
  }
  .button-group.camera-controls {
    justify-content: center;
  }
  .button-group .control-btn {
    min-width: 240px;
  }
  .pros-cons-container {
    grid-template-columns: 1fr 1fr;
  } /* Dos columnas en escritorio */
  .results-controls {
    flex-direction: row;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  #initialView.main-section {
    padding-top: 40px;
    padding-bottom: 40px;
  }
  .button-group.camera-controls {
    flex-direction: column-reverse;
  }
}
