:root {
  /* --- PALETTE AZIENDALE (Verde Scuro) --- */
  --primary: #1b4332;
  /* Verde Scuro (Navbar, Bottoni primari) */
  --primary-hover: #081c15;
  /* Verde ancora più scuro per hover */
  --accent: #40916c;
  /* Verde medio per accenti */
  --light-green: #d8f3dc;
  /* Sfondo leggero per elementi attivi */

  /* --- SUPPORT COLORS --- */
  --bg-body: #f8f9fa;
  /* Grigio chiarissimo sfondo */
  --bg-card: #ffffff;
  --text-main: #2d3436;
  --text-muted: #636e72;
  --border: #dfe6e9;

  /* --- STATUS --- */
  --danger: #d63031;
  --danger-bg: #ffe6e6;
  --warning: #fdcb6e;
  --success: #00b894;
}

/* === RESET & BASE === */
html {
  background-color: var(--primary);
}

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  text-decoration: none;
  color: inherit;
}

ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.container {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem;
  background-color: var(--bg-body);
}

h1,
h2,
h3 {
  color: var(--primary);
  margin-top: 0;
}

/* === NAVBAR === */
.navbar {
    display: flex;
    justify-content: space-between; /* Logo a Sx, User a Dx */
    align-items: center;
    padding: 0 15px;
    height: 60px;
    background-color: var(--primary); /* O il tuo colore header */
    color: white;
}

.navbar__brand {
    color: white;
    text-decoration: none;
    font-weight: bold;
    font-size: 1.1rem;
    white-space: nowrap; /* Evita che il logo vada a capo */
}

/* Contenitore destra (User + Btn) */
.user-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar__user {
    text-align: right;
    line-height: 1.2;
}

.navbar__user-name {
    color: white;
    text-decoration: none;
    font-weight: 600;
    display: block;
}

.navbar__user-role {
    font-size: 0.75rem;
    opacity: 0.8;
    display: block;
}

.btn-logout {
    border: 1px solid rgba(255,255,255,0.5);
    color: white;
    padding: 5px 10px;
    font-size: 0.85rem;
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  background-color: var(--primary);
  color: white;
  font-size: 0.95rem;
}

.btn:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: #636e72;
}

.btn-secondary:hover {
  background-color: #2d3436;
}

.btn-outline {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: white;
}

.btn-outline:hover {
  border-color: white;
  background: rgba(255, 255, 255, 0.1);
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}

.btn-new {
  margin-bottom: 20px;
}


/* === CARDS === */
.cards {
  display: grid;
  /* Default per mobile: 1 colonna che prende tutto lo spazio */
  grid-template-columns: 1fr; 
  gap: 1.5rem;
  margin-top: 1.5rem;
}

/* Quando lo schermo è più largo di 600px (tablet/desktop) */
@media (min-width: 600px) {
  .cards {
    /* Passa a 2 colonne */
    grid-template-columns: repeat(2, 1fr);
  }
}

.card {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--border);
  transition: transform 0.2s;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* === FORMS (Login, Edit, New) === */
.auth__form {
  max-width: 400px;
  margin: 0 auto;
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

section form:not(.auth__form) {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.form-group {
  margin-bottom: 1.2rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 1rem;
  font-family: inherit;
  box-sizing: border-box;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(64, 145, 108, 0.1);
}

/* Flex row per i form date */
.form-row-flex {
  display: flex;
  gap: 15px;
}

.form-col {
  flex: 1;
}

/* === TABLES === */
.table-container {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  margin-top: 10px;
}

#searchInput {
  width: 100%;
  padding: 12px;
  border: none;
  border-bottom: 1px solid var(--border);
  font-size: 1rem;
  outline: none;
}

/* === TABELLA GENERALE === */
table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--bg-card);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

