/* =================================================================
   SAM Design System — v1.0
   File obbligatorio per ogni applicazione dell'ecosistema SAM.
   NON modificare la struttura. Personalizzare SOLO le variabili
   nella sezione ":root — CONFIGURAZIONE APP".
   ================================================================= */

/* -----------------------------------------------------------------
   :root — CONFIGURAZIONE APP
   Modificare qui per personalizzare colori e identità.
   ----------------------------------------------------------------- */
:root {
  /* Colori principali — baseline SAM / Prenotazioni. */
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #dbeafe;
  --secondary:      #1a3a6b;
  --accent:         #2563eb;

  /* Superfici e sfondi — baseline SAM / Prenotazioni. */
  --bg:             #f8fafc;
  --surface:        #ffffff;
  --surface-hover:  #f1f5f9;
  --border:         #e5e7eb;
  --border-focus:   var(--primary);

  /* Testo */
  --text:           #111827;
  --text-muted:     #6b7280;
  --text-light:     #9ca3af;

  /* Feedback */
  --success:        #16a34a;
  --success-bg:     #dcfce7;
  --warning:        #d97706;
  --warning-bg:     #fef3c7;
  --danger:         #dc2626;
  --danger-bg:      #fee2e2;
  --info:           #0284c7;
  --info-bg:        #e0f2fe;

  /* Dimensioni */
  --max-width:      1100px;
  --header-height:  60px;
  --radius-sm:      6px;
  --radius:         8px;
  --radius-lg:      10px;
  --radius-xl:      14px;

  /* Ombre */
  --shadow-sm:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:         0 2px 8px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.05);
  --shadow-lg:      0 4px 16px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);

  /* Transizioni */
  --transition:     0.15s ease;
}


/* =================================================================
   RESET & BASE
   ================================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

/* =================================================================
   LAYOUT — HEADER
   ================================================================= */
.sam-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  z-index: 1000;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}

.sam-header__logo {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.5px;
}

.sam-header__logo img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.sam-header__name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.2px;
}

.sam-header__version {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1px 8px;
  margin-left: 4px;
}

.sam-header__spacer { flex: 1; }

/* =================================================================
   LAYOUT — MAIN CONTENT
   ================================================================= */
.sam-main {
  margin-top: var(--header-height);
  flex: 1;
  padding: 24px 16px 40px;
}

.sam-container {
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
}

/* =================================================================
   LAYOUT — FOOTER
   ================================================================= */
.sam-footer {
  border-top: 1px solid var(--border);
  padding: 12px 24px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  background: var(--surface);
}

/* =================================================================
   CARD SYSTEM
   ================================================================= */
.sam-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.sam-card + .sam-card { margin-top: 16px; }

.sam-card__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.sam-card__subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* KPI card */
.sam-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.sam-kpi__label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.sam-kpi__value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.sam-kpi__delta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.sam-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

/* =================================================================
   SISTEMA A SCHEDE (TAB)
   ================================================================= */
.sam-tabs {
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0;
  overflow-x: auto;
  margin-bottom: 20px;
}

.sam-tab {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.sam-tab:hover { color: var(--text); }

.sam-tab.active,
.sam-tab[aria-selected="true"] {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 500;
  text-decoration: none;
}

.sam-tab-content { display: none; }
.sam-tab-content.active { display: block; }

/* =================================================================
   PULSANTI
   ================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
              box-shadow var(--transition), opacity var(--transition);
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}

.btn:disabled,
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Primario */
.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  text-decoration: none;
  color: white;
}

/* Secondario */
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  text-decoration: none;
}

/* Danger */
.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { opacity: 0.9; text-decoration: none; color: white; }

/* Dimensioni */
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-lg { padding: 10px 22px; font-size: 15px; }

/* =================================================================
   FORM
   ================================================================= */
.sam-form-group { margin-bottom: 16px; }

.sam-form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 5px;
}

.sam-form-group label.required::after {
  content: ' *';
  color: var(--danger);
}

.sam-input,
.sam-select,
.sam-textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  font-family: inherit;
}

