/* ==========================================================
   LAYOUT – SIDEBAR + MAIN + TOPBAR + CONTENT
   ========================================================== */

/* ---------- SIDEBAR ---------- */
.sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  width: 280px;
  height: 100vh; /* Altezza esplicita per garantire scroll corretto */
  background: #0b1120;
  color: var(--sidebar-text);
  padding: 14px 0 12px;
  border-inline-end: 1px solid var(--sidebar-border);
  overflow-y: auto; /* Scroll verticale abilitato */
  overflow-x: visible; /* Permette ai submenu di uscire dalla sidebar */
  z-index: 100 !important;
  /* Garantisce che i link siano cliccabili */
  pointer-events: auto;
}

/* Header logo */
.sidebar-header {
  padding-inline: 18px;
  padding-bottom: 10px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #1f4fbf;
  color: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.6);
  font-size: 16px;
}

.logo-icon.logo-img {
  object-fit: contain;
  background: transparent;
  border: none;
}

.logo-text {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.logo-text-soft {
  font-weight: 500;
  opacity: 0.8;
}

/* Nome azienda nella sidebar: sempre bianco pieno, perfetta leggibilità */
.sidebar-brand-name {
  color: #ffffff !important;
  font-weight: 700;
  letter-spacing: 0.3px;
  opacity: 1;
}

.sidebar-brand-name:hover,
.sidebar .logo a:hover .sidebar-brand-name,
.sidebar .logo a:active .sidebar-brand-name,
.sidebar .logo a:focus .sidebar-brand-name {
  color: #ffffff !important;
}

.brand-main {
  color: #fff;
}

.brand-pro {
  color: #facc15;
  font-weight: 700;
}

/* Footer */
.sidebar-footer {
  margin-top: 14px;
  padding-top: 10px;
  padding-bottom: 4px;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.footer-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 18px;
  font-size: 13px;
  font-weight: 500; /* Gerarchia: footer più evidente */
  line-height: 1.5; /* Leggibilità migliorata */
  color: var(--sidebar-text-muted);
  /* Garantisce che i link siano cliccabili */
  pointer-events: auto;
  position: relative;
  z-index: 1;
  transition: background var(--transition-fast), color var(--transition-fast),
    transform var(--transition-fast), opacity var(--transition-fast);
}

.footer-link:hover {
  background: rgba(15, 23, 42, 0.95);
  color: var(--sidebar-text);
  transform: translateX(2px);
}

.sidebar-divider {
  margin: 8px 18px;
  border-top: 1px dashed rgba(148, 163, 184, 0.4);
}

/* ---------- MAIN LAYOUT ---------- */
.main-layout {
  position: relative;
  z-index: 1;
  margin-left: 280px;
  width: calc(100% - 280px); /* Previene sovrapposizione con sidebar */
  min-height: 100vh;
  display: block;
}

/* ================================
   CONFIGURATORE LAYOUT
   ================================ */
.configurator-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: calc(100vh - 80px);
}

.configurator-header {
  position: sticky;
  top: 60px;
  z-index: 700;
  background: var(--color-bg-card);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.configurator-body {
  display: grid;
  grid-template-columns: 260px 1fr 280px;
  gap: var(--space-3);
  min-height: 520px;
  overflow: hidden;
}

.configurator-sidebar,
.configurator-properties {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-3);
  min-width: 0;
}

.configurator-canvas {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  min-height: 520px;
  overflow: hidden;
  position: relative;
}

#canvas-stage {
  width: 100%;
  height: 100%;
  min-height: 520px;
}

.configurator-drawer {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-3);
  min-width: 0;
}

/* ---------- TOPBAR ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 800 !important;
  height: 60px;
  display: flex;
  align-items: center;
  padding-inline: var(--ds-space-3, 24px);
  gap: var(--ds-space-2, 16px);
  border-bottom: 1px solid var(--border, rgba(148, 163, 184, 0.35));
  background: var(--surface, #ffffff);
  box-shadow: var(--shadow-1, 0 1px 3px rgba(15, 23, 42, 0.06));
}

.menu-toggle {
  display: none;
  border: none;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-btn);
  transition: background var(--transition-fast),
    transform var(--transition-fast);
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 16px;
}

/* ==========================================================
   TOPBAR — SEZIONE RIPRISTINATA
   ========================================================== */

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.topbar-user:hover {
  background: var(--color-bg-soft);
  transform: translateY(-1px);
  color: inherit;
  text-decoration: none;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: #2263c5;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(34, 99, 197, 0.4);
  font-size: 16px;
  font-weight: 600;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.user-role {
  font-size: 11px;
  color: var(--text-soft);
  margin: 0;
}

/* ---------- CONTENT ---------- */
.content {
  padding: var(--ds-space-3, 24px) var(--ds-space-3, 24px) var(--ds-space-5, 40px);
  max-width: 1320px;
  margin: 0 auto;
}

.page-title {
  margin: 0 0 4px;
  font-size: var(--ds-title, 28px);
  font-weight: var(--ds-title-weight, 700);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-subtitle {
  margin: 0 0 var(--ds-space-3, 24px);
  font-size: var(--ds-subtitle, 14px);
  color: var(--text-muted, var(--color-text-muted));
  line-height: var(--ds-body-line, 1.5);
}

/* PageHeader: title + subtitle left, CTA right */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--ds-space-2, 16px);
  margin-bottom: var(--ds-space-3, 24px);
  padding-bottom: var(--ds-space-2, 16px);
  border-bottom: 1px solid var(--border, var(--color-border-subtle));
}

.page-header .page-title {
  margin-bottom: var(--space-1, 4px);
}

.page-header .page-subtitle {
  margin-bottom: 0;
}

.page-actions {
  display: flex;
  gap: var(--ds-space-2, 16px);
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.section-block {
  margin-bottom: 28px;
}

.section-title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: "";
  width: 4px;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(120deg, #2263c5, #0ea5e9);
}

.muted {
  font-size: 13px;
  color: var(--text-muted);
}
