/* ════════════════════════════════════════
     UTILIDADES — variables CSS globales
     Incluir PRIMERO en cualquier página
     ════════════════════════════════════════ */

/* ── Reset base ── */
  * { box-sizing: border-box; margin: 0; padding: 0; }

  /* ── Scroll nativo morado (aparece solo cuando hay contenido) ── */
  html {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--color-accent-dark) #1a1a2e;
  }
  html::-webkit-scrollbar          { width: 8px; height: 8px; }
  html::-webkit-scrollbar-track    { background: #1a1a2e; border-radius: 4px; }
  html::-webkit-scrollbar-thumb    { background: var(--color-accent-dark); border-radius: 4px; border: 2px solid #1a1a2e; }
  html::-webkit-scrollbar-thumb:hover { background: var(--color-accent); }
  html::-webkit-scrollbar-corner   { background: transparent; }

  body {
    font-family: Arial, sans-serif;
    background: transparent;
    color: var(--color-text);
  }

  :root {
    --color-bg-deep:      #0c0c16;
    --color-bg-card:      rgba(12, 12, 22, 0.82);
    --color-bg-input:     rgba(18, 18, 31, 0.9);
    --color-border:       #2a2a4a;
    --color-border-card:  rgba(206, 147, 216, 0.18);
    --color-accent:       #ce93d8;
    --color-accent-dark:  #6a1b9a;
    --color-text:         rgba(255, 255, 255, 0.7);
    --color-text-dim:     rgba(255, 255, 255, 0.45);
    --color-text-bright:  rgba(255, 255, 255, 0.9);
    --color-verde:        #81c784;
    --color-rojo:         #ff5252;
    --color-amarillo:     #f9a825;
  }

  /* ── Scrollbar morado (para elementos internos con scroll propio) ── */
  .scroll-morado::-webkit-scrollbar          { width: 8px; height: 8px; }
  .scroll-morado::-webkit-scrollbar-track    { background: #1a1a2e; border-radius: 4px; }
  .scroll-morado::-webkit-scrollbar-thumb    { background: var(--color-accent-dark); border-radius: 4px; border: 2px solid #1a1a2e; }
  .scroll-morado::-webkit-scrollbar-thumb:hover { background: var(--color-accent); }
  .scroll-morado::-webkit-scrollbar-corner  { background: transparent; }
  .scroll-morado { scrollbar-width: thin; scrollbar-color: var(--color-accent-dark) #1a1a2e; }

/* ── Botones utilitarios ── */
  .btn-sm {
    padding: 3px 10px;
    font-size: 15px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .btn-verde-bg {
    background: rgba(76, 175, 80, 0.2);
    border: 1px solid rgba(76, 175, 80, 0.4);
    color: var(--color-text);
  }
  .btn-verde-bg:hover { background: rgba(76, 175, 80, 0.35); color: var(--color-text-bright); }

  .btn-rojo-bg {
    background: rgba(244, 67, 54, 0.2);
    border: 1px solid rgba(244, 67, 54, 0.4);
    color: var(--color-text);
  }
  .btn-rojo-bg:hover { background: rgba(244, 67, 54, 0.35); color: var(--color-text-bright); }

  .btn-azul-bg {
    background: rgba(33, 150, 243, 0.2);
    border: 1px solid rgba(33, 150, 243, 0.4);
    color: var(--color-text);
  }
  .btn-azul-bg:hover { background: rgba(33, 150, 243, 0.35); color: var(--color-text-bright); }

  .btn-amarillo-bg {
    background: rgba(255, 193, 7, 0.2);
    border: 1px solid rgba(255, 193, 7, 0.4);
    color: var(--color-text);
  }
  .btn-amarillo-bg:hover { background: rgba(255, 193, 7, 0.35); color: var(--color-text-bright); }

  .btn-morado-bg {
    background: rgba(206, 147, 216, 0.2);
    border: 1px solid rgba(206, 147, 216, 0.4);
    color: var(--color-text);
  }
  .btn-morado-bg:hover { background: rgba(206, 147, 216, 0.35); color: var(--color-text-bright); }

  .btn-sm:disabled,
  .btn-verde-bg:disabled,
  .btn-rojo-bg:disabled,
  .btn-azul-bg:disabled,
  .btn-amarillo-bg:disabled,
  .btn-morado-bg:disabled {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.3) !important;
    cursor: not-allowed !important;
  }

/* ── Tarjetas / secciones ── */
  .form-section {
    margin-bottom: 15px;
    border: 1px solid var(--color-border-card);
    border-radius: 14px;
    padding: 12px;
    background: var(--color-bg-card);
    width: 100%;
  }

  .form-section-title {
    font-size: 17px;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--color-accent);
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
  }

  .form-section-title .titulo-texto { flex-shrink: 0; }

/* ── Toast ── */
  #toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #1a1a2e;
    color: var(--color-text);
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 15px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    border: 1px solid var(--color-border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  }
  #toast.visible { opacity: 1; }
  #toast.success { background: rgba(76, 175, 80, 0.9);  border-color: #4caf50; }
  #toast.error   { background: rgba(244, 67, 54, 0.9);  border-color: #f44336; }

/* ── Input de edición inline en tabla ── */
  .input-edicion {
    width: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 12px;
    color: var(--color-text);
    outline: none;
  }

/* ── Panel de información de registro ── */
  .info-titulo {
    font-weight: 500;
    font-size: 17px;
    color: var(--color-text);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--color-accent);
  }

  .info-fila {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 1px solid var(--color-border);
  }

  .info-label {
    color: var(--color-text);
    font-size: 15px;
    font-weight: 500;
    flex-shrink: 0;
    padding-right: 8px;
  }

  .info-valor {
    font-weight: normal;
    font-size: 15px;
    text-align: right;
    max-width: 200px;
    white-space: normal;
    word-break: break-word;
    color: var(--color-text);
  }

/* ── Quitar elemento de lista (archivos, equipos, etc.) ── */
  .archivo-quitar,
  .equipo-quitar {
    cursor: pointer;
    color: #ff8a80;
    font-weight: 500;
    padding: 0 3px;
    flex-shrink: 0;
  }

/* ── Lista de archivos adjuntos ── */
  .archivo-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 6px;
    margin-bottom: 3px;
    background: #12121f;
    border-radius: 8px;
    font-size: 15px;
    border: 1px solid var(--color-border);
    color: var(--color-text);
  }

/* ── Progreso de subida ── */
  .progreso-box {
    display: none;
    background: #12121f;
    border-radius: 8px;
    padding: 6px;
    flex-shrink: 0;
    border: 1px solid var(--color-border);
  }

  .progreso-texto {
    font-size: 15px;
    color: var(--color-text);
    margin-bottom: 3px;
    text-align: center;
  }

  .progreso-barra-bg {
    width: 100%;
    background: var(--color-border);
    border-radius: 20px;
    height: 10px;
    overflow: hidden;
  }

  .progreso-barra {
    height: 100%;
    width: 0%;
    background: #4caf50;
    border-radius: 20px;
    transition: width 0.3s ease;
  }

  .progreso-ok {
    display: none;
    margin-top: 4px;
    text-align: center;
    color: var(--color-verde);
    font-weight: 500;
    font-size: 15px;
  }

/* ── Preview de archivos en grid ── */
  .lista-archivos {
    max-height: 40px;
    overflow-y: auto;
    flex-shrink: 0;
  }

  .preview-vacio {
    color: var(--color-text-dim);
    font-style: italic;
    font-size: 15px;
    text-align: center;
    padding: 6px 0;
    flex-shrink: 0;
  }

  .preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
    gap: 6px;
  }

  .preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    cursor: pointer;
    transition: transform 0.15s;
    background: #12121f;
  }

  .preview-item:hover { transform: scale(1.05); }
  .preview-item img   { width: 100%; height: 100%; object-fit: cover; }

  .file-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: #12121f;
    color: var(--color-text);
  }

  .file-name {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,0.85);
    color: var(--color-text-bright);
    font-size: 15px;
    padding: 2px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

