/* ============================================
   style.css — Portale Buste Paga
   ============================================ */

:root {
  --purple:      #534AB7;
  --purple-dark: #3C3489;
  --purple-light:#EEEDFE;
  --teal:        #1D9E75;
  --teal-light:  #E1F5EE;
  --red:         #A32D2D;
  --amber:       #BA7517;
  --amber-light: #FAEEDA;
  --gray-50:     #F9F9F8;
  --gray-100:    #F1EFE8;
  --gray-200:    #D3D1C7;
  --gray-400:    #888780;
  --gray-600:    #5F5E5A;
  --gray-900:    #2C2C2A;
  --text:        #2C2C2A;
  --text-muted:  #5F5E5A;
  --border:      rgba(44,44,42,0.12);
  --radius:      8px;
  --radius-lg:   12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--gray-100);
  min-height: 100vh;
}

/* ---- NAVBAR ---- */
.navbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 32px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-brand { font-size: 15px; font-weight: 500; white-space: nowrap; }
.brand-dot { color: var(--purple); }
.navbar-links { display: flex; gap: 4px; flex: 1; }
.navbar-links a {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: background .15s, color .15s;
}
.navbar-links a:hover,
.navbar-links a.active { background: var(--gray-100); color: var(--text); }
.navbar-user { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--purple-light);
  color: var(--purple);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 500;
}
.user-name { font-size: 13px; color: var(--text-muted); }
.btn-logout {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background .15s;
}
.btn-logout:hover { background: var(--gray-100); }

/* ---- LAYOUT ---- */
.container { max-width: 1100px; margin: 0 auto; padding: 28px 24px; }
.page-title { font-size: 20px; font-weight: 500; margin-bottom: 20px; }

/* ---- CARD ---- */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 14px; font-weight: 500; }

/* ---- STAT GRID ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.stat-value { font-size: 26px; font-weight: 500; }
.stat-sub   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---- TABELLA ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 400;
  font-size: 12px;
}
td { padding: 10px 10px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gray-50); }

/* ---- BADGE ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 20px;
}
.badge-new     { background: var(--teal-light);   color: var(--teal); }
.badge-read    { background: var(--gray-100);      color: var(--gray-600); }
.badge-warn    { background: var(--amber-light);   color: var(--amber); }
.badge-admin   { background: var(--purple-light);  color: var(--purple); }

/* ---- BOTTONI ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--gray-100); }
.btn-primary { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn-primary:hover { background: var(--purple-dark); border-color: var(--purple-dark); }
.btn-sm { font-size: 12px; padding: 5px 10px; }
.btn-danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: #FFF5F5; }

/* ---- FORM ---- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 5px; }
.form-group input,
.form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  background: #fff;
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-light);
}
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---- ALERT ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-success { background: var(--teal-light); color: var(--teal); }
.alert-error   { background: #FCEBEB; color: var(--red); }
.alert-info    { background: var(--purple-light); color: var(--purple); }
.alert-warn    { background: var(--amber-light); color: var(--amber); }

/* ---- LOGIN PAGE ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
  padding: 24px;
}
.login-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  width: 100%;
  max-width: 400px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .brand { font-size: 20px; font-weight: 500; }
.login-logo p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.login-footer { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-muted); }
.login-footer a { color: var(--purple); text-decoration: none; }
.login-footer a:hover { text-decoration: underline; }

/* ---- PDF LIST (area dipendente) ---- */
.pdf-list { display: flex; flex-direction: column; gap: 10px; }
.pdf-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background .15s;
}
.pdf-item:hover { background: #fff; }
.pdf-icon {
  width: 34px; height: 42px;
  background: var(--red);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}
.pdf-info { flex: 1; }
.pdf-name { font-size: 14px; font-weight: 500; }
.pdf-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.pdf-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ---- UPLOAD AREA ---- */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.upload-zone:hover { background: var(--gray-100); border-color: var(--gray-200); }
.upload-zone p { font-size: 13px; color: var(--text-muted); margin-top: 8px; }
.upload-zone strong { font-size: 15px; }

/* ---- PROGRESS ---- */
.progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 6px;
  overflow: hidden;
  margin-top: 10px;
}
.progress-fill {
  height: 100%;
  background: var(--purple);
  border-radius: 6px;
  transition: width .3s ease;
}

