/* ==========================================================================
   GestioneTurni Desktop - Design System Ospedaliero Moderno (UI/UX)
   Stile per interfaccia sanitaria ad alta densità informativa (1366x768 -> 4K)
   ========================================================================== */

:root {
  /* Palette Colori Sfondo e Superficie */
  --bg-primary: #0b1120;
  --bg-secondary: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-hover: #334155;
  --bg-card: #182234;
  --border-color: #334155;
  --border-light: rgba(255, 255, 255, 0.08);

  /* Testo */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f172a;

  /* Primario & Accenti Ospedalieri */
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-glow: rgba(2, 132, 199, 0.35);
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;

  /* Specifiche Colori Turni Sanitari (Standard Richiesto) */
  --shift-m-bg: #10b981;    /* Verde per Mattina */
  --shift-m-text: #ffffff;
  --shift-p-bg: #f59e0b;    /* Giallo/Ambra per Pomeriggio */
  --shift-p-text: #ffffff;
  --shift-n-bg: #312e81;    /* Blu Notte profondo */
  --shift-n-text: #e0e7ff;
  --shift-s-bg: #475569;    /* Grigio Scuro per Smonto Notte */
  --shift-s-text: #f1f5f9;
  --shift-r-bg: #94a3b8;    /* Grigio Chiaro per Riposo */
  --shift-r-text: #0f172a;
  --shift-f-bg: #06b6d4;    /* Celeste per Ferie */
  --shift-f-text: #ffffff;
  --shift-mal-bg: #f43f5e;  /* Rosa/Pesca vivo per Malattia */
  --shift-mal-text: #ffffff;
  --shift-104-bg: #a855f7;  /* Lilla per Legge 104 */
  --shift-104-text: #ffffff;
  --shift-d-bg: #ea580c;    /* Arancione Diurno 12h */
  --shift-d-text: #ffffff;
  --shift-m6-bg: #059669;   /* Verde Smeraldo Mattina 6h */
  --shift-m6-text: #ffffff;
  --shift-m7-bg: #0d9488;   /* Teal / Petrolio Mattina 7h */
  --shift-m7-text: #ffffff;
  --shift-p6-bg: #d97706;   /* Ambra Pomeriggio 6h */
  --shift-p6-text: #ffffff;
  --shift-custom-bg: #6366f1; /* Indaco per turni personalizzati generici */
  --shift-custom-text: #ffffff;
  --shift-g-bg: #0284c7;    /* Blu Medicale Giornaliero */
  --shift-g-text: #ffffff;
  --shift-mat-bg: #ec4899;  /* Rosa Maternità */
  --shift-mat-text: #ffffff;
  --shift-per-bg: #d97706;  /* Ambra Permessi */
  --shift-per-text: #ffffff;

  /* Giorni speciali calendario */
  --col-saturday-bg: rgba(245, 158, 11, 0.09);
  --col-sunday-bg: rgba(239, 68, 68, 0.12);
  --col-holiday-bg: rgba(239, 68, 68, 0.15);
  --col-today-border: #38bdf8;

  /* Raggi e ombre */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 10px 10px -5px rgba(0, 0, 0, 0.4);

  /* Misure Griglia */
  --header-height: 64px;
  --filterbar-height: 48px;
  --emp-col-width: 250px;
  --day-col-width: 44px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.4;
  overflow: hidden;
  user-select: none;
  height: 100vh;
  width: 100vw;
}

/* ==========================================================================
   STRUTTURA PRINCIPALE DELL'APP
   ========================================================================== */

#app-root {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Header Superiore */
.header-bar {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 16px;
  z-index: 30;
  flex-shrink: 0;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.brand-text-block {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--accent-cyan);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Selettore Mese / Anno */
.month-selector-group {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2px 6px;
  gap: 6px;
}

.nav-arrow-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s ease;
}

.nav-arrow-btn:hover {
  background: var(--bg-surface-hover);
  color: #fff;
}

.month-label-display {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  padding: 0 6px;
  min-width: 140px;
  text-align: center;
}

/* Switcher Preventivo / Consuntivo */
.mode-toggle-group {
  display: flex;
  background: #090e1a;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 3px;
  gap: 2px;
}

.mode-pill-btn {
  padding: 4px 14px;
  border-radius: 16px;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-muted);
  background: transparent;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mode-pill-btn.active.mode-preventivo {
  background: #0284c7;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(2, 132, 199, 0.5);
}

.mode-pill-btn.active.mode-consuntivo {
  background: #10b981;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

/* Tabs di Navigazione */
.nav-tabs-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tab-nav-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.tab-nav-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.tab-nav-btn.active {
  background: var(--bg-surface);
  color: #38bdf8;
  border-bottom: 2px solid #38bdf8;
}

/* Azioni Rapide a Destra */
.header-actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-btn {
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background: var(--bg-surface-hover);
  border-color: #475569;
}

.action-btn-primary {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  border-color: #0284c7;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);
}

.action-btn-primary:hover {
  background: linear-gradient(135deg, #0369a1, #075985);
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.5);
}

.action-btn-danger {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.4);
  color: #fda4af;
}

