/* =========================================================
   LogiStack — Design System 2026
   Light SaaS moderno: sidebar scura, superfici chiare,
   palette indaco/slate, componenti Bootstrap re-skinnati.
   ========================================================= */

:root {
  /* Brand */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --primary-rgb: 79, 70, 229;

  /* Semantici */
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --info: #0ea5e9;
  --info-light: #f0f9ff;

  /* Neutri (slate) */
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;

  --bg-app: #f5f6fb;
  --surface: #ffffff;
  --border-color: #e6e8f0;
  --text-main: #1e2233;
  --text-muted: #6b7280;

  /* Forma */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, .06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, .10);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, .14);

  --sidebar-width: 272px;
  --topbar-height: 68px;
}

/* ---------- Base ---------- */
html { scroll-behavior: smooth; }

body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--slate-900);
}

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

::selection { background: var(--primary-light); color: var(--primary-hover); }

/* Scrollbar leggero */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Re-skin componenti Bootstrap (globale) ---------- */
.text-primary { color: var(--primary) !important; }
.bg-primary { background-color: var(--primary) !important; }
.border-primary { border-color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.bg-success { background-color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }

.btn {
  border-radius: var(--radius-sm);
  font-weight: 600;
  padding: .55rem 1.1rem;
  transition: all .15s ease;
}
.btn-lg { border-radius: var(--radius-md); }
.btn-sm { border-radius: 7px; }

.btn-primary {
  --bs-btn-bg: var(--primary);
  --bs-btn-border-color: var(--primary);
  --bs-btn-hover-bg: var(--primary-hover);
  --bs-btn-hover-border-color: var(--primary-hover);
  --bs-btn-active-bg: var(--primary-hover);
  --bs-btn-active-border-color: var(--primary-hover);
  --bs-btn-disabled-bg: var(--primary);
  --bs-btn-disabled-border-color: var(--primary);
  --bs-btn-focus-shadow-rgb: var(--primary-rgb);
  box-shadow: 0 2px 6px rgba(var(--primary-rgb), .28);
}
.btn-primary:hover { box-shadow: 0 4px 12px rgba(var(--primary-rgb), .32); transform: translateY(-1px); }

.btn-outline-primary {
  --bs-btn-color: var(--primary);
  --bs-btn-border-color: var(--primary);
  --bs-btn-hover-bg: var(--primary);
  --bs-btn-hover-border-color: var(--primary);
}

.btn-success { --bs-btn-bg: var(--success); --bs-btn-border-color: var(--success); --bs-btn-hover-bg: #0d9c6f; --bs-btn-hover-border-color: #0d9c6f; }
.btn-danger { --bs-btn-bg: var(--danger); --bs-btn-border-color: var(--danger); }
.btn-warning { --bs-btn-bg: var(--warning); --bs-btn-border-color: var(--warning); }

.card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.form-control, .form-select {
  border-radius: var(--radius-sm);
  border-color: var(--slate-200);
  padding: .55rem .85rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
label.form-label { font-weight: 600; color: var(--slate-700); font-size: .875rem; }

.alert { border-radius: var(--radius-md); border: 1px solid transparent; }

.dropdown-menu {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: .4rem;
}
.dropdown-item { border-radius: var(--radius-sm); padding: .5rem .75rem; font-size: .9rem; }
.dropdown-item:hover, .dropdown-item:focus { background-color: var(--primary-light); color: var(--primary-hover); }

.table { --bs-table-hover-bg: var(--slate-50); }
.table thead th {
  text-transform: uppercase;
  font-size: .72rem;
  letter-spacing: .04em;
  color: var(--slate-500);
  border-bottom-width: 1px;
  background-color: var(--slate-50);
}

.badge { font-weight: 600; border-radius: 6px; }

/* =========================================================
   Layout applicativo (utente autenticato): sidebar + topbar
   ========================================================= */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--slate-900), #141a2e 85%);
  color: var(--slate-300);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 1040;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: 1.35rem 1.4rem;
  color: #fff;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.sidebar-brand img { height: 40px; width: auto; }
.sidebar-brand .brand-name { font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; }
.sidebar-brand .brand-tag { font-size: .68rem; color: var(--slate-400); font-weight: 500; display: block; margin-top: -2px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem .8rem 1rem; }
.sidebar-section-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--slate-500);
  font-weight: 700;
  margin: 1.1rem .6rem .4rem;
}
.sidebar-section-label:first-child { margin-top: .2rem; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .62rem .8rem;
  border-radius: var(--radius-sm);
  color: var(--slate-300);
  text-decoration: none;
  font-weight: 500;
  font-size: .89rem;
  margin-bottom: .15rem;
  transition: background .15s ease, color .15s ease;
  position: relative;
}
.sidebar-link i, .sidebar-link .bi { width: 18px; text-align: center; font-size: .95rem; color: var(--slate-400); }
.sidebar-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-link:hover i, .sidebar-link:hover .bi { color: #fff; }
.sidebar-link.active { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(var(--primary-rgb), .35); }
.sidebar-link.active i, .sidebar-link.active .bi { color: #fff; }

.sidebar-link.dropdown-toggle::after { margin-left: auto; }
.sidebar-submenu { padding-left: 2.1rem; }
.sidebar-submenu .sidebar-link { font-size: .85rem; padding: .5rem .7rem; }

.sidebar-footer {
  padding: 1rem 1.2rem 1.3rem;
  border-top: 1px solid rgba(255, 255, 255, .07);
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.app-shell.no-sidebar .app-main { margin-left: 0; }

.topbar {
  height: var(--topbar-height);
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.topbar-heading { min-width: 0; overflow: hidden; }
.page-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--slate-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-subtitle {
  color: var(--text-muted);
  font-size: .82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-toggle {
  display: none;
  border: none;
  background: var(--slate-100);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  color: var(--slate-700);
}

.topbar-user-btn {
  display: flex;
  align-items: center;
  gap: .55rem;
  border: 1px solid var(--border-color);
  background: var(--surface);
  border-radius: 999px;
  padding: .35rem .9rem .35rem .4rem;
  color: var(--text-main);
  font-weight: 600;
  font-size: .88rem;
}
.topbar-user-btn .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem;
}

.content-area {
  padding: 1.75rem;
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  z-index: 1030;
}

.messages-container {
  position: fixed;
  top: calc(var(--topbar-height) + 14px);
  right: 20px;
  z-index: 1080;
  min-width: 320px;
  max-width: 380px;
}
.messages-container .alert { box-shadow: var(--shadow-md); }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .sidebar-toggle { display: inline-flex; }
  .sidebar-backdrop.show { display: block; }
  .content-area { padding: 1.1rem; }
  .topbar { padding: 0 1rem; gap: .6rem; }
}

@media (max-width: 575.98px) {
  .page-subtitle { display: none; }
  .topbar-user-btn { padding: .3rem; gap: 0; border-color: transparent; background: transparent; }
  .topbar-user-btn .username-text { display: none; }
  .topbar-user-btn::after { display: none; }
  .messages-container { left: 12px; right: 12px; min-width: 0; max-width: none; }
}

/* =========================================================
   Layout pagine non autenticate (login, ecc.)
   ========================================================= */
.auth-layout {
  min-height: 100vh;
  width: 100%;
  display: flex;
}

.auth-brand-panel {
  flex: 1.1;
  position: relative;
  background: radial-gradient(circle at 15% 20%, #6a63f0, transparent 55%),
              radial-gradient(circle at 85% 85%, #3b82f6, transparent 50%),
              linear-gradient(160deg, var(--slate-900), #1b1440 65%, #0f172a);
  color: #fff;
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.auth-brand-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .09) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: .5;
}
.auth-brand-panel .brand-row { display: flex; align-items: center; gap: .7rem; position: relative; z-index: 1; }
.auth-brand-panel .brand-row img { height: 48px; }
.auth-brand-panel .brand-row span { font-weight: 800; font-size: 1.3rem; }
.auth-brand-panel .pitch { position: relative; z-index: 1; max-width: 420px; }
.auth-brand-panel .pitch h2 { color: #fff; font-size: 1.9rem; line-height: 1.25; }
.auth-brand-panel .pitch p { color: rgba(255, 255, 255, .72); font-size: .96rem; }
.auth-brand-panel .pitch-list { list-style: none; padding: 0; margin: 1.5rem 0 0; position: relative; z-index: 1; }
.auth-brand-panel .pitch-list li {
  display: flex; align-items: center; gap: .65rem;
  color: rgba(255, 255, 255, .85); font-size: .88rem; margin-bottom: .7rem;
}
.auth-brand-panel .pitch-list i {
  width: 28px; height: 28px; border-radius: 8px;
  background: rgba(255, 255, 255, .12);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.auth-brand-panel .foot-note { position: relative; z-index: 1; color: rgba(255, 255, 255, .45); font-size: .78rem; }

.auth-form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--surface);
}
.auth-form-box { width: 100%; max-width: 380px; }
.auth-form-box .auth-title { font-size: 1.55rem; margin-bottom: .3rem; }
.auth-form-box .auth-subtitle { color: var(--text-muted); font-size: .92rem; margin-bottom: 2rem; }

.auth-mobile-brand {
  display: none;
  align-items: center;
  gap: .6rem;
  margin-bottom: 1.75rem;
}
.auth-mobile-brand img { height: 44px; }
.auth-mobile-brand span { font-weight: 800; font-size: 1.15rem; color: var(--slate-900); }

@media (max-width: 899.98px) {
  .auth-brand-panel { display: none; }
  .auth-mobile-brand { display: flex; }
}
