/* =========== Google Fonts ============ */
@import url("https://fonts.googleapis.com/css2?family=Ubuntu:wght@300;400;500;700&display=swap");

/* =============== Globals ============== */
* {
  font-family: "Ubuntu", sans-serif;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --blue: #1A1A1A ;
  --white: #EAEAEA ;
  --gray: #f5f5f5;
  --black1: #222;
  --black2: #999;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
}

.container {
  position: relative;
  width: 100%;
}

/* =============== Navigation ================ */
.navigation {
  position: fixed;
  width: 300px;
  height: 100%;
  background: var(--blue);
  border-left: 10px solid var(--blue);
  transition: 0.5s;
  overflow: hidden;
}

.navigation.active {
  width: 80px;
}

.navigation ul {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
}

.navigation ul li {
  position: relative;
  width: 100%;
  list-style: none;
  border-top-left-radius: 30px;
  border-bottom-left-radius: 30px;
  transition: background-color 0.3s;
}

/* 1. HOVER NORMAL (Blanco) */
.navigation ul li:hover,
.navigation ul li.hovered {
  background-color: var(--white);
}

/* 2. SELECCIONADO (Verde persistente) */
.navigation ul li.seleccionado {
  background-color: #2ecc71 !important;
}

/* 3. EXCEPCIÓN: El primer ítem (Logo) nunca cambia de fondo */
.navigation ul li:nth-child(1) {
  margin-bottom: 40px;
  pointer-events: none;
  background-color: transparent !important;
}

.navigation ul li a {
  position: relative;
  display: block;
  width: 100%;
  display: flex;
  text-decoration: none;
  color: var(--white);
}

.navigation ul li:hover a,
.navigation ul li.hovered a {
  color: var(--blue);
}

.navigation ul li.seleccionado a {
  color: var(--white) !important;
}

.navigation ul li a .icon {
  position: relative;
  display: block;
  min-width: 60px;
  height: 60px;
  line-height: 75px;
  text-align: center;
}

.navigation ul li a .icon ion-icon {
  font-size: 1.75rem;
}

.navigation ul li a .title {
  position: relative;
  display: block;
  padding: 0 10px;
  height: 60px;
  line-height: 60px;
  text-align: start;
  white-space: nowrap;
}

/* --------- curve outside (Las curvas blancas laterales) ---------- */
.navigation ul li:hover a::before,
.navigation ul li.hovered a::before,
.navigation ul li.seleccionado a::before {
  content: "";
  position: absolute;
  right: 0;
  top: -50px;
  width: 50px;
  height: 50px;
  background-color: transparent;
  border-radius: 50%;
  box-shadow: 35px 35px 0 10px var(--white);
  pointer-events: none;
}

.navigation ul li:hover a::after,
.navigation ul li.hovered a::after,
.navigation ul li.seleccionado a::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -50px;
  width: 50px;
  height: 50px;
  background-color: transparent;
  border-radius: 50%;
  box-shadow: 35px -35px 0 10px var(--white);
  pointer-events: none;
}

.navigation ul li:nth-child(1):hover a::before,
.navigation ul li:nth-child(1):hover a::after {
    display: none;
}

/* ===================== Main ===================== */
.main {
  position: absolute;
  width: calc(100% - 300px);
  left: 300px;
  min-height: 100vh;
  background: var(--white);
  transition: 0.5s;
}

.main.active {
  width: calc(100% - 80px);
  left: 80px;
}

.topbar {
  width: 100%;
  height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
}

.toggle {
  position: relative;
  width: 60px;
  height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2.5rem;
  cursor: pointer;
}

.search {
  position: relative;
  width: 400px;
  margin: 0 10px;
}

.search label {
  position: relative;
  width: 100%;
}

.search label input {
  width: 100%;
  height: 40px;
  border-radius: 40px;
  padding: 5px 20px;
  padding-left: 35px;
  font-size: 18px;
  outline: none;
  border: 1px solid var(--black2);
}

.search label ion-icon {
  position: absolute;
  top: 0;
  left: 10px;
  font-size: 1.2rem;
}

.user {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  margin-right: 50px;
}