.sam-textarea { min-height: 90px; resize: vertical; }

.sam-input:focus,
.sam-select:focus,
.sam-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.sam-input::placeholder,
.sam-textarea::placeholder { color: var(--text-light); }

.sam-form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.sam-form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
}

/* =================================================================
   TABELLE
   ================================================================= */
.sam-table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.sam-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.sam-table thead tr {
  background: var(--bg);
  border-bottom: 2px solid var(--border);
}

.sam-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.sam-table th:hover { color: var(--text); }

.sam-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.sam-table tbody tr:hover { background: var(--bg); }
.sam-table tbody tr:last-child td { border-bottom: none; }

/* Barra di ricerca tabella */
.sam-table-search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.sam-table-search .sam-input { max-width: 320px; }

/* =================================================================
   BADGE / STATI
   ================================================================= */
.sam-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.6;
}

.sam-badge-success  { background: var(--success-bg);  color: var(--success); }
.sam-badge-warning  { background: var(--warning-bg);  color: var(--warning); }
.sam-badge-danger   { background: var(--danger-bg);   color: var(--danger);  }
.sam-badge-info     { background: var(--info-bg);     color: var(--info);    }
.sam-badge-neutral  { background: var(--bg);          color: var(--text-muted); border: 1px solid var(--border); }

/* =================================================================
   ALERT / NOTIFICHE
   ================================================================= */
.sam-alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.sam-alert-success { background: var(--success-bg); color: var(--success); border-color: #bbf7d0; }
.sam-alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #fde68a; }
.sam-alert-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: #fecaca; }
.sam-alert-info    { background: var(--info-bg);    color: var(--info);    border-color: #bae6fd; }

/* =================================================================
   SIDEBAR (se necessaria)
   ================================================================= */
.sam-layout-sidebar {
  display: flex;
  gap: 0;
  min-height: calc(100vh - var(--header-height));
}

.sam-sidebar {
  width: 265px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  overflow-y: auto;
}

.sam-sidebar__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}

.sam-sidebar__item:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}

.sam-sidebar__item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}

.sam-sidebar__section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-light);
  padding: 12px 20px 5px;
}

/* =================================================================
   UTILITY
   ================================================================= */
.sam-flex        { display: flex; align-items: center; }
.sam-flex-gap    { gap: 12px; }
.sam-flex-between { justify-content: space-between; }
.sam-grid-2      { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sam-grid-3      { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.sam-mt-4        { margin-top: 4px; }
.sam-mt-8        { margin-top: 8px; }
.sam-mt-16       { margin-top: 16px; }
.sam-mt-24       { margin-top: 24px; }
.sam-text-muted  { color: var(--text-muted); font-size: 13px; }
.sam-text-small  { font-size: 13px; }
.sam-divider     { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* =================================================================
   ADMIN LAYOUT — Pattern gestionali (estratti da SAM Prenotazioni)
   Queste classi definiscono lo stile istituzionale operativo SAM.
   Usarle per gestionali, dashboard, console amministrative.
   NON usare hero, gradient, card decorative per applicazioni admin.
   ================================================================= */

/*
   Topbar admin — bianca, bordo inferiore, sticky
   Sostituisce .sam-header nei layout gestionali admin.
   Reference: Prenotazioni .topbar
*/
.sam-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.sam-topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sam-topbar__logo {
  width: 36px;
  height: 36px;
  background: var(--secondary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.sam-topbar__logo img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: contain;
}

.sam-topbar__name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

/*
   Layout admin — contenuto centrato con colonna principale e laterale
   Reference: Prenotazioni .portal-body + .main-col + .side-col
*/
.sam-admin-body {
  display: flex;
  gap: 24px;
  padding: 28px 32px;
  max-width: var(--max-width);
  margin: 0 auto;
  align-items: flex-start;
}

.sam-admin-main {
  flex: 1;
  min-width: 0;
}

.sam-admin-side {
  width: 280px;
  flex-shrink: 0;
  position: sticky;
  top: 72px;
}

/*
   Sfondo admin — grigio molto chiaro (non bianco puro)
   Reference: Prenotazioni body background
*/
.sam-admin-bg {
  background: #f1f5f9;
  min-height: 100vh;
}

/*
   Navigazione back + titolo pagina
   Reference: Prenotazioni .back-link + .page-title
*/
.sam-back-link {
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 16px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
}
.sam-back-link:hover { color: var(--primary); }

.sam-page-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
}

/*
   Service card — card operativa con icona, testo, azione
   Reference: Prenotazioni .service-item + .svc-icon + .svc-info
*/
.sam-svc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  margin-bottom: 10px;
  transition: border-color .15s, box-shadow .15s;
}
.sam-svc-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(37,99,235,.08);
}

.sam-svc-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.sam-svc-name  { font-size: 14px; font-weight: 500; color: var(--text); }
.sam-svc-meta  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.sam-svc-desc  { font-size: 12px; color: var(--text-muted); margin-top: 5px; line-height: 1.45; }

/*
   Form card — card per sezioni di form operativi
   Reference: Prenotazioni .form-card + .form-row + .fgrp
*/
.sam-form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 12px;
}

