/* ═══════════════════════════════════════════════════════════════
   GestioneOperai — style.css
   Verde chiaro + Bianco, sidebar fissa, responsive
   ═══════════════════════════════════════════════════════════════ */

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

/* ── Variabili ────────────────────────────────────────────────── */
:root {
  --primary:       #3a9e6f;
  --primary-dark:  #2d7d57;
  --primary-light: #e8f5ee;
  --primary-hover: #4ab87f;
  --accent:        #27ae60;

  --bg:            #f4f9f6;
  --surface:       #ffffff;
  --surface-2:     #f0f7f3;
  --border:        #d0e8db;
  --border-light:  #e8f3ec;

  --text:          #1a2e24;
  --text-muted:    #6b8f7a;
  --text-light:    #9ab8a8;

  --sidebar-w:     260px;
  --header-h:      60px;
  --radius:        8px;
  --radius-lg:     12px;
  --shadow:        0 2px 12px rgba(58,158,111,.12);
  --shadow-lg:     0 4px 24px rgba(58,158,111,.18);
  --transition:    0.2s ease;

  --danger:   #e74c3c;
  --warning:  #f39c12;
  --info:     #2980b9;
  --success:  #27ae60;
}

/* ── Reset base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Barlow', sans-serif;
  font-size: .93rem;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  overflow-x: hidden;
}

h1,h2,h3,h4,h5,h6 { font-family: 'Barlow Condensed', sans-serif; font-weight: 600; }

/* scrollbar sottile */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-light); }

/* ── Layout wrapper ───────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1000;
  transition: transform var(--transition);
  box-shadow: var(--shadow);
}

.sidebar-brand {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar-brand .brand-icon {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.2);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}

.sidebar-brand .brand-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: .03em;
  line-height: 1.2;
}

.sidebar-brand .brand-sub {
  font-size: .65rem;
  opacity: .8;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: .75rem 0;
}

.sidebar-section {
  padding: .5rem 1rem .25rem;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-light);
  margin-top: .5rem;
}

.nav-item-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .55rem 1.25rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  border-radius: 0;
  transition: all var(--transition);
  position: relative;
}

.nav-item-link i { width: 18px; text-align: center; font-size: .95rem; }

.nav-item-link:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.nav-item-link.active {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}

.nav-item-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.sidebar-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border-light);
  font-size: .8rem;
  color: var(--text-muted);
}

/* ── Main content ─────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left var(--transition);
}

/* ── Sidebar collassata (desktop) ─────────────────────────────── */
.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
}
.sidebar-collapsed .main-content {
  margin-left: 0;
}

/* ── Topbar ───────────────────────────────────────────────────── */
.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.topbar-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  color: var(--text-muted);
}

.topbar-avatar {
  width: 32px; height: 32px;
  background: var(--primary-light);
  border: 2px solid var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  color: var(--primary);
  overflow: hidden;
}

.topbar-avatar img { width: 100%; height: 100%; object-fit: cover; }

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  background: var(--primary-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--primary);
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}
.sidebar-toggle:hover {
  background: var(--primary);
  color: #fff;
}

/* ── Page content ─────────────────────────────────────────────── */
.page-content {
  padding: 1.5rem;
  flex: 1;
}