.user img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* BOTÓN PRINCIPAL ACCIÓN RGB */
.accionPrincipal {
  display: flex;
  justify-content: center;
  margin: 20px 0;
}

.btnNuevaVenta {
    position: relative;
    padding: 14px 28px;
    border: none;
    border-radius: 14px;
    background: #1A1A1A;
    color: white;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    overflow: hidden;
    z-index: 1;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    font-family: 'Outfit',sans-serif;
}

.btnNuevaVenta::before {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: 16px;
    background: linear-gradient(45deg, #ff0000, #ff7300, #fffb00, #48ff00, #00ffd5, #002bff, #7a00ff, #ff00ab, #ff0000);
    background-size: 400%;
    z-index: -2;
    animation: rgbBorder 10s linear infinite;
}

.btnNuevaVenta::after {
    content: "";
    position: absolute;
    inset: 2px;
    background: #111;
    border-radius: 12px;
    z-index: -1;
}

.btnNuevaVenta:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 255, 149, 0.774);
}

@keyframes rgbBorder {
    0% { background-position: 0% 50%; }
    100% { background-position: 400% 50%; }
}

.graficas, .tablas {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ===== FORMULARIO VENTA ===== */
.formularioVenta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  margin: 20px 0;
}

.campo {
  display: flex;
  flex-direction: column;
}

.campo label {
  font-size: 14px;
  margin-bottom: 5px;
  color: #555;
}

.campo input {
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #ccc;
}

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ===== BOTONES STANDARD ===== */
.acciones {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.btn {
  background: #2a2185;
  color: rgb(255, 255, 255);
  padding: 8px 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
}

.btn.success {
  background: #28a745;
}

.tablaContainer {
  overflow-x: auto;
}

#tablaVenta td {
  padding: 10px;
  font-family: 'Outfit',sans-serif;
}

.btn-eliminar {
  background: red;
  color: white;
  border: none;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
}

/* ===== TOTALES & DROPDOWNS ===== */
.totales {
  margin-top: 15px;
  text-align: right;
}

.totales h3 {
  color: #2a2185;
}

.comboBox {
  position: relative;
}

.comboBox input {
  width: 100%;
  padding-right: 30px;
}

.dropdown {
  position: absolute;
  width: 100%;
  background: white;
  border: 1px solid #ccc;
  border-radius: 6px;
  margin-top: 2px;
  max-height: 150px;
  overflow-y: auto;
  display: none;
  z-index: 1000;
}

.dropdown div {
  padding: 8px;
  cursor: pointer;
}

.dropdown div:hover {
  background: #2a2185;
  color: white;
}

/* ===== MÓDULO CATÁLOGO OPCIONES ===== */
.catalogoOpciones {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 30px;
  flex-wrap: wrap;
  margin: 20px auto;
}

.opcion {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
}

.icono {
  width: 70px;
  height: 70px;
  background: #1A1A1A;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  transition: 0.3s;
}

.opcion:hover .icono {
  transform: scale(1.1);
  background: #2ecc71;
}

.opcion span {
  margin-top: 5px;
  font-size: 14px;
}

/* ===== MENÚ PERFIL DE USUARIO ===== */
.userMenu {
  position: absolute;
  top: 50px;
  right: 0;
  width: 180px;
  background: rgb(255, 255, 255);
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: 0.3s;
}

.userMenu.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  z-index: 1000;
}

.menuItem {
  padding: 10px;
  cursor: pointer;
  transition: 0.2s;
}

.menuItem:hover {
  background: #2a2185;
  color: white;
}

.menuItem.logout { color: red; }
.menuItem.logout:hover {
  color: rgb(255, 255, 255);
  background-color: #ff0000;
}

.formularioPerfil, .formularioConfig {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin: 20px 0;
}


/* =========================================================================
   ✨ SECCIÓN DE TABLAS PREMIUM CORREGIDAS (CON CABECERA Y PAGINACIÓN FIJAS) ✨
   ========================================================================= */

