/* ===========================================
   RESET Y VARIABLES
   =========================================== */
:root {
  --primary-color: #2e7d32;
  --primary-dark: #1b5e20;
  --primary-light: #4caf50;
  --secondary-color: #ff9800;
  --light-bg: #f5f9f5;
  --dark-text: #333333;
  --light-text: #666666;
  --border-color: #e0e0e0;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --radius: 12px;
  --transition: all 0.3s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  font-family: 'Roboto', sans-serif;
  background-color: var(--light-bg);
  color: var(--dark-text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===========================================
   TIPOGRAFÍA Y ELEMENTOS BASE
   =========================================== */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  line-height: 1.3;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  font-family: 'Poppins', sans-serif;
  cursor: pointer;
  border: none;
  outline: none;
  transition: var(--transition);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ===========================================
   LAYOUT PRINCIPAL
   =========================================== */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ===========================================
   HEADER
   =========================================== */
header {
  text-align: center;
  padding: 30px 0 20px;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-bottom: 10px;
}

.logo i {
  font-size: 2.5rem;
  color: var(--primary-color);
}

.logo h1 {
  font-size: 2rem;
  color: var(--primary-dark);
}

.subtitle {
  font-size: 1rem;
  color: var(--light-text);
  font-weight: 300;
  max-width: 600px;
  margin: 0 auto;
}

/* ===========================================
   SECCIÓN DE SUBIDA - ESCRITORIO
   =========================================== */
.desktop-upload {
  display: block;
}

.upload-section {
  background-color: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
  margin-bottom: 30px;
}

.upload-box {
  border: 3px dashed var(--border-color);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  transition: var(--transition);
  position: relative;
  cursor: pointer;
}

.upload-box:hover {
  border-color: var(--primary-light);
}

.upload-box.dragover {
  border-color: var(--primary-color);
  background-color: rgba(46, 125, 50, 0.05);
}

.upload-icon {
  font-size: 3rem;
  color: var(--primary-light);
  margin-bottom: 15px;
}

.upload-box h3 {
  font-size: 1.5rem;
  margin-bottom: 10px;
  color: var(--dark-text);
}

.upload-box p {
  color: var(--light-text);
  margin-bottom: 20px;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.formats {
  margin-bottom: 25px;
  color: #888;
  font-size: 0.9rem;
}

/* Input de archivo oculto */
#fileInput {
  display: none;
}

/* ===========================================
   SECCIÓN DE SUBIDA - MÓVIL
   =========================================== */
.mobile-upload {
  display: none;
}

.mobile-options {
  text-align: center;
}

.mobile-options h3 {
  font-size: 1.5rem;
  color: var(--primary-dark);
  margin-bottom: 10px;
}

.mobile-options p {
  color: var(--light-text);
  margin-bottom: 25px;
}

.mobile-buttons {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 25px;
}

.mobile-option-btn {
  background-color: white;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 15px;
  width: 100%;
}

.mobile-option-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--primary-color);
}

.camera-btn {
  border-color: var(--primary-color);
}

.gallery-btn {
  border-color: #6c63ff;
}

.mobile-icon {
  background-color: #f0f7f0;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.camera-btn .mobile-icon {
  background-color: rgba(46, 125, 50, 0.1);
  color: var(--primary-color);
}

.gallery-btn .mobile-icon {
  background-color: rgba(108, 99, 255, 0.1);
  color: #6c63ff;
}

.mobile-icon i {
  font-size: 1.5rem;
}

.mobile-text {
  flex-grow: 1;
  text-align: left;
}

.mobile-text h4 {
  font-size: 1.1rem;
  margin-bottom: 5px;
  color: var(--dark-text);
}

.camera-btn .mobile-text h4 {
  color: var(--primary-color);
}

.gallery-btn .mobile-text h4 {
  color: #6c63ff;
}

.mobile-text p {
  color: var(--light-text);
  font-size: 0.9rem;
  margin-bottom: 0;
}

/* Input de archivo para móvil (oculto) */
#mobileFileInput {
  display: none;
}

/* ===========================================
   CONTENEDORES DE VISTA PREVIA
   =========================================== */
.preview-container {
  position: relative;
  margin-top: 20px;
  width: 100%;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
  display: none;
}

