/* FILE SINCRONIZZATO CON VERSIONE SERVER — OPNICT Portale v2 */
/* =========================================================
   MASTER.CSS — VERSIONE STABILE (FIX OVERLAY SIDEBAR)
   Problema risolto:
   - Alcune pagine (es. worker_badge.php) NON usano .content come wrapper,
     quindi con sidebar fixed il contenuto restava sotto la sidebar.
   Soluzione:
   - In desktop, spostiamo TUTTO il contenuto dell'app con padding-left su .app.
   - La sidebar resta fixed.
   - .content NON deve più gestire margin-left.
   Nota:
   - Thead sticky già rimosso.
   ========================================================= */

/* =========================
   RESET BASE
========================= */
*,
*::before,
*::after { box-sizing: border-box; }

:root{
  --sidebar-w: 240px;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #f5f7fa;
  color: #111;
}

/* =========================
   BLOCCO HEADER PUBBLICI
========================= */
header,
.hero,
.site-header,
.public-header {
  display: none !important;
}

/* =========================
   IMMAGINI SICURE
========================= */
img {
  max-width: 100%;
  height: auto;
}

/* =========================
   STRUTTURA APP
========================= */
.app {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* =========================
   SIDEBAR
========================= */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0b1220, #020617);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  color: #ffffff;
}

.sidebar .logo {
  text-align: center;
  margin-bottom: 18px;
}

.sidebar .logo img {
  max-width: 180px;
  height: auto;
}

.sidebar .nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar .nav a,
.sidebar .nav a:visited,
.sidebar .nav a:active,
.sidebar .nav a:focus {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  color: #ffffff !important;
  background: transparent;
}

.sidebar .nav a:hover {
  background: rgba(255,255,255,0.12);
}

.sidebar .nav a.active {
  background: rgba(255,255,255,0.22);
}

.sidebar .nav .logout {
  margin-top: auto;
}

/* =========================
   CONTENUTO (wrapper standard)
========================= */
.content {
  flex: 1;
  padding: 24px;
}

/* =========================
   HEADER PAGINA (H1 STICKY)
========================= */
.content > h1:first-child {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #f5f7fa;
  padding: 6px 0;
  margin: 0 0 10px 0;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

.content h1 { margin-bottom: 10px; }
.content h2 { margin-bottom: 10px; }

/* =========================
   FIX CONTENUTI PUBBLICI EREDITATI
========================= */
.content > img:first-child,
.content > .logo:first-child,
.content > .brand:first-child {
  display: none !important;
}

.content > h2:first-child,
.content > p:first-child {
  max-height: 0;
  overflow: hidden;
  margin: 0 !important;
  padding: 0 !important;
}

/* =========================
   FORM E INPUT
========================= */
input[type="text"],
input[type="search"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="password"],
select,
textarea {
  padding: 4px 8px;
  font-size: 13px;
  line-height: 1.2;
  border-radius: 6px;
  border: 1px solid #cfd4da;
}

label {
  font-size: 12px;
}

/* =========================
   SISTEMA PULSANTI
========================= */
.btn,
a.btn,
button,
input[type="submit"],
input[type="button"],
input[type="reset"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 13px;
  line-height: 1.2;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.18);
  background: #ffffff;
  color: #0b5ed7;
  text-decoration: none !important;
  white-space: nowrap;
}

.btn:hover,
a.btn:hover,
button:hover,
input[type="submit"]:hover {
  background: rgba(14,110,253,0.10);
  border-color: rgba(14,110,253,0.35);
}

.btn-danger {
  color: #b02a37;
  border-color: rgba(176,42,55,0.35);
}

.btn-danger:hover {
  background: rgba(176,42,55,0.10);
}
/* =========================
   VARIANTI PULSANTI
========================= */
.btn-primary,
a.btn-primary,
button.btn-primary,
input.btn-primary[type="submit"],
input.btn-primary[type="button"]{
  background: #0b5ed7;
  border-color: #0b5ed7;
  color: #fff !important;
}

