/*
 * Tapyn$ ERP — estilos consolidados del shell ERP.
 *
 * Fuentes:
 *   - erp-nav-* extraído desde el <style> inline de _nav.blade.php (Fase 6.9).
 *   - .erp-shell / .erp-sidebar-* / .erp-main-* NUEVOS (Capa B unificación).
 *
 * Las CSS custom properties --tapyns-navbar-h y --tapyns-sticky-offset
 * se definen en includes/css_general.blade.php.
 */

/* =====================================================================
 *  Shell unificado: sidebar izquierdo + main content
 * ===================================================================== */

.erp-shell {
  /* el padding-top global de <main> en css_general ya compensa la altura
     del navbar fixed; aquí solo dejamos respiro adicional opcional. */
  min-height: calc(100vh - var(--tapyns-navbar-h, 80px));
}

.erp-shell-row {
  display: flex;
  flex-wrap: nowrap;
  min-height: calc(100vh - var(--tapyns-navbar-h, 80px));
  margin: 0;
}

.erp-sidebar-col {
  width: 260px;
  flex: 0 0 260px;
  border-right: 1px solid #e8eaf2;
  background: #fafbfd;
  padding: 0;
}

.erp-sidebar-sticky {
  position: sticky;
  top: var(--tapyns-sticky-offset, 90px);
  max-height: calc(100vh - var(--tapyns-sticky-offset, 90px));
  overflow-y: auto;
  padding: 16px 12px 24px;
}

.erp-sidebar-sticky::-webkit-scrollbar {
  width: 5px;
}
.erp-sidebar-sticky::-webkit-scrollbar-thumb {
  background-color: #cfd4e3;
  border-radius: 3px;
}

.erp-main-col {
  flex: 1 1 auto;
  min-width: 0; /* permite shrink en flex */
  padding: 0;
}

.erp-main-inner {
  padding: 20px 24px 40px;
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 991.98px) {
  .erp-sidebar-col {
    display: none;
  }
  .erp-main-inner {
    padding: 12px 14px 32px;
  }
}

/* Page header dentro del main */
.erp-page-header {
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.erp-page-header h1 {
  font-size: 1.45rem;
  font-weight: 700;
  margin: 0;
  color: #212529;
  line-height: 1.15;
}

.erp-page-header .erp-page-subtitle {
  font-size: 13px;
  color: #6c757d;
  margin-top: 2px;
}

.erp-page-header .erp-sidebar-toggle {
  display: none;
  background: #fff;
  border: 1px solid #e8eaf2;
  border-radius: 10px;
  padding: 6px 12px;
  color: #586075;
  font-size: 18px;
  cursor: pointer;
}

@media (max-width: 991.98px) {
  .erp-page-header .erp-sidebar-toggle { display: inline-flex; }
}

/* =====================================================================
 *  Sidebar — cards + list-group items
 * ===================================================================== */

.erp-sidebar .erp-sidebar-card {
  background: #fff;
  border: 1px solid #e8eaf2;
  border-radius: 12px;
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.erp-sidebar .erp-sidebar-card-header {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #9aa1b4;
  font-weight: 700;
  padding: 10px 14px 6px;
  border-bottom: 1px solid #f1f3f9;
  background: #fcfcfd;
}

.erp-sidebar .erp-sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  color: #303642;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-bottom: 1px solid #f4f5fa;
  transition: background 0.12s, color 0.12s;
}

.erp-sidebar .erp-sidebar-link:last-child {
  border-bottom: 0;
}

.erp-sidebar .erp-sidebar-link i {
  font-size: 16px;
  line-height: 1;
  width: 18px;
  text-align: center;
  color: #6c7383;
  flex-shrink: 0;
}

.erp-sidebar .erp-sidebar-link:hover {
  background: #f4f8ff;
  color: #0d6efd;
  text-decoration: none;
}
.erp-sidebar .erp-sidebar-link:hover i {
  color: #0d6efd;
}

.erp-sidebar .erp-sidebar-link.active {
  background: #0d6efd;
  color: #fff;
  font-weight: 600;
}
.erp-sidebar .erp-sidebar-link.active i {
  color: #fff;
}

.erp-sidebar .erp-sidebar-link .erp-sidebar-badge {
  margin-left: auto;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #eef0f7;
  color: #586075;
  font-weight: 700;
}
.erp-sidebar .erp-sidebar-link.active .erp-sidebar-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* =====================================================================
 *  Offcanvas drawer mobile
 * ===================================================================== */

.erp-offcanvas-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1050;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}
.erp-offcanvas-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.erp-offcanvas {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 85vw;
  background: #fff;
  z-index: 1051;
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  overflow-y: auto;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
}
.erp-offcanvas.open {
  transform: translateX(0);
}