.recentOrders {
    background: #ffffff !important;
    padding: 25px !important;
    border-radius: 20px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.02) !important;
    border: 1px solid rgba(0, 0, 0, 0.01) !important;
    margin: 0 40px 20px 40px;
    
    /* 1. Modificamos la altura para que ocupe más espacio hacia abajo */
    height: 550px !important; 
    
    /* 2. Quitamos el scroll de la tarjeta completa */
    overflow: hidden !important; 
    display: flex;
    flex-direction: column;
}

.cardHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    flex-shrink: 0; /* Evita que la cabecera se encoja o se mueva */
}

.cardHeader h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1A1A1A;
    letter-spacing: -0.5px;
}

/* 🆕 NUEVO CONTENEDOR: El scroll y el tamaño estático ahora viven aquí */
.tabla-scroll-container {
    flex-grow: 1;          /* Hace que tome todo el espacio disponible del alto */
    overflow-y: auto;      /* Si hay demasiados registros, el scroll aparece SOLO aquí */
    margin-bottom: 15px;   /* Separación limpia con la paginación */
}

.recentOrders table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

/* Dejamos el thead pegajoso (sticky) por si los registros sobrepasan el alto interno */
.recentOrders table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.recentOrders table thead tr {
    background: #1A1A1A;
}

.recentOrders table thead td {
    font-weight: 600;
    font-size: 1.2rem;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 14px 16px;
    border: none;
    font-family: 'Passion One', sans-serif;
}

.recentOrders table tbody tr {
    border-bottom: 1px solid #f1f1f1;
    transition: background 0.2s ease;
}

.recentOrders table tbody tr:last-child {
    border-bottom: none;
}

.recentOrders table tbody tr td {
    padding: 14px 16px;
    font-size: 0.95rem;
    color: #2C3E50;
    vertical-align: middle;
}

/* Hover verde premium unificado */
.recentOrders table tbody tr:hover {
    background: rgba(46, 204, 113, 0.15) !important; /* Opacidad sutil verde */
    color: #1A1A1A !important;
    cursor: pointer;
}