th,
td {
  padding: 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

/* === HEADER TABELLA === */
th {
  background-color: var(--primary);
  color: white;
  font-weight: 600;
  position: relative;
  /* Necessario per posizionare la freccia */
  cursor: pointer;
  user-select: none;
  /* Evita che si selezioni il testo cliccando */
}

/* Stile Base per la freccia (Neutra/Default) */
th::after {
  content: ' \2195';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1em;
  font-weight: 900;
  opacity: 0.4;
  cursor: pointer;
}

/* Freccia Ascendente (Attiva) */
th.asc::after {
  content: ' \25B2';
  opacity: 1;
  color: #fff;
  font-size: 0.9em;
}

/* Freccia Discendente (Attiva) */
th.desc::after {
  content: ' \25BC';
  opacity: 1;
  color: #fff;
  font-size: 0.9em;
}

th:last-child::after {
  content: none !important;
}

th:last-child {
  cursor: default;
}

td.actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  /* Spazio tra la matita e il cestino */
  border-bottom: 1px solid var(--border);
  height: 100%;
}

td.actions form {
  margin: 0;
  display: inline-flex;
}

/* === MODALI (Settings Page) === */
.modal-overlay {
  display: none;
  /* Nascosto di default, JS lo mette a 'flex' */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  /* Sfondo scuro semitrasparente */
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
  /* Effetto sfocato moderno */
}

.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  position: relative;
  border-top: 5px solid var(--primary);
  /* Bordo verde in alto */
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.modal-header h3 {
  margin: 0;
  color: var(--primary);
  font-size: 1.25rem;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.2s;
}

.close-btn:hover {
  color: var(--danger);
}

.modal-footer {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Badge specifici per i costi */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: lowercase;
}

.badge-hour {
  background: #e0f2fe;
  color: #0369a1;
}

.badge-day {
  background: #fef3c7;
  color: #b45309;
}

.badge-fixed {
  background: #f3f4f6;
  color: #4b5563;
}

/* Status Badges */
.status {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: bold;
  text-transform: uppercase;
}

.status.active {
  background-color: #d1e7dd;
  color: #0f5132;
}

.status.draft {
  background-color: #e2e3e5;
  color: #41464b;
}

.status.suspended {
  background-color: #fff3cd;
  color: #856404;
}

.status.completed {
  background-color: #cff4fc;
  color: #055160;
}

.status.deleted {
  background-color: #f8d7da;
  color: #721c24;
}

/* === WORKER MANAGER (Area Assegnazione) === */
.workers-manager {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 1.5rem;
  background-color: #fff;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
}

/* La barra grigia/verde in alto */
.add-worker-bar {
  background-color: #f8f9fa;
  /* Grigio chiarissimo */
  padding: 20px 25px;
  /* Più spazio interno */
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 20px;
}

.add-worker-bar label {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  /* Evita che il testo vada a capo */
  font-size: 1.05rem;
}

/* Il contenitore che avvolge Select + Bottone */
.controls-wrapper {
  display: flex;
  gap: 10px;
  flex: 1;
  /* FONDAMENTALE: Occupa tutto lo spazio rimanente */
  align-items: center;
  /* Centra verticalmente il bottone rispetto alla input */
}

/* --- TOM SELECT CUSTOMIZATION (Per renderla "cicciotta") --- */

/* Wrapper esterno di TomSelect */
.ts-wrapper {
  width: 100%;
  /* Forza la larghezza piena */
}

/* L'input vero e proprio (stile a riposo) */
.ts-control {
  min-height: 48px !important;
  /* Più ALTA */
  border-radius: 6px !important;
  border: 1px solid #ced4da;
  display: flex !important;
  align-items: center;
  /* Testo centrato verticalmente */
  font-size: 1rem;
  padding-left: 15px !important;
  background-color: white;
}

/* Quando clicchi sulla select (Focus) */
.ts-wrapper.focus .ts-control {
  border-color: var(--primary) !important;
  /* Diventa verde */
  box-shadow: 0 0 0 3px rgba(27, 67, 50, 0.1) !important;
  /* Alone verde */
}

