/* ══════════════════════════════════════
   SIDEBAR — Puerto Chancay / COSCO
══════════════════════════════════════ */

/* ── OVERLAY MÓVIL ── */
.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(4,28,60,0.45);
  z-index: 150;
  opacity: 0;
  transition: opacity var(--trans);
  backdrop-filter: blur(2px);
}
.overlay.show { opacity: 1; }

/* ══ SIDEBAR ══ */
.sidebar {
  width: var(--sw);
  background: var(--blanco);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--gris-borde);
  box-shadow: 2px 0 12px rgba(0,0,0,0.04);
  z-index: 200;
  transition: width var(--trans);
  overflow: hidden;
  position: relative;
}
.sidebar.col { width: var(--sc); }

/* ── BRAND ── */
.sb-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 14px 16px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--gris-borde);
  overflow: hidden;
  transition: padding var(--trans), height var(--trans);
  gap: 10px;
}
.sidebar.col .sb-brand {
  padding: 14px 0;
  gap: 0;
}

.brand-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--trans);
}

.brand-logo-img {
  width: 120px;
  height: auto;
  object-fit: contain;
  transition: width var(--trans), opacity var(--trans);
}
.sidebar.col .brand-logo-img { width: 32px; }

.brand-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  line-height: 1.3;
  opacity: 1;
  max-height: 50px;
  overflow: hidden;
  transition: opacity var(--trans), max-height var(--trans), margin var(--trans);
}
.sidebar.col .brand-text {
  opacity: 0;
  max-height: 0;
  pointer-events: none;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--texto-main);
  letter-spacing: -0.2px;
  white-space: nowrap;
}
.brand-name span { color: var(--azul-medio); }

.brand-sub {
  font-size: 9px;
  color: var(--gris-texto);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 600;
  white-space: nowrap;
  margin-top: 2px;
}

/* ── NAV ── */
.sb-nav {
  flex: 1;
  overflow-y: auto; overflow-x: hidden;
  padding: 12px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--gris-borde) transparent;
  transition: padding var(--trans);
}
.sidebar.col .sb-nav { padding: 12px 0; }

.nav-divider {
  height: 1px;
  background: var(--gris-borde);
  margin: 8px 0 12px;
  transition: opacity var(--trans);
}
.sidebar.col .nav-divider { opacity: 0; margin: 4px 0; }

.nav-sep {
  font-size: 10.5px; font-weight: 700;
  color: var(--texto-main);
  padding: 0 10px 8px;
  display: block; white-space: nowrap;
  transition: opacity var(--trans), height var(--trans), padding var(--trans);
  height: 30px; overflow: hidden;
}
.sidebar.col .nav-sep { opacity: 0; height: 0; padding: 0; }

