/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--t-med);
  z-index: 100;
  user-select: none;
  border-right: 1px solid var(--sidebar-border);
}

.sidebar--collapsed { width: var(--sidebar-width-sm); }

/* ── Header ──────────────────────────────────────────────────────────────── */
.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 14px;
  height: 52px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  gap: 8px;
}

.sidebar__logo-link {
  display: flex;
  align-items: center;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

/* Full logo SVG (white version via filter) */
.sidebar__logo-img {
  height: 22px;
  width: auto;
  filter: brightness(0) invert(1);
  opacity: .92;
  flex-shrink: 0;
  transition: opacity var(--t-fast);
}
.sidebar__logo-img:hover { opacity: 1; }

/* Collapsed: show pig icon on white background */
.sidebar__logo-icon {
  display: none;
  width: 32px; height: 32px;
  background: #fff;
  border-radius: var(--radius);
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar__pig-icon {
  width: 26px;
  height: 26px;
  object-fit: contain;
  display: block;
}

.sidebar--collapsed .sidebar__logo-img  { display: none; }
.sidebar--collapsed .sidebar__logo-icon { display: flex; }

/* Collapsed header: stack logo-icon + expand button vertically */
.sidebar--collapsed .sidebar__header {
  flex-direction: column;
  justify-content: center;
  padding: 0;
  height: auto;
  min-height: 76px;
  gap: 4px;
}

/* Toggle button */
.sidebar__toggle {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
}
.sidebar__toggle:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar__toggle svg { width: 16px; height: 16px; }

/* Развёрнут: показываем кнопку свернуть, прячем раскрывашку */
.sidebar__toggle--expand { display: none; }

/* Свёрнут: прячем кнопку свернуть, показываем раскрывашку */
.sidebar--collapsed .sidebar__toggle--collapse { display: none; }
.sidebar--collapsed .sidebar__toggle--expand   { display: flex; }

/* ── Mode switch (Розница / ГУПР) ───────────────────────────────────────── */
.sidebar__mode-switch {
  display: flex;
  gap: 2px;
  margin: 8px 10px;
  padding: 2px;
  background: rgba(255,255,255,.06);
  border-radius: var(--radius);
  flex-shrink: 0;
}

.sidebar__mode-btn {
  flex: 1;
  padding: 6px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--sidebar-text);
  border-radius: var(--radius-sm);
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}

.sidebar__mode-btn:hover { color: var(--sidebar-text-active); }

.sidebar__mode-btn--active {
  background: var(--brand);
  color: #fff;
}

.sidebar--collapsed .sidebar__mode-switch { display: none; }

/* ── Nav ─────────────────────────────────────────────────────────────────── */
.sidebar__nav {
  flex: 1;
  padding: 6px 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar__divider {
  height: 1px;
  background: var(--sidebar-border);
  margin: 5px 10px;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  height: 36px;
  margin: 1px 6px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
}

.sidebar__link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

.sidebar__link--active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
}

/* Green left accent on active */
.sidebar__link--active::before {
  content: '';
  position: absolute;
  left: -6px; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--brand);
  border-radius: 0 2px 2px 0;
}

.sidebar__icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: .75;
}
.sidebar__link--active .sidebar__icon,
.sidebar__link:hover .sidebar__icon { opacity: 1; }
.sidebar__icon svg { width: 16px; height: 16px; }

.sidebar__label {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity var(--t-fast);
}

/* Collapsed state */
.sidebar--collapsed .sidebar__link {
  justify-content: center;
  padding: 0;
  margin: 1px 8px;
}
.sidebar--collapsed .sidebar__label { opacity: 0; width: 0; }
.sidebar--collapsed .sidebar__link::before { display: none; }

/* Tooltip on collapsed hover */
.sidebar--collapsed .sidebar__link::after {
  content: attr(title);
  position: absolute;
  left: calc(var(--sidebar-width-sm) - 4px);
  top: 50%; transform: translateY(-50%);
  background: #1c2029;
  color: #fff;
  font-size: 12.5px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  z-index: 200;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity var(--t-fast);
}
.sidebar--collapsed .sidebar__link:hover::after { opacity: 1; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.sidebar__footer {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--sidebar-border);
  gap: 8px;
  flex-shrink: 0;
  overflow: hidden;
  min-height: 52px;
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.sidebar__avatar {
  width: 28px; height: 28px;
  background: var(--brand);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar__user-info { min-width: 0; overflow: hidden; }

.sidebar__user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: #d0d4dc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__user-role {
  font-size: 11px;
  color: var(--sidebar-text);
  white-space: nowrap;
}

.sidebar--collapsed .sidebar__user-info { display: none; }
.sidebar--collapsed .sidebar__user { justify-content: center; }

.sidebar__logout {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
}
.sidebar__logout svg { width: 15px; height: 15px; }
.sidebar__logout:hover { background: rgba(204,43,29,.18); color: var(--red); }
.sidebar--collapsed .sidebar__logout { display: none; }

/* ── Nav badge ───────────────────────────────────────────────────────────── */
.sidebar__badge[hidden] { display: none; }

.sidebar__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  margin-left: auto;
  flex-shrink: 0;
  line-height: 1;
}

.sidebar--collapsed .sidebar__badge {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  font-size: 8px;
  border-radius: 7px;
  margin-left: 0;
}

/* Логотип клиники цветной на белом — на тёмном сайдбаре кладём его на подложку. */
.sidebar__logo-img { background: #fff; padding: 4px 8px; border-radius: var(--radius); height: 34px; width: auto; }
.sidebar__logo-icon img { width: 28px; height: 28px; object-fit: contain; background: #fff; border-radius: var(--radius-sm); }
