:root {
  --bs-brand: #3366cc;
  --bs-brand-rgb: 51, 102, 204;
  --bs-brand-dark: #125ca2;
  --bs-brand-light: #5580d4;
  --bs-sidebar-bg: #1e1e2e;
}

.btn-brand {
  background-color: var(--bs-brand);
  border-color: var(--bs-brand);
  color: #fff;
}
.btn-brand:hover, .btn-brand:focus {
  background-color: var(--bs-brand-dark);
  border-color: var(--bs-brand-dark);
  color: #fff;
}
.btn-outline-brand {
  border-color: var(--bs-brand);
  color: var(--bs-brand);
  background-color: transparent;
}
.btn-outline-brand:hover {
  background-color: var(--bs-brand);
  color: #fff;
}
.bg-brand {
  background-color: var(--bs-brand) !important;
}
.text-brand {
  color: var(--bs-brand) !important;
}
.border-brand {
  border-color: var(--bs-brand) !important;
}
.alert-brand {
  background-color: rgba(51,102,204,0.1);
  border-color: var(--bs-brand);
  color: var(--bs-brand-dark);
}

/* ── Sidebar layout ── */
.sidebar-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  min-height: 100vh;
  background-color: #1e1e2e;
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1040;
  transition: width 0.25s ease;
  overflow-x: hidden;
}

.sidebar.collapsed {
  width: 64px;
}

.sidebar-header {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-brand {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
  overflow-y: auto;
}

.sidebar-item {
  list-style: none;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  color: rgba(255,255,255,0.70);
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s;
  border-left: 3px solid transparent;
  cursor: pointer;
}

.sidebar-link:hover,
.sidebar-link.active {
  background-color: rgba(255,255,255,0.08);
  color: #fff;
  border-left-color: var(--bs-brand);
}

.sidebar-link .sidebar-icon {
  font-size: 1.1rem;
  min-width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-link .sidebar-label {
  transition: opacity 0.2s;
}

.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .sidebar-arrow {
  opacity: 0;
  pointer-events: none;
}

.sidebar-submenu {
  list-style: none;
  padding: 0;
  background-color: rgba(0,0,0,0.25);
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
}

.sidebar-submenu.open {
  max-height: 300px;
}

.sidebar-submenu .sidebar-link {
  padding-left: 2.5rem;
  font-size: 0.85rem;
}

.sidebar-arrow {
  margin-left: auto;
  font-size: 0.75rem;
  transition: transform 0.25s;
}

.sidebar-link[aria-expanded="true"] .sidebar-arrow {
  transform: rotate(90deg);
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-user {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.55);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.main-content {
  margin-left: 260px;
  flex: 1;
  min-height: 100vh;
  transition: margin-left 0.25s ease;
  background-color: #f8f9fa;
}

.main-content.sidebar-collapsed {
  margin-left: 64px;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: #fff;
  border-bottom: 1px solid #dee2e6;
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #343a40;
  flex: 1;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

@media (max-width: 768px) {
  .sidebar {
    width: 260px;
    transform: translateX(-260px);
    position: fixed;
    transition: transform 0.25s ease, width 0.25s ease;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    width: 260px;
  }
  .sidebar.collapsed {
    width: 260px;
  }
  .main-content {
    margin-left: 0 !important;
  }
  .topbar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .topbar-title {
    flex: 1 1 100%;
    order: 2;
    font-size: 0.95rem;
  }
  .sidebar-toggle {
    order: 1;
  }
  .topbar-user {
    order: 3;
    margin-left: auto;
  }
}

/* Backdrop overlay para sidebar en móvil */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1039;
}
.sidebar-backdrop.show {
  display: block;
}

/* Tom Select — match Bootstrap form-select sizing */
.ts-wrapper.form-control, .ts-wrapper.form-select {
  padding: 0;
  height: auto;
}
.ts-control {
  border: none !important;
  box-shadow: none !important;
}