.sam-form-card__title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sam-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.sam-form-row.single { grid-template-columns: 1fr; }

.sam-fgrp { display: flex; flex-direction: column; gap: 4px; }
.sam-fgrp label { font-size: 12px; color: var(--text-muted); }
.sam-fgrp input,
.sam-fgrp select,
.sam-fgrp textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  font-family: inherit;
  transition: border-color .15s;
}
.sam-fgrp input:focus,
.sam-fgrp select:focus,
.sam-fgrp textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.sam-fgrp textarea { resize: vertical; min-height: 80px; }

/*
   Form error inline
   Reference: Prenotazioni .form-error
*/
.sam-form-error-inline {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 7px;
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 10px;
}

/*
   Summary sidebar box
   Reference: Prenotazioni .summary-box + .sum-row
*/
.sam-summary-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}

.sam-sum-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #f3f4f6;
}
.sam-sum-row:last-child { border-bottom: none; }

.sam-sum-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #e0e7ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.sam-sum-icon--org { background: var(--secondary); color: white; font-size: 11px; font-weight: 700; }

.sam-sum-text { font-size: 13px; font-weight: 500; color: var(--text); }
.sam-sum-sub  { font-size: 12px; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }

/*
   Chips / tag operativi
   Reference: Prenotazioni .staff-chip
*/
.sam-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border: 1.5px solid var(--border);
  border-radius: 24px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: border-color .15s, background .15s;
  user-select: none;
  white-space: nowrap;
}
.sam-chip:hover { border-color: var(--primary); }
.sam-chip.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 500;
}

/*
   Success / Error state box
   Reference: Prenotazioni .success-box + .error-box
*/
.sam-state-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 40px;
  text-align: center;
}

.sam-state-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 16px;
}
.sam-state-icon--success { background: var(--success-bg); color: var(--success); }
.sam-state-icon--error   { background: var(--danger-bg);  color: var(--danger); }

.sam-state-title { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.sam-state-sub   { font-size: 14px; color: var(--text-muted); line-height: 1.6; margin-bottom: 20px; }

/*
   Mobile bar — barra azione fissa in basso su smartphone
   Reference: Prenotazioni .mobile-bar
*/
.sam-mobile-bar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  z-index: 300;
  align-items: center;
  gap: 12px;
  box-shadow: 0 -2px 16px rgba(0,0,0,.09);
}

.sam-mobile-bar__text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/*
   Step progress bar (wizard multi-step)
   Reference: Prenotazioni .steps-bar + .step-dot + .step-line
*/
.sam-steps {
  display: flex;
  align-items: center;
}

.sam-step-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  border: 2px solid var(--border);
  color: var(--text-muted);
  background: var(--surface);
  flex-shrink: 0;
  transition: all .2s;
}
.sam-step-dot.done,
.sam-step-dot.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.sam-step-line {
  width: 40px;
  height: 2px;
  background: var(--border);
  transition: background .2s;
}
.sam-step-line.done { background: var(--primary); }

