/*
 * PSB Gestionale — Theme v2 (SafetyPSB style)
 * Sidebar navy + KPI cards + clean tables
 * Deploy: sostituisce psb-theme.css in tutte le directory
 */

:root {
  --navy: #1a2332;
  --navy-light: #243447;
  --navy-dark: #0f1923;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #dbeafe;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --white: #ffffff;
  --sidebar-w: 240px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --transition: 0.2s ease;
}

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

body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--gray-900);
  background: var(--gray-100);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* === SIDEBAR === */
.psb-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--navy);
  color: var(--white);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--navy-light) transparent;
}

.psb-sidebar::-webkit-scrollbar { width: 4px; }
.psb-sidebar::-webkit-scrollbar-thumb { background: var(--navy-light); border-radius: 2px; }

.psb-sidebar-header {
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--navy-light);
  flex-shrink: 0;
}

.psb-sidebar-header h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--white);
}

.psb-sidebar-header small {
  color: var(--gray-400);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.psb-sidebar-nav {
  list-style: none;
  padding: 8px 0;
  flex: 1;
}

.psb-sidebar-nav .nav-section {
  padding: 16px 20px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--gray-500);
  font-weight: 600;
}

.psb-sidebar-nav .nav-section:first-child { padding-top: 8px; }

.psb-sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--gray-300);
  font-size: 13px;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}

.psb-sidebar-nav li a:hover {
  background: var(--navy-light);
  color: var(--white);
}

.psb-sidebar-nav li a.active {
  background: var(--primary);
  color: var(--white);
  border-left-color: var(--white);
  font-weight: 500;
}

.psb-sidebar-nav li a .nav-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.psb-sidebar-nav li a .nav-badge {
  margin-left: auto;
  background: rgba(255,255,255,0.15);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}

.psb-sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--navy-light);
  flex-shrink: 0;
}

.psb-sidebar-footer .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--gray-300);
  font-size: 12px;
}

.psb-sidebar-footer .user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: var(--white);
}

.psb-sidebar-footer .btn-logout {
  display: block;
  margin-top: 8px;
  padding: 6px 0;
  text-align: center;
  color: var(--gray-400);
  font-size: 12px;
  border: 1px solid var(--gray-600);
  border-radius: 4px;
  transition: all var(--transition);
  cursor: pointer;
  background: none;
  width: 100%;
}

.psb-sidebar-footer .btn-logout:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--white);
}

/* === MAIN CONTENT === */
.psb-main {
  margin-left: var(--sidebar-w);
  padding: 24px 32px;
  min-height: 100vh;
}

/* === PAGE HEADER === */
.psb-page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.psb-page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
}

.psb-page-header .page-date {
  color: var(--gray-500);
  font-size: 13px;
}

/* === KPI CARDS === */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  color: inherit;
}

.kpi-card.kpi-danger  { border-left-color: var(--danger); }
.kpi-card.kpi-warning { border-left-color: var(--warning); }
.kpi-card.kpi-success { border-left-color: var(--success); }

.kpi-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}

.kpi-card.kpi-danger  .kpi-value { color: var(--danger); }
.kpi-card.kpi-warning .kpi-value { color: var(--warning); }
.kpi-card.kpi-success .kpi-value { color: var(--success); }

.kpi-label {
  color: var(--gray-500);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 4px;
}

.kpi-sub {
  color: var(--gray-400);
  font-size: 11px;
  margin-top: 2px;
}

/* === SEMAFORO BAR === */
.semaforo-bar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 24px;
  background: var(--gray-200);
}

.semaforo-bar .seg-danger  { background: var(--danger); }
.semaforo-bar .seg-warning { background: var(--warning); }
.semaforo-bar .seg-success { background: var(--success); }

.semaforo-legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--gray-500);
  margin-top: -16px;
  margin-bottom: 24px;
}

.semaforo-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

/* === SECTION CARDS (Homepage) === */
.section {
  margin-bottom: 32px;
}

.section-header {
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-900);
}

.section-header p {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 2px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.section .cards .card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: all var(--transition);
  color: var(--gray-900);
  border-left: 3px solid transparent;
}

.section .cards .card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-left-color: var(--primary);
  color: var(--gray-900);
}

.section .cards .card-icon {
  font-size: 22px;
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--gray-50);
  border-radius: var(--radius);
}

.section .cards .card-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--gray-900);
}

.section .cards .card-desc {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
  line-height: 1.4;
}

.section .cards .card-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary-dark);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* === TABLES === */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  font-size: 13px;
}

thead th {
  background: var(--gray-50);
  color: var(--gray-600);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--gray-200);
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }

/* === BADGES === */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-success { background: var(--success-light); color: #065f46; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-danger  { background: var(--danger-light);  color: #991b1b; }
.badge-info    { background: var(--primary-light);  color: #1e40af; }

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-700);
  transition: all var(--transition);
}

.btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

/* === FORMS === */
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="search"],
select, textarea {
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 14px;
  color: var(--gray-900);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

/* === QUICK BAR (nascosta col nuovo design — la sidebar la sostituisce) === */
.quick-bar { display: none !important; }

/* === KPI ROW (vecchia — nascosta, sostituita da kpi-grid) === */
.kpi-row { display: none !important; }

/* === OLD HEADER ELEMENTS — nascosti === */
body > .header, .top-bar, .psb-header { display: none !important; }

/* === DIVIDER (vecchio) — nascosto === */
body > .divider, main > .divider { display: none !important; }

/* === ALERT / BANNER === */
.alert-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.alert-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--navy);
  color: var(--white);
}

.alert-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  text-decoration: none;
  transition: background var(--transition);
  font-size: 13px;
}

.alert-item:hover { background: var(--gray-50); }

/* === PAGINATION === */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin: 20px 0;
}

.pagination button, .pagination a {
  padding: 6px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: var(--white);
  color: var(--gray-700);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
}

.pagination button:hover, .pagination a:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

.pagination .active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

/* === FILTER BAR === */
.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* === STATUS DOT === */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-dot.green  { background: var(--success); }
.status-dot.red    { background: var(--danger); }
.status-dot.orange { background: var(--warning); }
.status-dot.gray   { background: var(--gray-400); }

/* === MOBILE === */
@media (max-width: 768px) {
  .psb-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  .psb-sidebar.open { transform: translateX(0); }
  .psb-main { margin-left: 0; padding: 16px; }
  .psb-mobile-toggle {
    position: fixed;
    top: 12px; left: 12px;
    z-index: 1001;
    background: var(--navy);
    color: var(--white);
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 18px;
    cursor: pointer;
    display: block;
  }
  .cards { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 769px) {
  .psb-mobile-toggle { display: none; }
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* === UTILITY === */
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted   { color: var(--gray-500) !important; }
.text-right   { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }

/* Fix: nascondi tutti i vecchi header/nav delle singole pagine */
.psb-main > header,
.psb-main > nav:not(.psb-sidebar-nav),
.psb-main > .page-header-bar,
.psb-main > .top-header {
  display: none !important;
}

/* Fix: il contenuto dentro .psb-main deve avere margin-left 0 (il margin è sul wrapper) */
.psb-main > * {
  margin-left: 0 !important;
}

/* Fix v2.1: nascondi vecchie sidebar e banner di Gestione Paghe Pro */
aside#sidebar, aside.sidebar {
  display: none !important;
}
.main-content {
  margin-left: 0 !important;
  width: 100% !important;
}
.app-header, .top-banner, .info-banner {
  display: none !important;
}

/* Fix v2.3: Layout pagine Gestione Paghe Pro */
.app-container {
  display: block !important;
  min-height: auto !important;
  height: auto !important;
}
.app-container > .main-content {
  margin-left: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  padding: 24px !important;
}
.scroll-progress {
  display: none !important;
}
/* Fix header vecchio "Gestione Paghe" con icona */
.app-container > .app-header,
.app-container > header:first-child,
.sidebar-toggle {
  display: none !important;
}

/* === FONT SIZE BOOST +3px === */
body { font-size: 16px !important; }
table, .table { font-size: 16px !important; }
td, th { font-size: 16px !important; padding: 10px 12px !important; }
.filters input, .filters select, input, select { font-size: 16px !important; }
.btn, button { font-size: 16px !important; }
.nav button, .tabs button { font-size: 16px !important; }
.pagination, .pagination .info, .pagination button { font-size: 15px !important; }
.card .label, .card .sub { font-size: 14px !important; }
.badge { font-size: 13px !important; }
h1 { font-size: 26px !important; }
h2 { font-size: 22px !important; }
h3 { font-size: 18px !important; }
p, li, span, div, a, label { font-size: inherit; }

/* === FONT SIZE BOOST +3px === */
body { font-size: 16px !important; }
table, .table { font-size: 16px !important; }
td, th { font-size: 16px !important; padding: 10px 12px !important; }
.filters input, .filters select, input, select { font-size: 16px !important; }
.btn, button { font-size: 16px !important; }
.nav button, .tabs button { font-size: 16px !important; }
.pagination, .pagination .info, .pagination button { font-size: 15px !important; }
.card .label, .card .sub { font-size: 14px !important; }
.badge { font-size: 13px !important; }
h1 { font-size: 26px !important; }
h2 { font-size: 22px !important; }
h3 { font-size: 18px !important; }
p, li, span, div, a, label { font-size: inherit; }