/* ── Card ─────────────────────────────────────────────────────── */
.card-dark {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-dark .card-header {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: .85rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.card-dark .card-header i { color: var(--primary); }

.card-dark .card-body { padding: 1.25rem; }

/* ── KPI stat card ────────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: box-shadow var(--transition), transform var(--transition);
}

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

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-icon.danger  { background: #fdecea; color: var(--danger); }
.stat-icon.warning { background: #fef9ec; color: var(--warning); }
.stat-icon.info    { background: #eaf3fb; color: var(--info); }

.stat-body { flex: 1; min-width: 0; }
.stat-value { font-family: 'Barlow Condensed', sans-serif; font-size: 2rem; font-weight: 700; line-height: 1; color: var(--text); }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }
.stat-delta { font-size: .75rem; margin-top: .35rem; }
.stat-delta.up   { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* ── Bottoni ──────────────────────────────────────────────────── */
.btn-primary-custom {
  background: var(--primary);
  border: none;
  color: #fff;
  border-radius: var(--radius);
  padding: .45rem 1rem;
  font-weight: 600;
  font-size: .88rem;
  transition: background var(--transition), box-shadow var(--transition);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}

.btn-primary-custom:hover, .btn-primary-custom:focus {
  background: var(--primary-dark);
  color: #fff;
  box-shadow: 0 3px 10px rgba(58,158,111,.35);
  outline: none;
}

.btn-outline-custom {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
  border-radius: var(--radius);
  padding: .4rem .95rem;
  font-weight: 600;
  font-size: .88rem;
  transition: all var(--transition);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}

.btn-outline-custom:hover {
  background: var(--primary);
  color: #fff;
}

.btn-icon {
  width: 30px; height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  font-size: .8rem;
}
.btn-icon:hover          { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-icon.edit:hover     { border-color: var(--info);    color: var(--info); }
.btn-icon.danger:hover   { border-color: var(--danger);  color: var(--danger); background: #fdecea; }
.btn-icon.success:hover  { border-color: var(--success); color: var(--success); background: #edfbf3; }

/* ── Tabella ──────────────────────────────────────────────────── */
.table-dark-custom {
  width: 100%;
  border-collapse: collapse;
  font-size: .86rem;
}

.table-dark-custom thead th {
  background: var(--surface-2);
  border-bottom: 2px solid var(--border);
  padding: .6rem .9rem;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  white-space: nowrap;
}

.table-dark-custom tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}

.table-dark-custom tbody tr:hover { background: var(--primary-light); }

.table-dark-custom tbody td {
  padding: .55rem .9rem;
  vertical-align: middle;
  color: var(--text);
}

/* ── Form ─────────────────────────────────────────────────────── */
.form-control-dark {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .88rem;
  padding: .45rem .8rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form-control-dark:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(58,158,111,.15);
  outline: none;
  background: var(--surface);
  color: var(--text);
}

.form-control-dark::placeholder { color: var(--text-light); }

.form-label-dark {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .3rem;
  display: block;
}

.form-select-dark {
  background: var(--surface) url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236b8f7a' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") no-repeat right .75rem center/14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .88rem;
  padding: .45rem 2.5rem .45rem .8rem;
  appearance: none;
  width: 100%;
  transition: border-color var(--transition);
}

.form-select-dark:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(58,158,111,.15);
  outline: none;
}

/* ── Badge status ─────────────────────────────────────────────── */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .22rem .6rem;
  border-radius: 20px;
  font-size: .73rem;
  font-weight: 600;
  letter-spacing: .02em;
}

.badge-status::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-status.success { background: #edfbf3; color: #1e8449; }
.badge-status.warning { background: #fef9ec; color: #b7770d; }
.badge-status.danger  { background: #fdecea; color: #c0392b; }
.badge-status.info    { background: #eaf3fb; color: #1a6fa3; }
.badge-status.muted   { background: var(--surface-2); color: var(--text-muted); }
.badge-status.primary { background: var(--primary-light); color: var(--primary-dark); }

/* ── Modal ────────────────────────────────────────────────────── */
.modal-dark .modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-dark .modal-header {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
}

.modal-dark .modal-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
}

.modal-dark .modal-footer {
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}

.modal-dark .btn-close { filter: none; opacity: .5; }
.modal-dark .btn-close:hover { opacity: 1; }

/* ── DataTables override ──────────────────────────────────────── */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .3rem .6rem;
  font-size: .85rem;
}

.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(58,158,111,.15);
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label { color: var(--text-muted); font-size: .82rem; }

.dataTables_wrapper .page-item.active .page-link { background: var(--primary); border-color: var(--primary); }
.dataTables_wrapper .page-link { color: var(--primary); border-color: var(--border); }
.dataTables_wrapper .page-link:hover { background: var(--primary-light); color: var(--primary-dark); }

/* ── Foto operaio ─────────────────────────────────────────────── */
.foto-op {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary-light);
}

.foto-op-lg {
  width: 100px; height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--primary);
}

.foto-placeholder {
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-family: 'Barlow Condensed', sans-serif;
}

.foto-op-xl {
  width: 130px; height: 130px;
  font-size: 2.6rem;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

@keyframes cardPulse {
  0%   { box-shadow: 0 0 0 0 rgba(45,122,79,.7); }
  60%  { box-shadow: 0 0 0 14px rgba(45,122,79,.1); }
  100% { box-shadow: 0 0 0 0 rgba(45,122,79,0); }
}
.card-op-pulse { animation: cardPulse .9s ease-out; }

/* ── QR scan overlay ──────────────────────────────────────────── */
#qrVideo {
  width: 100%;
  max-height: 260px;
  border-radius: var(--radius);
  display: block;
  background: #000;
}

#qrOverlay {
  background: rgba(0,0,0,.5);
  border-radius: var(--radius);
  cursor: pointer;
}

/* ── Turno attivo pill ────────────────────────────────────────── */
.turno-pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .75rem;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
}

.turno-pill.attivo  { background: #edfbf3; color: #1e8449; animation: pulse-green 2s infinite; }
.turno-pill.chiuso  { background: var(--surface-2); color: var(--text-muted); }

@keyframes pulse-green {
  0%,100% { box-shadow: 0 0 0 0 rgba(39,174,96,.4); }
  50%      { box-shadow: 0 0 0 6px rgba(39,174,96,0); }
}

/* ── Geo badge ────────────────────────────────────────────────── */
.geo-ok   { color: var(--success); }
.geo-warn { color: var(--danger); }

/* ── Login page ───────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e6b47 0%, #3a9e6f 50%, #6dbf94 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo i {
  font-size: 2.5rem;
  color: var(--primary);
}

.login-logo h1 {
  font-size: 1.6rem;
  margin: .5rem 0 .25rem;
  color: var(--text);
}

.login-logo p { color: var(--text-muted); font-size: .85rem; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-content { margin-left: 0 !important; }
  /* Su mobile la classe sidebar-collapsed non deve interferire */
  .sidebar-collapsed .sidebar { transform: translateX(-100%); }
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.3);
    z-index: 999;
  }
  .sidebar.open ~ .sidebar-overlay { display: block; }
}

@media (max-width: 576px) {
  .page-content { padding: 1rem; }
  .stat-value   { font-size: 1.6rem; }
}

/* ── Utility ──────────────────────────────────────────────────── */
.text-primary-custom { color: var(--primary) !important; }
.bg-primary-custom   { background: var(--primary) !important; }
.border-primary      { border-color: var(--primary) !important; }
.fw-600 { font-weight: 600; }
.fs-condensed { font-family: 'Barlow Condensed', sans-serif; }
.gap-sm { gap: .4rem; }
.cursor-pointer { cursor: pointer; }