/* ════════════════════════════════════════
   CONTENEDOR DE TABLA COMPARTIDO
   ════════════════════════════════════════ */
  #tabla-wrapper,
  #tabla-container {
    width: 100%;
    height: 450px;
    overflow-x: auto;
    overflow-y: auto;
    background: #12121f;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    position: relative;
    z-index: 10;
  }

/* ════════════════════════════════════════
   TABLA COMPARTIDA
   ════════════════════════════════════════ */
  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
    table-layout: auto;
    position: relative;
    z-index: 10;
  }

  th {
    background: rgba(26, 26, 46, 0.7);
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 6px 4px;
    text-align: center;
    border-bottom: 2px solid var(--color-accent-dark);
    border-right: 2px solid var(--color-accent-dark);
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    font-size: 15px;
    cursor: pointer;
    user-select: none;
    line-height: 1.2;
    min-width: 60px;
    color: var(--color-accent);
  }

  th:hover       { background: var(--color-border); }
  th:last-child  { border-right: none; }

  td {
    padding: 5px 4px;
    text-align: center;
    border-bottom: 1px solid var(--color-border);
    border-right: 1px solid #1a1a2e;
    vertical-align: middle;
    white-space: normal;
    word-break: normal;
    overflow-wrap: anywhere;
    min-width: 60px;
    max-width: 180px;
    color: var(--color-text);
  }

  td:last-child  { border-right: none; }

  tr:nth-child(odd)  { background: rgba(18, 18, 31, 0.4); }
  tr:nth-child(even) { background: rgba(26, 26, 46, 0.4); }
  tr:hover           { background: #2a1a3a !important; transition: background 0.2s ease; cursor: pointer; }
  td.editando        { background: #3a2a0a !important; box-shadow: inset 0 0 0 2px var(--color-amarillo); }

  .no-results {
    text-align: center;
    padding: 40px;
    color: var(--color-text-dim);
    font-style: italic;
  }

/* ════════════════════════════════════════
   INPUT / SELECT BASE (compartidos)
   ════════════════════════════════════════ */
  .input-base {
    padding: 10px 14px;
    font-size: 17px;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg-input);
    color: var(--color-text);
    width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
  }

  .input-base::placeholder { color: var(--color-text-dim); }

  .input-base:focus {
    border-color: var(--color-accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(206, 147, 216, 0.2);
    color: var(--color-text-bright);
  }

  .select-base {
    padding: 8px 4px;
    font-size: 14px;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg-input);
    cursor: pointer;
    min-width: 0;
    color: var(--color-text);
  }

  .select-base option {
    background: #12121f;
    color: var(--color-text);
  }

/* Layout vertical scrolleable (para páginas tipo Inventario) */
.layout-scroll-y {
  overflow-y: auto;
}

/* ── Layout de página estándar (compartido entre todas las páginas) ── */
.layout-pagina {
  display: flex;
  flex-direction: column;
  padding: 15px;
  gap: 10px;
  box-sizing: border-box;
}

/* Dentro de .layout-pagina el gap maneja la separación; anulamos el margin-bottom de .form-section */
.layout-pagina > .form-section,
.layout-pagina > * > .form-section {
  margin-bottom: 0;
}

/* ════════════════════════════════════════
   PANELES INFERIORES COMPARTIDOS
   ════════════════════════════════════════ */

/* ── Fila inferior: contenedor de columnas ── */
.panel-inferior {
  display: flex;
  gap: 10px;
}

/* ── Columna genérica (Archivos, Imágenes, Acciones, Carrito…) ── */
.panel-subida {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-card);
  border-radius: 14px;
}

