/* ESTILOS GENERALES */
body { 
  font-family: sans-serif; 
  padding: 20px; 
  margin: 0;
  background-color: #f8f9fa;
}

table { 
  width: 100%; 
  border-collapse: collapse; 
  margin-top: 20px; 
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

th, td { 
  padding: 10px; 
  border: 1px solid #ccc; 
  text-align: center; 
}

button { 
  padding: 6px 10px; 
  margin: 2px; 
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.logo {
  height: 50px;
  width: auto;
}

.datos-cambio {
  margin: 20px 0;
  padding: 15px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #f9f9f9;
  max-width: 100%;
}

.campos-datos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 24px;
}

.campos-datos label {
  display: flex;
  flex-direction: column;
  font-weight: 500;
  font-size: 14px;
}

.campos-datos input {
  margin-top: 4px;
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.campo-obligatorio {
  background-color: #fff9f9;
  border-left: 3px solid #dc3545 !important;
}

.campo-valido {
  border-left: 3px solid #28a745 !important;
}

.mensaje-error {
  color: #dc3545;
  font-size: 0.8rem;
  margin-top: 4px;
  display: none;
}

#tabla thead th {
  background-color: #1e37a4;
  color: white;
  padding: 10px;
  text-align: center;
  font-weight: bold;
  border: 1px solid #ccc;
}

#tablaParos thead th {
  background-color: #1e37a4;
  color: white;
  padding: 10px;
  text-align: center;
  font-weight: bold;
  border: 1px solid #ccc;
}

/* BOTONES */
.btn {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  color: white;
  font-weight: bold;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  transform-origin: center;
}

.btn:hover {
  transform: scale(1.05);
  opacity: 0.9;
}

.btn:active {
  transform: scale(0.95);
}

.btn.iniciar { 
  background-color: #28a745; 
}

.btn.iniciar:hover { 
  background-color: #218838; 
}

.btn.pausar { 
  background-color: #ffc107; 
  color: #333; 
}

.btn.pausar:hover { 
  background-color: #e0a800; 
}

.btn.reanudar {
  background-color: #17a2b8;
}

.btn.detener { 
  background-color: #dc3545; 
}

.btn.detener:hover { 
  background-color: #c82333; 
}

/* TABLAS */
#tabla tbody td {
  padding: 6px;
  border: 1px solid #ccc;
  text-align: center;
}

/* TOAST NOTIFICATIONS */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 24px;
  background: #333;
  color: white;
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  z-index: 1000;
  animation: fadeInOut 3s ease-in-out;
}

.toast-success { background: #4CAF50; }
.toast-error { background: #F44336; }
.toast-warning { background: #FF9800; }

@keyframes fadeInOut {
  0%, 100% { opacity: 0; transform: translateY(10px); }
  10%, 90% { opacity: 1; transform: translateY(0); }
}

/* CHECKLIST */
#pantalla-checklist {
  display: none;
}

#tabla-checklist {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
}

#tabla-checklist thead th {
  background-color: #1e37a4;
  color: white;
  padding: 10px;
  border: 1px solid #ccc;
  text-align: center;
  font-weight: bold;
}

#tabla-checklist tbody td {
  border: 1px solid #ccc;
  padding: 8px 12px;
  vertical-align: middle;
}

#tabla-checklist tbody td.checkbox-cell {
  text-align: center;
  width: 60px;
}

#tabla-checklist tbody td.desc-cell {
  text-align: left;
  padding-left: 15px;
}

#tabla-checklist input[type="checkbox"] {
  transform: scale(1.3);
  cursor: pointer;
}

/* ESTILOS PARA VALIDACIÓN DE DATOS */
.campo-valido {
  border-left: 3px solid #4CAF50 !important;
  background-color: #f8fff8 !important;
}

.campo-invalido {
  border-left: 3px solid #F44336 !important;
  background-color: #fff8f8 !important;
}