/*
   Info section — riquadro informativo con titolo
   Reference: Prenotazioni .info-section
*/
.sam-info-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 12px;
}
.sam-info-section h3 { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.sam-info-section p  { font-size: 13px; color: #374151; }

.sam-info-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 5px 0;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
}
.sam-info-row:last-child { border-bottom: none; }

/*
   =================================================================
   REGOLE STILISTICHE ADMIN — Valori normativi
   Ricavati da Prenotazioni come standard di riferimento.
   =================================================================

   Palette admin canonica:
     Sfondo pagina:    #f1f5f9
     Topbar:           bianca + bordo #e5e7eb
     Logo placeholder: #1a3a6b (--secondary)
     Azione primaria:  #2563eb (--primary)
     Testo principale: #111 / #111827
     Testo secondario: #6b7280
     Bordi:            #e5e7eb

   Border-radius admin (valori normativi):
     Card, box:        10px
     Input, btn:       7-8px
     Icone, logo:      8px
     Tag/chip:         24px (pillole)
     Avatar:           50%

   ⛔ Vietato nei layout admin:
     - hero section, gradient background, immagini decorative
     - border-radius > 14px su card
     - font size > 22px per titoli pagina
     - padding layout > 32px desktop
     - ombre aggressive (box-shadow oltre var(--shadow))
     - palette indaco, viola, colori "brand" non SAM
*/

/* ================================================================= */

/* =================================================================
   RESPONSIVE — MOBILE FIRST
   ================================================================= */
@media (max-width: 768px) {

  /* Admin topbar */
  .sam-topbar { padding: 0 14px; height: 52px; }
  .sam-topbar__name { font-size: 12px; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Admin body layout */
  .sam-admin-body { flex-direction: column; padding: 16px 14px 84px; gap: 0; max-width: 100%; }
  .sam-admin-side { display: none !important; }
  .sam-admin-main { width: 100%; }

  /* Mobile bar visibile */
  .sam-mobile-bar { display: flex; }

  /* Form admin */
  .sam-form-card { padding: 16px; }
  .sam-form-row  { grid-template-columns: 1fr; gap: 10px; }
  .sam-fgrp input, .sam-fgrp select, .sam-fgrp textarea { font-size: 16px; padding: 11px; }

  /* Step bar */
  .sam-step-dot  { width: 28px; height: 28px; font-size: 12px; }
  .sam-step-line { width: 22px; }

  /* Titoli */
  .sam-page-title { font-size: 18px; margin-bottom: 16px; }

  /* Service card */
  .sam-svc-card { flex-wrap: wrap; gap: 10px; padding: 14px; align-items: flex-start; }

  /* Sidebar nascosta su mobile */
  .sam-sidebar {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    z-index: 900;
    width: 280px;
    box-shadow: var(--shadow-lg);
  }

  .sam-sidebar.open { display: block; }

  /* Hamburger visibile su mobile */
  .sam-hamburger {
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    padding: 6px;
    border: none;
    background: transparent;
  }

  .sam-hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform var(--transition);
  }

  /* Bottoni full-width */
  .btn-block { width: 100%; justify-content: center; }

  /* Card impilate */
  .sam-kpi-grid { grid-template-columns: 1fr 1fr; }
  .sam-grid-2,
  .sam-grid-3 { grid-template-columns: 1fr; }

  /* Padding ridotto */
  .sam-main { padding: 16px 12px 32px; }
  .sam-card { padding: 16px; }

  /* Nessuno scroll orizzontale sul body */
  body { overflow-x: hidden; }
}

@media (max-width: 480px) {
  .sam-kpi-grid { grid-template-columns: 1fr; }
  .sam-tabs { gap: 0; }
  .sam-tab { padding: 9px 14px; font-size: 13px; }
}

/* =================================================================
   HAMBURGER — nascosto su desktop
   ================================================================= */
.sam-hamburger { display: none; }

@media (max-width: 768px) {
  .sam-hamburger { display: flex; }
}

/* =================================================================
   DOCUMENTATION MODULE — Classi per modulo Manuale e Changelog
   Attive quando DOCUMENTATION_MODULE=true in .project-config.
   Riferimento visivo: Gestionale SAM Lecce — manuale/index.php,
   changelog/index.php. Stessa palette e standard admin SAM.
   ================================================================= */

/*
   Layout documentazione — sidebar + contenuto centrale
   Reference: manuale/index.php layout
*/
.sam-doc-layout {
  display: flex;
  min-height: calc(100vh - 56px);
  max-width: var(--max-width);
  margin: 0 auto;
}

.sam-doc-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}

