/**
 * ==============================================================================
 * AJBRANCH EXECUTIVE COLLAPSIBLE SIDEBAR STYLES
 * ==============================================================================
 * Conforms to Urbanist typography, gold glow accents & micro-interactions.
 * 
 * TABLE OF CONTENTS:
 * 1. LAYOUT & ROOT CONTAINER
 * 2. HEADER: BRAND & TOP ACTIONS (32x32)
 * 3. NAVIGATION: GROUPS, ITEMS & BADGES
 * 4. BOTTOM UTILITIES: SETTINGS & THEME
 * 5. EXECUTIVE USER PROFILE & MARQUEE
 * 6. COLLAPSED RAIL STATE RULES
 * ==============================================================================
 */

/* ─────────────────────────────────────────────────────────────
   1. LAYOUT & ROOT CONTAINER
   ───────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  background-color: var(--bg-app);
}

.app-sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100vh;
  flex-shrink: 0;
  transition: width 0.24s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  z-index: 100;
  user-select: none;
}

.app-sidebar.collapsed {
  width: 72px;
}

/* ─────────────────────────────────────────────────────────────
   2. HEADER: BRAND & TOP ACTIONS (32x32)
   ───────────────────────────────────────────────────────────── */
.sidebar-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 60px;
  min-height: 60px;
  box-sizing: border-box;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  text-decoration: none;
  flex: 1;
  min-width: 0;
}

.brand-logo-badge {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  background: linear-gradient(135deg, #1e1b18 0%, #0f1015 100%);
  border: 1px solid var(--accent-gold);
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(201, 162, 39, 0.2);
  flex-shrink: 0;
  box-sizing: border-box;
}

[data-theme="light"] .brand-logo-badge {
  background: linear-gradient(135deg, #ffffff 0%, #f4f3ec 100%);
  border-color: var(--accent-gold);
  box-shadow: 0 2px 8px rgba(179, 136, 20, 0.15);
}

.brand-monogram {
  font-family: var(--font-sans);
  font-weight: 900;
  font-size: 14px;
  color: var(--accent-gold);
  letter-spacing: -0.5px;
  line-height: 1;
}

.brand-text {
  overflow: hidden;
  white-space: nowrap;
  transition: opacity 0.2s ease;
  min-width: 0;
}

.brand-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-sidebar);
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand-subtitle {
  font-size: 9.5px;
  color: var(--text-sidebar-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
}

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.sidebar-header-btn {
  background: var(--bg-sidebar-item);
  border: 1px solid var(--border-sidebar-item);
  border-radius: var(--radius-xs);
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sidebar-muted);
  cursor: pointer;
  position: relative;
  transition: all 0.18s ease;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

.sidebar-header-btn:hover {
  background: var(--bg-sidebar-item-hover);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.sidebar-header-btn .svg-icon {
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
  display: block;
}

.header-notif-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: var(--status-crimson);
  color: #fff;
  border: 1.5px solid var(--bg-sidebar);
  font-size: 9px;
  font-weight: 900;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0 3px;
}

.svg-collapse-icon {
  width: 16px;
  height: 16px;
  transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─────────────────────────────────────────────────────────────
   3. NAVIGATION: GROUPS, ITEMS & BADGES
   ───────────────────────────────────────────────────────────── */
.sidebar-nav {
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-sidebar-muted);
  padding: 6px 12px 2px;
  opacity: 0.75;
  transition: all 0.2s ease;
  user-select: none;
}

.nav-section-label:not(:first-child) {
  margin-top: 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  min-height: 40px;
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  color: var(--text-sidebar);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
  position: relative;
  box-sizing: border-box;
  text-align: left;
}

.nav-active-pill {
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background-color: transparent;
  border-radius: 0 2px 2px 0;
  transition: background-color 0.18s ease;
}

.nav-item:hover {
  background-color: var(--bg-sidebar-hover);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.nav-item:hover .nav-icon {
  transform: scale(1.08);
  color: var(--accent-gold);
}

.nav-item.active {
  background: var(--bg-sidebar-active);
  border-color: rgba(201, 162, 39, 0.28);
  color: var(--accent-gold);
  font-weight: 700;
}

.nav-item.active .nav-active-pill {
  background-color: var(--accent-gold);
  box-shadow: 0 0 8px var(--accent-gold);
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  position: relative;
  transition: transform 0.18s ease, color 0.18s ease;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
}

.nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Badge superpuesto en la esquina superior derecha del icono */
.nav-icon-badge {
  position: absolute;
  top: -5px;
  right: -6px;
  background: var(--accent-gold);
  color: #000;
  border: 1.5px solid var(--bg-sidebar);
  font-size: 8.5px;
  font-weight: 900;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0 3px;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 6px rgba(201, 162, 39, 0.5);
  box-sizing: border-box;
}

/* ─────────────────────────────────────────────────────────────
   4. BOTTOM UTILITIES: SETTINGS & THEME
   ───────────────────────────────────────────────────────────── */
.sidebar-bottom-section {
  padding: 10px 8px 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-utility-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.utility-item-btn {
  flex: 1;
  height: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  background: var(--bg-sidebar-item);
  border: 1px solid var(--border-sidebar-item);
  border-radius: var(--radius-xs);
  color: var(--text-sidebar-muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
  box-sizing: border-box;
  position: relative;
}

.utility-item-btn:hover {
  background: var(--bg-sidebar-item-hover);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.utility-item-btn.active {
  background: var(--bg-sidebar-active);
  border-color: rgba(201, 162, 39, 0.55);
  color: var(--accent-gold);
  font-weight: 700;
  box-shadow: 0 0 12px rgba(201, 162, 39, 0.22);
}

.utility-item-btn.active .nav-active-pill {
  background-color: var(--accent-gold);
}

.utility-item-btn.active .nav-icon {
  color: var(--accent-gold);
  transform: scale(1.08);
}

.utility-item-btn .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.utility-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.utility-theme-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-sidebar-item);
  border: 1px solid var(--border-sidebar-item);
  border-radius: var(--radius-xs);
  color: var(--text-sidebar-muted);
  cursor: pointer;
  transition: all 0.18s ease;
  flex-shrink: 0;
  box-sizing: border-box;
  padding: 0;
}

.utility-theme-btn:hover {
  background: var(--bg-sidebar-item-hover);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.utility-theme-btn .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.utility-theme-btn svg {
  width: 18px;
  height: 18px;
}

/* ─────────────────────────────────────────────────────────────
   5. EXECUTIVE USER PROFILE & GLIDE MARQUEE
   ───────────────────────────────────────────────────────────── */
.sidebar-user-card {
  padding: 8px 10px;
  background: var(--bg-sidebar-item);
  border: 1px solid var(--border-sidebar-item);
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.18s ease;
  min-height: 48px;
  box-sizing: border-box;
  cursor: pointer;
}

.sidebar-user-card:hover {
  border-color: var(--accent-gold);
  background: var(--bg-sidebar-item-hover);
}

.user-avatar-container {
  position: relative;
  flex-shrink: 0;
}

.user-avatar-badge {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent-gold-light) 0%, rgba(0, 0, 0, 0.4) 100%);
  color: var(--accent-gold);
  border: 1px solid var(--accent-gold);
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 12.5px;
  font-family: var(--font-sans);
}

.user-online-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 7px;
  height: 7px;
  background: var(--status-emerald);
  border: 1.5px solid var(--bg-sidebar);
  border-radius: 50%;
}

.user-meta-info {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  min-width: 0;
}

.user-name-wrapper {
  overflow: hidden;
  white-space: nowrap;
  position: relative;
  width: 100%;
  display: block;
}

.user-name-label {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-sidebar);
  display: inline-block;
  white-space: nowrap;
  will-change: transform;
  cursor: pointer;
  transition: transform 0.35s ease-out;
}

.user-name-label.is-overflowing {
  animation: user-name-glide 3.8s ease-in-out infinite alternate;
}

@keyframes user-name-glide {
  0%, 20% {
    transform: translateX(0px);
  }
  80%, 100% {
    transform: translateX(var(--scroll-diff, -40px));
  }
}

.user-role-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 1px;
}

