/* ============================================================
   LAYOUT — sidebar, topbar, bottom bar, footer
   ============================================================ */

:root {
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 72px;
  --topbar-h: 56px;
  --bottombar-h: 60px;
  --footer-h: 40px;
  --transition: 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);

  /* Accento principale */
  --accent: #185fa5;
  --accent-light: #e6f1fb;
  --accent-text: #0c447c;
  --bg-color: #f4f6f8;
  --box-shadow: 0 10px 15px -3px rgba(0,0,0,0.04), 0 4px 6px -4px rgba(0,0,0,0.02);
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: 1px solid rgba(255, 255, 255, 0.5);
}

/* ── Base ─────────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg-color);
  font-family: 'Inter', var(--bs-font-sans-serif);
  font-size: 14px;
  color: #333;
}

/* ── Layout principale ────────────────────────────────────── */

/* Pagina con sidebar (utente loggato) */
body.has-sidebar {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 1fr;
  min-height: 100dvh;
  transition: grid-template-columns var(--transition);
}

body.has-sidebar.sidebar-collapsed {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}

/* Pagina pubblica (login ecc.) */
body.is-public .g-main {
  width: 100%;
  min-height: 100dvh;
}

/* ── Sidebar ──────────────────────────────────────────────── */

.g-sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  border-right: var(--glass-border);
  box-shadow: 4px 0 24px rgba(0,0,0,0.02);
  overflow: hidden;
  transition: width var(--transition);
  z-index: 100;
}

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

/* Brand */
.g-sidebar-header {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

.g-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  overflow: hidden;
}

.g-brand-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.g-brand-name {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  opacity: 1;
  transition: opacity var(--transition);
}

.g-brand-name img {
    height: 24px;
}

.sidebar-collapsed .g-brand-name {
  opacity: 0;
}

/* Nav */
.g-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
}

.g-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.g-nav-section {
  padding: 12px 14px 4px;
  font-size: 10px;
  font-weight: 600;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  overflow: hidden;
  opacity: 1;
  transition: opacity var(--transition);
}

.sidebar-collapsed .g-nav-section {
  opacity: 0;
}

.g-nav-item {
  margin: 1px 6px;
}

.g-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: #555;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  transition: all var(--transition);
}

.g-nav-link:hover {
  background: rgba(0, 0, 0, 0.03);
  color: #111;
  transform: translateX(4px);
}

.g-nav-item.active .g-nav-link {
  background: var(--accent-light);
  color: var(--accent-text);
}

.g-nav-icon {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  font-size: 13px;
}

.g-nav-label {
  font-size: 13px;
  overflow: hidden;
  opacity: 1;
  transition: opacity var(--transition);
}

.sidebar-collapsed .g-nav-label {
  opacity: 0;
}

/* Footer sidebar */
.g-sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  border-top: 0.5px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
  overflow: hidden;
}

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

.g-user-name {
  font-size: 12px;
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 1;
  transition: opacity var(--transition);
}

.sidebar-collapsed .g-user-name {
  opacity: 0;
}

.g-logout {
  color: #aaa;
  font-size: 14px;
  text-decoration: none;
  flex-shrink: 0;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition);
}

.g-logout:hover {
  color: #e24b4a;
}

/* ── Area principale ──────────────────────────────────────── */

.g-main {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow: hidden;
}

/* ── Topbar ───────────────────────────────────────────────── */

.g-topbar {
  position: sticky;
  top: 0;
  z-index: 90;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  border-bottom: var(--glass-border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
  flex-shrink: 0;
}

/* Toggle sidebar */
.g-sidebar-toggle {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  flex-shrink: 0;
  transition: background var(--transition);
}

.g-sidebar-toggle:hover {
  background: #f4f4f4;
}

/* Titolo e breadcrumb */
.g-page-info {
  flex: 1;
  min-width: 0;
}

.g-page-title {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: #111;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.g-breadcrumb {
  font-size: 11px;
  color: #aaa;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.g-breadcrumb-root {
  color: #bbb;
}
.g-breadcrumb-sep {
  margin: 0 4px;
  color: #ccc;
}
.g-breadcrumb-current {
  color: #888;
}

.g-env-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  background: #fff3cd;
  color: #856404;
}

/* Azioni topbar */
.g-topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.g-icon-btn {
  width: 32px;
  height: 32px;
  border: 0.5px solid rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  position: relative;
  transition: background var(--transition);
}

.g-icon-btn:hover {
  background: #f4f4f4;
}

.g-notify-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e24b4a;
  border: 1.5px solid #fff;
}

/* Avatar */
.g-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 0.5px solid rgba(0, 0, 0, 0.1);
}

.g-avatar-btn {
  cursor: pointer;
  border: 0.5px solid rgba(0, 0, 0, 0.1);
}

/* ── Contenuto pagina ─────────────────────────────────────── */

.g-content {
  flex: 1;
  padding: 20px 16px;
  overflow-y: auto;
  background: var(--bg-color);
}

/* Card */

.card {
  border: 0;
  box-shadow: var(--box-shadow);
}

.card-header{
  border:0;
}

/* ── Footer ───────────────────────────────────────────────── */

.g-footer {
  height: var(--footer-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 11px;
  color: #aaa;
  border-top: 0.5px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

/* ── Bottom bar mobile ────────────────────────────────────── */

.g-bottombar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottombar-h);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  border-top: var(--glass-border);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.04);
  z-index: 200;
  justify-content: space-around;
  align-items: center;
}

.g-bb-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 20px;
  border-radius: 8px;
  color: #aaa;
  text-decoration: none;
  transition: color var(--transition);
}

.g-bb-item.active,
.g-bb-item:hover {
  color: var(--accent);
}

.g-bb-icon {
  font-size: 18px;
}
.g-bb-label {
  font-size: 10px;
  font-weight: 500;
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 768px) {
  body.has-sidebar {
    grid-template-columns: 1fr;
  }

  .g-sidebar {
    display: none;
  }

  .g-sidebar-toggle {
    display: none;
  }

  .g-bottombar {
    display: flex;
  }

  /* Spazio per la bottom bar */
  .g-main {
    padding-bottom: var(--bottombar-h);
  }
}