.sam-doc-sidebar__search {
  padding: 0 14px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.sam-doc-sidebar__item {
  display: block;
  padding: 8px 18px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border-left: 3px solid transparent;
}
.sam-doc-sidebar__item:hover { background: var(--bg); color: var(--text); }
.sam-doc-sidebar__item.active {
  color: var(--primary);
  background: var(--primary-light);
  border-left-color: var(--primary);
  font-weight: 500;
}

.sam-doc-sidebar__sub {
  padding-left: 32px;
  font-size: 12px;
}

.sam-doc-sidebar__section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-light);
  padding: 12px 18px 4px;
}

.sam-doc-content {
  flex: 1;
  min-width: 0;
  padding: 28px 36px;
  background: var(--bg);
}

/* Rendering Markdown nel contenuto */
.sam-doc-content h1 { font-size: 22px; font-weight: 600; margin-bottom: 16px; color: var(--text); }
.sam-doc-content h2 { font-size: 17px; font-weight: 600; margin: 28px 0 12px; color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.sam-doc-content h3 { font-size: 15px; font-weight: 500; margin: 20px 0 8px; color: var(--text); }
.sam-doc-content p  { font-size: 14px; line-height: 1.7; color: var(--text); margin-bottom: 12px; }
.sam-doc-content code { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: 13px; font-family: var(--font-mono, monospace); }
.sam-doc-content pre { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; overflow-x: auto; margin-bottom: 14px; }
.sam-doc-content pre code { background: none; border: none; padding: 0; }
.sam-doc-content ul, .sam-doc-content ol { padding-left: 20px; margin-bottom: 12px; }
.sam-doc-content li { font-size: 14px; line-height: 1.7; color: var(--text); margin-bottom: 3px; }
.sam-doc-content table { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 13px; }
.sam-doc-content th { background: var(--bg); text-align: left; padding: 8px 12px; font-weight: 500; border-bottom: 2px solid var(--border); color: var(--text-muted); }
.sam-doc-content td { padding: 8px 12px; border-bottom: 1px solid var(--border); }

/*
   Changelog — toolbar filtri
   Reference: changelog/index.php toolbar
*/
.sam-changelog-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.sam-changelog-toolbar select,
.sam-changelog-toolbar input[type="text"] {
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  font-family: inherit;
  transition: border-color var(--transition);
}
.sam-changelog-toolbar select:focus,
.sam-changelog-toolbar input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.sam-changelog-toolbar input[type="text"] { flex: 1; min-width: 180px; }

/*
   Changelog — form inserimento nuova entry
*/
.sam-changelog-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.sam-changelog-form__toggle {
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
  font-weight: 500;
  margin-bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/*
   Changelog — gruppo per versione
   Reference: changelog/index.php .version-group
*/
.sam-version-group {
  margin-bottom: 24px;
}

.sam-version-group__header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

.sam-version-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  background: var(--primary);
  color: white;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

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

/*
   Changelog — singola entry
*/
.sam-change-entry {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.sam-change-entry:last-child { border-bottom: none; }
.sam-change-entry:hover { background: var(--bg); }

.sam-change-entry__title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 3px;
}

.sam-change-entry__desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 5px;
}

.sam-change-entry__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/*
   File tag — filepath cliccabile nella entry changelog
*/
.sam-file-tag {
  display: inline-block;
  padding: 2px 7px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  color: var(--text-muted);
  cursor: default;
}
.sam-file-tag:hover { border-color: var(--primary); color: var(--primary); }

/*
   Badge categoria changelog
*/
.sam-cat-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.sam-cat-badge--aggiunto  { background: var(--success-bg);  color: var(--success); }
.sam-cat-badge--modificato { background: var(--primary-light); color: var(--primary-dark); }
.sam-cat-badge--corretto  { background: var(--warning-bg);  color: var(--warning); }
.sam-cat-badge--rimosso   { background: var(--danger-bg);   color: var(--danger); }
.sam-cat-badge--sistema   { background: var(--bg);          color: var(--text-muted); border: 1px solid var(--border); }
.sam-cat-badge--sicurezza { background: #ede9fe;             color: #6d28d9; }

/*
   Stat tile — KPI strip changelog
*/
.sam-stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0;
  background: var(--secondary);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
}

.sam-stat-tile {
  padding: 16px 20px;
  border-right: 1px solid rgba(255,255,255,.12);
}
.sam-stat-tile:last-child { border-right: none; }

.sam-stat-tile__label {
  font-size: 11px;
  color: rgba(255,255,255,.65);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.sam-stat-tile__value {
  font-size: 26px;
  font-weight: 700;
  color: white;
  line-height: 1.1;
}

.sam-stat-tile__sub {
  font-size: 12px;
  color: rgba(255,255,255,.5);
  margin-top: 3px;
}

/* Stat tile variante chiara (per dashboard generica) */
.sam-stat-tile--light {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.sam-stat-tile--light .sam-stat-tile__label { color: var(--text-muted); }
.sam-stat-tile--light .sam-stat-tile__value { color: var(--text); }

/*
   Responsive documentazione
*/
@media (max-width: 768px) {
  .sam-doc-layout { flex-direction: column; }
  .sam-doc-sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
  }
  .sam-doc-content { padding: 16px 14px; }
  .sam-changelog-toolbar { flex-direction: column; align-items: stretch; }
  .sam-changelog-toolbar input[type="text"] { min-width: 0; }
  .sam-stat-strip { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .sam-stat-strip { grid-template-columns: 1fr; }
}

/* =================================================================
   PATTERN A — Dashboard Gestionale (macro-card con voci APRI)
   Riferimento: Gestionale SAM Lecce — dashboard principale
   Usare quando APP_TYPE=gestionale in .project-config
   Vedere: DESIGN_PATTERNS.md — Pattern A
   ================================================================= */

.sam-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  padding: 28px 32px;
  max-width: var(--max-width);
  margin: 0 auto;
}

.sam-module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.sam-module-card__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
  margin-bottom: 8px;
}

.sam-module-card__title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.2;
}

