/* =========================================================
   app-modern.css — Design system light (non-breaking).
   Solo tokens + typography + polish cosmetico su HEADER/CARDS.
   NON sovrascrive form-check, form-control, input, btn, table:
   preserva completamente il comportamento Bootstrap 5.3.
   ========================================================= */

/* Base globale — no FOUC-hide (visualizzazione immediata contenuto) */
html{background:#fafbfd;font-size:14px!important;font-family:'Inter',system-ui,-apple-system,sans-serif!important}
body{background:#fafbfd;font-size:14px!important;font-family:'Inter',system-ui,-apple-system,sans-serif!important;color:#0f172a}
/* Legacy header eliminato dal DOM. Backup CSS se residuo: transparent, no gradient */
body > header.app-header,body > .app-header,body > .sa-header{display:none!important}
header.app-header,.app-header{background:transparent!important;color:transparent!important;box-shadow:none!important}

/* -------- DESIGN TOKENS -------- */
:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-dark: #1d4ed8;
  --primary-rgb: 37, 99, 235;
  --accent: #f59e0b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;

  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --surface-hover: #f8fafc;

  --text: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;

  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 24px rgba(15, 23, 42, 0.10), 0 4px 8px rgba(15, 23, 42, 0.05);
  --shadow-primary: 0 8px 24px rgba(var(--primary-rgb), 0.25);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;

  --container-max: 1440px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast: 150ms var(--ease);
  --t-base: 220ms var(--ease);
}

/* -------- BASE (typography only) -------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

/* Scrollbar moderna (browser Blink) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.25);
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(100, 116, 139, 0.45); background-clip: padding-box; }

/* -------- HEADER POLISH (cosmetic only) -------- */
.app-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 {
  letter-spacing: -0.015em;
}

.app-header .logo-icon {
  backdrop-filter: none;
}

/* -------- MENU CARDS (index.html) -------- */
.menu-card {
  transition: box-shadow var(--t-base), transform var(--t-base), border-color var(--t-base);
  position: relative;
  overflow: hidden;
}
.menu-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--t-base);
}
.menu-card:hover::before { transform: scaleX(1); }
.menu-card:hover {
  transform: translateY(-2px);
}

/* -------- CARDS (generic polish) -------- */
.card {
  transition: box-shadow var(--t-base);
}

/* -------- BUTTON POLISH (cosmetico, non rompe) -------- */
.btn {
  letter-spacing: -0.005em;
}
.btn-primary {
  box-shadow: 0 1px 2px rgba(var(--primary-rgb), 0.1);
}
.btn-primary:hover {
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.25);
}

button:has(i.bi-trash),
button:has(i.bi-trash3),
button:has(i.bi-trash-fill),
button:has(i.bi-trash3-fill),
.btn:has(i.bi-trash),
.btn:has(i.bi-trash3),
.btn:has(i.bi-trash-fill),
.btn:has(i.bi-trash3-fill) {
  background: var(--danger, #dc3545) !important;
  border-color: var(--danger, #dc3545) !important;
  color: #fff !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: .45rem !important;
  text-align: center !important;
}
button:has(i.bi-trash):hover,
button:has(i.bi-trash3):hover,
button:has(i.bi-trash-fill):hover,
button:has(i.bi-trash3-fill):hover,
.btn:has(i.bi-trash):hover,
.btn:has(i.bi-trash3):hover,
.btn:has(i.bi-trash-fill):hover,
.btn:has(i.bi-trash3-fill):hover {
  background: #b91c1c !important;
  border-color: #b91c1c !important;
  color: #fff !important;
}
button:has(i.bi-trash) i,
button:has(i.bi-trash3) i,
button:has(i.bi-trash-fill) i,
button:has(i.bi-trash3-fill) i,
.btn:has(i.bi-trash) i,
.btn:has(i.bi-trash3) i,
.btn:has(i.bi-trash-fill) i,
.btn:has(i.bi-trash3-fill) i {
  color: #fff !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
}

/* Focus a11y migliorato */
.btn:focus-visible, .form-control:focus-visible, .form-select:focus-visible, .form-check-input:focus-visible {
  outline: 2px solid rgba(var(--primary-rgb), 0.45);
  outline-offset: 2px;
}

/* -------- EMPTY STATE (utility class opzionale) -------- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  font-size: 3rem;
  opacity: 0.3;
  margin-bottom: 16px;
  display: block;
}

/* -------- SKELETON LOADER (utility class opzionale) -------- */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--surface-alt) 25%, var(--border) 50%, var(--surface-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

/* -------- RESPONSIVE HEADER (mobile) -------- */
@media (max-width: 768px) {
  .app-header {
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .app-header h1 { font-size: 1.1rem; }
  .app-header small { font-size: 0.72rem; }
}

@media (max-width: 480px) {
  .app-header small { display: none; }
}

/* Touch: rimuovi transform hover */
@media (hover: none) {
  .menu-card:hover, .card:hover { transform: none; }
}

/* Print */
@media print {
  .app-header, .no-print { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* Container max-width (non invasivo) */
.container, .container-fluid {
  max-width: var(--container-max);
}
