/* ==========================================================================
   SPIKE UI — Design System 2026
   Bootstrap 5.3 layer + layout + accessibilità + compat legacy (Remark/BS3)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */
:root {
  /* Brand */
  --sp-brand: #1d4ed8;
  --sp-brand-strong: #1e40af;
  --sp-brand-soft: #dbeafe;
  --sp-accent: #0ea5e9;

  /* Superfici (light) */
  --sp-bg: #f4f6fb;
  --sp-surface: #ffffff;
  --sp-surface-2: #f8fafc;
  --sp-border: #e2e8f0;
  --sp-border-strong: #cbd5e1;

  /* Testo */
  --sp-text: #0f172a;
  --sp-text-muted: #64748b;
  --sp-text-faint: #94a3b8;

  /* Sidebar */
  --sp-sidebar-bg: #0f172a;
  --sp-sidebar-text: #cbd5e1;
  --sp-sidebar-text-active: #ffffff;
  --sp-sidebar-hover: rgba(255, 255, 255, 0.06);
  --sp-sidebar-active: rgba(59, 130, 246, 0.22);
  --sp-sidebar-category: #64748b;
  --sp-sidebar-width: 264px;

  /* Topbar */
  --sp-topbar-h: 60px;
  --sp-topbar-bg: rgba(255, 255, 255, 0.85);

  /* Stato */
  --sp-success: #15803d;
  --sp-success-bg: #dcfce7;
  --sp-warning: #a16207;
  --sp-warning-bg: #fef9c3;
  --sp-danger: #b91c1c;
  --sp-danger-bg: #fee2e2;
  --sp-info: #0369a1;
  --sp-info-bg: #e0f2fe;

  /* Geometria & effetti */
  --sp-radius: 12px;
  --sp-radius-sm: 8px;
  --sp-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 4px 16px -8px rgba(15, 23, 42, 0.12);
  --sp-shadow-lg: 0 8px 32px -8px rgba(15, 23, 42, 0.25);
  --sp-focus-ring: 0 0 0 3px rgba(29, 78, 216, 0.35);

  --sp-font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;

  /* Rimappa i token Bootstrap principali */
  --bs-primary: var(--sp-brand);
  --bs-body-bg: var(--sp-bg);
  --bs-body-color: var(--sp-text);
  --bs-body-font-family: var(--sp-font);
  --bs-border-color: var(--sp-border);
  --bs-border-radius: var(--sp-radius-sm);
}

[data-bs-theme="dark"] {
  --sp-bg: #0b1120;
  --sp-surface: #101a2e;
  --sp-surface-2: #16223a;
  --sp-border: #1e293b;
  --sp-border-strong: #334155;

  --sp-text: #e2e8f0;
  --sp-text-muted: #94a3b8;
  --sp-text-faint: #64748b;

  --sp-brand-soft: rgba(59, 130, 246, 0.18);

  --sp-sidebar-bg: #0a0f1e;
  --sp-topbar-bg: rgba(16, 26, 46, 0.85);

  --sp-success-bg: rgba(34, 197, 94, 0.15);
  --sp-success: #4ade80;
  --sp-warning-bg: rgba(234, 179, 8, 0.15);
  --sp-warning: #facc15;
  --sp-danger-bg: rgba(239, 68, 68, 0.15);
  --sp-danger: #f87171;
  --sp-info-bg: rgba(14, 165, 233, 0.15);
  --sp-info: #38bdf8;

  --sp-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px -8px rgba(0, 0, 0, 0.5);
  --sp-shadow-lg: 0 8px 32px -8px rgba(0, 0, 0, 0.7);
}

/* --------------------------------------------------------------------------
   2. Base & accessibilità
   -------------------------------------------------------------------------- */
html {
  scroll-behavior: smooth;
}

