/* layout.css — strutture di pagina e navigazione (topbar desktop,
   sidebar tablet, mobile header / bottom-nav / overlay menu, page container).
   Le regole di switch tra le tre nav vivono in responsive.css. */

/* ─── App container ──────────────────────────────────────────────────── */
#app-container { min-height: 100vh; }

/* ─── Topbar desktop ─────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: stretch;
  gap: 2px;
  background: var(--bg-header);
  color: var(--text-on-dark);
  padding: 0 14px;
  height: var(--topbar-h);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(0,0,0,0.1);
}

.topbar .tab {
  appearance: none;
  background: transparent;
  border: 0;
  color: rgba(255,255,255,0.78);
  padding: 0 14px;
  height: 100%;
  font-size: var(--fs);
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-bottom: 2px solid transparent;
  transition: color .12s, background .12s, border-color .12s;
}
.topbar .tab:hover {
  color: #fff;
  background: rgba(255,255,255,0.05);
}
.topbar .tab.active,
.topbar .tab[data-active="true"] {
  color: #fff;
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* Dropdown su tab "Vendite", "Acquisti", "Registro" */
.tab-dropdown {
  position: relative;
  display: inline-flex;
  align-items: stretch;
}
.tab-dropdown > .tab::after {
  content: "▾";
  font-size: 9px;
  margin-left: 4px;
  opacity: 0.7;
}
.tab-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  background: #fff;
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
  padding: 6px 0;
  z-index: 200;
  flex-direction: column;
  margin-top: 0;
}
.tab-dropdown:hover .tab-dropdown-menu,
.tab-dropdown:focus-within .tab-dropdown-menu {
  display: flex;
}
/* I bottoni del menu hanno lo stesso padding orizzontale del trigger (.tab)
   così il testo del primo item è verticalmente allineato con quello del
   trigger sopra. */
.tab-dropdown-menu button {
  appearance: none;
  background: transparent;
  border: 0;
  text-align: left;
  padding: 8px 14px;
  font-size: var(--fs);
  color: var(--text-body);
  border-radius: 0;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: flex-start; /* override del default Chrome che è 'center' sui <button> */
  gap: 8px;
  width: 100%;
}
.tab-dropdown-menu button:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* Topbar utility (sync, bell, user, esci) */
#sync-status {
  align-self: center;
  margin-left: auto;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: 600;
}
#user-info { color: rgba(255,255,255,0.75) !important; }
#btn-bell { color: #fff; }
.topbar .btn {
  align-self: center;
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
  color: #fff;
}
.topbar .btn:hover {
  background: rgba(255,255,255,0.18);
}

/* ─── Tablet sidebar ─────────────────────────────────────────────────── */
.tablet-sidebar {
  display: none;                       /* attivata in responsive.css */
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--tablet-sidebar-w);
  background: var(--bg-header);
  z-index: 90;
  flex-direction: column;
  padding: 8px 0;
  gap: 2px;
  transition: width .18s ease;
  overflow: hidden;
}
.tablet-sidebar.open { width: var(--tablet-sidebar-w-open); }

.tablet-sidebar-toggle,
.tablet-sidebar-item {
  appearance: none;
  background: transparent;
  border: 0;
  color: rgba(255,255,255,0.85);
  padding: 10px 12px;
  font-size: var(--fs);
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  border-radius: 0;
  white-space: nowrap;
}
.tablet-sidebar-toggle { font-size: 18px; padding: 12px; }
.tablet-sidebar-item .sidebar-icon {
  flex: 0 0 26px;
  font-size: 18px;
  display: inline-flex;
  justify-content: center;
}
.tablet-sidebar-item .sidebar-label { font-size: var(--fs); }
.tablet-sidebar-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.tablet-sidebar-item.active {
  background: rgba(37,99,235,0.18);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar-divider { border-top: 1px solid rgba(255,255,255,0.08) !important; margin: 4px 8px !important; }

/* Quando sidebar collassata, nascondi le label */
.tablet-sidebar:not(.open) .sidebar-label { display: none; }

/* ─── Mobile header (top) ────────────────────────────────────────────── */
.mobile-header {
  display: none;                       /* attivato in responsive.css */
  align-items: center;
  gap: 10px;
  height: var(--mobile-header-h);
  background: var(--bg-header);
  color: #fff;
  padding: 0 14px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.hamburger-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 22px;
  padding: 6px 10px;
  cursor: pointer;
}
.mobile-header-title {
  flex: 1;
  font-size: var(--fs-md);
  font-weight: 600;
}
.mobile-header .btn {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.22);
  color: #fff;
}

/* ─── Mobile bottom nav ──────────────────────────────────────────────── */
.bottom-nav {
  display: none;                       /* attivato in responsive.css */
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: var(--bottom-nav-h);
  background: #fff;
  border-top: 1px solid var(--border);
  z-index: 90;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}
.bottom-nav-inner {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: 100%;
}
.bottom-nav-item {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  padding: 4px 2px;
  font-size: 10px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.bottom-nav-item .nav-icon { font-size: 18px; line-height: 1; }
.bottom-nav-item.active { color: var(--accent); font-weight: 600; }

/* ─── Mobile off-canvas menu ─────────────────────────────────────────── */
.mobile-menu-overlay {
  display: none;                       /* attivato da JS aggiungendo .open */
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  animation: fadeIn .15s ease;
}
.mobile-menu-overlay.open { display: block; }
.mobile-menu {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 80%; max-width: 320px;
  background: #fff;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideInLeft .18s ease;
}
.mobile-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.mobile-menu-header h3 { margin: 0; font-size: var(--fs-lg); }
.mobile-menu-items {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mobile-menu-item {
  appearance: none;
  background: transparent;
  border: 0;
  text-align: left;
  padding: 10px 18px;
  font-size: var(--fs-md);
  color: var(--text-body);
  cursor: pointer;
  font-family: inherit;
}
.mobile-menu-item:hover { background: var(--bg-muted); }
.mobile-menu-item.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}
.mobile-menu-divider { border-top: 1px solid var(--border); margin: 6px 0; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideInLeft { from { transform: translateX(-100%); } to { transform: translateX(0); } }

/* ─── Page container ─────────────────────────────────────────────────── */
.page {
  display: none;
  padding: 18px 22px 32px;
  max-width: 1500px;
  margin: 0 auto;
}
.page.active { display: block; }

.page-title {
  font-size: var(--fs-2xl);
  font-weight: 600;
  margin: 0 0 18px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-primary);
  margin: 18px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Toolbar (filtri/azioni in cima a una sezione) */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.toolbar .spacer { flex: 1; }
/* Override: dentro toolbar i form field non devono occupare 100% di larghezza
   (altrimenti vanno a capo per via del width:100% di base sui form field) */
.toolbar input,
.toolbar select,
.toolbar textarea { width: auto; }