.erp-offcanvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #e8eaf2;
  background: #fafbfd;
}
.erp-offcanvas-header h5 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #212529;
}
.erp-offcanvas-close {
  background: transparent;
  border: 0;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #586075;
  padding: 0 4px;
}
.erp-offcanvas-body {
  padding: 14px 12px 24px;
  flex: 1;
}

/* Solo aplica el offcanvas en <992px — en desktop usamos el sidebar fijo. */
@media (min-width: 992px) {
  .erp-offcanvas,
  .erp-offcanvas-backdrop {
    display: none !important;
  }
}

/* =====================================================================
 *  Nav horizontal (erp-nav-*) — extraído desde _nav.blade.php inline.
 *  Solo se muestra en mobile (<992px); en desktop usa el sidebar.
 * ===================================================================== */

.erp-nav-wrap {
  background: #fff;
  border: 1px solid #e8eaf2;
  border-radius: 14px;
  padding: 8px;
  margin-bottom: 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.erp-nav-wrap::-webkit-scrollbar { height: 6px; }
.erp-nav-wrap::-webkit-scrollbar-thumb { background: #cfd4e3; border-radius: 3px; }

.erp-nav-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  min-width: max-content;
  align-items: center;
}

.erp-nav-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #586075;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
}
.erp-nav-item i { font-size: 16px; line-height: 1; }
.erp-nav-item:hover {
  background: #f4f8ff;
  color: #0d6efd;
  text-decoration: none;
}
.erp-nav-item.active {
  background: #0d6efd;
  color: #fff;
  box-shadow: 0 2px 6px rgba(13, 110, 253, 0.25);
}
.erp-nav-item.active:hover {
  background: #0b5fd6;
  color: #fff;
}
.erp-nav-item .erp-nav-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 2px;
}
.erp-nav-item:not(.active) .erp-nav-badge {
  background: #eef0f7;
  color: #586075;
}

.erp-nav-divider {
  display: inline-block;
  width: 1px;
  height: 24px;
  background: #e8eaf2;
  margin: 0 4px;
  flex-shrink: 0;
}

@media (min-width: 992px) {
  .erp-nav-row { flex-wrap: wrap; }
  .erp-nav-group { margin-bottom: 6px; }
  .erp-nav-group:last-child { margin-bottom: 0; }
  .erp-nav-group-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #9aa1b4;
    font-weight: 700;
    padding: 6px 4px 4px;
  }
  .erp-nav-divider { display: none; }
}

@media (max-width: 991.98px) {
  .erp-nav-group-label { display: none; }
  .erp-nav-group { display: contents; }
}

/* En desktop el erp-nav-wrap se OCULTA porque el sidebar ya tiene los grupos */
@media (min-width: 992px) {
  .erp-nav-wrap.erp-nav-mobile-only { display: none; }
}

/* =====================================================================
 *  Tokens de tarjetas reutilizables del ERP (consistencia visual)
 * ===================================================================== */

.tap-card {
  background: #fff;
  border: 1px solid #e8eaf2;
  border-radius: 14px;
}
.tap-card-padded { padding: 18px; }
.tap-muted { color: #586075; }
