/* Reset básico */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: system-ui, sans-serif;
}

body {
  background-color: #f9fafb;
  color: #111827;
  line-height: 1.6;
}

/* Layout principal */
.page-container {
  display: flex;
  min-height: 100vh;
}

main {
  flex: 1;
  padding: 2rem;
}

/* --- NAV --- */
nav {
  background-color: #1e3a8a;
  padding: 1rem 2rem;
  border-radius: 0.5rem;
  margin-bottom: 2rem;
  display: flex;
  justify-content: center;
  gap: 1.5rem;
}

nav a {
  color: #fff;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

nav a:hover {
  color: #93c5fd;
}

/* --- Títulos --- */
h1 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: #1d4ed8;
}

h2 {
  margin: 2rem 0 1rem;
  font-size: 1.25rem;
  color: #1e3a8a;
}

h3 {
  margin: 1rem 0 0.5rem;
  font-size: 1.1rem;
  color: #1e3a8a;
}

/* --- Secciones del formulario --- */
section.section {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

/* Grid de inputs */
.grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.field-row {
  display: flex;
  flex-direction: column;
  overflow: auto;
  max-height: 126px;
}

label {
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: #1e3a8a;
}

/* Inputs y selects */
input,
select,
textarea {
  padding: 0.6rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #3b82f6;
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

/* Botones */
button {
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  border-radius: 0.5rem;
  padding: 0.6rem 1.2rem;
  border: none;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

button.primary {
  background-color: #3b82f6;
  color: white;
}

button.primary:hover {
  background-color: #1d4ed8;
}

button.secundary {
  background-color: #e0f2fe;
  color: #1d4ed8;
}

button.secundary:hover {
  background-color: #bfdbfe;
}

button.danger {
  background-color: #f87171;
  color: white;
}

button.danger:hover {
  background-color: #ef4444;
}

button.ghost {
  background-color: transparent;
  color: #1e3a8a;
  border: 1px solid #1e3a8a;
}

button.ghost:hover {
  background-color: #1e3a8a;
  color: white;
}

/* Errores y notas */
.error {
  color: #dc2626;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.note {
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 0.25rem;
}

.sidebar {
  position: fixed;
  top: 0;
  left: -300px;
  width: 300px;
  height: 100%;
  background-color: #1e3a8a;
  color: white;
  transition: left 0.3s ease;
  padding: 20px;
  padding-top: 70px;
  overflow-y: auto;
  z-index: 999;
}

/* Sidebar visible */
.sidebar.active {
  left: 0;
}

/* Estilos lista */
.sidebar ul {
  list-style: none;
  padding: 0;
}

.sidebar li {
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  padding-bottom: 10px;
}

.sidebar strong {
  font-size: 16px;
}

.sidebar small {
  display: block;
  font-size: 13px;
  color: #ddd;
}

/* Botón flotante */
.menu-btn {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 1000;
  background: #fff;
  border: 1px solid #ccc;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  color: black;
}

.inventario-side-info--productos {
  position: relative;
}

#mainContent {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 2rem;
}

.inventario-header {
  grid-column: 1 / 3;
}

.actions {
  width: 100%;
  grid-column: 1 / 5;
  display: flex;
  justify-content: end;
}

/* Contenedor lateral */
.container-detalle-producto {
  position: fixed;
  top: 90px;
  right: 0;
  background: #f9fafb;
  border-left: 3px solid #1d4ed8;
  box-shadow: -4px 0 12px rgba(0, 0, 0, 0.1);
  padding: 1rem;
  overflow-y: auto;
  z-index: 1000;
  width: 300px;
  max-height: 80vh;
}

.container-detalle-producto h3 {
  color: #1e3a8a;
  font-size: 1.2rem;
  margin-bottom: 1rem;
  text-align: center;
  border-bottom: 2px solid #3b82f6;
  padding-bottom: 0.5rem;
}

/* Lista de detalles */
.detalle-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 250px;
}

/* Tarjetas */
.detalle-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 1rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.detalle-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* Cabecera */
.detalle-header {
  background: #3b82f6;
  color: #fff;
  font-weight: bold;
  border-radius: 0.5rem;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.8rem;
  text-align: center;
}

/* Cuerpo */
.detalle-body p {
  margin: 0.3rem 0;
  font-size: 0.95rem;
  color: #111827;
}

.detalle-body b {
  color: #1e3a8a;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
  background-color: #fefefe;
  margin: 5% auto;
  padding: 2rem;
  border-radius: 0.75rem;
  width: 80%;
  max-width: 600px;
  position: relative;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  position: absolute;
  top: 1rem;
  right: 1.5rem;
}

.close:hover,
.close:focus {
  color: #000;
}

/* Tabla de inventario */
.tabla-container {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin: 2rem 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.tabla-wrapper {
  overflow-x: auto;
  margin-top: 1rem;
}

.tabla-inventario {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.tabla-inventario th,
.tabla-inventario td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

.tabla-inventario th {
  background-color: #f8fafc;
  font-weight: 600;
  color: #1e3a8a;
  position: sticky;
  top: 0;
}

.tabla-inventario tr:hover {
  background-color: #f8fafc;
}

/* Estados de stock */
.stock-bajo {
  color: #f59e0b;
  font-weight: 600;
}

.stock-agotado {
  color: #dc2626;
  font-weight: 600;
}

.stock-disponible {
  color: #059669;
  font-weight: 600;
}

/* Botones de acción en tabla */
.accion-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  margin: 0 0.25rem;
}

.accion-btn.editar {
  background-color: #3b82f6;
  color: white;
}

.accion-btn.eliminar {
  background-color: #dc2626;
  color: white;
}

.accion-btn.ver {
  background-color: #6b7280;
  color: white;
}

/* Sidebar de resumen del inventario */
.sidebar-inventario {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  height: fit-content;
  position: sticky;
  top: 2rem;
}

.sidebar-inventario h3 {
  color: #1e3a8a;
  font-size: 1.2rem;
  margin-bottom: 1.5rem;
  text-align: center;
  border-bottom: 2px solid #3b82f6;
  padding-bottom: 0.5rem;
}

.sidebar-inventario h4 {
  color: #374151;
  font-size: 1rem;
  margin: 1.5rem 0 0.75rem 0;
  font-weight: 600;
}

/* Estadísticas generales */
.resumen-estadisticas {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 1rem;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.stat-number {
  font-size: 1.5rem;
  font-weight: bold;
  color: #1e3a8a;
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.875rem;
  color: #6b7280;
  font-weight: 500;
}

/* Listas de productos */
.lista-productos,
.lista-categorias,
.lista-movimientos {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.producto-item {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  transition: background-color 0.2s ease;
}

.producto-item:hover {
  background: #f3f4f6;
}

.producto-nombre {
  font-weight: 600;
  color: #1e3a8a;
  margin-bottom: 0.25rem;
}

.producto-stock {
  color: #6b7280;
  font-size: 0.8rem;
}

.stock-bajo-item {
  border-left: 3px solid #f59e0b;
  background: #fef3c7;
}

.stock-agotado-item {
  border-left: 3px solid #dc2626;
  background: #fee2e2;
}

.categoria-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  background: #f8fafc;
  border-radius: 0.375rem;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.categoria-nombre {
  font-weight: 500;
  color: #374151;
}

.categoria-cantidad {
  background: #3b82f6;
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.movimiento-item {
  background: #f8fafc;
  border-left: 3px solid #3b82f6;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.8rem;
}

.movimiento-tipo {
  font-weight: 600;
  color: #1e3a8a;
}

.movimiento-producto {
  color: #6b7280;
  margin: 0.25rem 0;
}

.movimiento-fecha {
  color: #9ca3af;
  font-size: 0.75rem;
}

.sin-productos {
  color: #9ca3af;
  font-style: italic;
  text-align: center;
  padding: 1rem;
  font-size: 0.875rem;
}

/* Scrollbar personalizado */
.lista-productos::-webkit-scrollbar,
.lista-categorias::-webkit-scrollbar,
.lista-movimientos::-webkit-scrollbar {
  width: 6px;
}

.lista-productos::-webkit-scrollbar-track,
.lista-categorias::-webkit-scrollbar-track,
.lista-movimientos::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}

.lista-productos::-webkit-scrollbar-thumb,
.lista-categorias::-webkit-scrollbar-thumb,
.lista-movimientos::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.lista-productos::-webkit-scrollbar-thumb:hover,
.lista-categorias::-webkit-scrollbar-thumb:hover,
.lista-movimientos::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Responsive */
@media (max-width: 1024px) {
  #mainContent {
    grid-template-columns: 1fr;
  }
  
  .sidebar-inventario {
    position: relative;
    top: auto;
    margin-top: 2rem;
  }
}

@media (max-width: 768px) {
  .grid {
    grid-template-columns: 1fr;
  }
  
  .tabla-wrapper {
    font-size: 0.8rem;
  }
  
  .modal-content {
    width: 95%;
    margin: 10% auto;
    padding: 1rem;
  }
  
  .container-detalle-producto {
    width: 100%;
    position: relative;
    max-height: none;
  }
  
  .resumen-estadisticas {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .stat-card {
    padding: 0.75rem;
  }
  
  .stat-number {
    font-size: 1.25rem;
  }
}
