/* === SIDEBAR LAYOUT === */
:root {
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 56px;
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-text-muted: #94a3b8;
  --sidebar-item-hover-bg: rgba(255,255,255,0.06);
  --sidebar-item-hover-text: #f1f5f9;
  --sidebar-item-active-bg: rgba(230,51,63,0.15);
  --sidebar-item-active-text: #f9a3a9;
  --sidebar-item-active-indicator: #e6333f;
  --sidebar-border: rgba(255,255,255,0.08);
  --sidebar-section-label: #64748b;
  --sidebar-focus-ring: #f9a3a9;
  --sidebar-icon: #94a3b8;
  --sidebar-icon-active: #f26d76;
  --topbar-height: 56px;
}

.admin-layout {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.admin-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.admin-main {
  flex: 1;
}

/* Sidebar header */
.sidebar-header {
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-logo-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.sidebar-logo-img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.sidebar-logo-text {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}

/* Sidebar nav */
.sidebar-nav {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sidebar-section-label);
  padding: 20px 16px 4px;
  margin: 0;
}

.sidebar-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* NavItem */
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  min-height: 44px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 6px;
  position: relative;
  transition: background-color 150ms ease-out, color 150ms ease-out;
  font-size: 14px;
  font-weight: 500;
}

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

.sidebar-item[aria-current="page"] {
  background-color: var(--sidebar-item-active-bg);
  color: var(--sidebar-item-active-text);
}

.sidebar-item[aria-current="page"]::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--sidebar-item-active-indicator);
  border-radius: 0 2px 2px 0;
}

.sidebar-item:focus-visible {
  outline: 2px solid var(--sidebar-focus-ring);
  outline-offset: -2px;
  border-radius: 6px;
}

.sidebar-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--sidebar-icon);
  transition: color 150ms ease-out;
}

.sidebar-item:hover .sidebar-icon,
.sidebar-item[aria-current="page"] .sidebar-icon {
  color: var(--sidebar-icon-active);
}

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--sidebar-border);
  margin-top: auto;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  margin-bottom: 4px;
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #475569, #1e293b);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 500;
  color: #e2e8f0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--sidebar-text-muted);
  margin: 0;
  text-transform: capitalize;
}

.sidebar-logout-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  min-height: 44px;
  border-radius: 6px;
  color: var(--sidebar-text-muted);
  text-decoration: none;
  font-size: 13px;
  transition: color 150ms ease-out, background-color 150ms ease-out;
  width: 100%;
}

.sidebar-logout-btn:hover {
  color: #f87171;
  background-color: rgba(239,68,68,0.1);
}

.sidebar-logout-btn:focus-visible {
  outline: 2px solid var(--sidebar-focus-ring);
  outline-offset: -2px;
  border-radius: 6px;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #000;
  color: #fff;
  padding: 8px 16px;
  z-index: 100;
  font-size: 14px;
  text-decoration: none;
  transition: top 0ms;
}

.skip-link:focus {
  top: 0;
}

/* Admin topbar (tutti i breakpoint — ospita la global search da Tranche 4 redesign IA) */
.admin-topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 40;
}

/* Sidebar backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  z-index: 30;
}

.sidebar-backdrop.is-visible {
  display: block;
}

/* Mobile breakpoint */
@media (max-width: 767px) {
  .admin-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 200ms ease-out;
    width: 280px;
    height: 100%;
  }

  .admin-sidebar.is-open {
    transform: translateX(0);
  }

  .admin-content {
    margin-left: 0;
  }
}

/* Tablet breakpoint */
@media (min-width: 768px) and (max-width: 1023px) {
  .admin-sidebar {
    width: var(--sidebar-collapsed-width);
  }

  .sidebar-label,
  .sidebar-logo-text,
  .sidebar-section-label,
  .sidebar-user-info {
    display: none;
  }
}

/* Desktop breakpoint */
@media (min-width: 1024px) {
  .admin-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .admin-sidebar,
  .sidebar-backdrop,
  .sidebar-item {
    transition: none;
  }
}
