/* =============================================================================
   LIS Refertazione Lab — base.css
   Font, variabili CSS, reset, animazioni, utility, stampa
   ============================================================================= */

/* --- Font Import --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* =============================================================================
   CSS CUSTOM PROPERTIES (variabili globali)
   ============================================================================= */
:root {
  /* --- Colori primari --- */
  --color-primary: #0f766e;
  --color-primary-light: #14b8a6;
  --color-primary-dark: #0d9488;
  --color-primary-50: #f0fdfa;
  --color-primary-100: #ccfbf1;
  --color-primary-200: #99f6e4;

  /* --- Colori semantici --- */
  --color-danger: #dc2626;
  --color-danger-light: #fef2f2;
  --color-danger-50: #fef2f2;
  --color-warning: #d97706;
  --color-warning-light: #fffbeb;
  --color-warning-50: #fffbeb;
  --color-success: #16a34a;
  --color-success-light: #f0fdf4;
  --color-success-50: #f0fdf4;
  --color-info: #2563eb;
  --color-info-light: #eff6ff;
  --color-info-50: #eff6ff;

  /* --- Colori di superficie --- */
  --color-bg: #f8fafb;
  --color-surface: #ffffff;
  --color-surface-hover: #f1f5f9;
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-text-muted: #94a3b8;
  --color-border: #e2e8f0;
  --color-border-light: #f1f5f9;

  /* --- Overlay / dialog (usati da lis-dialog.js) --- */
  --color-overlay: rgba(15, 23, 42, 0.5);
  --z-modal: 10060;
  --dialog-radius: 14px;
  --focus-ring: 0 0 0 3px rgba(20, 184, 166, 0.35);

  /* --- Sidebar --- */
  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-text-active: #ffffff;
  --sidebar-hover: #1e293b;
  --sidebar-active-accent: #14b8a6;
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 64px;

  /* --- Topbar --- */
  --topbar-height: 56px;

  /* --- Tipografia --- */
  --font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-size-xs: calc(11px*var(--fs,1));
  --font-size-sm: calc(12px*var(--fs,1));
  --font-size-base: calc(14px*var(--fs,1));
  --font-size-md: calc(15px*var(--fs,1));
  --font-size-lg: calc(16px*var(--fs,1));
  --font-size-xl: calc(18px*var(--fs,1));
  --font-size-2xl: calc(20px*var(--fs,1));
  --font-size-3xl: calc(24px*var(--fs,1));
  --font-size-4xl: calc(30px*var(--fs,1));
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* --- Spaziatura --- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* --- Bordi e ombre --- */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-2xl: 16px;
  --radius-full: 9999px;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

  /* --- Transizioni --- */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* --- Colori gruppi analisi --- */
  --group-ematologia: #dc2626;
  --group-chimica: #2563eb;
  --group-enzimi: #7c3aed;
  --group-lipidi: #d97706;
  --group-coagulazione: #0891b2;
  --group-urine: #84cc16;
  --group-ormoni: #ec4899;
  --group-sierologia: #f97316;
  --group-markers: #6366f1;
  --group-feci: #92400e;
  --group-microbiologia: #059669;
  --group-spermio: #be185d;
  --group-elettroforesi: #1e40af;
  --group-autoimmunita: #b45309;
  --group-tiroide: #0d9488;
  --group-cardio: #be123c;
  --group-tossicologia: #4338ca;
}

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

/* 03/11/2026 dimensione del testo, come in Threpsis (tema-em.js, pulsante «Testo» nella barra in alto).
   Ogni font-size del LIS e' calc(Npx*var(--fs,1)). Dove --fs non esiste, come nelle finestre di stampa aperte
   a parte, vale 1. I PDF dei referti li genera il server e non usano questi fogli. */
:root { --fs: 1; }
html[data-fs="normale"] { --fs: 1; }
html[data-fs="grande"] { --fs: 1.15; }
html[data-fs="molto-grande"] { --fs: 1.3; }
@media print { html[data-fs] { --fs: 1; } }
/* i tooltip: Tippy scrive 14px nel proprio foglio, caricato dopo questo */
html .tippy-box { font-size: calc(14px*var(--fs,1)); }

html {
  font-size: var(--font-size-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-semibold);
  line-height: 1.3;
  color: var(--color-text);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }

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

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
}

table {
  border-collapse: collapse;
  width: 100%;
}

/* --- Scrollbar personalizzata --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background-color: var(--color-primary-light);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-primary);
}
/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-primary-light) transparent;
}

/* =============================================================================
   ANIMAZIONI
   ============================================================================= */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slideOutRight {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100%); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* =============================================================================
   CLASSI UTILITY
   ============================================================================= */
