/* ============================================================
   LA FALCO — Area Gestionale
   ============================================================ */

:root {
  /* Palette rosso e bianco — colori del logo */
  --navy-950: #3a0708;
  --navy-900: #4a090b;
  --navy-800: #5f0d0f;
  --amber: #e63946;
  --amber-dark: #b3202c;
  --green: #34c275;
  --red: #e25555;
  --blue: #4d8df0;
  --text-dark: #2b1214;
  --text-body: #6b4f52;
  --text-soft: #9a7e80;
  --bg: #f9f3f3;
  --surface: #ffffff;
  --border: #eedede;
  --radius: 12px;
  --shadow: 0 4px 18px rgba(58, 7, 8, 0.06);
  --font-head: 'Sora', sans-serif;
  --font-body: 'Inter', sans-serif;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-head); color: var(--text-dark); }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 1.5rem;
  background: var(--navy-950);
}
.brand { display: flex; align-items: center; gap: 0.65rem; }
.brand-logo { width: 32px; height: 32px; color: var(--amber); }
.brand-text {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.06em;
  color: #fdf6f6;
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand-text small {
  font-weight: 400;
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--amber);
}
.topbar-right { display: flex; align-items: center; gap: 1.2rem; }
.topbar-date { color: #ddbcbe; font-size: 0.82rem; }
.btn-back {
  color: #fdf6f6;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  transition: border-color 0.2s, color 0.2s;
}
.btn-back:hover { border-color: var(--amber); color: var(--amber); }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: calc(100vh - 64px);
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.2rem 0.8rem;
}
.side-nav { display: grid; gap: 0.25rem; }
.side-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  border: none;
  background: none;
  text-align: left;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-body);
  transition: background 0.15s, color 0.15s;
}
.side-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.side-link:hover { background: var(--bg); }
.side-link.active {
  background: var(--navy-950);
  color: #fff;
}
.side-link.active svg { color: var(--amber); }
.side-badge {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--bg);
  color: var(--text-soft);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  min-width: 26px;
  text-align: center;
}
.side-link.active .side-badge { background: rgba(255,255,255,0.15); color: #fff; }

.sidebar-foot { display: grid; gap: 0.5rem; }
.btn-mini {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-body);
  transition: background 0.15s, border-color 0.15s;
}
.btn-mini:hover { background: var(--bg); }
.btn-mini--danger { color: var(--red); }
.btn-mini--danger:hover { border-color: var(--red); background: #fdf0f0; }

/* ---------- Main ---------- */
.main { padding: 2rem 2.2rem; overflow-x: hidden; }
.tab { display: none; }
.tab.active { display: block; animation: fadein 0.25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

.page-head { margin-bottom: 1.6rem; }
.page-head h1 { font-size: 1.5rem; font-weight: 800; }
.page-head p { font-size: 0.9rem; color: var(--text-soft); }

/* ---------- Stats ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.1rem;
  margin-bottom: 1.6rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.4rem;
  display: flex;
  flex-direction: column;
}
.stat-label { font-size: 0.78rem; font-weight: 600; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-family: var(--font-head); font-size: 2.1rem; font-weight: 800; color: var(--text-dark); margin: 0.2rem 0; }
.stat-value--amber { color: var(--amber-dark); }
.stat-value--green { color: var(--green); }
.stat-foot { font-size: 0.76rem; color: var(--text-soft); }

/* ---------- Panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.3rem 1.5rem;
  margin-bottom: 1.4rem;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}
.panel-head h2 { font-size: 1.05rem; font-weight: 700; }
.link-btn {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 0.84rem;
  font-weight: 600;
}
.link-btn:hover { text-decoration: underline; }

.dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
.dash-list { display: grid; gap: 0.6rem; }
.dash-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--bg);
  border-radius: 10px;
  padding: 0.7rem 1rem;
  font-size: 0.86rem;
}
.dash-item strong { color: var(--text-dark); font-weight: 600; }
.dash-item .muted { color: var(--text-soft); font-size: 0.78rem; }

/* ---------- Forms ---------- */
.inline-form { display: flex; flex-wrap: wrap; gap: 0.7rem; }
.inline-form input, .inline-form select,
.filters input, .filters select {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.6rem 0.85rem;
  font-size: 0.88rem;
  font-family: var(--font-body);
  color: var(--text-dark);
  background: #fff;
}
.inline-form input:focus, .inline-form select:focus,
.filters input:focus, .filters select:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(230,57,70,0.15);
}
.inline-form input { flex: 1 1 160px; }
.inline-form .grow { flex: 2 1 220px; }
.btn-add {
  background: var(--navy-950);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 0.6rem 1.3rem;
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.2s;
}
.btn-add:hover { background: var(--navy-800); }

.filters { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.filters input[type="search"] { min-width: 190px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 0.87rem; }
thead th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  padding: 0.6rem 0.8rem;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 0.75rem 0.8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: #fbf7f7; }
td .cell-main { font-weight: 600; color: var(--text-dark); }
td .cell-sub { font-size: 0.78rem; color: var(--text-soft); }

/* Stato pills + select */
.pill {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  white-space: nowrap;
}
.pill--green { background: #e3f7ec; color: #1d8a50; }
.pill--amber { background: #fdf2dc; color: #a87312; }
.pill--red { background: #fdeaea; color: #b43c3c; }
.pill--grey { background: #eceff5; color: #5d6b84; }
.pill--blue { background: #e7effd; color: #2f63bd; }

.status-select {
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  background: #fff;
  color: var(--text-dark);
}

.btn-del {
  background: none;
  border: none;
  color: var(--text-soft);
  font-size: 1rem;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.btn-del:hover { color: var(--red); background: #fdeaea; }

/* ---------- Richieste cards ---------- */
.cards-list { display: grid; gap: 0.9rem; }
.req-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--amber);
  border-radius: 10px;
  padding: 1rem 1.2rem;
}
.req-card.req-card--closed { border-left-color: #c2cad8; opacity: 0.75; }
.req-head {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}
.req-head strong { color: var(--text-dark); font-size: 0.95rem; }
.req-head .muted { font-size: 0.78rem; color: var(--text-soft); }
.req-head .req-actions { margin-left: auto; display: flex; align-items: center; gap: 0.4rem; }
.req-msg { font-size: 0.88rem; margin: 0.3rem 0 0.5rem; }
.req-meta { display: flex; gap: 1.2rem; flex-wrap: wrap; font-size: 0.8rem; color: var(--text-soft); }
.req-meta a { color: var(--blue); }
.req-meta a:hover { text-decoration: underline; }

.empty-msg {
  text-align: center;
  color: var(--text-soft);
  font-size: 0.88rem;
  padding: 1.6rem 0 0.6rem;
  display: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-cols { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 64px;
    z-index: 40;
    flex-direction: column;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.7rem;
  }
  .side-nav {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.3rem;
    padding-bottom: 0.3rem;
    scrollbar-width: none;
  }
  .side-nav::-webkit-scrollbar { display: none; }
  .side-link { white-space: nowrap; padding: 0.65rem 0.9rem; }
  .sidebar-foot { display: flex; margin-top: 0.6rem; }
  .main { padding: 1.3rem 1rem; }
  .topbar { padding: 0 1rem; }
  .topbar-date { display: none; }

  /* 16px minimi: evita lo zoom automatico di iOS sul focus */
  .inline-form input, .inline-form select,
  .filters input, .filters select { font-size: 16px; }
  .inline-form input { flex: 1 1 100%; }
  .inline-form select { flex: 1 1 47%; }
  .btn-add { flex: 1 1 100%; padding: 0.75rem 1.3rem; }

  .panel { padding: 1.1rem 1rem; }
  .panel-head { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
  .panel-head .filters { width: 100%; }
  .filters input[type="search"] { flex: 1 1 auto; min-width: 0; }

  .req-head .req-actions { margin-left: 0; width: 100%; }
  .req-actions .status-select { flex: 1; padding: 0.45rem 0.6rem; }

  /* Bersagli touch più ampi */
  .btn-del { font-size: 1.1rem; padding: 0.45rem 0.7rem; }
  .status-select { padding: 0.4rem 0.6rem; }
}

@media (max-width: 540px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.7rem; }
  .stat-card { padding: 1rem 1.1rem; }
  .stat-value { font-size: 1.6rem; }
  .page-head h1 { font-size: 1.25rem; }
  .brand-text { font-size: 0.9rem; }
  .btn-back { padding: 0.35rem 0.8rem; font-size: 0.78rem; }
  .dash-item { flex-direction: column; align-items: flex-start; gap: 0.3rem; }
  .dash-item > div:last-child { text-align: left !important; }
}
