/* =============================================================================
   K-BOTANAS · Sidebar + Topbar — Riel oscuro plegable 74 ↔ 232
   Requiere kb-design-system.css cargado antes que este archivo.
   ========================================================================== */

/* Layout global: riel fijo + main con margen que se ajusta al plegado */
.kb-app { min-height: 100vh; }
.kb-main {
  min-width: 0; display: flex; flex-direction: column;
  margin-left: var(--kb-rail-w);
  transition: margin-left .22s cubic-bezier(.4,0,.2,1);
}
body.kb-nav-open .kb-main { margin-left: var(--kb-rail-w-open); }
@media (max-width: 880px) {
  .kb-main { margin-left: 0; }
  body.kb-nav-open .kb-main { margin-left: 0; }
}

/* ============ SIDEBAR ============ */
.kb-sidebar {
  position: fixed; top: 0; left: 0; height: 100vh; z-index: 50;
  width: var(--kb-rail-w);
  background: var(--kb-rail);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: width .22s cubic-bezier(.4,0,.2,1);
}
body.kb-nav-open .kb-sidebar {
  width: var(--kb-rail-w-open);
  box-shadow: 6px 0 28px rgba(0,0,0,.28);
}
@media (max-width: 880px) {
  .kb-sidebar { width: var(--kb-rail-w-open); transform: translateX(-100%); transition: transform .25s ease; }
  .kb-sidebar.is-open { transform: translateX(0); }
  body.kb-nav-open .kb-sidebar { width: var(--kb-rail-w-open); }
}

/* Toggle */
.kb-sb-toggle {
  width: 46px; height: 46px; border: 0; background: transparent; color: var(--kb-rail-muted);
  cursor: pointer; display: grid; place-items: center; border-radius: 12px;
  margin: 4px auto 2px; flex-shrink: 0;
}
.kb-sb-toggle:hover { background: var(--kb-rail-hover); color: var(--kb-rail-text); }
body.kb-nav-open .kb-sb-toggle { width: calc(100% - 16px); justify-content: flex-start; padding: 0 13px; margin: 4px 8px 2px; }

/* Marca */
.kb-sb-brand { display: flex; align-items: center; gap: 11px; padding: 8px 14px 12px;
  justify-content: center; flex-shrink: 0; border-bottom: none; }
body.kb-nav-open .kb-sb-brand { justify-content: flex-start; }
.kb-sb-logo { width: 38px; height: 38px; border-radius: 11px; background: var(--kb-accent-grad);
  color: #fff; display: grid; place-items: center; font-family: var(--kb-font-display);
  font-weight: 700; font-size: 18px; flex-shrink: 0; }
.kb-sb-brand-text { display: none; line-height: 1.1; min-width: 0; }
body.kb-nav-open .kb-sb-brand-text { display: block; }
.kb-sb-brand-name { font-family: var(--kb-font-display); font-size: 14px; font-weight: 700; color: #fff; }
.kb-sb-brand-sub { font-family: var(--kb-font-mono); font-size: 8px; letter-spacing: .16em;
  text-transform: uppercase; color: rgba(255,255,255,.42); margin-top: 2px; }

/* Sucursal: solo visible al desplegar */
.kb-sb-branch { display: none; padding: 4px 14px 10px; flex-shrink: 0; }
body.kb-nav-open .kb-sb-branch { display: block; }
.kb-sb-branch-label { font-family: var(--kb-font-mono); font-size: 9px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--kb-rail-muted); margin-bottom: 4px; }
.kb-sb-branch-row { display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 500; color: var(--kb-rail-text); }
.kb-sb-branch-row svg { color: var(--kb-rail-muted); flex-shrink: 0; }

/* Grupos / secciones */
.kb-sb-group { margin-bottom: 8px; }
.kb-sb-group-title { display: none; font-family: var(--kb-font-mono); text-transform: uppercase;
  letter-spacing: .16em; font-size: 9px; color: var(--kb-rail-muted); padding: 12px 13px 4px; }
body.kb-nav-open .kb-sb-group-title { display: block; }

/* Nav items */
.kb-sb-nav { padding: 6px 8px; flex: 1; overflow-y: auto; overflow-x: hidden; }
.kb-sb-nav::-webkit-scrollbar { width: 0; }

.kb-nav-item {
  position: relative; display: flex; align-items: center; gap: 13px;
  width: 46px; height: 46px; margin: 2px auto; padding: 0; justify-content: center;
  border-radius: 12px; color: var(--kb-rail-muted); font-size: 13px; font-weight: 600;
  cursor: pointer; text-decoration: none; border: none; background: none;
  font-family: inherit; text-align: left;
}
body.kb-nav-open .kb-nav-item { width: 100%; justify-content: flex-start; padding: 0 13px; }
.kb-nav-item:hover { background: var(--kb-rail-hover); color: var(--kb-rail-text); }
.kb-nav-item.active { background: var(--kb-rail-active-bg); color: var(--kb-accent-2); }
.kb-nav-item.active::before { content: ""; position: absolute; left: -8px; top: 11px; bottom: 11px;
  width: 3px; border-radius: 3px; background: var(--kb-accent-2); }