/* ── Columna Pendientes (igual a panel-subida pero sin gap interno) ── */
.panel-pendientes {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-card);
  border-radius: 14px;
}

#pendientes-scroll {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#buscar-pendientes { flex-shrink: 0; }

/* ── Área scrolleable interna ── */
.scroll-area {
  display: flex;
  flex-direction: column;
}


/* ── Fila de archivo: Elegir (izq) + botones acción (der) ── */
.archivo-fila {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}

.archivo-fila .archivo-acciones {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

input[type="file"] {
  width: 100%;
  font-size: 15px;
  color: var(--color-text);
}

/* ── Preview "Ver más" ── */
.preview-ver-mas {
  display: none;
  text-align: center;
  font-size: 17px;
  color: var(--color-accent);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Badge de notificaciones sobre botón de pestaña ── */
.reloj-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  border: 2px solid #1a1a2e;
  pointer-events: none;
  z-index: 100;
  font-family: sans-serif;
}

/* ── Alarma: agitación del botón de notas ── */
@keyframes alarmaShake {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  10%, 50%  { transform: translateX(-4px) rotate(-4deg); }
  30%, 70%  { transform: translateX(4px) rotate(4deg); }
  90%       { transform: translateX(-2px) rotate(-2deg); }
}

.alarma-shake {
  animation: alarmaShake 0.5s ease infinite;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.6), 0 0 20px rgba(239,68,68,0.4) !important;
  border-color: #ef4444 !important;
  color: #fca5a5 !important;
}
/* ── Formularios ── */
.form-row {
  display: -webkit-flex;
  display: flex;
  gap: 10px;
  width: 100%;
}