#imagePreview, #mobileImagePreview {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.remove-btn {
  position: absolute;
  top: -10px;
  right: -10px;
  background-color: white;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  color: #f44336;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.remove-btn:hover {
  background-color: #f44336;
  color: white;
}

.remove-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.remove-btn.disabled:hover {
  background-color: white;
  color: #f44336;
}

/* ===========================================
   CONTROLES (BOTONES ANALIZAR Y REINICIAR)
   =========================================== */
.controls {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 30px;
  flex-wrap: wrap;
}

.analyze-btn, .reset-btn {
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 50px;
  min-width: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.analyze-btn {
  background-color: var(--primary-color);
  color: white;
}

.analyze-btn:hover:not(:disabled) {
  background-color: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(46, 125, 50, 0.3);
}

.analyze-btn:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.reset-btn {
  background-color: white;
  color: var(--dark-text);
  border: 2px solid var(--border-color);
}

.reset-btn:hover:not(:disabled) {
  background-color: #f5f5f5;
  border-color: var(--light-text);
}

.reset-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Spinner para botón de análisis */
.btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===========================================
   SECCIÓN DE CONSEJOS
   =========================================== */
.info-tips {
  margin-top: 30px;
  padding: 20px;
  background-color: #f0f7f0;
  border-radius: var(--radius);
}

.info-tips h4 {
  color: var(--primary-dark);
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
}

.info-tips ul {
  list-style-type: none;
  padding-left: 0;
}

.info-tips li {
  padding: 8px 0;
  padding-left: 28px;
  position: relative;
  font-size: 0.95rem;
}

.info-tips li:before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--primary-color);
  font-weight: bold;
  font-size: 1rem;
}

/* ===========================================
   SECCIÓN DE RESULTADOS
   =========================================== */
.results-section {
  background-color: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
  margin-bottom: 30px;
  display: none;
}

.results-section h2 {
  color: var(--primary-dark);
  margin-bottom: 25px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.5rem;
}

/* Indicador de carga */
.loading {
  text-align: center;
  padding: 40px 20px;
  display: none;
}

.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

.loading p {
  font-size: 1.1rem;
  color: var(--dark-text);
  margin-bottom: 5px;
}

.loading-sub {
  color: var(--light-text);
  font-size: 0.9rem;
}

/* Contenedor de resultados */
.results-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.result-card {
  background-color: #f9f9f9;
  border-radius: var(--radius);
  padding: 20px;
  border-left: 4px solid var(--primary-color);
}

.result-card h3 {
  color: var(--primary-dark);
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
}

.result-card p {
  margin-bottom: 8px;
  line-height: 1.6;
  font-size: 0.95rem;
}

/* Barra de confianza */
.confidence-bar {
  height: 8px;
  background-color: #e0e0e0;
  border-radius: 4px;
  margin-top: 10px;
  margin-bottom: 10px;
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  background-color: var(--primary-color);
  border-radius: 4px;
  transition: width 1.5s ease;
}

/* ===========================================
   FOOTER
   =========================================== */
footer {
  text-align: center;
  padding: 25px 0;
  color: var(--light-text);
  border-top: 1px solid var(--border-color);
  margin-top: 20px;
}

footer p {
  margin-bottom: 15px;
  font-size: 0.9rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--primary-color);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.9rem;
  transition: var(--transition);
}

.footer-links a:hover {
  color: var(--primary-dark);
}

/* ===========================================
   MODAL
   =========================================== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal-content {
  background-color: white;
  border-radius: var(--radius);
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  background-color: white;
  z-index: 1;
}

.modal-header h3 {
  color: var(--primary-dark);
  font-size: 1.3rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--light-text);
  line-height: 1;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition);
}

.modal-close:hover {
  background-color: #f5f5f5;
  color: var(--dark-text);
}

.modal-body {
  padding: 20px;
  line-height: 1.6;
}

.modal-body h4 {
  color: var(--primary-dark);
  margin-bottom: 10px;
  font-size: 1.1rem;
}

.modal-body p {
  margin-bottom: 15px;
  font-size: 0.95rem;
}

.modal-body ul, .modal-body ol {
  margin-left: 20px;
  margin-bottom: 15px;
}

.modal-body li {
  margin-bottom: 8px;
  font-size: 0.95rem;
}

/* ===========================================
   NOTIFICACIONES TOAST
   =========================================== */
