@import url("visual_refresh.css?v=20261020c");

html,
body,
button,
input,
select,
textarea {
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}

body { margin: 0; }

.nav-active {
  background: rgb(37 99 235);
  color: white;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}

.flash-alert {
  animation: fadeIn .18s ease-out;
}

.sidebar-logo {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.15));
}

.sidebar-brand {
  padding: 10px 14px;
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(to bottom, #ffffff, #f8fafc);
}

.sidebar-brand-logo {
  display: block;
  width: 100%;
  max-width: 240px;
  object-fit: contain;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.sidebar-brand-logo:hover {
  transform: scale(1.03);
  opacity: 0.9;
}

.sidebar-brand-fallback {
  width: 100%;
  text-align: left;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Mobile nav ===== */

.app-sidebar {
  box-shadow: 0 10px 35px rgba(15, 23, 42, 0.18);
}

.mobile-sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

body.sidebar-open .mobile-sidebar-overlay {
  opacity: 1;
  pointer-events: auto;
}

body.sidebar-open {
  overflow: hidden;
}

body.sidebar-open .app-sidebar {
  transform: translateX(0);
}

.mobile-nav-toggle {
  flex: 0 0 auto;
}

@media (min-width: 768px) {
  .app-sidebar {
    box-shadow: none;
  }

  .mobile-sidebar-overlay {
    display: none;
  }

  body.sidebar-open {
    overflow: auto;
  }
}

@media (max-width: 1023.98px) {
  .sidebar-brand {
    min-height: 84px;
    padding: 10px 12px;
  }

  .sidebar-brand-logo {
    max-width: 220px;
  }
}

.nav-active {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.18);
}

.nav-active i {
  color: #fff;
}

.sidebar-brand-link {
  display: block;
  width: 100%;
}

.sidebar-brand-fallback {
  width: 100%;
  text-align: center;
}

.sidebar-brand-fallback .text-xl {
  line-height: 1.2;
  word-break: break-word;
}

/* ===== Sidebar / layout base ===== */

/* Por defecto: el sidebar usa la altura que necesite y acompaña la página */
.app-sidebar {
  min-height: 100vh;
  height: auto;
  max-height: none;
  overflow: visible;
}

.app-sidebar nav {
  flex: 0 0 auto;
  min-height: auto;
  overflow-y: visible;
  padding-bottom: 12px;
}

.app-sidebar > .p-4 {
  flex: 0 0 auto;
}

/* Solo en Ventas POS: pantalla fija + scroll interno real del menú */
body.page-ventas .app-sidebar {
  height: 100vh;
  max-height: 100vh;
  min-height: 0;
  overflow: hidden;
}

body.page-ventas .app-sidebar .sidebar-brand {
  flex: 0 0 auto;
}

body.page-ventas .app-sidebar nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 12px;
}

body.page-ventas .app-sidebar > .p-4 {
  flex: 0 0 auto;
}

/* Scrollbar solo cuando el menú realmente scrollea */
body.page-ventas .app-sidebar nav::-webkit-scrollbar {
  width: 8px;
}

body.page-ventas .app-sidebar nav::-webkit-scrollbar-track {
  background: transparent;
}

body.page-ventas .app-sidebar nav::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
  border: 2px solid #fff;
}

body.page-ventas .app-sidebar nav::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ===== Navegación agrupada ===== */

.sidebar-section-label {
  padding: 14px 14px 6px;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  line-height: 1.2;
  text-transform: uppercase;
}

.sidebar-section-label:first-child {
  padding-top: 2px;
}

.sidebar-nav-group {
  position: relative;
}

.sidebar-nav-parent {
  display: flex;
  width: 100%;
  align-items: stretch;
  overflow: hidden;
  border-radius: 1rem;
  color: #334155;
  transition: background-color .16s ease, color .16s ease, box-shadow .16s ease;
}

.sidebar-nav-parent:hover {
  background: #f1f5f9;
}

.sidebar-nav-parent.nav-active {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.18);
}

.sidebar-nav-parent.nav-parent-active {
  background: #eff6ff;
  color: #1d4ed8;
  box-shadow: inset 0 0 0 1px #bfdbfe;
}

.sidebar-nav-primary {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  align-items: center;
  gap: .75rem;
  padding: .75rem .35rem .75rem 1rem;
  color: inherit;
  font-size: .875rem;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
}

