/* ============================================================
   base.css — Reset, variabili, tipografia, layout
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Lora:ital,wght@0,500;0,600;1,400&display=swap');

/* ── VARIABILI ─────────────────────────────────────────────── */
:root {
  /* Colori principali */
  --blue-900: #0c1a2e;
  --blue-800: #122338;
  --blue-700: #1a3350;
  --blue-600: #1e4080;
  --blue-500: #2356a4;
  --blue-400: #3a72c8;
  --blue-100: #dce8f8;
  --blue-50:  #f0f5fd;

  --red-600:  #c0392b;
  --red-500:  #e74c3c;
  --red-100:  #fde8e6;

  --green-600: #1e7e5a;
  --green-500: #27ae60;
  --green-100: #d4f4e2;

  --amber-500: #f39c12;
  --amber-100: #fef3cd;

  --ink:    #0f1923;
  --ink2:   #2d3a48;
  --ink3:   #5a6a7a;
  --ink4:   #8a9aaa;
  --border: #d8e4f0;
  --bg:     #f4f7fb;
  --surface:#ffffff;
  --surface2:#f8fafd;

  /* Tipografia */
  --font-ui:   'Outfit', system-ui, sans-serif;
  --font-body: 'Lora', Georgia, serif;

  /* Spazi */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Ombre */
  --shadow-xs: 0 1px 3px rgba(12,26,46,.06);
  --shadow-sm: 0 2px 8px rgba(12,26,46,.08);
  --shadow:    0 4px 20px rgba(12,26,46,.10);
  --shadow-lg: 0 8px 40px rgba(12,26,46,.14);

  /* Transizioni */
  --t: .2s ease;
}

/* ── RESET ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; overflow-y: auto; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font-family: inherit; }
ul, ol { list-style: none; }

/* ── SCROLLBAR ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink4); }

/* ── TIPOGRAFIA ────────────────────────────────────────────── */
h1,h2,h3,h4,h5 { font-weight: 700; line-height: 1.25; color: var(--ink); }
h1 { font-size: clamp(22px, 4vw, 32px); }
h2 { font-size: clamp(18px, 3vw, 24px); }
h3 { font-size: clamp(15px, 2.5vw, 18px); }
p  { color: var(--ink3); line-height: 1.7; }

/* ── LAYOUT APP ────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--blue-900);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform var(--t);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-logo img {
  height: 40px;
  width: auto;
  max-width: 48px;
  object-fit: contain;
  flex-shrink: 0;
  /* filter rimosso: il logo appare con i colori originali */
}
.sidebar-logo-text {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,.9);
  line-height: 1.3;
  letter-spacing: .02em;
}
.sidebar-logo-sub {
  font-size: 10px;
  font-weight: 400;
  color: rgba(255,255,255,.4);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-section {
  padding: 16px 12px 4px;
}
.sidebar-section-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  padding: 0 8px;
  margin-bottom: 4px;
}