.notification {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: white;
  border-radius: var(--radius);
  padding: 15px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1001;
  transform: translateX(100%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  max-width: 350px;
  border-left: 4px solid var(--primary-color);
}

.notification.show {
  transform: translateX(0);
  opacity: 1;
}

.notification.success {
  border-left-color: #4caf50;
}

.notification.error {
  border-left-color: #f44336;
}

.notification.warning {
  border-left-color: #ff9800;
}

.notification.info {
  border-left-color: #2196f3;
}

.notification i {
  font-size: 1.2rem;
}

.notification.success i {
  color: #4caf50;
}

.notification.error i {
  color: #f44336;
}

.notification.warning i {
  color: #ff9800;
}

.notification.info i {
  color: #2196f3;
}

.notification span {
  flex-grow: 1;
  font-weight: 500;
  font-size: 0.95rem;
}

.notification-close {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

.notification-close:hover {
  background-color: #f5f5f5;
  color: #333;
}

/* ===========================================
   ESTADOS DESHABILITADOS DURANTE ANÁLISIS
   =========================================== */
.upload-section.disabled {
  opacity: 0.8;
  pointer-events: none;
}

/* ===========================================
   MEDIA QUERIES - RESPONSIVE
   =========================================== */

/* Móviles pequeños (hasta 480px) */
@media (max-width: 480px) {
  .container {
    padding: 0 15px;
  }
  
  header {
    padding: 20px 0 15px;
  }
  
  .logo {
    flex-direction: column;
    gap: 10px;
  }
  
  .logo h1 {
    font-size: 1.7rem;
  }
  
  .upload-section {
    padding: 20px 15px;
  }
  
  .upload-box {
    padding: 30px 15px;
  }
  
  .controls {
    flex-direction: column;
    align-items: center;
  }
  
  .analyze-btn, .reset-btn {
    width: 100%;
    max-width: 280px;
  }
  
  .results-section {
    padding: 20px 15px;
  }
  
  .notification {
    left: 15px;
    right: 15px;
    max-width: none;
    transform: translateY(100%);
  }
  
  .notification.show {
    transform: translateY(0);
  }
}

/* Móviles (hasta 768px) */
@media (max-width: 768px) {
  .desktop-upload {
    display: none !important;
  }
  
  .mobile-upload {
    display: block !important;
  }
  
  .controls {
    gap: 10px;
  }
  
  .footer-links {
    gap: 15px;
  }
}

/* Tabletas (769px a 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .container {
    padding: 0 30px;
  }
  
  .mobile-upload {
    display: none !important;
  }
  
  .desktop-upload {
    display: block !important;
  }
  
  .results-container {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Escritorio (más de 1024px) */
@media (min-width: 1025px) {
  .mobile-upload {
    display: none !important;
  }
  
  .desktop-upload {
    display: block !important;
  }
  
  .results-container {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .result-card:nth-child(3),
  .result-card:nth-child(4) {
    grid-column: span 1;
  }
  
  .result-card:nth-child(1) {
    grid-column: span 2;
  }
}

/* Pantallas grandes (más de 1200px) */
@media (min-width: 1200px) {
  .container {
    padding: 0;
  }
  
  .results-container {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .result-card:nth-child(1) {
    grid-column: span 3;
  }
  
  .result-card:nth-child(2),
  .result-card:nth-child(3),
  .result-card:nth-child(4) {
    grid-column: span 1;
  }
}

/* Para orientación horizontal en móviles */
@media (max-height: 600px) and (orientation: landscape) {
  .upload-section {
    padding: 15px;
  }
  
  .upload-box {
    padding: 20px 15px;
  }
  
  .preview-container {
    max-width: 200px;
  }
  
  #imagePreview, #mobileImagePreview {
    max-height: 150px;
  }
}

/* Para prevenir zoom en inputs en iOS */
@media (max-width: 768px) {
  input, textarea, select {
    font-size: 16px; /* Previene el zoom en iOS */
  }
}

/* Mejoras de accesibilidad para enfoque */
button:focus, a:focus, input:focus {
  outline: 2px solid var(--primary-light);
  outline-offset: 2px;
}

/* Animación suave para scroll */
html {
  scroll-behavior: smooth;
}

/* Prevenir selección de texto en botones */
button {
  user-select: none;
}