/*
 * Live Dashboard - Presenze Giornaliere
 * Design: dark glassmorphism con accenti colorati
 */

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

:root {
  --ldb-bg:       #0f1117;
  --ldb-surface:  #1a1d27;
  --ldb-surface2: #22263a;
  --ldb-border:   rgba(255,255,255,0.07);
  --ldb-text:     #e2e8f0;
  --ldb-muted:    #64748b;
  --ldb-present:  #22c55e;
  --ldb-late:     #f97316;
  --ldb-break:    #3b82f6;
  --ldb-left:     #94a3b8;
  --ldb-absent:   #ef4444;
  --ldb-accent:   #6366f1;
  --ldb-radius:   16px;
}

/* ── Wrapper principale ── */
.tp-live-dashboard,
.tp-live-dashboard *,
.tp-live-dashboard *::before,
.tp-live-dashboard *::after {
  box-sizing: border-box;
}

.tp-live-dashboard {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--ldb-bg);
  color: var(--ldb-text);
  padding: 28px;
  border-radius: 24px;
  min-height: 300px;
}

/* ── Header ── */
.tp-live-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}
.tp-live-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.tp-live-title span { color: var(--ldb-accent); }
.tp-live-updated {
  font-size: 12px;
  color: var(--ldb-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tp-live-dot {
  width: 8px; height: 8px;
  background: var(--ldb-present);
  border-radius: 50%;
  animation: tp-pulse 2s infinite;
}
@keyframes tp-pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(0.8); }
}

/* ── KPI Cards ── */
.tp-live-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.tp-kpi {
  background: var(--ldb-surface);
  border: 1px solid var(--ldb-border);
  border-radius: var(--ldb-radius);
  padding: 18px 16px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s;
}
.tp-kpi:hover { transform: translateY(-2px); }
.tp-kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--kpi-color, var(--ldb-accent));
  border-radius: 3px 3px 0 0;
}
.tp-kpi-value {
  font-size: 36px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 6px;
  color: var(--kpi-color, white);
}
.tp-kpi-label {
  font-size: 12px;
  color: var(--ldb-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tp-kpi-icon {
  position: absolute;
  top: 16px; right: 14px;
  font-size: 22px;
  opacity: 0.25;
}
.tp-kpi--present  { --kpi-color: var(--ldb-present); }
.tp-kpi--late     { --kpi-color: var(--ldb-late); }
.tp-kpi--break    { --kpi-color: var(--ldb-break); }
.tp-kpi--left     { --kpi-color: var(--ldb-left); }
.tp-kpi--absent   { --kpi-color: var(--ldb-absent); }

/* ── Sezione grafico ── */
.tp-live-section {
  background: var(--ldb-surface);
  border: 1px solid var(--ldb-border);
  border-radius: var(--ldb-radius);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.tp-live-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ldb-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 20px;
}

/* ── Timeline Bar Chart ── */
.tp-timeline-wrap {
  overflow-x: auto;
}
.tp-timeline-axis {
  display: flex;
  align-items: flex-end;
  margin-bottom: 8px;
  min-width: 480px;
}
.tp-timeline-axis-name {
  width: 150px;
  min-width: 150px;
  padding-right: 12px;
  flex-shrink: 0;
}
.tp-timeline-axis-track {
  flex: 1;
  position: relative;
  height: 18px;
}
.tp-timeline-axis-badge {
  margin-left: 10px;
  width: 82px;
  min-width: 82px;
  flex-shrink: 0;
}
.tp-timeline-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--ldb-muted);
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  line-height: 1;
}
.tp-timeline-tick::before {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  width: 1px;
  height: 4px;
  background: var(--ldb-border);
}

.tp-timeline-rows {}
.tp-timeline-row {
  display: flex;
  align-items: center;
  height: 36px;
  margin-bottom: 6px;
  min-width: 480px;
}
.tp-timeline-name {
  width: 150px;
  min-width: 150px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ldb-text);
  padding-right: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}