.campo-obligatorio:not(:focus) {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { background-color: #fff9f9; }
  50% { background-color: #fff0f0; }
}

.valid-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
}

.valid-icon.valid {
  color: #4CAF50;
}

.valid-icon.invalid {
  color: #F44336;
}

/* ANIMACIONES Y EFECTOS */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

#tabla tr, #tablaParos tr {
  animation: fadeIn 0.3s ease-out;
}

@keyframes bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.guardado {
  animation: bounce 0.5s;
}

/* Sortable.js clases */
.sortable-chosen {
  opacity: 0.8;
  box-shadow: 0 0 15px rgba(0,0,0,0.2);
  border-radius: 8px;
  transform: scale(1.02);
}

.sortable-ghost {
  opacity: 0.4;
}

/* Campos de edición de tiempo */
.edit-tiempo-input {
  width: 70px;
  padding: 6px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* RESPONSIVE - MÓVILES */
@media (max-width: 768px) {
  body {
    padding: 10px;
    padding-bottom: 100px;
  }
  
  .header {
    flex-direction: column;
    text-align: center;
    gap: 8px;
  }
  
  .campos-datos {
    grid-template-columns: 1fr !important;
    gap: 8px;
  }
  
  /* Tablas en modo tarjeta para móviles */
  .table-container {
    overflow-x: auto;
    margin-bottom: 1rem;
    border-radius: 8px;
  }
  
  #tabla, #tablaParos {
    display: flex;
    flex-direction: column;
    min-width: 100%;
  }
  
  #tabla thead, #tablaParos thead {
    display: none;
  }
  
  #tabla tr, #tablaParos tr {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 12px;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  }
  
  #tabla td, #tablaParos td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 8px;
    border: none;
    border-bottom: 1px solid #f5f5f5;
    text-align: right;
  }
  
  #tabla td:last-child, #tablaParos td:last-child {
    border-bottom: none;
  }
  
  #tabla td::before, #tablaParos td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #1e37a4;
    margin-right: 12px;
    flex: 1;
    text-align: left;
  }
  
  #tabla td > *, #tablaParos td > * {
    flex: 2;
    text-align: right;
  }
  
  /* formato de celda de "Orden" */
  #tabla td.drag-handle {
    background-color: #1e37a4;
    color: white;              
    text-align: center;
    font-weight: bold;
  }

  #tabla td.drag-handle .drag-icon {
    color: white;
    font-size: 30px;
  }
  #tabla td.drag-handle::before {
    color: white !important;
    font-weight: bold;
  }
  
  /* Resaltar nombre de actividades en móvil */
  #tabla td.editable {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
  }
  
  /* Drag handle para móviles */
  .drag-handle {
    display: table-cell !important;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
  }
  
  .drag-icon {
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    padding: 12px;
    display: inline-block;
    cursor: grab;
    font-size: 1.2rem;
    color: #1e37a4;
  }
  
  /* Botones de paros específicos para móvil */
  #tablaParos .btn {
    width: 36px;     
    height: 36px;
    display: flex;   
    align-items: center;
    justify-content: center;
    font-size: 18px;  
    padding: 0;      
    margin: 2px;      
    border-radius: 6px; 
  }
  
  #tablaParos td[data-label="Acciones"] {
    display: flex;
    gap: 5px;
    justify-content: flex-end;
  }
  
  #tablaParos td[data-label="Acciones"] button {
    flex: none;
    width: 40px;
    padding: 6px 0;
  }
  
  /* Botones de eliminar en móvil */
  #tablaParos button.icon-btn,
  #tabla button[onclick^="eliminarActividad"] {
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;  
    padding: 0;
    margin: 2px;
    border-radius: 6px;
    background: #f8f8f8;
    border: 1px solid #ddd;
    cursor: pointer;
  }

  #tablaParos button.icon-btn:hover,
  #tabla button[onclick^="eliminarActividad"]:hover {
    background: #f0f0f0;
  }
  
  /* Botón flotante para móviles */
  #btn-add-mobile {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #1e37a4;
    color: white;
    font-size: 28px;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    border: none;
    cursor: pointer;
    z-index: 1000;
  }
  
  #btn-add-mobile:hover {
    background: #14266d;
  }
  
  /* Selectores responsivos */
  .responsive-select {
    font-size: 0.90rem;
    padding: 6px 8px;
    height: 36px;
    max-width: 140px;
  }
  
  /* Botones principales */
  .btn-principal {
    display: block;
    width: 100%;
    padding: 14px;
    margin: 10px 0;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    text-align: center;
  }
  
  .btn-principal.enviar {
    background-color: #28a745;
    color: white;
  }
  
  .btn-principal.restablecer {
    background-color: #dc3545;
    color: white;
  }
  
  .btn-principal.checklist {
    background-color: #1e37a4;
    color: white;
  }
  
  /* Títulos */
  .titulo-app {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1e37a4;
    text-align: center;
    margin: 15px 0;
    letter-spacing: 1px;
  }
  
  /* Campos de edición de tiempo en móvil */
  .edit-tiempo-input {
    width: 100%;
    padding: 10px;
    font-size: 16px;
  }
  
  /* Formato de campos dato del cambio de molde */
  #datosMolde input {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 1rem;
    background-color: #f9f9f9;
  }

  #datosMolde input:focus {
    border-color: #1e37a4;
    background: #fff;
    box-shadow: 0 0 6px rgba(30,55,164,0.3);
    outline: none;
  }

  #datosMolde label {
    font-weight: 600;
    margin-bottom: 4px;
    display: block;
    color: #333;
  }
}