.btn-sidebar-logout {
  background: transparent;
  border: none;
  color: var(--text-sidebar-muted);
  cursor: pointer;
  padding: 4px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  transition: all 0.15s ease;
  flex-shrink: 0;
  box-sizing: border-box;
}

.btn-sidebar-logout svg {
  width: 15px;
  height: 15px;
}

.btn-sidebar-logout:hover {
  color: var(--status-crimson);
  background: rgba(244, 63, 94, 0.12);
}

/* ─────────────────────────────────────────────────────────────
   6. COLLAPSED RAIL STATE RULES (.collapsed)
   ───────────────────────────────────────────────────────────── */
.app-sidebar.collapsed .brand-text {
  display: none;
}

.app-sidebar.collapsed .sidebar-header {
  flex-direction: column;
  justify-content: center;
  padding: 10px 4px;
  height: auto;
  gap: 8px;
}

.app-sidebar.collapsed .sidebar-header-actions {
  flex-direction: column;
  gap: 6px;
}

.app-sidebar.collapsed .svg-collapse-icon {
  transform: rotate(180deg);
}

.app-sidebar.collapsed .nav-section-label:first-child {
  display: none;
}

.app-sidebar.collapsed .nav-section-label:not(:first-child) {
  display: block;
  width: 28px;
  height: 1px;
  margin: 8px auto;
  padding: 0;
  background-color: var(--border-sidebar-item);
  font-size: 0;
  color: transparent;
  opacity: 0.75;
  border-radius: var(--radius-xs);
  box-sizing: border-box;
}

.app-sidebar.collapsed .nav-label {
  display: none;
}

.app-sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0;
  width: 100%;
  height: 40px;
  min-height: 40px;
  box-sizing: border-box;
}

.app-sidebar.collapsed .sidebar-utility-row {
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.app-sidebar.collapsed .utility-label {
  display: none;
}

.app-sidebar.collapsed .utility-item-btn {
  width: 100%;
  height: 40px;
  min-height: 40px;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  box-sizing: border-box;
  position: relative;
}

.app-sidebar.collapsed .utility-item-btn:hover {
  background: var(--bg-sidebar-hover);
  border-color: transparent;
  color: var(--accent-gold);
}

.app-sidebar.collapsed .utility-item-btn.active {
  background: var(--bg-sidebar-active);
  color: var(--accent-gold);
  border-color: transparent;
  box-shadow: none;
}

.app-sidebar.collapsed .utility-theme-btn {
  width: 100%;
  height: 40px;
  min-height: 40px;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  box-sizing: border-box;
}

.app-sidebar.collapsed .utility-theme-btn:hover {
  background: var(--bg-sidebar-hover);
  border-color: transparent;
  color: var(--accent-gold);
}

.app-sidebar.collapsed .sidebar-user-card {
  width: 100%;
  height: 40px;
  min-height: 40px;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  box-sizing: border-box;
}

.app-sidebar.collapsed .sidebar-user-card:hover {
  background: var(--bg-sidebar-hover);
}

.app-sidebar.collapsed .user-meta-info {
  display: none;
}
