/* =============================================
   VARIABLES Y CONFIGURACIÓN GLOBAL
   ============================================= */
:root {
  --primary: #ff8a37;        /* Naranja principal */
  --secondary: #dc3545;       /* Rojo */
  --success: #3ff339;         /* Verde */
  --danger: #dc3545;          /* Rojo */
  --warning: #ff8a37;         /* Naranja */
  --info: #ff8a37;            /* Naranja */
  --light: #f8f9fa;
  --dark: #2c3e50;
  --white: #ffffff;
  --gray: #6c757d;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 15px 40px rgba(0, 0, 0, 0.2);
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-image: url('../img/imagenfondo4.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  position: relative;
  padding: 1rem;
}

body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(3px);
  z-index: 0;
}

/* =============================================
   CONTENEDOR PRINCIPAL
   ============================================= */
.container {
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  padding: 2rem;
  border-radius: 40px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3), 0 0 0 2px var(--primary) inset;
  border: 1px solid rgba(255,138,55,0.3);
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  transition: var(--transition);
}

.container:hover {
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4), 0 0 0 2px var(--secondary) inset;
}

/* =============================================
   TÍTULOS
   ============================================= */
h1 {
  color: var(--primary);
  text-align: center;
  margin-bottom: 2rem;
  font-weight: 700;
  font-size: 2.5rem;
  position: relative;
  padding-bottom: 1rem;
  letter-spacing: -0.5px;
  border-bottom: none;
}

h1::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 2px;
}

h2 {
  color: var(--dark);
  text-align: center;
  margin-bottom: 2rem;
  font-weight: 600;
  font-size: 2rem;
  position: relative;
  padding-bottom: 0.8rem;
  border-bottom: none;
}

h2::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 2px;
}

/* =============================================
   FORMULARIOS
   ============================================= */
label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--dark);
  font-size: 0.95rem;
  letter-spacing: 0.3px;
}

.required-field::after {
  content: ' *';
  color: var(--danger);
  font-weight: bold;
}

input[type='text'],
input[type='number'],
input[type='date'],
select,
textarea {
  width: 100%;
  padding: 0.8rem 1.2rem;
  border: 2px solid #e0e0e0;
  border-radius: 15px;
  font-size: 1rem;
  transition: var(--transition);
  background-color: var(--white);
  color: var(--dark);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

input[type='text']:focus,
input[type='number']:focus,
input[type='date']:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 4px rgba(255,138,55,0.1);
  background-color: var(--white);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%232c3e50' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
}

/* =============================================
   BOTONES
   ============================================= */
.btn-submit, .btn, button[type="button"], .botonLimpiar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 1.8rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
  width: auto;
  margin: 0.5rem 0;
}

.btn-submit::before, .btn::before, button[type="button"]::before, .botonLimpiar::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn-submit:hover::before, .btn:hover::before, button[type="button"]:hover::before, .botonLimpiar:hover::before {
  width: 300px;
  height: 300px;
}

.btn-submit {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--white);
  margin-left: 0; /* quitamos el margin-left fijo */
  width: auto;
  min-width: 200px;
}

.btn-submit:hover {
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(255,138,55,0.4);
}

.botonLimpiar {
  background: linear-gradient(135deg, var(--success), #2ecc71);
  color: var(--dark);
  border: none;
}

.botonLimpiar:hover {
  background: linear-gradient(135deg, #2ecc71, var(--success));
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(63,243,57,0.4);
}

/* Botón de eliminar (rojo) */
.remove-btn {
  background: linear-gradient(135deg, var(--danger), #c0392b);
  color: white;
  border: none;
  padding: 0.8rem 1.2rem;
  border-radius: 30px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 5px 10px rgba(220,53,69,0.3);
}

.remove-btn:hover {
  background: linear-gradient(135deg, #c0392b, var(--danger));
  transform: scale(1.05);
  box-shadow: 0 8px 15px rgba(220,53,69,0.4);
}

/* =============================================
   FILAS DINÁMICAS (items-container)
   ============================================= */
.items-container {
  margin-bottom: 1.5rem;
}

.item-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  align-items: center;
}

.item-row input {
  flex: 1;
}

/* =============================================
   TABLAS
   ============================================= */
.table-responsive {
  overflow-x: auto;
  margin-top: 2rem;
  border-radius: 30px;
  background: rgb(255, 136, 0);
  backdrop-filter: blur(5px);
  padding: 5px;
  box-shadow: 0 15px 30px rgba(0,0,0,0.1);
  border: 2px solid var(--primary);
}

#tablaRegistros {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
  border-radius: 30px;
  overflow: hidden;
}

#tablaRegistros thead th {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  font-weight: 600;
  padding: 1rem;
  text-align: center;
  border: none;
}

#tablaRegistros tbody td {
  padding: 0.8rem;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  color: var(--dark);
  background: rgba(255,255,255,0.7);
}

#tablaRegistros tbody tr:hover {
  background-color: rgba(255,138,55,0.15) !important;
  cursor: pointer;
  transition: var(--transition);
}

#tablaRegistros tbody tr.selected {
  background-color: rgba(220,53,69,0.2) !important;
  border-left: 4px solid var(--secondary);
}

/* =============================================
   SPINNER Y TOAST (mantenidos y mejorados)
   ============================================= */
.spinner2 {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 70px;
  height: 70px;
  border: 5px solid rgba(255,138,55,0.2);
  border-top-color: var(--primary);
  border-right-color: var(--secondary);
  border-bottom-color: var(--success);
  border-left-color: var(--warning);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 10000;
  transform: translate(-50%, -50%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

#toast2 {
  position: fixed;
  top: 30px;
  right: 20px;
  min-width: 350px;
  max-width: 500px;
  padding: 1rem 1.5rem;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  color: var(--dark);
  border-radius: 50px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  opacity: 0;
  font-size: 1rem;
  font-weight: 600;
  pointer-events: none;
  border-left: 5px solid var(--success);
  border-right: 5px solid var(--primary);
  text-align: center;
}

#toast2.show {
  animation: fadeInRight 0.5s forwards;
}

#toast2.hide {
  animation: fadeOutRight 0.5s forwards;
}

@keyframes fadeInRight {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeOutRight {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100%); }
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
  .container {
    padding: 1.5rem;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.6rem;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .btn-submit {
    width: 100%;
  }

  .item-row {
    flex-direction: column;
    gap: 5px;
  }

  .remove-btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.3rem;
  }
}