.action-btn-danger:hover {
  background: #f43f5e;
  color: #ffffff;
}

/* Contenitore Viste */
.main-view-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

.view-section {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

.view-section.active {
  display: flex;
}

/* ==========================================================================
   VISTA 1: TABELLONE MENSILE DEI TURNI
   ========================================================================== */

.tabellone-toolbar {
  height: var(--filterbar-height);
  background: #111827;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  gap: 16px;
}

.filter-left-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper input {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 12px 6px 30px;
  color: #ffffff;
  font-size: 12px;
  width: 200px;
  transition: all 0.2s ease;
}

.search-input-wrapper input:focus {
  outline: none;
  border-color: #0284c7;
  width: 250px;
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.search-input-icon {
  position: absolute;
  left: 9px;
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
}

.role-filter-pills {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.role-pill {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.role-pill.active {
  background: var(--primary);
  color: #ffffff;
}

/* Legenda Turni orizzontale */
.legend-chips-group {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.chip-dot {
  width: 9px;
  height: 9px;
  border-radius: 2px;
}

/* Griglia Tabellone */
.grid-table-container {
  flex: 1;
  overflow: auto;
  position: relative;
  background: var(--bg-primary);
}

.turni-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 12px;
}

/* Header Tabella (Giorni) */
.turni-table thead th {
  position: sticky;
  top: 0;
  background: #131d2e;
  color: var(--text-primary);
  font-weight: 600;
  text-align: center;
  border-bottom: 2px solid #334155;
  border-right: 1px solid var(--border-light);
  padding: 6px 2px;
  z-index: 20;
  user-select: none;
}

.turni-table thead th.th-employee-col {
  position: sticky;
  left: 0;
  z-index: 25;
  background: #111a2a;
  text-align: left;
  padding-left: 14px;
  width: var(--emp-col-width);
  min-width: var(--emp-col-width);
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.4);
}

.th-day-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: var(--day-col-width);
}

.th-day-number {
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.th-day-name {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Evidenziazione Sabato e Domenica / Festivi */
.col-saturday {
  background-color: var(--col-saturday-bg) !important;
}

.col-saturday .th-day-name,
.col-saturday .th-day-number {
  color: #fbbf24;
}

.col-sunday {
  background-color: var(--col-sunday-bg) !important;
}

.col-sunday .th-day-name,
.col-sunday .th-day-number {
  color: #f87171;
}

.col-holiday {
  background-color: var(--col-holiday-bg) !important;
}

.col-holiday .th-day-name,
.col-holiday .th-day-number {
  color: #ef4444;
  font-weight: 800;
}

/* Righe Dipendenti */
.turni-table tbody tr {
  transition: background-color 0.1s ease;
}

.turni-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.turni-table tbody td {
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-light);
  padding: 3px 2px;
  text-align: center;
  vertical-align: middle;
}

/* Colonna Sticky Dipendente */
.td-employee-card {
  position: sticky;
  left: 0;
  z-index: 10;
  background: #0f172a;
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.4);
  text-align: left !important;
  padding: 6px 10px !important;
  width: var(--emp-col-width);
  min-width: var(--emp-col-width);
}

.emp-row-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.emp-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #1e293b;
  border: 1px solid #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #38bdf8;
  flex-shrink: 0;
}

.emp-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}