/* ---- LOG ---- */
.log-list { display: flex; flex-direction: column; }
.log-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.log-item:last-child { border-bottom: none; }
.log-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.log-text { font-size: 13px; }
.log-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---- DOT STATUS ---- */
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.dot-green  { background: var(--teal); }
.dot-amber  { background: #EF9F27; }
.dot-gray   { background: var(--gray-400); }

/* ---- RESPONSIVE ---- */
@media (max-width: 640px) {
  .navbar-links { display: none; }
  .form-row     { grid-template-columns: 1fr; }
  .stat-grid    { grid-template-columns: 1fr 1fr; }
  .pdf-actions  { flex-direction: column; }
  .container    { padding: 16px; }
}

/* ============================================
   RESPONSIVE — Mobile first (smartphone/tablet)
   ============================================ */

/* Viewport meta già in layout.php */

/* Navbar mobile */
@media (max-width: 768px) {
  .navbar { padding: 0 16px; gap: 12px; }
  .navbar-links { display: none; } /* sostituito dal menu hamburger */
  .user-name { display: none; }

  /* Menu mobile a tendina */
  .nav-mobile-toggle {
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    padding: 6px;
  }
  .nav-mobile-toggle span {
    width: 22px; height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: all .2s;
  }
  .nav-mobile-menu {
    position: fixed;
    top: 56px; left: 0; right: 0;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
    z-index: 99;
    display: none;
    flex-direction: column;
  }
  .nav-mobile-menu.open { display: flex; }
  .nav-mobile-menu a {
    font-size: 14px;
    padding: 12px 20px;
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
  }
  .nav-mobile-menu a:last-child { border-bottom: none; }

  /* Layout */
  .container { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .form-row  { grid-template-columns: 1fr; }

  /* Tabella scrollabile su mobile */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 500px; }

  /* PDF item verticale su mobile */
  .pdf-item { flex-direction: column; align-items: flex-start; gap: 10px; }
  .pdf-actions { display: flex; gap: 8px; width: 100%; }
  .pdf-actions .btn { flex: 1; justify-content: center; }

  /* Card padding ridotto */
  .card { padding: 14px 16px; }
  .login-card { padding: 24px 20px; }

  /* Upload zone touch-friendly */
  .upload-zone { padding: 28px 16px; }
  .upload-zone strong { font-size: 14px; }

  /* Bottoni full width su mobile */
  .btn-mobile-full { width: 100%; justify-content: center; }

  /* Stat grid 2 colonne */
  .stat-val { font-size: 20px; }

  /* Nascondi colonne meno importanti nelle tabelle */
  .hide-mobile { display: none; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .page-title { font-size: 17px; }
  .pdf-name   { font-size: 13px; }
  .badge      { font-size: 10px; padding: 2px 6px; }
}

/* Touch target minimo 44px per bottoni */
.btn { min-height: 40px; }
@media (max-width: 768px) {
  .btn { min-height: 44px; font-size: 14px; padding: 10px 16px; }
  .btn-sm { min-height: 36px; font-size: 13px; }
}

/* CUD badge speciale */
.badge-cud {
  background: #E6F1FB;
  color: #185FA5;
}

/* Separatore sezioni documento */
.doc-section-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 10px 0 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ── HAMBURGER MENU MOBILE ── */
.hamburger{
  display:none;
  flex-direction:column;justify-content:center;
  gap:5px;width:36px;height:36px;padding:6px;
  cursor:pointer;border:none;background:transparent;
  border-radius:var(--radius);flex-shrink:0;
}
.hamburger:hover{background:var(--gray-100)}
.hamburger span{
  display:block;width:20px;height:2px;
  background:var(--text);border-radius:2px;transition:all .2s;
}

/* Menu mobile a tendina */
.mob-nav{
  display:none;
  position:fixed;top:56px;left:0;right:0;
  background:#fff;border-bottom:1px solid var(--border);
  z-index:99;padding:8px 0;
  box-shadow:0 4px 12px rgba(26,26,46,.08);
}
.mob-nav.open{display:block}
.mob-nav a{
  display:block;padding:14px 22px;
  font-size:14px;color:var(--text);
  text-decoration:none;border-bottom:1px solid var(--border);
  transition:background .12s;
}
.mob-nav a:last-child{border-bottom:none}
.mob-nav a:hover{background:var(--gray-100)}
.mob-nav a.active{color:var(--purple);font-weight:500;background:var(--purple-light)}

@media(max-width:768px){
  .navbar-links{display:none}
  .hamburger{display:flex}
  .user-name{display:none}
}

/* ============================================
   RESPONSIVE EXTRA — Area dipendente mobile
   ============================================ */
@media (max-width: 768px) {

  /* Login card full width */
  .login-wrap { padding: 16px; }
  .login-card { width: 100%; max-width: 100%; box-sizing: border-box; }

  /* Container più stretto */
  .container { padding: 12px; }

  /* Stat grid 2 colonne su mobile */
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px 12px; }
  .stat-value { font-size: 22px; }

  /* Card padding ridotto */
  .card { border-radius: 10px; }
  .card-header { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }

  /* PDF lista mobile */
  .pdf-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
  }
  .pdf-actions {
    display: flex;
    gap: 8px;
    width: 100%;
  }
  .pdf-actions .btn {
    flex: 1;
    justify-content: center;
    text-align: center;
  }

  /* Comunicazioni mobile */
  .comunicazione-item { padding: 12px 14px; }

  /* Profilo mobile */
  .profilo-form .form-row { grid-template-columns: 1fr; }

  /* Tabelle scrollabili */
  .table-wrap { overflow-x: auto; }
  table { min-width: 480px; font-size: 13px; }
  th, td { padding: 10px 12px; }

  /* Bottoni mobile */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }

  /* Hero banner dashboard */
  .hero-banner { padding: 20px 16px; }
  .hero-banner h1 { font-size: 18px; }
  .hero-banner p { font-size: 12px; }
  .hero-pills { display: none; }

  /* Grid azioni rapide */
  .azioni-rapide { gap: 8px; }

  /* Non visto grid — 1 colonna su mobile piccolo */
  .non-visto-grid { grid-template-columns: 1fr !important; }

  /* Form upload */
  .upload-zone { padding: 20px 12px; }

  /* Page title */
  .page-title { font-size: 18px; }

  /* Flex wrap su mobile */
  .flex-mobile-wrap { flex-wrap: wrap; }

  /* Nasconde colonne secondarie nelle tabelle */
  .hide-mobile { display: none !important; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-value { font-size: 20px; }
  .page-title { font-size: 16px; }
  .container { padding: 10px; }
  .card-header { padding: 10px 14px; }
}

/* Profilo grid — 1 colonna su mobile */
@media (max-width: 768px) {
  .profilo-grid {
    grid-template-columns: 1fr !important;
  }
}