body.kb-nav-open .kb-nav-item.active::before { left: -5px; }
.kb-nav-item.disabled { cursor: default; opacity: .55; }

.kb-nav-icon { width: 20px; height: 20px; flex-shrink: 0; display: grid; place-items: center; }
.kb-nav-icon svg { width: 20px; height: 20px; }
.kb-nav-label { display: none; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.kb-nav-open .kb-nav-label { display: block; }

/* tooltip (solo modo plegado) */
.kb-nav-tt { position: absolute; left: 56px; top: 50%; transform: translateY(-50%);
  background: var(--kb-rail); color: #fff; font-size: 11px; padding: 5px 9px; border-radius: 7px;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: .12s; z-index: 60; font-weight: 500; }
.kb-nav-item:hover .kb-nav-tt { opacity: 1; }
body.kb-nav-open .kb-nav-tt { display: none; }

.kb-nav-badge { display: none; font-size: 10.5px; font-weight: 700; background: var(--kb-accent-grad);
  color: #fff; padding: 1px 8px; border-radius: 999px; flex-shrink: 0; font-family: var(--kb-font-mono); }
body.kb-nav-open .kb-nav-badge { display: inline-flex; }
.kb-nav-badge.soon { background: transparent; color: var(--kb-rail-muted);
  border: 1px solid var(--kb-rail-hover); }

/* Footer (user) */
.kb-sb-user { display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-top: 1px solid var(--kb-rail-hover); flex-shrink: 0; justify-content: center; }
body.kb-nav-open .kb-sb-user { justify-content: flex-start; }
.kb-sb-avatar { width: 38px; height: 38px; border-radius: 11px; background: #2c1f27;
  color: var(--kb-accent-2); display: grid; place-items: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.kb-sb-user-meta { display: none; flex: 1; min-width: 0; line-height: 1.1; }
body.kb-nav-open .kb-sb-user-meta { display: block; }
.kb-sb-user-name { font-size: 12.5px; font-weight: 600; color: var(--kb-rail-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-sb-user-role { font-size: 10px; color: var(--kb-rail-muted); }
.kb-sb-logout { display: none; background: none; border: none; cursor: pointer; color: var(--kb-rail-muted);
  padding: 4px; border-radius: 6px; place-items: center; }
body.kb-nav-open .kb-sb-logout { display: grid; }
.kb-sb-logout:hover { background: var(--kb-rail-hover); color: var(--kb-accent-2); }

/* ============ TOPBAR ============ */
.kb-topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--kb-line);
  background: var(--kb-paper);
  position: sticky; top: 0; z-index: 50;
}
.kb-topbar-mobile-btn {
  display: none;
  background: none; border: 1px solid var(--kb-line-strong);
  width: 36px; height: 36px;
  border-radius: 8px;
  cursor: pointer;
  align-items: center; justify-content: center;
  color: var(--kb-ink-2);
}
@media (max-width: 880px) {
  .kb-topbar-mobile-btn { display: inline-flex; }
}

.kb-topbar-title {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
}
.kb-topbar-title h1 {
  font-family: var(--kb-font-display);
  font-size: 22px;
  letter-spacing: -0.015em;
  font-weight: 500;
  color: var(--kb-ink);
}

.kb-topbar-search {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--kb-line);
  background: var(--kb-cream-soft);
  min-width: 220px;
}
.kb-topbar-search input {
  border: none; outline: none; background: transparent;
  font-size: 12.5px; color: var(--kb-ink);
  flex: 1;
  font-family: var(--kb-font-sans);
}
.kb-topbar-search input::placeholder { color: var(--kb-ink-4); }

.kb-topbar-bell {
  position: relative;
  background: none; border: 1px solid var(--kb-line);
  width: 36px; height: 36px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--kb-ink-2);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s;
}
.kb-topbar-bell:hover { background: var(--kb-cream-soft); }
.kb-topbar-bell-dot {
  position: absolute; top: 7px; right: 7px;
  width: 7px; height: 7px;
  background: var(--kb-terracotta);
  border-radius: 50%;
}

/* Mobile drawer overlay */
.kb-drawer-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(31,26,20,.5);
  backdrop-filter: blur(2px);
  z-index: 150;
}
.kb-drawer-overlay.is-open { display: block; }

/* Main content */
.kb-main-content {
  padding: 24px 28px 60px;
  flex: 1;
}
@media (max-width: 880px) {
  .kb-main-content { padding: 18px 16px 60px; }
}

/* Eyebrow */
.kb-eyebrow {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--kb-terracotta);
  font-weight: 600;
  margin-bottom: 8px;
}