body {
  background: var(--sp-bg);
  color: var(--sp-text);
  font-family: var(--sp-font);
  font-size: 0.9375rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Focus visibile e coerente su TUTTO (navigazione tastiera) */
:focus-visible {
  outline: 3px solid var(--sp-brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.btn:focus-visible,
.form-control:focus,
.form-select:focus {
  box-shadow: var(--sp-focus-ring);
  border-color: var(--sp-brand);
  outline: none;
}

/* Skip link — visibile solo al focus */
.sp-skip-link {
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  z-index: 11000;
  padding: 0.6rem 1rem;
  background: var(--sp-surface);
  color: var(--sp-text);
  border: 2px solid var(--sp-brand);
  border-radius: var(--sp-radius-sm);
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--sp-shadow-lg);
  transform: translateY(-300%);
}

.sp-skip-link:focus {
  transform: translateY(0);
}

/* Riduzione movimento */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Solo screen reader (già in BS5 come .visually-hidden, alias legacy) */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

a {
  color: var(--sp-brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   3. Layout: topbar + sidebar + main
   -------------------------------------------------------------------------- */
.sp-topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--sp-topbar-h);
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem;
  background: var(--sp-topbar-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--sp-border);
}

.sp-topbar .sp-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  color: var(--sp-text);
  text-decoration: none;
  margin-right: 0.5rem;
}

.sp-topbar .sp-brand img {
  height: 30px;
  width: auto;
}

.sp-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--sp-text-muted);
  font-size: 1.15rem;
  position: relative;
  transition: background 0.15s ease, color 0.15s ease;
}

.sp-icon-btn:hover {
  background: var(--sp-surface-2);
  color: var(--sp-text);
}

.sp-icon-btn .badge {
  position: absolute;
  top: 2px;
  right: 0;
  font-size: 0.62rem;
}

.sp-topbar .dropdown-menu {
  box-shadow: var(--sp-shadow-lg);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
}

/* Sidebar */
.sp-sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--sp-sidebar-width);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  background: var(--sp-sidebar-bg);
  color: var(--sp-sidebar-text);
  transition: transform 0.25s ease;
  overflow: hidden;
}

.sp-sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: var(--sp-topbar-h);
  padding: 0 1.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}

.sp-sidebar-header a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  text-decoration: none;
}

.sp-sidebar-header img {
  height: 30px;
}

.sp-sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.75rem 1.5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

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

.sp-nav-category {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--sp-sidebar-category);
  padding: 1.1rem 0.75rem 0.4rem;
}