.emp-name {
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.emp-sub-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.badge-role {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
}

.badge-role-inf {
  background: rgba(2, 132, 199, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(2, 132, 199, 0.4);
}

.badge-role-oss {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-role-coord {
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.4);
}

.badge-fte {
  font-size: 9px;
  color: var(--text-muted);
}

.badge-exempt-tag {
  font-size: 9px;
  color: #f43f5e;
  font-weight: 700;
  cursor: help;
}

/* Cella Turno Interattiva */
.td-shift-cell {
  position: relative;
  min-width: var(--day-col-width);
  height: 40px;
  cursor: pointer;
  user-select: none;
  transition: all 0.1s ease;
}

.td-shift-cell:hover {
  filter: brightness(1.15);
  box-shadow: inset 0 0 0 1px #38bdf8;
}

.td-shift-cell.selected {
  box-shadow: inset 0 0 0 2px #38bdf8, 0 0 8px rgba(56, 189, 248, 0.5) !important;
  z-index: 5;
}

/* Badge Codice Turno */
.shift-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 28px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s ease;
}

.shift-badge:active {
  transform: scale(0.92);
}

/* Varianti Turni */
.shift-M { background: var(--shift-m-bg); color: var(--shift-m-text); }
.shift-P { background: var(--shift-p-bg); color: var(--shift-p-text); }
.shift-N { background: var(--shift-n-bg); color: var(--shift-n-text); border: 1px solid #6366f1; }
.shift-S { background: var(--shift-s-bg); color: var(--shift-s-text); }
.shift-R { background: var(--shift-r-bg); color: var(--shift-r-text); }
.shift-F { background: var(--shift-f-bg); color: var(--shift-f-text); }
.shift-MAL { background: var(--shift-mal-bg); color: var(--shift-mal-text); }
.shift-104 { background: var(--shift-104-bg); color: var(--shift-104-text); }
.shift-L104 { background: var(--shift-104-bg); color: var(--shift-104-text); }
.shift-D { background: var(--shift-d-bg); color: var(--shift-d-text); }
.shift-D12 { background: var(--shift-d-bg); color: var(--shift-d-text); }
.shift-M6 { background: var(--shift-m6-bg); color: var(--shift-m6-text); }
.shift-M7 { background: var(--shift-m7-bg); color: var(--shift-m7-text); }
.shift-P6 { background: var(--shift-p6-bg); color: var(--shift-p6-text); }
.shift-custom { background: var(--shift-custom-bg); color: var(--shift-custom-text); border: 1px solid rgba(255, 255, 255, 0.25); }
.shift-G { background: var(--shift-g-bg); color: var(--shift-g-text); }
.shift-MAT { background: var(--shift-mat-bg); color: var(--shift-mat-text); }
.shift-PER { background: var(--shift-per-bg); color: var(--shift-per-text); }

/* Indicatore Turno Forzato o con Note */
.shift-forced-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 4px #f59e0b;
}

.shift-substituted-badge {
  position: absolute;
  bottom: 1px;
  right: 2px;
  font-size: 8px;
  color: #38bdf8;
  font-weight: 800;
}

/* Guardrail Alert in tempo reale: Bordo rosso lampeggiante */
.shift-violation-cell {
  animation: violation-pulse 1.2s infinite ease-in-out;
  background-color: rgba(239, 68, 68, 0.25) !important;
}

@keyframes violation-pulse {
  0%, 100% {
    box-shadow: inset 0 0 0 2px #ef4444;
  }
  50% {
    box-shadow: inset 0 0 0 3px #dc2626, 0 0 10px rgba(239, 68, 68, 0.7);
  }
}

/* Footer Tabellone: Fabbisogno e Totali Copertura */
.turni-table tfoot th,
.turni-table tfoot td {
  position: sticky;
  bottom: 0;
  background: #111a2a;
  border-top: 2px solid #334155;
  border-bottom: 1px solid #334155;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 2px;
  text-align: center;
  z-index: 15;
}

.turni-table tfoot tr:first-child th,
.turni-table tfoot tr:first-child td {
  bottom: 48px; /* Offset se ci sono più righe */
}

.tfoot-label-col {
  position: sticky;
  left: 0;
  z-index: 25;
  background: #0d1524 !important;
  text-align: left !important;
  padding-left: 14px !important;
  color: #94a3b8;
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.4);
}

.fabbisogno-ok {
  color: #34d399;
}

.fabbisogno-shortage {
  color: #f87171;
  background: rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  padding: 1px 3px;
  font-weight: 800;
}

.fabbisogno-surplus {
  color: #fbbf24;
}

/* Popover Selezione Rapida Turno */
.shift-quick-popover {
  position: fixed;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: var(--radius-lg);
  padding: 10px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  width: 290px;
  max-height: 460px;
  animation: fadeInPop 0.12s ease-out;
}

@keyframes fadeInPop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.popover-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 6px;
  border-bottom: 1px solid #334155;
  margin-bottom: 6px;
}

.popover-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 13px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.popover-close-btn:hover {
  color: #f1f5f9;
}

.popover-shifts-container {
  overflow-y: auto;
  max-height: 310px;
  padding-right: 4px;
}

.popover-shifts-container::-webkit-scrollbar {
  width: 5px;
}

.popover-shifts-container::-webkit-scrollbar-track {
  background: #0f172a;
  border-radius: 4px;
}

.popover-shifts-container::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}

.popover-group-section {
  margin-bottom: 8px;
}

.popover-group-label {
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.popover-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.popover-btn {
  border: 1px solid transparent;
  padding: 5px 2px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.1s ease;
  min-height: 38px;
  user-select: none;
}

.popover-btn .popover-sub {
  font-size: 8px;
  font-weight: 500;
  opacity: 0.85;
  margin-top: 1px;
  white-space: nowrap;
}

.popover-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.2);
  box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

.popover-footer-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  border-top: 1px solid #334155;
  padding-top: 8px;
}