.sidebar-nav-toggle {
  display: inline-flex;
  width: 2.75rem;
  flex: 0 0 2.75rem;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.sidebar-nav-toggle:hover {
  background: rgba(148, 163, 184, .14);
}

.sidebar-nav-parent.nav-active .sidebar-nav-toggle:hover {
  background: rgba(255, 255, 255, .14);
}

.sidebar-nav-toggle i {
  font-size: .7rem;
  transition: transform .18s ease;
}

.sidebar-submenu {
  display: grid;
  max-height: 0;
  margin: 0 0 0 1.55rem;
  gap: .2rem;
  overflow: hidden;
  border-left: 1px solid transparent;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: max-height .22s ease, margin-top .22s ease, padding .22s ease,
    opacity .16s ease, border-color .16s ease, visibility 0s linear .22s;
}

.sidebar-nav-group.is-open .sidebar-submenu,
.sidebar-nav-group.has-active-child:not(.is-collapsed) .sidebar-submenu {
  max-height: 14rem;
  margin-top: .3rem;
  padding: .1rem 0 .15rem .55rem;
  border-left-color: #dbe3ee;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

.sidebar-nav-group.is-open .sidebar-nav-toggle i,
.sidebar-nav-group.has-active-child:not(.is-collapsed) .sidebar-nav-toggle i {
  transform: rotate(180deg);
}

.sidebar-submenu-link {
  display: flex;
  min-height: 2.35rem;
  align-items: center;
  gap: .65rem;
  border-radius: .8rem;
  padding: .55rem .7rem;
  color: #64748b;
  font-size: .8rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}

.sidebar-submenu-link i {
  width: 1rem;
  flex: 0 0 1rem;
  text-align: center;
}

.sidebar-submenu-link:hover {
  background: #f1f5f9;
  color: #1e40af;
}

.sidebar-submenu-link.nav-active {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 5px 14px rgba(37, 99, 235, .16);
}

@media (min-width: 768px) {
  .app-sidebar {
    position: sticky !important;
    top: 0;
    height: 100vh;
    min-height: 0;
    max-height: 100vh;
    overflow: hidden;
  }

  .app-sidebar nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  .app-sidebar > .p-4 {
    flex: 0 0 auto;
  }
}

/* ===== Foco y validación ===== */

:where(a, button, input, select, textarea):focus-visible {
  outline: 3px solid rgba(37, 99, 235, .32);
  outline-offset: 2px;
}

.app-field-invalid {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .12) !important;
}

/* ===== Avisos no bloqueantes ===== */

.app-toast-region {
  position: fixed;
  z-index: 100;
  top: 18px;
  right: 18px;
  display: flex;
  width: min(390px, calc(100vw - 32px));
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.app-toast {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 30px;
  gap: 10px;
  align-items: start;
  padding: 13px;
  border: 1px solid #dbe3ee;
  border-radius: 18px;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 18px 45px rgba(15, 23, 42, .18);
  pointer-events: auto;
  animation: appToastIn .18s ease-out;
}

.app-toast.is-leaving {
  opacity: 0;
  transform: translateY(-5px);
  transition: opacity .18s ease, transform .18s ease;
}

.app-toast-icon {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  color: #1d4ed8;
  background: #dbeafe;
}

.app-toast-success .app-toast-icon {
  color: #047857;
  background: #d1fae5;
}

.app-toast-warning .app-toast-icon {
  color: #b45309;
  background: #fef3c7;
}

.app-toast-error .app-toast-icon {
  color: #b91c1c;
  background: #fee2e2;
}

.app-toast-title {
  margin: 0;
  color: #0f172a;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.3;
}

.app-toast-message {
  margin: 2px 0 0;
  color: #475569;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.app-toast-close {
  display: inline-flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  color: #64748b;
  background: transparent;
  cursor: pointer;
}

.app-toast-close:hover {
  color: #0f172a;
  background: #f1f5f9;
}

@keyframes appToastIn {
  from { opacity: 0; transform: translateY(-7px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== Diálogo común ===== */

.app-dialog[hidden] {
  display: none;
}

.app-dialog {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  padding: 18px;
}

.app-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(3px);
}

.app-dialog-card {
  position: relative;
  display: grid;
  width: min(480px, 100%);
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 14px;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 30px 75px rgba(15, 23, 42, .28);
  animation: appDialogIn .18s ease-out;
}

.app-dialog-icon {
  display: inline-flex;
  width: 46px;
  height: 46px;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  color: #1d4ed8;
  background: #dbeafe;
  font-size: 18px;
}

.app-dialog.is-danger .app-dialog-icon {
  color: #b91c1c;
  background: #fee2e2;
}

.app-dialog-title {
  margin: 1px 0 0;
  color: #0f172a;
  font-size: 18px;
  font-weight: 850;
  line-height: 1.25;
}

.app-dialog-message {
  margin: 7px 0 0;
  color: #475569;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-line;
}

.app-dialog-input-wrap {
  margin-top: 14px;
}

.app-dialog-input-wrap label {
  display: block;
  margin-bottom: 6px;
  color: #334155;
  font-size: 12px;
  font-weight: 750;
}

.app-dialog-input {
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  color: #0f172a;
  background: #fff;
  outline: 0;
}

.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 18px;
}

.app-dialog-btn {
  min-height: 42px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.app-dialog-btn-secondary {
  color: #334155;
  border-color: #dbe3ee;
  background: #fff;
}

.app-dialog-btn-secondary:hover {
  background: #f8fafc;
}

.app-dialog-btn-primary {
  color: #fff;
  background: #2563eb;
}

.app-dialog.is-danger .app-dialog-btn-primary {
  background: #dc2626;
}

body.app-dialog-open {
  overflow: hidden;
}

@keyframes appDialogIn {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== Tablas responsive comunes ===== */

.app-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.app-responsive-table {
  min-width: 720px;
}

@media (max-width: 1023.98px) {
  .app-sidebar {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
  }

  .app-sidebar nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .app-sidebar > .p-4 {
    flex: 0 0 auto;
  }

  .app-toast-region {
    top: 12px;
    right: 16px;
  }

  .app-dialog-card {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 11px;
    padding: 17px;
    border-radius: 21px;
  }

  .app-dialog-icon {
    width: 40px;
    height: 40px;
    border-radius: 14px;
  }

  .app-dialog-actions {
    flex-direction: column-reverse;
  }

  .app-dialog-btn {
    width: 100%;
  }

  .app-table-wrap.app-table-cards {
    overflow: visible;
    border: 0 !important;
  }

  .app-table-cards .app-responsive-table,
  .app-table-cards .app-responsive-table tbody,
  .app-table-cards .app-responsive-table tr,
  .app-table-cards .app-responsive-table td {
    display: block;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .app-table-cards .app-responsive-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .app-table-cards .app-responsive-table tbody {
    display: grid;
    gap: 12px;
  }

  .app-table-cards .app-responsive-table tr {
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 5px 16px rgba(15, 23, 42, .04);
  }

  .app-table-cards .app-responsive-table td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 11px 14px;
    border-top: 1px solid #edf2f7;
    text-align: right;
  }

  .app-table-cards .app-responsive-table td:first-child {
    border-top: 0;
  }

  .app-table-cards .app-responsive-table td::before {
    content: attr(data-label);
    flex: 0 0 38%;
    color: #64748b;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .03em;
    text-align: left;
    text-transform: uppercase;
  }

  .app-table-cards .app-responsive-table td[data-primary] {
    display: block;
    padding-top: 14px;
    padding-bottom: 14px;
    text-align: left;
    background: #f8fafc;
  }

  .app-table-cards .app-responsive-table td[data-primary]::before,
  .app-table-cards .app-responsive-table td[data-empty]::before {
    display: none;
  }

  .app-table-cards .app-responsive-table td[data-empty] {
    display: block;
    text-align: center;
  }

  .app-table-cards .app-responsive-table td[data-actions] {
    display: block;
    text-align: left;
    background: #f8fafc;
  }

  .app-table-cards .app-responsive-table td[data-actions]::before {
    display: none;
  }

  .app-table-cards .app-responsive-table td[data-actions] > * {
    display: flex;
    width: 100%;
  }

  .app-table-cards .app-responsive-table td[data-actions] a,
  .app-table-cards .app-responsive-table td[data-actions] button,
  .app-table-cards .app-responsive-table td[data-actions] form {
    flex: 1 1 auto;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* Access rules never override business visibility in the other direction. */
[data-access-hidden]{display:none!important}

/* Shared keyboard access and motion preferences. */
.app-skip-link { position: fixed; left: 16px; top: 12px; z-index: 1000;
  transform: translateY(-160%); padding: 12px 18px; border-radius: 12px;
  background: #1e40af; color: #fff; font-weight: 600; }
.app-skip-link:focus { transform: translateY(0); }
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid #2563eb !important; outline-offset: 3px;
}
#appContent { scroll-margin-top: 100px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important;
    animation-iteration-count: 1 !important; transition-duration: .01ms !important;
    scroll-behavior: auto !important; }
}

/* La confirmacion global debe quedar sobre los formularios de devolucion/correo. */
#appDialog { z-index: 2000; }