/* Navegación móvil */
.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: white;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  z-index: 900;
}

.mobile-nav button {
  flex: 1;
  padding: 12px;
  border: none;
  background: none;
  font-size: 0.9rem;
}

/* Feedback y mensajes */
#feedback {
  margin: 15px 0;
  padding: 10px;
  border-radius: 4px;
  font-weight: bold;
  text-align: center;
}

hr {
  margin: 30px 0;
  border: none;
  border-top: 1px solid #ddd;
}

/* MEJORAS PARA SORTABLE EN MÓVILES */
.sortable-ghost {
  opacity: 0.4;
  background: #f8f9fa;
}

.sortable-chosen {
  transform: rotate(2deg);
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.sortable-drag {
  opacity: 0.8;
  background: white;
}

/* PREVENIR SELECTION DURING DRAG */
body.sortable-dragging {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* MEJORAR DRAG HANDLE EN MÓVILES */
.drag-icon {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  cursor: grab;
}

.drag-icon:active {
  cursor: grabbing;
}

#modal-editar-tiempo * {
  pointer-events: auto !important;
}

#edit-cancel, #edit-save {
  pointer-events: auto !important;
  cursor: pointer !important;
}


/* MEJORAS PARA DRAG AND DROP */
.sortable-ghost {
  opacity: 0.4;
  background: #f0f0f0;
}

.sortable-chosen {
  transform: rotate(1deg);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.sortable-drag {
  opacity: 0.9;
  background: white;
}

/* MEJORAR DRAG HANDLE */
.drag-icon {
  cursor: grab;
  transition: all 0.2s ease;
  padding: 8px;
  border-radius: 4px;
}

.drag-icon:hover {
  background-color: #f0f0f0;
}

.drag-icon:active {
  cursor: grabbing;
  background-color: #e0e0e0;
}

/* PREVENIR SELECTION DURING DRAG */
body.sortable-dragging {
  user-select: none;
}

/* MEJORAS ESPECÍFICAS PARA MÓVIL */
@media (max-width: 768px) {
  .drag-icon {
    padding: 12px;
    font-size: 1.2rem;
  }
  
  .sortable-chosen {
    transform: none; /* Eliminar rotación en móvil para mejor rendimiento */
  }
}