/* ── NAV ITEM ── */
.nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  height: 44px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  color: var(--gris-texto);
  font-size: 13.5px; font-weight: 500;
  transition: background var(--trans), color var(--trans), box-shadow var(--trans);
  position: relative;
  margin-bottom: 2px;
  overflow: hidden;
  white-space: nowrap;
  padding: 0;
  box-sizing: border-box;
}
.nav-item:hover {
  background: var(--gris-fondo);
  color: var(--texto-main);
}
.nav-item.active {
  background: linear-gradient(135deg, var(--azul-medio) 0%, var(--azul-claro) 100%);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(24,95,165,0.30);
}
.nav-item.active .nav-icon svg { color: #fff; }
.nav-item.active .nav-chevron  { color: rgba(255,255,255,0.65); }
.nav-item.active .nav-badge    { background: rgba(255,255,255,0.25); color: #fff; }

/* ── NAV ICON ── */
.nav-icon {
  min-width: var(--sc);
  width: var(--sc);
  height: 44px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; flex-grow: 0;
}
.nav-icon svg {
  width: 18px; height: 18px;
  color: var(--gris-texto);
  flex-shrink: 0;
  transition: color var(--trans);
  display: block;
}
.nav-item:hover .nav-icon svg { color: var(--texto-main); }
.sidebar.col .nav-icon { min-width: var(--sc); width: var(--sc); }

/* ── NAV LABEL ── */
.nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity var(--trans), max-width var(--trans);
  opacity: 1; max-width: 200px;
}
.sidebar.col .nav-label { opacity: 0; max-width: 0; pointer-events: none; }

/* ── BADGE ── */
.nav-badge {
  height: 18px; min-width: 18px; padding: 0 5px;
  background: var(--azul-claro);
  color: #fff; font-size: 9px; font-weight: 700;
  border-radius: 9px; line-height: 18px; text-align: center;
  flex-shrink: 0; margin-right: 10px;
  transition: opacity var(--trans), transform var(--trans);
}
.sidebar.col .nav-badge { opacity: 0; transform: scale(0); margin: 0; }

/* ── CHEVRON ── */
.nav-chevron {
  width: 32px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: #C0C8D2;
  transition: transform var(--trans), color var(--trans), opacity var(--trans), width var(--trans);
}
.nav-chevron svg { width: 14px; height: 14px; }
.nav-item.open   .nav-chevron { transform: rotate(180deg); }
.nav-item:hover  .nav-chevron { color: var(--gris-texto); }
.sidebar.col     .nav-chevron { opacity: 0; width: 0; pointer-events: none; }

/* ── TOOLTIP ── */
.nav-item .tip {
  position: fixed;
  left: calc(var(--sc) + 10px);
  background: var(--texto-main);
  color: #fff; font-size: 12px; font-weight: 500;
  padding: 6px 12px; border-radius: 8px;
  white-space: nowrap; pointer-events: none;
  opacity: 0; z-index: 9999;
  transition: opacity 0.15s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}
.nav-item .tip::before {
  content: '';
  position: absolute; left: -5px; top: 50%; transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: var(--texto-main);
  border-left: 0;
}
.sidebar.col .nav-item:hover .tip { opacity: 1; }

/* ── SUBMENÚ ── */
.submenu {
  overflow: hidden; max-height: 0;
  transition: max-height 0.28s ease;
}
.submenu.open         { max-height: 300px; }
.sidebar.col .submenu { max-height: 0 !important; }

.sub-item {
  display: flex;
  align-items: center;
  width: 100%;
  height: 38px;
  border-radius: 8px;
  cursor: pointer; text-decoration: none;
  color: var(--gris-texto);
  font-size: 13px; font-weight: 500;
  transition: background var(--trans), color var(--trans);
  margin-bottom: 1px;
  overflow: hidden;
  box-sizing: border-box;
}
.sub-item:hover  { background: var(--gris-fondo); color: var(--azul-medio); }
.sub-item.active { color: var(--azul-medio); font-weight: 600; background: rgba(24,95,165,0.06); }

.sub-dot {
  min-width: var(--sc);
  width: var(--sc);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sub-dot::after {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gris-borde);
  transition: background var(--trans);
}
.sub-item:hover  .sub-dot::after,
.sub-item.active .sub-dot::after { background: var(--azul-claro); }

.sub-label {
  overflow: hidden;
  transition: opacity var(--trans), max-width var(--trans);
  opacity: 1; max-width: 200px;
}
.sidebar.col .sub-label { opacity: 0; max-width: 0; }

/* ── FOOTER DEL SIDEBAR ── */
.sb-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--gris-borde);
  padding: 12px 10px;
  transition: padding var(--trans);
}
.sidebar.col .sb-footer { padding: 12px 0; }

.cosco-row {
  display: flex; align-items: center; justify-content: center;
  padding: 4px 0 10px; opacity: .28;
  transition: opacity var(--trans), height var(--trans), padding var(--trans);
  height: 30px; overflow: hidden;
}
.cosco-row img { height: 15px; object-fit: contain; }
.sidebar.col .cosco-row { height: 0; opacity: 0; padding: 0; }

/* ── USER CARD ── */
.user-card {
  display: flex;
  align-items: center;
  height: 52px;
  border-radius: 12px;
  cursor: pointer;
  background: var(--gris-fondo);
  border: 1px solid var(--gris-borde);
  transition: background var(--trans), box-shadow var(--trans), border-color var(--trans);
  overflow: hidden;
  padding: 0;
}
.user-card:hover {
  background: #eaf0f8;
  box-shadow: 0 2px 10px rgba(24,95,165,0.10);
  border-color: rgba(24,95,165,0.20);
}
.sidebar.col .user-card {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  justify-content: center;
}

.user-avatar {
  min-width: var(--sc);
  width: var(--sc);
  height: 52px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: min-width var(--trans), width var(--trans);
}
.sidebar.col .user-avatar { min-width: var(--sc); width: var(--sc); }

.avatar-circle {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--azul-medio), var(--azul-claro));
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
  box-shadow: 0 3px 8px rgba(24,95,165,0.28);
  transition: border-radius var(--trans);
}
.sidebar.col .avatar-circle { border-radius: 50%; }

.user-info {
  flex: 1;
  overflow: hidden;
  transition: opacity var(--trans), max-width var(--trans);
  opacity: 1; max-width: 160px;
}
.sidebar.col .user-info { opacity: 0; max-width: 0; pointer-events: none; }

.user-name {
  font-size: 12.5px; font-weight: 600;
  color: var(--texto-main); white-space: nowrap;
}
.user-role {
  font-size: 10px; color: var(--gris-texto); white-space: nowrap;
  display: flex; align-items: center; gap: 4px; margin-top: 1px;
}
.user-role::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: #10B981; box-shadow: 0 0 5px #10B981; flex-shrink: 0;
}

.user-chevron-icon {
  display: flex; align-items: center; justify-content: center;
  width: 32px; color: #C0C8D2;
  transition: opacity var(--trans), width var(--trans);
}
.sidebar.col .user-chevron-icon { opacity: 0; width: 0; }

/* ══ RESPONSIVE SIDEBAR ══ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sw) !important;
    transform: translateX(-100%);
    transition: transform var(--trans);
    z-index: 200;
    box-shadow: none;
  }
  .sidebar.mob-open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(4,28,60,0.20);
  }
  .overlay { display: block; }
}