/* Testo */
.text-danger { color: var(--color-danger) !important; }
.text-warning { color: var(--color-warning) !important; }
.text-success { color: var(--color-success) !important; }
.text-info { color: var(--color-info) !important; }
.text-primary { color: var(--color-primary) !important; }
.text-secondary { color: var(--color-text-secondary) !important; }
.text-muted { color: var(--color-text-muted) !important; }

/* Sfondo */
.bg-danger-light { background: var(--color-danger-light) !important; }
.bg-warning-light { background: var(--color-warning-light) !important; }
.bg-success-light { background: var(--color-success-light) !important; }
.bg-info-light { background: var(--color-info-light) !important; }
.bg-primary-light { background: var(--color-primary-50) !important; }

/* Margini */
.mt-1 { margin-top: var(--space-1) !important; }
.mt-2 { margin-top: var(--space-2) !important; }
.mt-3 { margin-top: var(--space-3) !important; }
.mt-4 { margin-top: var(--space-4) !important; }
.mb-1 { margin-bottom: var(--space-1) !important; }
.mb-2 { margin-bottom: var(--space-2) !important; }
.mb-3 { margin-bottom: var(--space-3) !important; }
.mb-4 { margin-bottom: var(--space-4) !important; }
.ml-1 { margin-left: var(--space-1) !important; }
.ml-2 { margin-left: var(--space-2) !important; }
.mr-1 { margin-right: var(--space-1) !important; }
.mr-2 { margin-right: var(--space-2) !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }

/* Padding */
.p-1 { padding: var(--space-1) !important; }
.p-2 { padding: var(--space-2) !important; }
.p-3 { padding: var(--space-3) !important; }
.p-4 { padding: var(--space-4) !important; }

/* Flexbox */
.flex { display: flex !important; }
.inline-flex { display: inline-flex !important; }
.flex-col { flex-direction: column !important; }
.flex-wrap { flex-wrap: wrap !important; }
.items-center { align-items: center !important; }
.items-start { align-items: flex-start !important; }
.items-end { align-items: flex-end !important; }
.justify-between { justify-content: space-between !important; }
.justify-center { justify-content: center !important; }
.justify-end { justify-content: flex-end !important; }
.gap-1 { gap: var(--space-1) !important; }
.gap-2 { gap: var(--space-2) !important; }
.gap-3 { gap: var(--space-3) !important; }
.gap-4 { gap: var(--space-4) !important; }
.flex-1 { flex: 1 !important; }

/* Display */
.hidden { display: none !important; }
.block { display: block !important; }

/* Testo */
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.text-left { text-align: left !important; }
.font-bold { font-weight: var(--font-weight-bold) !important; }
.font-semibold { font-weight: var(--font-weight-semibold) !important; }
.font-medium { font-weight: var(--font-weight-medium) !important; }
.text-sm { font-size: var(--font-size-sm) !important; }
.text-xs { font-size: var(--font-size-xs) !important; }
.text-lg { font-size: var(--font-size-lg) !important; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Dimensioni */
.w-full { width: 100% !important; }

/* Bordi */
.rounded { border-radius: var(--radius-md) !important; }
.rounded-lg { border-radius: var(--radius-lg) !important; }
.rounded-full { border-radius: var(--radius-full) !important; }

/* Cursore */
.cursor-pointer { cursor: pointer !important; }

/* Overflow */
.overflow-hidden { overflow: hidden !important; }
.overflow-auto { overflow: auto !important; }

/* Posizione */
.relative { position: relative !important; }
.absolute { position: absolute !important; }
.sticky { position: sticky !important; }

/* Fix: SVG inline nelle icone devono avere dimensioni limitate */
.page-header svg, .ai-panel-header svg, .btn svg,
.nav-item svg, .sidebar-logo svg, .topbar-toggle svg,
.dropdown-item svg, .modal-close svg, .note-btn svg,
.toast-icon svg, .toast-close svg, .empty-state svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  flex-shrink: 0;
  vertical-align: middle;
}

.page-header-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, var(--color-bg) 25%, var(--color-border-light) 50%, var(--color-bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* =============================================================================
   PRINT STYLES
   ============================================================================= */
@media print {
  .sidebar,
  .topbar,
  .report-toolbar,
  .summary-bar,
  .toast-container,
  .spinner-overlay,
  .modal-overlay {
    display: none !important;
  }
  .main-content {
    margin: 0;
    padding: 0;
    width: 100%;
  }
  .patient-card,
  .results-table-wrapper {
    box-shadow: none;
    border: 1px solid #ddd;
  }
  body {
    background: #fff;
    color: #000;
    font-size: calc(11px*var(--fs,1));
  }
}
