/* WauCRM — stylesheet unico, stile AdminLTE */
:root {
  --sidebar-bg: #1f2937;
  --sidebar-hover: #374151;
  --sidebar-text: #d1d5db;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --muted: #6b7280;
  --bg: #f3f4f6;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --sidebar-w: 230px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

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

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

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 18px 20px;
  font-size: 20px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-brand a { color: #fff; text-decoration: none; }

.sidebar-nav { padding: 10px 0; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14.5px;
  transition: background 0.15s ease, padding-left 0.15s ease;
}
.sidebar-nav a:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; padding-left: 26px; }
.sidebar-nav a.active { background: var(--primary); color: #fff; }
.nav-icon { width: 20px; text-align: center; }
.nav-section {
  padding: 14px 20px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9ca3af;
}

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-weight: 600; font-size: 17px; flex: 1; }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.user-name { color: var(--muted); font-size: 14px; }

.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text);
  padding: 4px 8px;
}

.content { padding: 20px; max-width: 1280px; width: 100%; }

.sidebar-backdrop { display: none; }

/* ---------- Card ---------- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}
.card:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1); }
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.card-body { padding: 18px; }
.card-body.p0 { padding: 0; }

/* ---------- Stat box ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-box {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  border-left: 4px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-box:hover { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12); }
.stat-box.green { border-left-color: var(--success); }
.stat-box.green .stat-icon { color: var(--success); }
.stat-box.orange { border-left-color: var(--warning); }
.stat-box.orange .stat-icon { color: var(--warning); }
.stat-box.gray { border-left-color: var(--muted); }
.stat-box.gray .stat-icon { color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat-icon { font-size: 40px; color: var(--primary); opacity: 0.22; line-height: 1; }

/* ---------- Tabelle ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 14px; text-align: left; vertical-align: middle; }
.table th {
  background: #f9fafb;
  border-bottom: 2px solid var(--border);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}
.table td { border-bottom: 1px solid var(--border); }
.table tbody tr:hover { background: #f9fafb; }
.table .actions { white-space: nowrap; text-align: right; }
.table-empty { padding: 24px; text-align: center; color: var(--muted); }

/* ---------- Bottoni ---------- */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  background: #e5e7eb;
  color: var(--text);
  line-height: 1.4;
}
.btn { transition: filter 0.12s ease, transform 0.08s ease, box-shadow 0.12s ease; }
.btn:hover { text-decoration: none; filter: brightness(0.95); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12); }
.btn:active { transform: scale(0.97); }
.btn .bi { margin-right: 2px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
form.inline { display: inline; }

/* ---------- Badge ---------- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-gray { background: #e5e7eb; color: #374151; }
.badge-orange { background: #fef3c7; color: #92400e; }
.badge-product { background: #ede9fe; color: #5b21b6; margin: 1px 2px 1px 0; }

/* ---------- Form ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 16px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 13px; font-weight: 600; color: #374151; }
.form-control {
  padding: 8px 11px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14.5px;
  font-family: inherit;
  background: #fff;
  width: 100%;
}
.form-control:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-hint { font-size: 12.5px; color: var(--muted); }

.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 14px; }
.checkbox-item { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; padding: 4px 0; }
.checkbox-item input { margin-top: 3px; }
.product-category-title { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 12px 0 6px; }
.product-category-title:first-child { margin-top: 0; }

/* ---------- Flash ---------- */
.flash {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.flash .bi { font-size: 16px; line-height: 1.4; }
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar-bg);
  padding: 20px;
}
.login-box { width: 100%; max-width: 380px; }
.login-brand { text-align: center; color: #fff; font-size: 28px; font-weight: 700; margin-bottom: 20px; }
.login-card { background: #fff; border-radius: var(--radius); padding: 26px; box-shadow: 0 8px 30px rgba(0,0,0,0.3); }
.login-card h1 { margin: 0 0 18px; font-size: 17px; font-weight: 600; text-align: center; color: var(--muted); }
.login-card .form-group { margin-bottom: 14px; }
.login-card .btn { width: 100%; padding: 10px; }

/* ---------- Calendario ---------- */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-title { font-size: 17px; font-weight: 700; min-width: 170px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.cal-dow {
  padding: 8px 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  background: #f9fafb;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.cal-day {
  min-height: 108px;
  padding: 6px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: #fff;
  font-size: 13px;
}
.cal-day.other-month { background: #f9fafb; }
.cal-day.other-month .cal-day-num { color: #c0c4cc; }
.cal-day.today { background: #eff6ff; }
.cal-day.today .cal-day-num {
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  width: 24px; height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cal-day-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.cal-day-num { font-weight: 600; font-size: 13px; }
.cal-day-label { display: none; font-weight: 600; color: var(--muted); font-size: 12.5px; }
.cal-add { color: #c0c4cc; font-size: 15px; line-height: 1; text-decoration: none; }
.cal-add:hover { color: var(--primary); text-decoration: none; }
.cal-event {
  display: block;
  margin-bottom: 3px;
  padding: 3px 6px;
  border-radius: 4px;
  background: #dbeafe;
  color: #1e40af;
  font-size: 12px;
  line-height: 1.35;
  text-decoration: none;
  overflow: hidden;
}
.cal-event { transition: transform 0.1s ease, filter 0.12s ease; }
.cal-event:hover { text-decoration: none; filter: brightness(0.94); transform: translateX(2px); }
.cal-event.completato { background: #dcfce7; color: #166534; }
.cal-event.annullato { background: #f3f4f6; color: #9ca3af; text-decoration: line-through; }
.cal-event .who { font-weight: 700; }

/* ---------- Utility ---------- */
.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.mb0 { margin-bottom: 0; }
.page-actions { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.search-form { display: flex; gap: 8px; flex: 1; max-width: 420px; }
h2.section-title { font-size: 16px; margin: 0; }
.detail-list { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 14.5px; }
.detail-list dt { color: var(--muted); font-weight: 500; }
.detail-list dd { margin: 0; word-break: break-word; }

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 90;
  }
  .main { margin-left: 0; }
  .hamburger { display: block; }
  .content { padding: 14px; }
  .topbar { padding: 0 14px; }
  .user-name { display: none; }

  /* Tabelle → card impilate */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 10px;
    width: auto;
    background: #fff;
    box-shadow: var(--shadow);
    overflow: hidden;
  }
  .table tbody tr:hover { background: #fff; }
  .table td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
    padding: 8px 14px;
    border-bottom: 1px solid #f3f4f6;
    text-align: right;
  }
  .table td:last-child { border-bottom: none; }
  .table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
    flex-shrink: 0;
  }
  .table td:not([data-label])::before { content: none; }
  .table td.actions { justify-content: flex-end; padding-top: 10px; padding-bottom: 10px; background: #f9fafb; }
  .table td.table-empty { display: block; text-align: center; border: none; }
  .table td:empty { display: none; }

  /* Calendario → agenda verticale */
  .cal-grid { display: block; border: none; }
  .cal-dow { display: none; }
  .cal-day { min-height: 0; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px; }
  .cal-day:not(.has-events):not(.today) { display: none; }
  .cal-day.other-month:not(.has-events) { display: none; }
  .cal-day-label { display: inline; }
  .cal-event { font-size: 13px; }
}