.sam-module-card__desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.55;
}

.sam-module-card__list {
  border-top: 1px solid var(--border);
  padding-top: 4px;
}

.sam-module-card__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.sam-module-card__item:last-child { border-bottom: none; }

.sam-module-card__item a,
.sam-module-card__item .sam-apri {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.sam-module-card__item a:hover { text-decoration: underline; }

/* Stat strip gestionale (sfondo --secondary) */
.sam-kpi-strip-dark {
  background: var(--secondary);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 0;
}

.sam-kpi-strip-dark .sam-stat-tile {
  border-right: 1px solid rgba(255,255,255,.12);
  padding: 18px 28px;
}
.sam-kpi-strip-dark .sam-stat-tile:last-child { border-right: none; }

.sam-kpi-strip-dark .sam-stat-tile__label {
  font-size: 11px;
  color: rgba(255,255,255,.55);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.sam-kpi-strip-dark .sam-stat-tile__value {
  font-size: 15px;
  font-weight: 600;
  color: white;
}

/* Responsive Pattern A */
@media (max-width: 768px) {
  .sam-dashboard-grid {
    padding: 16px 14px;
    grid-template-columns: 1fr;
    gap: 14px;
  }
}
@media (min-width: 769px) and (max-width: 1100px) {
  .sam-dashboard-grid { grid-template-columns: repeat(2, 1fr); }
}
