/* =============================================================================
   LIS Refertazione Lab — worklist.css
   Dashboard (stat card, attivita recente) e Worklist (filtri, tabella pazienti)
   ============================================================================= */

/* =============================================================================
   DASHBOARD
   ============================================================================= */
.page-header {
  margin-bottom: var(--space-6);
}

/* Bottoni azione riga worklist (Annulla / Pubblica) */
.btn-action {
  padding: 4px 10px;
  margin-left: 4px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: calc(12px*var(--fs,1));
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn-action:hover { transform: translateY(-1px); }
.btn-action:disabled { opacity: 0.5; cursor: wait; }
.btn-revert {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}
.btn-revert:hover { background: #fde68a; }
.btn-republish {
  background: #dbeafe;
  color: #1e40af;
  border-color: #93c5fd;
}
.btn-republish:hover { background: #bfdbfe; }

.page-header h1 {
  font-size: var(--font-size-2xl);
  margin-bottom: var(--space-1);
}

.page-header p {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

/* Griglia stat cards */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  transition: all var(--transition-base);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.stat-card-info {
  flex: 1;
  min-width: 0;
}

.stat-card-number {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  line-height: 1.1;
  margin-bottom: var(--space-1);
}

.stat-card-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-medium);
}

.stat-card-trend {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  margin-top: var(--space-1);
}

/* Varianti colori stat cards */
.stat-card.teal .stat-card-icon { background: var(--color-primary-100); color: var(--color-primary); }
.stat-card.teal .stat-card-number { color: var(--color-primary); }
.stat-card.teal::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--color-primary);
}

.stat-card.blue .stat-card-icon { background: var(--color-info-50); color: var(--color-info); }
.stat-card.blue .stat-card-number { color: var(--color-info); }
.stat-card.blue::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--color-info);
}

.stat-card.amber .stat-card-icon { background: var(--color-warning-50); color: var(--color-warning); }
.stat-card.amber .stat-card-number { color: var(--color-warning); }
.stat-card.amber::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--color-warning);
}

.stat-card.green .stat-card-icon { background: var(--color-success-50); color: var(--color-success); }
.stat-card.green .stat-card-number { color: var(--color-success); }
.stat-card.green::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--color-success);
}

/* Attivita recente */
.recent-activity {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
}

.recent-activity h3 {
  font-size: var(--font-size-lg);
  margin-bottom: var(--space-4);
}

.activity-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border-light);
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.activity-dot.teal { background: var(--color-primary); }
.activity-dot.blue { background: var(--color-info); }
.activity-dot.amber { background: var(--color-warning); }
.activity-dot.green { background: var(--color-success); }