/* Il menu a tendina che si apre */
.ts-dropdown {
  border-radius: 6px;
  margin-top: 5px;
  border-color: var(--primary);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.ts-dropdown .option {
  padding: 10px 15px;
  /* Opzioni più spaziose */
  font-size: 1rem;
}

/* Opzione attiva (hover) */
.ts-dropdown .active {
  background-color: var(--light-green);
  color: var(--primary);
}

/* --- BOTTONE PIÙ --- */
#btnAddWorker {
  height: 48px;
  /* Stessa altezza della select */
  width: 50px;
  font-size: 1.5rem;
  /* Più grande */
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  flex-shrink: 0;
  /* Evita che si schiacci */
  line-height: 1;
  background-color: var(--primary);
  border: 1px solid var(--primary);
}

#btnAddWorker:hover {
  background-color: var(--primary-hover);
}

/* --- LISTA E HEADER --- */
.worker-header {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 60px;
  /* Colonne definite */
  background: #fff;
  padding: 12px 25px;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.worker-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 60px;
  /* Deve combaciare con header */
  padding: 15px 25px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  gap: 15px;
  background: white;
  transition: background 0.2s;
}

.worker-row:hover {
  background-color: #fafafa;
}

/* Input date nella riga */
.worker-row input[type="date"] {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  color: var(--text-main);
}