/* Botones de acciones ✏️ 🗑️ */
.recentOrders table tbody tr td button {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.recentOrders table tbody tr td button:hover {
    background: #1A1A1A;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* =========================================================================
   🔘 BOTÓN PREMIUM 3D INTERACTIVO (CATÁLOGOS)
   ========================================================================= */

/* Contenedor principal invisible del botón */
.btn-3d-contenedor {
  position: relative;
  background: transparent;
  padding: 0px;
  border: none;
  cursor: pointer;
  outline-offset: 4px;
  outline-color: #2ecc71; /* Línea de enfoque verde */
  transition: filter 250ms;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  margin-bottom: 10px;
  margin-left: 400px;
}

/* Capa 1: Sombra difuminada en el fondo */
.btn-3d-sombra {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background: #2ecc70b4;
  border-radius: 10px;
  filter: blur(2px);
  will-change: transform;
  transform: translateY(2px);
  transition: transform 600ms cubic-bezier(0.3, 0.7, 0.4, 1);
}

/* Capa 2: Bloque intermedio que simula el grosor/relieve del botón */
.btn-3d-borde-lateral {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  border-radius: 10px;
  background: linear-gradient(
    to right,
    #2ecc71 0%,
    #1f8d4d 8%,
    #2ecc71 92%,
    #2ecc71 100%
  );
}
/* #0d0d0d 0%,
    #1A1A1A 8%,
    #1A1A1A 92%,
    #050505 100% */

/* Capa 3: Cara frontal (la superficie que se presiona) */
.btn-3d-cara-frontal {
  display: flex;             /* Cambiado a flex para alinear icono y texto */
  align-items: center;       /* Centrado vertical perfecto */
  justify-content: center;
  gap: 8px;                  /* Espacio exacto entre el icono y el texto */
  position: relative;
  border-radius: 10px;
  background: #1a1a1a; 
  padding: 10px 20px;
  color: white;
  font-weight: 500;
  font-size: 0.95rem;
  font-family: 'Ubuntu', sans-serif;
  transform: translateY(-4px); 
  transition: transform 600ms cubic-bezier(0.3, 0.7, 0.4, 1);
}

/* --- EFECTOS AL PASAR EL MOUSE (HOVER) --- */

.btn-3d-contenedor:hover {
  filter: brightness(110%);
}

/* La cara frontal sube un poco más y cambia a verde */
.btn-3d-contenedor:hover .btn-3d-cara-frontal {
  background: #2ecc71;
  transform: translateY(-6px);
  transition: transform 250ms cubic-bezier(0.3, 0.7, 0.4, 1.5);
}

/* La sombra se estira al subir el botón */
.btn-3d-contenedor:hover .btn-3d-sombra {
  transform: translateY(4px);
  transition: transform 250ms cubic-bezier(0.3, 0.7, 0.4, 1.5);
}

/* --- EFECTOS AL HACER CLIC (ACTIVE) --- */

/* La cara frontal se hunde mecánicamente */
.btn-3d-contenedor:active .btn-3d-cara-frontal {
  transform: translateY(-2px);
  transition: transform 34ms;
}

/* La sombra se encoge al aplastar el botón */
.btn-3d-contenedor:active .btn-3d-sombra {
  transform: translateY(1px);
  transition: transform 34ms;
}

.btn-3d-contenedor:focus:not(:focus-visible) {
  outline: none;
}

/* Alineaciones limpias globales */
.contenidoPrincipal .recentOrders table tr td {
    text-align: left !important;
}

/* Solo la última columna se alinea a la derecha (Fechas/Totales/Acciones) */
.recentOrders table thead td:last-child,
.recentOrders table tbody tr td:last-child {
    text-align: right !important;
}

/* =========================================================================
   📊 COMPONENTE DE PAGINACIÓN PREMIUM FIJA
   ========================================================================= */

.paginacion-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: 1px solid #f1f1f1;
    font-family: 'Ubuntu', sans-serif;
    flex-shrink: 0; /* Clava la paginación abajo de forma inamovible */
    background: #ffffff;
}

.info-paginacion {
    font-size: 0.9rem;
    color: #757575;
}

.paginacion-controles {
    display: flex;
    align-items: center;
    gap: 15px;
}

.num-pagina {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1A1A1A;
    background: #f1f1f1;
    padding: 6px 12px;
    border-radius: 6px;
}

.btn-pagi {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    color: #1A1A1A;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-pagi:hover:not(:disabled) {
    background: #1A1A1A;
    color: #ffffff;
    border-color: #1A1A1A;
    transform: translateY(-1px);
}

.btn-pagi:disabled {
    background: #f8f9fa;
    color: #cccccc;
    border-color: #e0e0e0;
    cursor: not-allowed;
}

/* =========================================================================
   🚨 ESTILOS DE ALERTA DINÁMICOS DESDE LA DB
   ========================================================================= */

.success-alert, .error-alert {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: 'Ubuntu', sans-serif;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
}

.success-alert {
    background-color: rgba(46, 204, 113, 0.12);
    border: 1px solid rgba(46, 204, 113, 0.3);
    color: #1e7e34;
}

.error-alert {
    background-color: rgba(231, 76, 60, 0.12);
    border: 1px solid rgba(231, 76, 60, 0.3);
    color: #b21f1f;
}

/* Opcional: Pequeños Badges de estado en la tabla */
.status-badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}
.status-badge.active {
    background: rgba(46, 204, 113, 0.2);
    color: #1e7e34;
}
.status-badge.inactive {
    background: rgba(231, 76, 60, 0.2);
    color: #b21f1f;
}


/* ====================== Responsive Design ========================== */
@media (max-width: 991px) {
  .navigation { left: -300px; }
  .navigation.active { width: 300px; left: 0; }
  .main { width: 100%; left: 0; }
  .main.active { left: 300px; }
}

@media (max-width: 768px) {
  .contenidoPrincipal { grid-template-columns: 1fr; }
  .recentOrders { overflow-x: auto; margin: 0 20px 20px 20px; }
}

@media (max-width: 480px) {
  .user { min-width: 40px; }
  .navigation { width: 100%; left: -100%; z-index: 1000; }
  .navigation.active { width: 100%; left: 0; }
  .toggle { z-index: 10001; }
  .main.active .toggle {
    color: #fff;
    position: fixed;
    right: 0;
    left: initial;
  }
}