.tp-timeline-bar-track {
  flex: 1;
  background: var(--ldb-surface2);
  border-radius: 6px;
  height: 24px;
  position: relative;
  overflow: hidden;
}
.tp-timeline-segment {
  position: absolute;
  top: 0; height: 100%;
  border-radius: 4px;
  min-width: 3px;
  transition: opacity 0.2s;
}
.tp-timeline-segment:hover { opacity: 0.8; }
.tp-timeline-segment--work  { background: linear-gradient(90deg, #22c55e, #16a34a); }
.tp-timeline-segment--break { background: linear-gradient(90deg, #3b82f6, #2563eb); }
.tp-timeline-segment--late  { background: linear-gradient(90deg, #f97316, #ea580c); }

.tp-timeline-badge {
  margin-left: 10px;
  width: 82px;
  min-width: 82px;
  text-align: center;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  white-space: nowrap;
}
.tp-timeline-badge--present  { background: rgba(34,197,94,.2);  color: var(--ldb-present); }
.tp-timeline-badge--late     { background: rgba(249,115,22,.2); color: var(--ldb-late); }
.tp-timeline-badge--break    { background: rgba(59,130,246,.2); color: var(--ldb-break); }
.tp-timeline-badge--left     { background: rgba(148,163,184,.2);color: var(--ldb-left); }
.tp-timeline-badge--absent   { background: rgba(239,68,68,.2);  color: var(--ldb-absent); }

/* ── Tabella dettaglio ── */
.tp-live-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tp-live-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: 13px;
}
.tp-live-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--ldb-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 12px 12px;
  border-bottom: 1px solid var(--ldb-border);
  white-space: nowrap;
}
.tp-live-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--ldb-border);
  vertical-align: middle;
}
.tp-live-table tr:last-child td { border-bottom: none; }
.tp-live-table tr:hover td { background: rgba(255,255,255,0.02); }

.tp-emp-name { font-weight: 600; color: #1A1D27 !important;}
.tp-emp-dept { font-size: 11px; color: var(--ldb-muted); margin-top: 1px; }

.tp-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.tp-status-pill::before { content:''; width:6px;height:6px;border-radius:50%;background:currentColor; }

.tp-status-pill--PRESENTE       { background: rgba(34,197,94,.15);  color: var(--ldb-present); }
.tp-status-pill--IN_RITARDO     { background: rgba(249,115,22,.15); color: var(--ldb-late); }
.tp-status-pill--IN_PAUSA       { background: rgba(59,130,246,.15); color: var(--ldb-break); }
.tp-status-pill--USCITO         { background: rgba(148,163,184,.15);color: var(--ldb-left); }
.tp-status-pill--ASSENTE        { background: rgba(239,68,68,.15);  color: var(--ldb-absent); }
.tp-status-pill--ASSENZA_AUTORIZZATA { background: rgba(99,102,241,.15); color: var(--ldb-accent); }

.tp-time-chip {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 3px 8px;
  background: var(--ldb-surface2);
  border-radius: 6px;
  color: var(--ldb-text);
  white-space: nowrap;
}
.tp-time-chip--none { color: var(--ldb-muted); font-weight: 400; opacity: 0.6; }
.tp-time-chip--in   { color: #16a34a; background: rgba(34, 197, 94, 0.12); }
.tp-time-chip--break { color: #2563eb; background: rgba(59, 130, 246, 0.12); }
.tp-time-chip--break-end { color: #3b82f6; background: rgba(59, 130, 246, 0.08); }
.tp-time-chip--ongoing { color: #ea580c; background: rgba(249, 115, 22, 0.12); font-size: 11px; }
.tp-time-chip--out  { color: #64748b; background: rgba(148, 163, 184, 0.15); }

.tp-hours-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tp-hours-bar-bg {
  flex: 1;
  height: 6px;
  background: var(--ldb-surface2);
  border-radius: 3px;
  overflow: hidden;
  min-width: 60px;
}
.tp-hours-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--ldb-accent), var(--ldb-present));
  transition: width 0.5s ease;
}
.tp-hours-text { font-size: 12px; color: var(--ldb-muted); white-space: nowrap; }

/* ── Vuoto ── */
.tp-live-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--ldb-muted);
  font-size: 14px;
}
.tp-live-empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ── Skeleton loading ── */
.tp-skeleton {
  background: linear-gradient(90deg, var(--ldb-surface2) 25%, rgba(255,255,255,0.05) 50%, var(--ldb-surface2) 75%);
  background-size: 400% 100%;
  animation: tp-shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes tp-shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ── Legenda ── */
.tp-live-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.tp-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--ldb-muted);
}
.tp-legend-dot {
  width: 10px; height: 10px;
  border-radius: 2px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .tp-live-dashboard { padding: 16px; }
  .tp-live-kpis { grid-template-columns: repeat(3, 1fr); }
  .tp-timeline-name,
  .tp-timeline-axis-name { width: 100px; min-width: 100px; font-size: 11px; }
  .tp-live-table td:nth-child(3),
  .tp-live-table th:nth-child(3) { display: none; }
}
@media (max-width: 480px) {
  .tp-live-kpis { grid-template-columns: repeat(2, 1fr); }
  .tp-kpi-value { font-size: 28px; }
}