.btn-remove {
  background-color: var(--danger);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-remove:hover {
  background-color: #b71c1c;
}

/* === DIPENDENTE DASHBOARD === */
.date-selector {
  background: white;
  padding: 15px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  margin-bottom: 20px;
}

.date-input {
  border: 1px solid #ccc;
  padding: 8px;
  border-radius: 4px;
}

.cantiere-card h2 {
  color: var(--primary);
  font-size: 1.4rem;
  margin-bottom: 0.5rem;
}

.cantiere-info {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.shift-box {
  background: var(--light-green);
  padding: 12px;
  border-radius: 6px;
  color: var(--primary);
  font-weight: 500;
  border-left: 4px solid var(--accent);
}

/* === UTILS === */
.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px;
  border-radius: 4px;
  border: 1px solid var(--danger);
  margin-bottom: 15px;
}

.text-center {
  text-align: center;
}

.mt-2 {
  margin-top: 1rem;
}

.d-flex {
  display: flex;
  gap: 10px;
}

/* Mobile */

@media (max-width: 768px) {

  .worker-header {
    display: none;
  }

  .worker-row {
    grid-template-columns: 1fr;
    gap: 5px;
    border-bottom: 4px solid #f0f0f0;
    padding: 15px;
  }

  .form-row-flex {
    flex-direction: column;
    gap: 0;
  }

  .brand-suffix {
    display: none;
  }

  .navbar__center {
        display: none;
    }

    /* 3. Nascondiamo il ruolo (Admin/Dipendente) per salvare spazio */
    .navbar__user-role {
        display: none;
    }

    /* 4. Riduciamo leggermente il nome */
    .navbar__user-name {
        font-size: 0.9rem;
    }

    /* 5. Avviciniamo nome e bottone */
    .user-controls {
        gap: 8px;
    }
}

/* --- DASHBOARD EMPLOYEE INIZIO/FINE TURNO --- */
.breakout-bar {
    width: 100vw; /* Larghezza viewport totale */
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw; /* Tira a sinistra */
    margin-right: -50vw; /* Tira a destra */
    border-radius: 0; /* Niente bordi tondi, è una barra */
    margin-bottom: 30px;
    margin-top: -32px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.banner-inner {
    max-width: 1200px; /* O la larghezza del tuo container principale */
    margin: 0 auto;
    padding: 15px 24px; /* Spazio interno */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 1. Modalità INATTIVA  */
.shift-banner.mode-ready {
    background-color: #9aebee;
    border-bottom: 1px solid #e5e7eb;
    color: #1f2937;
}

/* 2. Modalità ATTIVA  */
.shift-banner.mode-working {
    background-color: #2ccc81; 
    border-bottom: 1px solid #a7f3d0;
    color: #064e3b;
}

/* Modalità COMPLETATO */
.shift-banner.mode-completed {
    background: linear-gradient(135deg, #344f6b, #4ca1af);
    color: white;
}

/* Indicatore Completato */
.status-indicator.completed {
    background: rgba(255,255,255,0.2);
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
}

/* Bottone Vedi Riepilogo */
.action-btn.btn-summary {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.4);
    text-decoration: none;
    display: inline-block;
    padding: 10px 20px;
    border-radius: 30px;
    transition: background 0.2s;
}

.action-btn.btn-summary:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Testi */
.text-group h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.text-group p {
    margin: 2px 0 0 0;
    font-size: 0.85rem;
    opacity: 0.8;
}

.banner-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Indicatori (Pallini colorati) */
.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    position: relative;
}

.status-indicator.offline {
    background-color: #9ca3af; /* Grigio */
    border: 2px solid #e5e7eb;
}

.status-indicator.online {
    background-color: #00a72a; /* Verde */
}

/* Animazione Ping per l'online */
.ping {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: #00a72a;
    opacity: 0.7;
    animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
    75%, 100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Bottoni */
.action-btn {
    padding: 8px 20px;
    border-radius: 6px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

/* Bottone Start (Nero o Blu Scuro per contrasto su bianco) */
.btn-start {
    background-color: #111827;
    color: white;
}
.btn-start:hover {
    background-color: #374151;
    transform: translateY(-1px);
}

/* Bottone Stop (Rosso/Rosa su fondo verde) */
.btn-stop {
    background-color: #ffffff;
    color: #dc2626;
    border: 1px solid #fecaca;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.btn-stop:hover {
    background-color: #fef2f2;
    border-color: #dc2626;
}
/* === MODERN UPLOAD AREA (Versione Elegante & Compatta) === */
.file-upload-wrapper {
    margin-bottom: 20px;
    width: 100%; /* Si assicura che stia nel contenitore */
}

.file-drop-area {
    position: relative;
    display: flex;
    /* Cambiamo in ROW per affiancare bottone e testo (riduce l'altezza) */
    flex-direction: row; 
    align-items: center;
    justify-content: center;
    gap: 15px; /* Spazio tra bottone e scritta */
    
    width: 100%;
    /* FONDAMENTALE: Include il padding nel calcolo del 100% */
    box-sizing: border-box; 
    
    padding: 15px 20px; /* Meno padding verticale per farlo più "slim" */
    border: 2px dashed #cbd5e0; /* Grigio leggermente più moderno */
    border-radius: 8px;
    background-color: #f8f9fa;
    transition: all 0.2s ease;
    cursor: pointer;
}

/* Effetto Hover */
.file-drop-area:hover, .file-drop-area.is-dragover {
    background-color: #e8f5e9;
    border-color: var(--primary);
    transform: translateY(-1px); /* Piccolo effetto sollevamento */
}

/* Bottone finto */
.fake-btn {
    background-color: var(--primary);
    color: white;
    padding: 6px 14px; /* Un po' più piccolo */
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    /* Rimuoviamo il margin-bottom perché ora siamo in orizzontale */
    margin-bottom: 0; 
    white-space: nowrap; /* Evita che il testo vada a capo */
}

.file-msg {
    font-size: 0.9rem;
    color: #666;
    user-select: none;
}

/* Input invisibile */
.file-input {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 100%;
    opacity: 0;
    cursor: pointer;
}

/* === ANTEPRIME (Più piccole e ordinate) === */
.preview-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.preview-item {
    width: 60px;  /* Anteprime più piccole */
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #ddd;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