.activity-text {
  flex: 1;
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

.activity-text strong {
  font-weight: var(--font-weight-semibold);
}

.activity-time {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* =============================================================================
   WORKLIST
   ============================================================================= */
.worklist {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
  overflow: hidden;
}

.worklist-header {
  padding: var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

/* 02/11/2026: schede, filtri, ricerca e date restano visibili mentre si scorre la lista dei pazienti.
   `.worklist` ha overflow:hidden, che impedisce lo sticky: `clip` taglia gli angoli allo stesso modo ma non
   crea un contenitore di scorrimento. Solo vista per paziente. --topbar-height segue da sola il tema.
   Sugli schermi molto bassi resta com'era, per non togliere spazio alla lista.
   In orizzontale scorre solo .patient-table-wrapper: la fascia sta fuori e non si muove. */
@media (min-height: 560px) {
  #worklist-patient-view .worklist { overflow: clip; }
  #worklist-patient-view .worklist-header {
    position: sticky;
    top: var(--topbar-height);
    z-index: 50;
    background: var(--color-surface);
    box-shadow: 0 8px 12px -10px rgba(24, 48, 88, 0.30);
  }
}

/* 02/11/2026 un solo «Oggi»: dal 29/10 il periodo scelto a mano scade a fine giornata, quindi 📅 Oggi e ↻ Oggi davano
   lo stesso risultato. Resta ↻ Oggi (#btn-date-reset). Le altre pagine che usano questi pulsanti non cambiano. */
#worklist-patient-view .date-quick-buttons [data-dq="today"] { display: none; }

/* 02/11/2026 fascia alta compatta: prima riga schede + chip, seconda riga ricerca + date. Nessun comando nascosto.
   Va tutto a capo da solo sugli schermi piu' stretti. Sotto 1025 px (tablet, telefono) resta com'era. */
@media (min-width: 1025px) {
  .main-content:has(#worklist-patient-view) { padding-top: var(--space-2); }
  #wl-vista { flex: none; margin-left: 10px; }
  #wl-vista .btn { padding: 5px 12px; }
  #worklist-patient-view .worklist-header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 14px; }
  #worklist-patient-view .status-tabs { margin: 0; padding: 3px; }
  #worklist-patient-view .status-tab { padding: 5px 12px; }
  #wl-freschezza { margin-left: 10px !important; padding-right: 8px; }
  #received-filter { margin: 0 0 0 auto !important; flex-wrap: nowrap !important; }
  #worklist-patient-view .worklist-filters { flex: 1 1 100%; gap: 8px; }
  #worklist-patient-view .search-bar input,
  #worklist-patient-view .date-filter input[type="date"] { height: 36px; }
  #bulk-sign-bar, #pub-check-bar { margin: 8px 14px !important; padding: 5px 12px !important; border-width: 1px !important; }
  #bulk-sign-bar .btn, #pub-check-bar .btn { padding: 4px 12px !important; font-size: calc(12px*var(--fs,1)) !important; }
  #pub-check-bar > div:first-child { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
  /* 04/11/2026: la barra di firma sta dentro la fascia fissa (setupBulkSignBar): occupa una riga intera */
  #worklist-patient-view .worklist-header > #bulk-sign-bar { flex: 1 1 100%; margin: 0 !important; }
}

/* Tabs stato segmentati */
.status-tabs {
  display: inline-flex;
  background: var(--color-bg);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
  margin-bottom: var(--space-4);
}

.status-tab {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
}

.status-tab:hover {
  color: var(--color-text);
  background: var(--color-surface);
}

.status-tab.active {
  background: var(--color-primary);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.status-tab .tab-count {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  background: rgba(255, 255, 255, 0.2);
  padding: 0 6px;
  border-radius: var(--radius-full);
  line-height: 18px;
}

.status-tab.active .tab-count {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* Barra di ricerca e filtri */
.worklist-filters {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.search-bar {
  position: relative;
  flex: 1;
  min-width: 280px;
}

.search-bar input {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-4) 0 40px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  background: var(--color-surface);
  transition: all var(--transition-base);
  outline: none;
}

.search-bar input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

.search-bar input::placeholder {
  color: var(--color-text-muted);
}

.search-bar .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  pointer-events: none;
}

.search-bar .search-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

/* Toggle tipo ricerca */
.search-type-toggle {
  display: inline-flex;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.search-type-btn {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  background: var(--color-surface);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.search-type-btn.active {
  background: var(--color-primary);
  color: #ffffff;
}

.search-type-btn:not(.active):hover {
  background: var(--color-surface-hover);
}

/* Filtro data */
.date-filter {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.date-filter label {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
}

.date-filter input[type="date"] {
  height: 36px;
  padding: 0 var(--space-3);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  background: var(--color-surface);
  outline: none;
  transition: border-color var(--transition-fast);
}

.date-filter input[type="date"]:focus {
  border-color: var(--color-primary);
}

/* Tabella pazienti */
.patient-table-wrapper {
  overflow-x: auto;
}

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

.patient-table thead th {
  padding: var(--space-3) var(--space-3);
  text-align: left;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--color-border);
  background: var(--color-bg);
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
  transition: color var(--transition-fast);
  position: sticky;
  top: 0;
  z-index: 5;
}

.patient-table thead th:hover {
  color: var(--color-primary);
}

.patient-table thead th .sort-icon {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.3;
  font-size: calc(10px*var(--fs,1));
  vertical-align: middle;
}

.patient-table thead th.sorted .sort-icon {
  opacity: 1;
  color: var(--color-primary);
}

.patient-table tbody tr {
  border-bottom: 1px solid var(--color-border-light);
  transition: background var(--transition-fast);
  cursor: pointer;
}

.patient-table tbody tr:nth-child(even) {
  background: var(--color-bg);
}

/* 13/11/2026: riga sotto il mouse piu' evidente (prima #f0fdfa, quasi invisibile) */
.patient-table tbody tr:hover {
  background: rgba(20, 184, 166, 0.30);
}
.patient-table tbody tr:hover > td:first-child {
  box-shadow: inset 4px 0 0 #0d9488;
}

.patient-table tbody td {
  padding: var(--space-3) var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  white-space: nowrap;
}

.patient-table .patient-name {
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
}

.patient-table .patient-cf {
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  letter-spacing: 0.5px;
}

/* Compattazione progressiva: a schermi più stretti riduce padding e dimensione
   dei pulsanti azione così tutte le colonne e i bottoni (Anteprima, Scarica PDF,
   Annulla, Pubblica) restano visibili. Il wrapper resta overflow-x:auto come rete
   di sicurezza a qualsiasi risoluzione. Solo grafica, nessuna logica toccata. */
@media (max-width: 1600px) {
  .patient-table thead th,
  .patient-table tbody td { padding: var(--space-2) var(--space-2); }
  .patient-table .btn-action {
    padding: 3px 8px !important;
    font-size: calc(11px*var(--fs,1)) !important;
    margin-right: 3px !important;
  }
}
@media (max-width: 1366px) {
  .patient-table thead th,
  .patient-table tbody td { padding: 6px 6px; font-size: var(--font-size-xs); }
  .patient-table .btn-action { padding: 3px 6px !important; font-size: calc(10px*var(--fs,1)) !important; }
}