.form-group {
  -webkit-flex: 1;
  flex: 1;
  min-width: 0;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
}

.form-group label {
  font-size: 15px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 3px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 6px 8px;
  border: 2px solid #2a2a4a;
  border-radius: 8px;
  font-size: 15px;
  background: #12121f;
  color: rgba(255, 255, 255, 0.7);
}

.form-group select {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.form-group select option {
  background: #0d0d0d;
  color: rgba(255, 255, 255, 0.7);
}

.form-group textarea {
  resize: none;
  min-height: 50px;
  overflow: hidden;
}

/* ── Toggle switch ── */
.chk-toggle {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.chk-toggle + label {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  background: #2a2a4a;
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.3s ease;
  flex-shrink: 0;
}

.chk-toggle + label::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #888;
  transition: all 0.3s ease;
}

.chk-toggle + label:hover   { background: #3a3a5a; }
.chk-toggle:checked + label { background: #ce93d8; }

.chk-toggle:checked + label::after {
  left: 20px;
  background: #fff;
}

.chk-toggle:focus-visible + label {
  box-shadow: 0 0 0 3px rgba(206, 147, 216, 0.3);
}

/* ── Checkbox cuadrado ── */
.chk-dark {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.chk-dark + label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.7);
  user-select: none;
}

.chk-dark + label::before {
  content: '';
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border: 2px solid #2a2a4a;
  border-radius: 4px;
  background: #0d0d0d;
  transition: all 0.2s ease;
}

.chk-dark + label:hover::before {
  border-color: #ce93d8;
  background: #1a1a2e;
}

.chk-dark:checked + label::before {
  background: #ce93d8;
  border-color: #ce93d8;
}

.chk-dark + label::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 50%;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: translateY(-65%) rotate(45deg) scale(0);
  transition: transform 0.15s ease;
}

.chk-dark:checked + label::after {
  transform: translateY(-65%) rotate(45deg) scale(1);
}

.chk-dark:focus-visible + label::before {
  box-shadow: 0 0 0 3px rgba(206, 147, 216, 0.3);
}

/* ── Tarjeta búsqueda + tabla (base compartida) ── */
.tarjeta-busqueda-tabla {
  margin: 0;
  min-width: 0;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  position: relative;
  z-index: 10;
}

/* ── Botones de acción (compartidos con layout principal) ── */
.btn-buscar {
  background: rgba(33, 150, 243, 0.2);
  border: 1px solid rgba(33, 150, 243, 0.4);
  color: rgba(255, 255, 255, 0.7);
}
.btn-buscar:hover {
  background: rgba(33, 150, 243, 0.35);
  color: rgba(255, 255, 255, 0.9);
}

.btn-reset {
  background: rgba(255, 193, 7, 0.2);
  border: 1px solid rgba(255, 193, 7, 0.4);
  color: rgba(255, 255, 255, 0.7);
}
.btn-reset:hover {
  background: rgba(255, 193, 7, 0.35);
  color: rgba(255, 255, 255, 0.9);
}

.btn-verde {
  background: rgba(76, 175, 80, 0.2);
  border: 1px solid rgba(76, 175, 80, 0.4);
  color: rgba(255, 255, 255, 0.7);
}
.btn-verde:hover {
  background: rgba(76, 175, 80, 0.35);
  color: rgba(255, 255, 255, 0.9);
}

.btn-rojo {
  background: rgba(244, 67, 54, 0.2);
  border: 1px solid rgba(244, 67, 54, 0.4);
  color: rgba(255, 255, 255, 0.7);
}
.btn-rojo:hover {
  background: rgba(244, 67, 54, 0.35);
  color: rgba(255, 255, 255, 0.9);
}

.btn-azul {
  background: rgba(33, 150, 243, 0.2);
  border: 1px solid rgba(33, 150, 243, 0.4);
  color: rgba(255, 255, 255, 0.7);
}
.btn-azul:hover {
  background: rgba(33, 150, 243, 0.35);
  color: rgba(255, 255, 255, 0.9);
}

.btn-buscar, .btn-reset, .btn-verde, .btn-rojo, .btn-azul {
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  flex-shrink: 0;
  transition: all 0.2s;
}

.btn-buscar:disabled, .btn-reset:disabled, .btn-verde:disabled,
.btn-rojo:disabled, .btn-azul:disabled {
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: rgba(255, 255, 255, 0.3) !important;
  cursor: not-allowed !important;
}