.btn-primary:hover,
a.btn-primary:hover,
button.btn-primary:hover,
input.btn-primary[type="submit"]:hover{
  background: #0a58ca;
  border-color: #0a58ca;
}

.btn-secondary,
a.btn-secondary,
button.btn-secondary,
input.btn-secondary[type="submit"],
input.btn-secondary[type="button"]{
  background: #ffffff;
  border-color: rgba(0,0,0,0.18);
  color: #111 !important;
}

.btn-secondary:hover,
a.btn-secondary:hover,
button.btn-secondary:hover{
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.25);
}
/* =========================
   TABELLE (NO STICKY)
========================= */
table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

th, td {
  padding: 6px 8px;
  vertical-align: middle;
}

thead th {
  background: #f1f3f5;
  font-size: 12px;
  border-bottom: 1px solid #dee2e6;
  position: static;
}

tbody tr:hover {
  background: rgba(14,110,253,0.08);
}

table td a {
  margin: 2px 6px 2px 0;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 900px) {
  :root{ --sidebar-w: 200px; }
}

/* Mobile: sidebar sopra, nessun offset laterale */
@media (max-width: 720px) {
  .app { flex-direction: column; padding-left: 0 !important; }
  .sidebar {
    position: static !important;
    width: 100% !important;
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }
  .sidebar .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .content { padding: 16px; }
}

/* =========================
   DESKTOP: SIDEBAR FIXED + APP OFFSET (FIX DEFINITIVO)
========================= */
@media (min-width: 721px) {
  /* Sidebar fissa */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow: hidden;
    z-index: 1000;
  }

  /* Sposta TUTTO il contenuto dell'app a destra della sidebar
     (funziona anche per pagine che NON usano .content) */
  .app {
    padding-left: var(--sidebar-w);
  }

  /* Scroll verticale sul contenuto dell'app */
  .app {
    height: 100vh;
    overflow-y: auto;
  }

  /* Il wrapper .content non deve più usare margin-left */
  .content {
    margin-left: 0 !important;
  }
}

/* === FINE FILE — MASTER.CSS STABILE === */

/* =========================================================
   DASHBOARD KPI CARDS (OPNICT v2)
   ========================================================= */

.kpi-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:16px;
  margin-top:16px;
}

@media (max-width: 900px){
  .kpi-grid{ grid-template-columns:1fr; }
}

.kpi-card{
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap:6px;
  padding:18px 18px;
  background:#fff;
  border:1px solid #e6e9ef;
  border-radius:16px;
  box-shadow:0 2px 10px rgba(0,0,0,.04);
  text-decoration:none;
  color:inherit;
  min-height:96px;
}

.kpi-card:hover{
  transform: translateY(-1px);
  box-shadow:0 8px 18px rgba(0,0,0,.08);
}

.kpi-value{
  font-size:42px;
  font-weight:800;
  line-height:1;
  letter-spacing:-.02em;
}

.kpi-label{
  font-size:14px;
  font-weight:600;
  color:#394150;
}

/* Varianti */
.kpi-card.dark{
  background:linear-gradient(135deg,#0b1324,#0e1b34);
  border-color:#0e1b34;
  color:#fff;
}

.kpi-card.dark .kpi-label{ color:rgba(255,255,255,.82); }

.kpi-card.warn{
  background:#fff3e8;
  border-color:#ffd8b6;
}

.kpi-card.danger{
  background:#ffecec;
  border-color:#ffb6b6;
}

/* Header pagina */
.page-header h1{
  margin:0 0 6px 0;
}

.page-header .muted{
  margin:0;
  color:#667085;
  font-weight:500;
}

/* =========================================================
   SPAZIO DINAMICO IN FONDO (solo pagine con liste lunghe)
   Usa: <section class="content content--longlist">
   ========================================================= */
.content.content--longlist{
  padding-bottom: 160px;
}