.sidebar-nav { padding: 8px 12px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,.55);
  cursor: pointer;
  transition: all var(--t);
  margin-bottom: 2px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
}
.nav-item:hover {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.9);
}
.nav-item.active {
  background: var(--blue-600);
  color: #fff;
  font-weight: 600;
}
.nav-item svg { flex-shrink: 0; opacity: .7; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}
.sidebar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--blue-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.sidebar-user-info strong {
  font-size: 12.5px;
  font-weight: 600;
  color: rgba(255,255,255,.9);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.sidebar-user-info span {
  font-size: 10.5px;
  color: rgba(255,255,255,.35);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* MAIN CONTENT */
.main-content {
  flex: 1;
  margin-left: 260px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* TOPBAR */
.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-xs);
}
.topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  flex: 1;
}
.topbar-breadcrumb {
  font-size: 12px;
  color: var(--ink4);
  margin-top: 1px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

/* PAGE CONTENT */
.page {
  flex: 1;
  padding: 32px;
  max-width: 1200px;
  width: 100%;
}

/* ── CARDS ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 24px;
  box-shadow: var(--shadow-xs);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}
.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-subtitle {
  font-size: 12.5px;
  color: var(--ink4);
  margin-top: 2px;
}

/* STAT CARDS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--t);
}
.stat-card:hover { box-shadow: var(--shadow-sm); }
.stat-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 6px;
}
.stat-icon-blue  { background: var(--blue-50); color: var(--blue-500); }
.stat-icon-green { background: var(--green-100); color: var(--green-600); }
.stat-icon-amber { background: var(--amber-100); color: var(--amber-500); }
.stat-icon-red   { background: var(--red-100); color: var(--red-600); }
.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1;
}
.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink4);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ── TABELLE ───────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table thead th {
  background: var(--blue-900);
  color: rgba(255,255,255,.7);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
}
.table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--t);
}
.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover { background: var(--surface2); }
.table td {
  padding: 12px 16px;
  color: var(--ink2);
  vertical-align: middle;
}

/* ── FORM ──────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
.form-full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink2);
  letter-spacing: .03em;
  text-transform: uppercase;
}
.field input,
.field select,
.field textarea {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  transition: border-color var(--t), box-shadow var(--t);
  outline: none;
  width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(35,86,164,.12);
}
.field textarea { resize: vertical; min-height: 80px; }
.field small {
  font-size: 11.5px;
  color: var(--ink4);
}

/* ── BADGE ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-pending  { background: var(--amber-100); color: #7a5200; }
.badge-approved { background: var(--green-100); color: var(--green-600); }
.badge-rejected { background: var(--red-100);   color: var(--red-600); }
.badge-amber    { background: #fff8e1;               color: #b45309; }
.badge-locked   { background: #ffe8d6; color: #7a3500; }
.badge-active   { background: var(--blue-100); color: var(--blue-600); }
.badge-inactive { background: var(--bg); color: var(--ink4); border: 1px solid var(--border); }

/* ── BOTTONI ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--t);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}
.btn svg { flex-shrink: 0; }
.btn-primary {
  background: var(--blue-600);
  color: #fff;
  box-shadow: 0 2px 8px rgba(35,86,164,.25);
}
.btn-primary:hover { background: var(--blue-500); box-shadow: 0 4px 14px rgba(35,86,164,.35); }
.btn-danger  { background: var(--red-600); color: #fff; }
.btn-danger:hover  { background: var(--red-500); }
.btn-success { background: var(--green-600); color: #fff; }
.btn-success:hover { background: var(--green-500); }
.btn-ghost {
  background: none;
  color: var(--ink3);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { border-color: var(--blue-400); color: var(--blue-500); background: var(--blue-50); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 9px; font-size: 11px; }

/* ── ALERT / FLASH ─────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
}
.alert-success { background: var(--green-100); color: var(--green-600); border-left: 4px solid var(--green-500); }
.alert-error   { background: var(--red-100);   color: var(--red-600);   border-left: 4px solid var(--red-500); }
.alert-warning { background: var(--amber-100); color: #7a5200;          border-left: 4px solid var(--amber-500); }
.alert-info    { background: var(--blue-100);  color: var(--blue-600);  border-left: 4px solid var(--blue-400); }

/* ── TABS ──────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
}
.tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink3);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--t);
  white-space: nowrap;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { color: var(--blue-500); }
.tab.active { color: var(--blue-600); border-bottom-color: var(--blue-600); }
.tab-count {
  background: var(--blue-100);
  color: var(--blue-600);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
}
.tab.active .tab-count { background: var(--blue-600); color: #fff; }

/* ── EMPTY STATE ───────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 20px;
  text-align: center;
  gap: 10px;
}
.empty-state svg { opacity: .25; }
.empty-state p { color: var(--ink4); font-size: 14px; }

/* ── TOGGLE ────────────────────────────────────────────────── */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink2);
}
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 38px; height: 22px;
  background: var(--border);
  border-radius: 99px;
  transition: background var(--t);
  position: relative;
  flex-shrink: 0;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-xs);
  transition: left var(--t);
}
.toggle input:checked + .toggle-track { background: var(--blue-500); }
.toggle input:checked + .toggle-track::after { left: 19px; }

/* ── MODAL ─────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(12,26,46,.5);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 28px;
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modalIn .25s ease;
}
@keyframes modalIn {
  from { opacity:0; transform: translateY(20px) scale(.97); }
  to   { opacity:1; transform: none; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink3);
  transition: background var(--t);
}
.modal-close:hover { background: var(--border); }

/* ── MOBILE HAMBURGER ──────────────────────────────────────── */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--ink);
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 199;
}

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .menu-toggle { display: flex; }
  .page { padding: 20px 16px; }
  .topbar { padding: 0 16px; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .table td, .table th { padding: 10px 12px; }
}

/* ── ANIMAZIONI ────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity:0; transform: translateY(10px); }
  to   { opacity:1; transform: none; }
}
.fade-in { animation: fadeIn .35s ease both; }
.fade-in-delay-1 { animation-delay: .07s; }
.fade-in-delay-2 { animation-delay: .14s; }
.fade-in-delay-3 { animation-delay: .21s; }