.popover-action-btn {
  flex: 1;
  background: #334155;
  border: none;
  color: #f8fafc;
  font-size: 10px;
  font-weight: 600;
  padding: 6px 4px;
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s ease;
}

.popover-action-btn:hover {
  background: #475569;
}

.popover-btn-clear {
  background: #475569;
  color: #fca5a5;
  max-width: 60px;
}

.popover-btn-clear:hover {
  background: #ef4444;
  color: #ffffff;
}

/* Catalogo Turni Reparto Styling */
.badge-shift-system {
  display: inline-block;
  padding: 3px 8px;
  background: #334155;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
}

.badge-shift-custom {
  display: inline-block;
  padding: 3px 8px;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.4);
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
}

.badge-tipo-diurno {
  display: inline-block;
  padding: 2px 7px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  font-size: 11px;
  border-radius: 4px;
  font-weight: 500;
}

.badge-tipo-notte {
  display: inline-block;
  padding: 2px 7px;
  background: rgba(99, 102, 241, 0.2);
  color: #c7d2fe;
  font-size: 11px;
  border-radius: 4px;
  font-weight: 500;
}

.badge-tipo-riposo {
  display: inline-block;
  padding: 2px 7px;
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  font-size: 11px;
  border-radius: 4px;
  font-weight: 500;
}

.badge-tipo-assenza {
  display: inline-block;
  padding: 2px 7px;
  background: rgba(6, 182, 212, 0.15);
  color: #67e8f9;
  font-size: 11px;
  border-radius: 4px;
  font-weight: 500;
}

.btn-delete-shift {
  background: rgba(244, 63, 94, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(244, 63, 94, 0.3);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-delete-shift:hover {
  background: #f43f5e;
  color: #ffffff;
}

.color-preset-btn {
  transition: transform 0.1s ease, border-color 0.1s ease;
}

.color-preset-btn:hover {
  transform: scale(1.15);
}

.color-preset-btn.selected {
  border-color: #ffffff !important;
  box-shadow: 0 0 0 2px #38bdf8;
}

/* ==========================================================================
   VISTE SECONDARIE (Anagrafica, Setup, Desiderata, Statistiche, Audit)
   ========================================================================== */

.standard-view-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg-primary);
}

.view-header-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.view-header-title {
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.view-header-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 3px;
}

/* Card e Tabelle Standard */
.data-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: 20px;
}

.data-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
}

.data-card-title {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
}

.data-card-body {
  padding: 20px;
}

/* Tabelle Dati */
.standard-data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.standard-data-table th {
  background: #0f172a;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.standard-data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

.standard-data-table tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Statistiche & KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.kpi-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.kpi-title {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-icon {
  font-size: 16px;
  color: #38bdf8;
}

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.kpi-subtext {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Modali e Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 17, 32, 0.85);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-dialog {
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: modalEnter 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-dialog-large {
  max-width: 850px;
}

@keyframes modalEnter {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #182234;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  border-radius: var(--radius-sm);
}

.modal-close-btn:hover {
  color: #fff;
  background: var(--bg-surface-hover);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border-color);
  background: #182234;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* Modale Trova Sostituto */
.substitute-candidate-card {
  background: #111a2a;
  border: 1px solid #334155;
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.15s ease;
}

.substitute-candidate-card:hover {
  border-color: #0284c7;
  background: #132238;
}

.candidate-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge-legal-100 {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.badge-legal-disqualified {
  background: rgba(244, 63, 94, 0.2);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.4);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Modale Esporta 3 Opzioni */
.export-options-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.export-card {
  background: #111a2a;
  border: 1px solid #334155;
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.export-card:hover {
  border-color: #0284c7;
  transform: translateY(-3px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
  background: #152236;
}

.export-card-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.export-card-title {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
}

.export-card-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 16px;
  flex: 1;
}

/* Modale Autenticazione / PIN */
.auth-box {
  max-width: 420px;
  margin: 0 auto;
  text-align: center;
}

.auth-lock-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(2, 132, 199, 0.15);
  border: 1px solid rgba(2, 132, 199, 0.3);
  color: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin: 0 auto 16px auto;
}

.auth-title {
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
}

.auth-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.form-group {
  display: flex;
  flex-direction: column;
  text-align: left;
  margin-bottom: 16px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: #ffffff;
  font-size: 13px;
  font-family: inherit;
  transition: all 0.15s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: #0284c7;
  box-shadow: 0 0 0 2px var(--primary-glow);
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: #1e293b;
  border-left: 4px solid #0284c7;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  min-width: 280px;
  max-width: 400px;
  color: #ffffff;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: toastSlide 0.25s ease-out;
}

.toast-success { border-left-color: #10b981; }
.toast-error { border-left-color: #f43f5e; }
.toast-warning { border-left-color: #f59e0b; }

@keyframes toastSlide {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Scrollbar personalizzata dark */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #090e1a;
}

::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #475569;
}
