/* ============================================================
   SIDEBAR + LAYOUT — Reluz Conta
   Sidebar fijo 268px (siempre expandido), tinta plana #101828,
   acento azul Reluz. Mismas clases/IDs que usa el JS
   (buildSidebar + renderUserBox).
   ============================================================ */

/* ---- Layout general ---- */
.app-layout { min-height: 100vh; }

.main-content {
  margin-left: 268px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Sidebar (fijo, siempre expandido) — tinta plana Reluz ---- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 268px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1030;
  transition: left 0.2s ease, box-shadow 0.2s ease;
}

/* ---- Logo ---- */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-height);
  padding: 0 22px;
  border-bottom: 1px solid var(--sidebar-border);
  text-decoration: none;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-logo-img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 10px;
}

.sidebar-logo-text {
  display: inline-block;
  font-size: 16.5px;
  font-weight: 800;
  color: var(--sidebar-text-active);
  line-height: 1;
  letter-spacing: -0.2px;
}

.sidebar-logo-text::after {
  content: 'Contabilizador';
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.42);
  letter-spacing: 0.01em;
  margin-top: 5px;
}

/* ---- Nav ---- */
.sidebar-nav {
  flex: 1;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sidebar-section-label);
  padding: 22px 12px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.sidebar-section-label:first-child { padding-top: 14px; }

/* ---- Scrollbar del nav (visible y sutil, estilo STAY) ---- */
.sidebar-nav { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.22) transparent; }
.sidebar-nav::-webkit-scrollbar { width: 8px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.32); background-clip: padding-box; }

/* ---- Empresa conectada (bloque obligatorio del rebrand) ---- */
.sidebar-empresa {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 4px 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-empresa-dot {
  width: 8px; height: 8px; border-radius: 99px;
  background: #10B981; flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}
.sidebar-empresa-txt { display: flex; flex-direction: column; min-width: 0; }
.sidebar-empresa-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--sidebar-section-label);
}
.sidebar-empresa-nombre {
  font-size: 13.5px; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 3px;
}
.sidebar-empresa-nit {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.sidebar-empresa-nit:empty { display: none; }

/* ---- Items ---- */
.sidebar-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  height: 45px;
  padding: 0 14px;
  margin: 3px 0;
  border-radius: 12px;
  color: var(--sidebar-text);
  font-size: 14.5px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  flex-shrink: 0;
  transition: background 0.12s ease, color 0.12s ease;
}

.sidebar-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--sidebar-text-active);
}

.sidebar-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
  font-weight: 600;
  box-shadow: inset 3.5px 0 0 0 var(--sidebar-active-accent);
}

.sidebar-item.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.sidebar-item-icon {
  font-size: 17.5px;
  width: 22px;
  flex-shrink: 0;
  text-align: center;
}

.sidebar-item-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-badge {
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  padding: 3.5px 9px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
}

/* ---- Footer (usuario / logout) ---- */
.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding: 14px 12px;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-footer #dian-nav-status {
  white-space: nowrap;
  margin-bottom: 8px;
}

.sidebar-userbox {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: 11px;
}

.sidebar-userbox-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(145deg, #1D4ED8, #1E40AF);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-userbox-info {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-userbox-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--sidebar-text-active);
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-userbox-role {
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.4);
}

.sidebar-userbox-logout {
  flex-shrink: 0;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: color 0.12s ease;
}

.sidebar-userbox-logout:hover { color: var(--sidebar-text-active); }

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-height);
  background: var(--app-surface);
  border-bottom: 1px solid var(--app-border);
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.topbar-title {
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.3px;
  color: var(--app-text);
  line-height: 1.2;
}

.topbar-subtitle {
  font-size: 12.5px;
  color: var(--app-text-muted);
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Chip de empresa conectada en el header (§6.1) */
.topbar-empresa {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 6px 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 10px;
  max-width: 300px;
}
.topbar-empresa-dot {
  width: 8px; height: 8px; border-radius: 99px;
  background: #10B981; flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}
.topbar-empresa-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.18; }
.topbar-empresa-nombre {
  font-size: 12.5px; font-weight: 700; color: var(--accent-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-empresa-nit { font-family: var(--font-mono); font-size: 10.5px; color: var(--app-text-muted); }

.sidebar-toggle-mobile {
  display: none;
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--app-text);
  padding: var(--space-1) var(--space-2);
}

/* ---- Page content ---- */
.page-content { padding: 24px 32px 40px; flex: 1; }

.page-header { margin-bottom: var(--space-5); }

.page-title {
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--app-text);
  margin: 0;
}

.page-description {
  font-size: var(--text-sm);
  color: var(--app-text-muted);
  margin-top: 2px;
}

/* ---- Card base ---- */
.card {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* ---- Responsive: móvil (sidebar off-canvas) ---- */
@media (max-width: 767.98px) {
  .sidebar {
    left: -100%;
    box-shadow: none;
  }
  .sidebar.sidebar-open {
    left: 0;
    box-shadow: var(--shadow-lg);
  }
  .main-content { margin-left: 0; }
  .sidebar-toggle-mobile {
    display: inline-flex;
    align-items: center;
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(36, 29, 24, 0.45);
    z-index: 1025;
  }
  .sidebar-backdrop.show { display: block; }
}
