/* Panel ComprasVentas — layout sidebar + contenido lado a lado */
:root {
  --sidebar-width: 260px;
  --sidebar-bg: #1e293b;
  --primary: #0d6efd;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: #f1f5f9;
  font-family: "Segoe UI", system-ui, sans-serif;
  overflow-x: hidden;
}

/* Contenedor principal: menú a la izquierda, contenido a la derecha */
.app-wrapper {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: stretch;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  flex: 0 0 var(--sidebar-width) !important;
  width: var(--sidebar-width) !important;
  max-width: var(--sidebar-width) !important;
  min-width: var(--sidebar-width) !important;
  background: var(--sidebar-bg) !important;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  max-height: 100vh;
  z-index: 1040;
  display: flex !important;
  flex-direction: column !important;
  overflow-x: hidden;
  overflow-y: auto;
  transition: transform .25s ease;
}

.sidebar-brand {
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
}

.sidebar .nav-link {
  border-radius: .375rem;
  margin: 0 .5rem;
  padding: .5rem .75rem;
  font-size: .9rem;
}

.sidebar .nav-link:hover {
  background: rgba(255, 255, 255, .08);
  color: #fff !important;
}

.sidebar-footer {
  flex-shrink: 0;
  margin-top: auto;
}

.main-content {
  flex: 1 1 auto !important;
  width: calc(100% - var(--sidebar-width)) !important;
  max-width: calc(100% - var(--sidebar-width)) !important;
  min-width: 0 !important;
  margin-left: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  background: #f1f5f9;
  min-height: 100vh;
}

.content-area {
  flex: 1;
}

.kpi-card {
  border: 0;
  border-radius: .75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
  transition: transform .15s;
}

.kpi-card:hover {
  transform: translateY(-2px);
}

.kpi-card .kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.kpi-card .kpi-label {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: #64748b;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  z-index: 1035;
}

.auth-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #0f172a 100%);
}

.table-actions .btn {
  padding: .25rem .5rem;
}

/* Tablas responsivas */
.table-responsive {
  -webkit-overflow-scrolling: touch;
  margin-bottom: .5rem;
}

/* Móvil: sidebar oculto / overlay y adaptabilidad */
@media (max-width: 991.98px) {
  .app-wrapper {
    flex-direction: column !important;
  }

  .sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width) !important;
    height: 100vh;
    transform: translateX(-100%);
    flex: none !important;
    z-index: 1050 !important;
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .main-content {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
  }

  .sidebar-backdrop.show {
    display: block;
    z-index: 1045;
  }
}

/* Pantallas pequeñas (celulares) */
@media (max-width: 767.98px) {
  .content-area {
    padding: .85rem .65rem !important;
  }

  .topbar {
    padding: .5rem .75rem !important;
  }

  .topbar h1 {
    font-size: 1.1rem;
  }

  .card-body {
    padding: .85rem;
  }

  .kpi-card .kpi-value {
    font-size: 1.3rem;
  }

  /* DataTables en celulares */
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter {
    float: none !important;
    text-align: left !important;
    margin-bottom: .5rem;
  }

  .dataTables_wrapper .dataTables_filter input {
    width: 100% !important;
    margin-left: 0 !important;
    margin-top: .25rem;
  }

  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate {
    float: none !important;
    text-align: center !important;
    margin-top: .75rem;
  }

  .dataTables_wrapper .dataTables_paginate .pagination {
    justify-content: center !important;
    flex-wrap: wrap;
    gap: 3px;
  }

  .table-actions {
    display: flex;
    gap: 4px;
    align-items: center;
  }

  .table-actions .btn {
    padding: .3rem .55rem;
    font-size: .85rem;
  }
}

/* POS */
.pos-product-card {
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.pos-product-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 2px var(--primary);
}
.pos-product-card:active {
  transform: scale(0.98);
}
.pos-cart {
  max-height: 420px;
  overflow-y: auto;
}

@media print {
  .sidebar,
  .topbar,
  .sidebar-backdrop,
  #sidebarToggle {
    display: none !important;
  }
  .main-content {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* Autocomplete de productos en compra / importación */
.producto-autocomplete-wrap {
  position: relative;
}
.producto-dropdown {
  background: #ffffff;
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
  z-index: 1060 !important;
}
.producto-dropdown .list-group-item {
  border-left: 0;
  border-right: 0;
  cursor: pointer;
  padding: 0.45rem 0.75rem;
  text-decoration: none;
  color: #212529;
}
.producto-dropdown .list-group-item:first-child {
  border-top: 0;
}
.producto-dropdown .list-group-item:last-child {
  border-bottom: 0;
}
.producto-dropdown .list-group-item:hover,
.producto-dropdown .list-group-item.active-item {
  background-color: #f1f5f9;
  color: #0f172a;
}
.producto-dropdown mark {
  background-color: #fef08a;
  padding: 0 2px;
  border-radius: 2px;
}
#tablaDetalle {
  margin-bottom: 5rem;
}

