/* ============================================================
   styles.css — Noleggio Pedalò
   Mobile-first, tema lago/mare. Nessuna dipendenza.
   ============================================================ */

:root {
  --bg: #f2f7fb;
  --surface: #ffffff;
  --ink: #0f2a3d;
  --ink-soft: #5b7185;
  --line: #dce6ef;
  --brand: #0a8ec9;
  --brand-dark: #0870a0;
  --accent: #1fb8a6;
  --danger: #e2523b;
  --danger-dark: #c1391f;
  --warn: #e6a100;
  --ok: #24a35a;
  --shadow: 0 2px 10px rgba(15, 42, 61, .08);
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

/* ---------- Layout ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  padding: 14px 16px calc(14px + env(safe-area-inset-top, 0));
  padding-top: max(14px, env(safe-area-inset-top, 0));
  box-shadow: var(--shadow);
}
.app-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-header .sub { margin: 2px 0 0; font-size: 12.5px; opacity: .9; }

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 16px 96px;
}

.view { display: none; }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view-title { font-size: 18px; font-weight: 700; margin: 4px 0 14px; }

/* ---------- Bottom nav ---------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -2px 12px rgba(15,42,61,.06);
}
.tabbar button {
  flex: 1;
  border: 0;
  background: none;
  color: var(--ink-soft);
  padding: 9px 2px 8px;
  font-size: 10.5px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}
.tabbar button .ic { font-size: 21px; line-height: 1; }
.tabbar button.active { color: var(--brand); }

/* ---------- Cards / list ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.card h3 { margin: 0 0 4px; font-size: 16px; }
.muted { color: var(--ink-soft); font-size: 13.5px; }

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 650; font-size: 15.5px; }
.list-item .meta { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.list-item .avatar {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: #e6f4fb; color: var(--brand-dark);
  font-size: 20px; flex-shrink: 0;
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .2px;
}
.badge.libero { background: #dff5e8; color: var(--ok); }
.badge.noleggiato { background: #fde7e2; color: var(--danger-dark); }
.badge.aperto { background: #fff2d6; color: #9a6b00; }
.badge.chiuso { background: #e7edf2; color: var(--ink-soft); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  transition: filter .12s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn:hover { filter: brightness(1.05); }
.btn.block { width: 100%; }
.btn.lg { padding: 15px 18px; font-size: 16.5px; }
.btn.ghost { background: #eaf1f7; color: var(--brand-dark); }
.btn.accent { background: var(--accent); }
.btn.danger { background: var(--danger); }
.btn.ok { background: var(--ok); }
.btn.sm { padding: 8px 12px; font-size: 13.5px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; }
.row.tight { gap: 8px; }

.fab-row { display: flex; gap: 10px; margin-bottom: 14px; }

/* ---------- Forms ---------- */
label.field { display: block; margin-bottom: 12px; }
label.field .lbl { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 11px;
  padding: 12px 13px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(10,142,201,.15);
}
textarea { min-height: 70px; resize: vertical; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,42,61,.45);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  width: 100%;
  max-width: 560px;
  border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0));
  max-height: 92vh;
  overflow-y: auto;
  animation: slideup .22s ease;
}
@media (min-width: 620px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 20px; }
}
@keyframes slideup { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.icon-btn { background: #eef3f7; border: 0; width: 34px; height: 34px; border-radius: 10px; font-size: 18px; cursor: pointer; color: var(--ink-soft); }

/* ---------- Scanner ---------- */
#scanWrap { position: relative; background: #000; border-radius: 14px; overflow: hidden; }
#scanVideo { width: 100%; display: block; max-height: 60vh; object-fit: cover; }
#scanFrame {
  position: absolute; inset: 12% 14%;
  border: 3px solid rgba(255,255,255,.9);
  border-radius: 16px;
  box-shadow: 0 0 0 4000px rgba(0,0,0,.35);
}
.scan-hint { text-align: center; color: var(--ink-soft); font-size: 13.5px; margin: 10px 0 0; }

/* ---------- QR print ---------- */
.qr-card {
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 16px;
  background: #fff;
}
.qr-card canvas, .qr-card img { margin: 0 auto; }
.qr-card .qr-num { font-size: 22px; font-weight: 800; margin-top: 8px; letter-spacing: .5px; }
.qr-card .qr-model { color: var(--ink-soft); font-size: 13px; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 44px 16px; color: var(--ink-soft); }
.empty .big { font-size: 46px; margin-bottom: 8px; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters label.field { margin-bottom: 0; flex: 1; min-width: 130px; }
.seg { display: inline-flex; background: #e7eef4; border-radius: 11px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: none; padding: 8px 12px; border-radius: 9px; font-weight: 600; font-size: 13.5px; color: var(--ink-soft); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--brand-dark); box-shadow: var(--shadow); }

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat.warn { border-color: #f3c26b; background: #fff8e6; }
.stat.warn .n { color: #b45309; }
.btn-col { display: flex; flex-direction: column; gap: 6px; }
.badge.pagato { background: #dff5e8; color: var(--ok); }
.badge.dainc { background: #fff2d6; color: #9a6b00; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-align: center; box-shadow: var(--shadow); }
.stat .n { font-size: 24px; font-weight: 800; color: var(--brand-dark); }
.stat .l { font-size: 11.5px; color: var(--ink-soft); margin-top: 2px; }

/* ---------- Countdown ---------- */
.cd { font-weight: 800; font-variant-numeric: tabular-nums; }
.cd.late { color: var(--danger); }
.cd.soon { color: var(--warn); }
.cd.ok { color: var(--ok); }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 100; box-shadow: var(--shadow);
  max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Table (storico print) ---------- */
.tbl-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; background: var(--surface); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
table.data th, table.data td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { background: #eef4f8; font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .3px; }
table.data tr:last-child td { border-bottom: 0; }

.search-box { position: relative; margin-bottom: 12px; }
.search-box input { padding-left: 38px; }
.search-box .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-soft); }

.hint-inline { font-size: 12.5px; color: var(--ink-soft); margin-top: -6px; margin-bottom: 12px; }

/* ---------- Login ---------- */
.login-screen {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, var(--brand), var(--brand-dark));
}
.login-card {
  background: var(--surface);
  width: 100%; max-width: 380px;
  border-radius: 20px;
  padding: 28px 22px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  text-align: center;
}
.login-card h1 { margin: 6px 0 2px; font-size: 22px; }
.login-card .muted { margin: 0 0 16px; }
.login-card .field { text-align: left; }
.login-logo { font-size: 52px; line-height: 1; }
.login-error { color: var(--danger); font-size: 13.5px; font-weight: 600; min-height: 18px; margin: 10px 0 0; }

/* ---------- Print ---------- */
.print-only { display: none; }
@media print {
  .app-header, .tabbar, .filters, .fab-row, .btn, .seg, #toast, .no-print { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .view:not(.active) { display: none; }
  .print-only { display: block; }
  table.data { box-shadow: none; }
  table.data th, table.data td { border-color: #bbb; white-space: normal; }
  .print-head { margin-bottom: 10px; }
  .print-head h2 { margin: 0 0 2px; }
}
