* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  border-radius: 15px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 30px;
  text-align: center;
}

header h1 {
  font-size: 2.5em;
  margin-bottom: 10px;
}

header p {
  font-size: 1.1em;
  opacity: 0.9;
}

.tabs {
  display: flex;
  background: #f5f5f5;
  border-bottom: 2px solid #ddd;
}

.tab-btn {
  flex: 1;
  padding: 15px;
  text-align: center;
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1em;
  font-weight: 600;
  color: #666;
  transition: all 0.3s;
}

.tab-btn:hover {
  background: #e0e0e0;
  text-decoration: none;
  color: #666;
}

.tab-btn.active {
  background: white;
  color: #667eea;
  border-bottom: 3px solid #667eea;
}

.tab-content {
  padding: 30px;
  animation: fadeIn 0.5s;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Formularios */
.form-ciclo,
.search-form {
  width: 100%;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: #333;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px;
  border: 2px solid #ddd;
  border-radius: 5px;
  font-size: 1em;
  transition: border-color 0.3s;
  font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: #667eea;
}

.form-group small {
  display: block;
  margin-top: 5px;
  color: #666;
  font-size: 0.9em;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

/* Huevos */
.huevos-container {
  margin-bottom: 30px;
}

.huevo-item {
  background: #f9f9f9;
  padding: 20px;
  margin-bottom: 15px;
  border-radius: 8px;
  border-left: 4px solid #667eea;
}

.huevo-item h4 {
  color: #667eea;
  margin-bottom: 15px;
}

/* Botones */
.btn-primary,
.btn-secondary,
.btn-danger {
  display: inline-block;
  padding: 12px 30px;
  border: none;
  border-radius: 5px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  text-decoration: none;
  text-align: center;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
  text-decoration: none;
  color: white;
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-secondary:hover {
  background: #5a6268;
  text-decoration: none;
  color: white;
}

.btn-danger {
  background: #dc3545;
  color: white;
  padding: 8px 15px;
  font-size: 0.9em;
}

.btn-danger:hover {
  background: #c82333;
  text-decoration: none;
  color: white;
}

/* Búsqueda */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  align-items: center;
}

.search-bar input {
  flex: 1;
  padding: 10px;
  border: 2px solid #ddd;
  border-radius: 5px;
  font-size: 1em;
}

/* Cards de ciclo */
.lista-ciclos {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ciclo-card {
  background: #f9f9f9;
  border-radius: 10px;
  padding: 20px;
  border-left: 5px solid #667eea;
  transition: all 0.3s;
}

.ciclo-card:hover {
  transform: translateX(5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.ciclo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.ciclo-header h3 {
  color: #667eea;
  margin: 0;
}

.ciclo-header .fecha {
  color: #666;
  font-size: 0.9em;
}

.ciclo-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 15px;
}

.ciclo-info-item {
  background: white;
  padding: 10px;
  border-radius: 5px;
  text-align: center;
}

.ciclo-info-item strong {
  color: #666;
  font-size: 0.9em;
}

.ciclo-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* No data */
.no-data {
  text-align: center;
  padding: 40px;
  color: #666;
}

.no-data p {
  margin-bottom: 20px;
  font-size: 1.1em;
}

/* Estadísticas */
.stats-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 25px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.stat-card h3 {
  font-size: 1em;
  margin-bottom: 10px;
  opacity: 0.9;
}

.stat-card p {
  font-size: 2.5em;
  font-weight: bold;
}

/* Gráfico de barras CSS */
.chart-container {
  background: #f9f9f9;
  padding: 20px;
  border-radius: 10px;
}

.grafico-barras {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.barra-item {
  display: flex;
  align-items: center;
  gap: 15px;
}

.barra-label {
  width: 80px;
  font-weight: 600;
  color: #333;
}

.barra-container {
  flex: 1;
  background: #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
  height: 30px;
  position: relative;
}

.barra {
  height: 100%;
  border-radius: 10px;
  transition: width 0.5s ease;
  position: relative;
}

.barra-texto {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: white;
  font-weight: 600;
  font-size: 0.9em;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Detalle del ciclo */
.detalle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 15px;
  border-bottom: 2px solid #eee;
}

.detalle-header h2 {
  color: #667eea;
  margin: 0;
}

.detalle-info {
  margin-bottom: 30px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.info-item {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
}

.info-item label {
  font-weight: 600;
  color: #666;
  display: block;
  margin-bottom: 5px;
}

.info-item .valor {
  font-size: 1.2em;
  color: #333;
}

.notas-section {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
}

.notas-section label {
  font-weight: 600;
  color: #666;
  display: block;
  margin-bottom: 10px;
}

.notas-content {
  color: #333;
  line-height: 1.6;
}

/* Huevos en detalle */
.huevos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.huevo-detalle {
  background: #f9f9f9;
  padding: 15px;
  border-radius: 8px;
  border-left: 4px solid #667eea;
}

.huevo-detalle.fertil {
  border-left-color: #4caf50;
}

.huevo-detalle.en_desarrollo {
  border-left-color: #ff9800;
}

.huevo-detalle.muerto {
  border-left-color: #f44336;
}

.huevo-detalle.infertil {
  border-left-color: #9e9e9e;
}

.huevo-header h4 {
  margin: 0 0 10px 0;
  color: #333;
}

.huevo-info p {
  margin-bottom: 8px;
  font-size: 0.9em;
}

.estado-badge,
.resultado-badge {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.8em;
  font-weight: 600;
}

.estado-badge {
  background: #e3f2fd;
  color: #1976d2;
}

.resultado-badge.fertil {
  background: #e8f5e8;
  color: #2e7d32;
}

.resultado-badge.en_desarrollo {
  background: #fff3e0;
  color: #ef6c00;
}

.resultado-badge.muerto {
  background: #ffebee;
  color: #c62828;
}

.resultado-badge.infertil {
  background: #f5f5f5;
  color: #616161;
}

/* Galería */
.galeria {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
  margin-top: 20px;
}

.media-item {
  background: #f5f5f5;
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.3s;
}

.media-item:hover {
  transform: scale(1.05);
}

.galeria img,
.galeria video {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

/* Mensajes */
.mensaje {
  padding: 15px 25px;
  border-radius: 5px;
  color: white;
  font-weight: 600;
  margin-bottom: 20px;
  animation: slideIn 0.3s;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.mensaje.exito {
  background: #28a745;
}

.mensaje.error {
  background: #dc3545;
}

/* Responsive */
@media (max-width: 768px) {
  header h1 {
    font-size: 1.8em;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .stats-container {
    grid-template-columns: 1fr 1fr;
  }

  .ciclo-info {
    grid-template-columns: 1fr 1fr;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .huevos-grid {
    grid-template-columns: 1fr;
  }

  .ciclo-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .ciclo-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .detalle-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }

  .search-bar {
    flex-direction: column;
  }

  .search-bar input {
    width: 100%;
  }

  .galeria {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

@media (max-width: 480px) {
  body {
    padding: 10px;
  }

  .container {
    border-radius: 10px;
  }

  header {
    padding: 20px;
  }

  .tab-content {
    padding: 20px;
  }

  .tabs {
    flex-direction: column;
  }

  .tab-btn {
    text-align: center;
  }

  .ciclo-info {
    grid-template-columns: 1fr;
  }

  .stats-container {
    grid-template-columns: 1fr;
  }
}

/*para loading*/
/* Loading Spinner */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  flex-direction: column;
}

.loading-overlay.active {
  display: flex;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #f3f3f3;
  border-top: 5px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

.loading-text {
  color: white;
  font-size: 1.2em;
  font-weight: 600;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Deshabilitar formulario durante loading */
.form-disabled {
  pointer-events: none;
  opacity: 0.6;
}

/* Modal Galería */
.modal-galeria {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 10000;
  justify-content: center;
  align-items: center;
}

.modal-galeria.active {
  display: flex;
}

.modal-galeria-content {
  position: relative;
  max-width: 90%;
  max-height: 90%; /* Recuperamos la altura completa */
  text-align: center;
  padding-top: 60px; /* Espacio para los controles superiores */
  padding-bottom: 80px; /* Espacio para el botón descargar */
}

@media (max-width: 768px) {
  .modal-galeria-content {
    max-height: 85%;
    padding-top: 70px;
    padding-bottom: 100px;
  }
}

.modal-media {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 10px;
}

.modal-video {
  max-width: 90vw;
  max-height: 80vh;
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  color: white;
  font-size: 2.5em;
  cursor: pointer;
  background: none;
  border: none;
  z-index: 10001;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.3s;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.8);
  color: #333;
  border: none;
  padding: 15px 20px;
  cursor: pointer;
  font-size: 1.5em;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  font-weight: bold;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.modal-nav:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.modal-prev {
  left: 20px;
}

.modal-next {
  right: 20px;
}

.modal-download {
  position: absolute;
  bottom: 0px; /* Posición fija desde abajo */
  left: 50%;
  transform: translateX(-50%);
  background: #667eea;
  color: white;
  border: none;
  padding: 12px 25px;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
  font-size: 1em;
  white-space: nowrap;
  z-index: 10001;
}

@media (max-width: 768px) {
  .modal-download {
    bottom: 15px;
    padding: 15px 30px;
    font-size: 1.1em;
  }
}

.modal-download:hover {
  background: #5a6fd8;
  text-decoration: none;
  color: white;
}

.media-counter {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-size: 1.2em;
  background: rgba(0, 0, 0, 0.7);
  padding: 8px 20px;
  border-radius: 20px;
  font-weight: 600;
  z-index: 10001;
}

.btnElilimar {
  background-color: #dc3545;
  border-color: #dc3545;
  color: white;
  padding: 10px 20px;
  border-radius: 5px;
  text-decoration: none;
  display: inline-block;
  font-weight: bold;
  cursor: pointer;
}
.btnElilimar:hover {
  background-color: #c82333;
  border-color: #bd2130;
}

/*===============para modal editar*/
/* Modal Edición */
/*===============para modal editar*/
/* Modal Edición */
.modal-edicion-content {
  position: relative;
  background: white;
  padding: 50px 30px 30px 30px; /* Más padding arriba para el botón cerrar */
  border-radius: 15px;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  width: 95%;
  margin: 20px;
}

.modal-edicion-content h2 {
  color: #667eea;
  margin-bottom: 20px;
  text-align: center;
  font-size: 1.5em; /* Tamaño más razonable */
  padding: 0 40px; /* Espacio para el botón cerrar */
  word-break: break-word; /* Evitar que el título sea demasiado largo */
}

/* Ajustar botón cerrar en modal edición */
.modal-edicion-content .modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  color: #666;
  font-size: 1.8em; /* Tamaño más pequeño */
  cursor: pointer;
  background: none;
  border: none;
  z-index: 10001;
  width: 35px;
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.3s;
}

.modal-edicion-content .modal-close:hover {
  background: rgba(0, 0, 0, 0.1);
}

.galeria-edicion {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 15px;
  margin: 15px 0;
}

.media-item-edicion {
  position: relative;
  background: #f5f5f5;
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.3s;
}

.media-item-edicion:hover {
  transform: scale(1.05);
}

.media-item-edicion img,
.media-item-edicion video {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}

.eliminar-media {
  position: absolute;
  top: 5px;
  right: 5px;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 50%;
  width: 25px;
  height: 25px;
  cursor: pointer;
  font-size: 0.8em;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
}

.eliminar-media:hover {
  background: #c82333;
}

.modal-actions {
  display: flex;
  gap: 15px;
  justify-content: flex-end;
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

/* Responsive para modal edición */
@media (max-width: 768px) {
  .modal-edicion-content {
    padding: 20px;
    margin: 10px;
  }

  .modal-actions {
    flex-direction: column;
  }

  .galeria-edicion {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}

#btn_guardar {
  margin-right: 5px;
}

/*botones agregar*/
/* Agregar después de los estilos existentes */
/*botones agregar*/
.select-with-button {
  display: flex;
  align-items: center;
  gap: 10px;
}

.select-with-button select {
  flex: 1;
}

.add-option-btn {
  background: #28a745;
  color: white;
  border: none;
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 10px;
  transition: background 0.3s;
  white-space: nowrap;
  flex-shrink: 0;
}

.add-option-btn:hover {
  background: #218838;
}

.option-input-container {
  display: none;
  gap: 8px;
  margin-top: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.option-input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  min-width: 100px;
}

.option-input-container .btn-primary,
.option-input-container .btn-secondary {
  padding: 6px 12px;
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
}

.option-buttons {
  display: flex;
  gap: 6px;
  width: 100%;
}

/* Responsive para móviles - OPTIMIZADO */
@media (max-width: 768px) {
  .option-input-container {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    margin-top: 4px;
  }

  .option-input {
    min-width: auto;
    width: 100%;
    padding: 5px 8px;
    font-size: 12px;
  }

  .option-input-container .btn-primary,
  .option-input-container .btn-secondary {
    width: 100%;
    padding: 6px 8px;
    font-size: 11px;
  }

  .select-with-button {
    flex-direction: column;
    gap: 6px;
  }

  .select-with-button select {
    width: 100%;
    padding: 6px 8px;
    font-size: 13px;
  }

  .add-option-btn {
    width: 100%;
    padding: 6px 8px;
    font-size: 11px;
  }

  .option-buttons {
    flex-direction: row;
    gap: 4px;
  }

  .option-buttons .btn-primary,
  .option-buttons .btn-secondary {
    flex: 1;
    padding: 4px 6px;
    font-size: 10px;
  }
}

@media (max-width: 480px) {
  .option-input-container {
    gap: 4px;
  }

  .option-input {
    padding: 4px 6px;
    font-size: 11px;
  }

  .option-input-container .btn-primary,
  .option-input-container .btn-secondary {
    padding: 4px 6px;
    font-size: 10px;
  }

  .select-with-button {
    gap: 4px;
  }

  .select-with-button select {
    padding: 4px 6px;
    font-size: 12px;
  }

  .add-option-btn {
    padding: 4px 6px;
    font-size: 10px;
  }

  .option-buttons {
    gap: 3px;
  }

  .option-buttons .btn-primary,
  .option-buttons .btn-secondary {
    padding: 3px 5px;
    font-size: 9px;
  }
}

@media (max-width: 360px) {
  .option-input-container {
    gap: 3px;
  }

  .option-input {
    padding: 3px 5px;
    font-size: 10px;
  }

  .option-input-container .btn-primary,
  .option-input-container .btn-secondary {
    padding: 3px 5px;
    font-size: 9px;
  }

  .select-with-button select {
    padding: 3px 5px;
    font-size: 11px;
  }

  .add-option-btn {
    padding: 3px 5px;
    font-size: 9px;
  }
}

#btn_editarCiclo {
  margin-top: 5px;
}

/*==============boton exportar================*/
/* Contenedor buscar y exportar */
.search-export-container {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-form {
  flex: 1;
  min-width: 300px;
}

.export-section {
  flex-shrink: 0;
}

.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  white-space: nowrap;
}

/* Responsive para buscar/exportar */
@media (max-width: 768px) {
  .search-export-container {
    flex-direction: column;
    gap: 15px;
  }

  .search-form {
    width: 100%;
    min-width: auto;
  }

  .search-bar {
    flex-direction: column;
  }

  .export-section {
    width: 100%;
    text-align: center;
  }

  .export-btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .search-export-container {
    gap: 10px;
  }
}