.sp-nav-item > a,
.sp-nav-toggle {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  margin-bottom: 2px;
  border: none;
  border-radius: var(--sp-radius-sm);
  background: transparent;
  color: var(--sp-sidebar-text);
  font-size: 0.9rem;
  text-align: left;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.sp-nav-item > a:hover,
.sp-nav-toggle:hover {
  background: var(--sp-sidebar-hover);
  color: var(--sp-sidebar-text-active);
  text-decoration: none;
}

.sp-nav-item > a[aria-current="page"],
.sp-nav-item > a.active {
  background: var(--sp-sidebar-active);
  color: var(--sp-sidebar-text-active);
  font-weight: 600;
}

.sp-nav-item > a:focus-visible,
.sp-nav-toggle:focus-visible {
  outline: 3px solid var(--sp-accent);
  outline-offset: -3px;
}

.sp-nav-emoji {
  font-size: 1.05rem;
  width: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}

.sp-nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sp-nav-badge {
  background: var(--sp-danger);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  min-width: 1.4rem;
  text-align: center;
}

[data-bs-theme="dark"] .sp-nav-badge { color: #fff; }

.sp-nav-toggle .sp-nav-caret {
  transition: transform 0.2s ease;
  font-size: 0.7rem;
}

.sp-nav-toggle[aria-expanded="true"] .sp-nav-caret {
  transform: rotate(90deg);
}

.sp-nav-sub {
  list-style: none;
  margin: 0 0 0.25rem;
  padding-left: 2.2rem;
}

.sp-nav-sub a {
  display: block;
  padding: 0.42rem 0.75rem;
  border-radius: var(--sp-radius-sm);
  color: var(--sp-sidebar-text);
  font-size: 0.86rem;
  text-decoration: none;
}

.sp-nav-sub a:hover {
  background: var(--sp-sidebar-hover);
  color: var(--sp-sidebar-text-active);
}

.sp-nav-sub a[aria-current="page"] {
  background: var(--sp-sidebar-active);
  color: var(--sp-sidebar-text-active);
  font-weight: 600;
}

/* Main content */
.sp-main {
  margin-left: var(--sp-sidebar-width);
  padding: calc(var(--sp-topbar-h) + 1.5rem) 1.75rem 2.5rem;
  min-height: 100vh;
  outline: none;
}

.sp-topbar {
  left: var(--sp-sidebar-width);
}

/* Sidebar chiusa (desktop) */
body.sp-sidebar-collapsed .sp-sidebar {
  transform: translateX(-100%);
}

body.sp-sidebar-collapsed .sp-main,
body.sp-sidebar-collapsed .sp-topbar {
  margin-left: 0;
  left: 0;
}

/* Mobile: off-canvas */
@media (max-width: 991.98px) {
  .sp-sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }

  body.sp-sidebar-open .sp-sidebar {
    transform: translateX(0);
    box-shadow: var(--sp-shadow-lg);
  }

  .sp-main,
  .sp-topbar {
    margin-left: 0 !important;
    left: 0 !important;
  }

  .sp-main {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .sp-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1035;
    background: rgba(15, 23, 42, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  body.sp-sidebar-open .sp-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Footer */
.sp-footer {
  margin-left: var(--sp-sidebar-width);
  padding: 1rem 1.75rem;
  color: var(--sp-text-muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--sp-border);
}

body.sp-sidebar-collapsed .sp-footer {
  margin-left: 0;
}

@media (max-width: 991.98px) {
  .sp-footer {
    margin-left: 0;
  }
}

/* --------------------------------------------------------------------------
   4. Intestazione pagina & breadcrumb
   -------------------------------------------------------------------------- */
.sp-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.sp-page-header h1 {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.sp-page-header .breadcrumb {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
}

.breadcrumb-item + .breadcrumb-item::before {
  color: var(--sp-text-faint);
}

.sp-page-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   5. Card / pannelli
   -------------------------------------------------------------------------- */
.sp-card,
.card {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  box-shadow: var(--sp-shadow);
}

.sp-card .card-header,
.card > .card-header {
  background: transparent;
  border-bottom: 1px solid var(--sp-border);
  padding: 1rem 1.25rem;
  font-weight: 600;
}

.sp-card .card-body,
.card > .card-body {
  padding: 1.25rem;
}

/* Card statistiche dashboard */
.sp-stat {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
}

.sp-stat-emoji {
  font-size: 1.9rem;
  line-height: 1;
  width: 3.25rem;
  height: 3.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--sp-radius);
  background: var(--sp-brand-soft);
  flex-shrink: 0;
}

.sp-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.sp-stat-label {
  color: var(--sp-text-muted);
  font-size: 0.82rem;
}

/* --------------------------------------------------------------------------
   6. Tabelle & DataTables
   -------------------------------------------------------------------------- */
.sp-table-wrap {
  overflow-x: auto;
}

.table {
  --bs-table-bg: transparent;
  color: var(--sp-text);
  font-size: 0.875rem;
  vertical-align: middle;
}

.table > thead > tr > th {
  background: var(--sp-surface-2);
  color: var(--sp-text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--sp-border-strong);
  padding: 0.7rem 0.75rem;
  white-space: nowrap;
}

.table > tbody > tr > td {
  padding: 0.65rem 0.75rem;
  border-color: var(--sp-border);
}

.table-hover > tbody > tr:hover > * {
  background: var(--sp-surface-2);
  color: var(--sp-text);
}

.table td {
  font-variant-numeric: tabular-nums;
}

/* DataTables (integrazione BS5) */
div.dataTables_wrapper div.dataTables_filter input {
  margin-left: 0.5rem;
}

.dataTables_wrapper .dataTables_length select {
  min-width: 4.5rem;
}

.dataTables_wrapper .dataTables_paginate .page-link {
  color: var(--sp-text);
  background: var(--sp-surface);
  border-color: var(--sp-border);
}

.dataTables_wrapper .dataTables_paginate .page-item.active .page-link {
  background: var(--sp-brand);
  border-color: var(--sp-brand);
  color: #fff;
}

.dataTables_wrapper .dt-buttons .btn {
  margin-right: 0.35rem;
}

table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control::before {
  background-color: var(--sp-brand) !important;
}

div.dataTables_processing {
  background: var(--sp-surface);
  color: var(--sp-text);
  border-radius: var(--sp-radius);
  box-shadow: var(--sp-shadow-lg);
}

/* --------------------------------------------------------------------------
   7. Bottoni, badge, stati
   -------------------------------------------------------------------------- */
.btn {
  border-radius: var(--sp-radius-sm);
  font-weight: 500;
}

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

/* Bottoni-icona azioni tabella (compat: markup legacy .btn-icon.btn-flat) */
.btn-icon,
.btn.btn-flat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--sp-radius-sm);
  border: 1px solid var(--sp-border);
  background: var(--sp-surface);
  color: var(--sp-text-muted);
}

.btn-icon:hover,
.btn.btn-flat:hover {
  background: var(--sp-surface-2);
  color: var(--sp-brand);
  border-color: var(--sp-border-strong);
}

/* Badge stato ordini/lead */
.sp-badge {
  display: inline-block;
  padding: 0.25em 0.7em;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.sp-badge-success { background: var(--sp-success-bg); color: var(--sp-success); }
.sp-badge-warning { background: var(--sp-warning-bg); color: var(--sp-warning); }
.sp-badge-danger  { background: var(--sp-danger-bg);  color: var(--sp-danger); }
.sp-badge-info    { background: var(--sp-info-bg);    color: var(--sp-info); }
.sp-badge-neutral { background: var(--sp-surface-2);  color: var(--sp-text-muted); }

/* --------------------------------------------------------------------------
   8. Modali & alert
   -------------------------------------------------------------------------- */
.modal-content {
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  box-shadow: var(--sp-shadow-lg);
  background: var(--sp-surface);
  color: var(--sp-text);
}

.modal-header {
  border-bottom: 1px solid var(--sp-border);
}

.modal-footer {
  border-top: 1px solid var(--sp-border);
}

.modal-header.sp-danger {
  background: var(--sp-danger-bg);
  color: var(--sp-danger);
}

.alert {
  border-radius: var(--sp-radius-sm);
}

/* --------------------------------------------------------------------------
   9. Form
   -------------------------------------------------------------------------- */
.form-label,
label {
  font-weight: 500;
  font-size: 0.86rem;
}

.form-control,
.form-select {
  background: var(--sp-surface);
  border-color: var(--sp-border-strong);
  color: var(--sp-text);
  border-radius: var(--sp-radius-sm);
}

.form-control::placeholder {
  color: var(--sp-text-faint);
}

/* --------------------------------------------------------------------------
   10. COMPAT LEGACY — markup BS3/Remark generato dagli endpoint ajax
       (insert.php / update.php / view.php / notification())
   -------------------------------------------------------------------------- */

/* .form-group orizzontali con .control-label (BS3) */
.form-group {
  margin-bottom: 1rem;
}

.form-group::after {
  content: "";
  display: table;
  clear: both;
}

.control-label {
  padding-top: calc(0.375rem + 1px);
  margin-bottom: 0;
  text-align: right;
}

@media (max-width: 767.98px) {
  .control-label {
    text-align: left;
    margin-bottom: 0.25rem;
  }
}

/* Griglia float BS3 dentro le modali legacy */
.modal-body .row > [class*="col-"],
.form-group > [class*="col-"] {
  position: relative;
  padding-right: 12px;
  padding-left: 12px;
}

.form-group [class*="col-sm-"],
.form-group [class*="col-lg-"] {
  float: left;
}

.form-group .col-sm-3 { width: 25%; }
.form-group .col-sm-9 { width: 75%; }
.form-group .col-sm-6 { width: 50%; }
.form-group .col-sm-4 { width: 33.3333%; }
.form-group .col-sm-8 { width: 66.6667%; }
.form-group .col-sm-12,
.form-group .col-lg-12 { width: 100%; }

@media (max-width: 767.98px) {
  .form-group [class*="col-sm-"] {
    float: none;
    width: 100%;
  }
}

/* Vecchio bottone chiudi (.close) di alert e modali BS3 */
.close {
  float: right;
  background: transparent;
  border: 0;
  font-size: 1.3rem;
  line-height: 1;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
}

.close:hover {
  opacity: 1;
}

/* Colori legacy Remark usati nel markup esistente */
.white { color: #fff !important; }
.bg-red-600 { background-color: var(--sp-danger) !important; color: #fff; }
.bg-cyan-600 { background-color: var(--sp-info) !important; color: #fff; }
.bg-green-600 { background-color: var(--sp-success) !important; color: #fff; }
.bg-blue-600 { background-color: var(--sp-brand) !important; color: #fff; }
.bg-orange-600 { background-color: #ea580c !important; color: #fff; }

/* Utility spaziatura/font legacy */
.margin-top-10 { margin-top: 10px !important; }
.margin-top-20 { margin-top: 20px !important; }
.margin-top-30 { margin-top: 30px !important; }
.margin-right-10 { margin-right: 10px !important; }
.margin-left-10 { margin-left: 10px !important; }
.margin-bottom-10 { margin-bottom: 10px !important; }
.margin-bottom-20 { margin-bottom: 20px !important; }
.padding-right-10 { padding-right: 10px !important; }
.font-size-16 { font-size: 1rem !important; }
.font-size-26 { font-size: 1.45rem !important; }
.font-weight-100 { font-weight: 300 !important; }
.width-full { width: 100% !important; }

/* Icone web-icons/font-awesome legacy: se i font non sono caricati,
   gli <i class="icon"> restano vuoti ma non rompono il layout.
   Fallback unicode/emoji per le icone più usate nel markup generato. */
i.icon {
  display: inline-block;
  min-width: 1em;
  font-style: normal;
}

.icon.wb-chevron-left-mini::before { content: "‹"; }
.icon.wb-chevron-right-mini::before { content: "›"; }
.icon.wb-plus::before { content: "+"; font-weight: 700; }
.icon.wb-minus::before { content: "−"; font-weight: 700; }
.icon.wb-pencil::before { content: "✏️"; }
.icon.wb-eye::before { content: "👁️"; }
.icon.wb-close::before,
.icon.wb-close-mini::before { content: "✕"; }
.icon.wb-check::before { content: "✓"; font-weight: 700; }
.icon.wb-download::before { content: "⬇️"; }
.icon.wb-upload::before { content: "⬆️"; }
.icon.wb-user::before { content: "👤"; }
.icon.wb-users::before { content: "👥"; }
.icon.wb-settings::before { content: "⚙️"; }
.icon.wb-power::before { content: "⏻"; }
.icon.wb-bell::before { content: "🔔"; }
.icon.wb-envelope::before { content: "✉️"; }
.icon.wb-lock::before { content: "🔒"; }
.icon.wb-print::before { content: "🖨️"; }
.icon.wb-refresh::before { content: "🔄"; }
.icon.fa-dollar::before { content: "$"; font-weight: 700; }
.icon.fa-eur::before { content: "€"; font-weight: 700; }
.icon.fa-file-pdf-o::before { content: "📄"; }
.icon.fa-file-excel-o::before { content: "📊"; }
.icon.fa-th-list::before { content: "📋"; }
.icon.fa-sort-amount-desc::before { content: "↓"; }
.icon.fa-building::before { content: "🏢"; }
.icon.fa-user::before { content: "👤"; }

/* Vecchio layout .page dentro .sp-main (pagine complesse non ancora
   riscritte a fondo): rese neutre, la struttura viene dal nuovo layout */
.sp-main .page { margin: 0; padding: 0; }
.sp-main .page-header {
  display: block;
  padding: 0;
  margin-bottom: 1.25rem;
  background: transparent;
  border: 0;
}
.sp-main .page-title { font-size: 1.45rem; font-weight: 700; margin: 0 0 0.25rem; }
.sp-main .page-header .breadcrumb { margin: 0.25rem 0 0.5rem; font-size: 0.82rem; padding: 0; background: transparent; }
.sp-main .page-header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.5rem 0; }
.sp-main .page-content { padding: 0; }
.label {
  display: inline-block;
  padding: 0.25em 0.7em;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--sp-surface-2);
  color: var(--sp-text-muted);
}
.label-success { background: var(--sp-success-bg); color: var(--sp-success); }
.label-warning { background: var(--sp-warning-bg); color: var(--sp-warning); }
.label-danger { background: var(--sp-danger-bg); color: var(--sp-danger); }
.label-info, .label-primary { background: var(--sp-info-bg); color: var(--sp-info); }
.panel-title { font-size: 1rem; font-weight: 600; margin: 0; }
.panel-heading { padding: 1rem 1.25rem; border-bottom: 1px solid var(--sp-border); }
.panel-heading + .panel-body { padding-top: 1.25rem; }
.panel-desc { display: block; color: var(--sp-text-muted); font-size: 0.82rem; font-weight: 400; margin-top: 0.25rem; }

/* Vecchi .panel eventualmente residui → sembrano card */
.panel {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  box-shadow: var(--sp-shadow);
  margin-bottom: 1.25rem;
}

.panel-heading { padding: 1rem 1.25rem 0; }
.panel-body { padding: 1.25rem; }

/* --------------------------------------------------------------------------
   11. Select2 theming (tema BS5 + dark)
   -------------------------------------------------------------------------- */
.select2-container--bootstrap-5 .select2-selection {
  background: var(--sp-surface);
  border-color: var(--sp-border-strong);
  color: var(--sp-text);
}

.select2-container--bootstrap-5 .select2-dropdown {
  background: var(--sp-surface);
  border-color: var(--sp-border);
  color: var(--sp-text);
}

.select2-container--bootstrap-5 .select2-results__option--highlighted {
  background: var(--sp-brand);
  color: #fff;
}

/* --------------------------------------------------------------------------
   12. Notifiche topbar
   -------------------------------------------------------------------------- */
.sp-notif-menu {
  width: 340px;
  max-width: 92vw;
  padding: 0;
  overflow: hidden;
}

.sp-notif-menu .sp-notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--sp-border);
  font-weight: 600;
}

.sp-notif-list {
  max-height: 320px;
  overflow-y: auto;
}

.sp-notif-item {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.7rem 1rem;
  color: var(--sp-text);
  text-decoration: none;
  border-bottom: 1px solid var(--sp-border);
}

.sp-notif-item:hover {
  background: var(--sp-surface-2);
  text-decoration: none;
}

.sp-notif-item .sp-notif-emoji {
  font-size: 1.25rem;
  width: 2.4rem;
  height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--sp-brand-soft);
  flex-shrink: 0;
}

.sp-notif-item time {
  display: block;
  color: var(--sp-text-muted);
  font-size: 0.75rem;
}

.sp-notif-foot {
  display: block;
  text-align: center;
  padding: 0.65rem;
  font-weight: 600;
  border-top: 1px solid var(--sp-border);
}

/* --------------------------------------------------------------------------
   13. Timeline CRM
   -------------------------------------------------------------------------- */
.sp-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

.sp-timeline::before {
  content: "";
  position: absolute;
  left: 1.1rem;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 2px;
  background: var(--sp-border);
}

.sp-timeline-item {
  position: relative;
  padding: 0 0 1.25rem 3rem;
}

.sp-timeline-emoji {
  position: absolute;
  left: 0;
  top: 0;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--sp-surface-2);
  border: 2px solid var(--sp-border);
  font-size: 1rem;
  z-index: 1;
}

.sp-timeline-body {
  background: var(--sp-surface-2);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-sm);
  padding: 0.75rem 1rem;
}

.sp-timeline-meta {
  color: var(--sp-text-muted);
  font-size: 0.78rem;
  margin-bottom: 0.25rem;
}

/* --------------------------------------------------------------------------
   14. Stampa
   -------------------------------------------------------------------------- */
@media print {
  .sp-sidebar,
  .sp-topbar,
  .sp-footer,
  .sp-page-actions,
  .dt-buttons,
  .dataTables_filter,
  .dataTables_length,
  .dataTables_paginate {
    display: none !important;
  }

  .sp-main {
    margin: 0;
    padding: 0;
  }

  .sp-card,
  .card {
    box-shadow: none;
    border: none;
  }
}
