/* work.piscineconcaverde.it — app.css */

:root {
  --primary: #0ea5e9;
  --primary-dark: #0284c7;
  --primary-light: #e0f2fe;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --muted2: #94a3b8;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --warn: #f59e0b;
  --warn-bg: #fef3c7;
  --err: #dc2626;
  --err-bg: #fee2e2;
  --maybe: #f59e0b;
  --maybe-bg: #fef3c7;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.45;
  -webkit-tap-highlight-color: rgba(14,165,233,0.15);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

/* ============ topbar ============ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 10px 16px;
  gap: 12px;
  min-height: 56px;
}
.topbar-brand {
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  text-decoration: none;
  display: flex; align-items: center; gap: 8px;
}
.topbar-brand .dot {
  width: 26px; height: 26px;
  background: var(--primary);
  border-radius: 8px;
  display: inline-block;
  position: relative;
}
.topbar-brand .dot::after {
  content: '';
  position: absolute; inset: 5px;
  border-radius: 4px;
  background: #fff;
  opacity: 0.85;
}
.topbar-spacer { flex: 1; }
.topbar-user {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.topbar-user .role-badge {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.topbar-menu-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
}

/* ============ side menu (admin desktop) ============ */
.app-wrap { display: flex; min-height: calc(100vh - 56px); }
.sidebar {
  width: 230px;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 16px 0;
  display: none;
}
.sidebar a {
  display: block;
  padding: 10px 18px;
  color: var(--text);
  font-size: 14px;
  border-left: 3px solid transparent;
  text-decoration: none;
}
.sidebar a:hover { background: var(--bg); }
.sidebar a.active {
  background: var(--primary-light);
  border-left-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 600;
}
.main { flex: 1; min-width: 0; padding: 16px; padding-bottom: 88px; }
@media (min-width: 900px) {
  .sidebar { display: block; }
  .main { padding: 28px 32px; }
}

/* ============ bottom nav (mobile, dipendente) ============ */
.botnav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 40;
  padding-bottom: env(safe-area-inset-bottom);
}
.botnav a {
  flex: 1;
  text-align: center;
  padding: 10px 4px 8px;
  color: var(--muted);
  font-size: 11px;
  text-decoration: none;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.botnav a .ico { font-size: 22px; line-height: 1; }
.botnav a.active { color: var(--primary); font-weight: 600; }
@media (min-width: 900px) {
  .botnav { display: none; }
  .main { padding-bottom: 28px; }
}

/* ============ tipografia ============ */
h1 { font-size: 22px; margin: 0 0 16px; font-weight: 700; }
h2 { font-size: 18px; margin: 0 0 12px; font-weight: 700; }
h3 { font-size: 15px; margin: 0 0 8px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
@media (min-width: 900px) {
  h1 { font-size: 26px; }
  h2 { font-size: 20px; }
}
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ============ card ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-tight { padding: 12px; }
.card-row { display: flex; align-items: center; gap: 12px; }
.card-row + .card-row { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }

/* ============ buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--primary);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  min-height: 44px;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--err); }
.btn-danger:hover { background: #b91c1c; }
.btn-ok { background: var(--ok); }
.btn-ok:hover { background: #15803d; }
.btn-sm { padding: 6px 12px; font-size: 13px; min-height: 34px; border-radius: 8px; }
.btn-full { display: flex; width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============ form ============ */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.form-control, input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=date], input[type=time], input[type=color], select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}
input[type=color] { padding: 4px; height: 44px; }
.form-control:focus, input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary-light);
  border-color: var(--primary);
}
.help { color: var(--muted); font-size: 12px; margin-top: 4px; }
.form-row { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 700px) {
  .form-row.cols-2 { grid-template-columns: 1fr 1fr; }
  .form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* ============ flash ============ */
.flash-wrap { margin-bottom: 14px; }
.flash {
  padding: 10px 14px; border-radius: 10px; font-size: 14px;
  margin-bottom: 8px; border: 1px solid transparent;
}
.flash-ok   { background: var(--ok-bg);   color: #14532d; border-color: #bbf7d0; }
.flash-err  { background: var(--err-bg);  color: #7f1d1d; border-color: #fecaca; }
.flash-info { background: var(--primary-light); color: var(--primary-dark); border-color: #bae6fd; }

/* ============ table ============ */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: #fff; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.t th {
  background: var(--bg);
  font-weight: 700;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
table.t tr:last-child td { border-bottom: 0; }
table.t tr:hover td { background: #fafbfc; }

/* ============ badge / chip ============ */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--border);
  color: var(--muted);
}
.badge-ok   { background: var(--ok-bg);   color: #14532d; }
.badge-warn { background: var(--warn-bg); color: #78350f; }
.badge-err  { background: var(--err-bg);  color: #7f1d1d; }
.badge-info { background: var(--primary-light); color: var(--primary-dark); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.chip .swatch { width: 10px; height: 10px; border-radius: 999px; display: inline-block; }

/* ============ calendar (mobile dipendente) ============ */
.cal-month-title {
  font-size: 18px; font-weight: 700;
  text-transform: capitalize;
  margin: 4px 0 10px;
  text-align: center;
}
.cal-week-head {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 8px 0 4px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-cell {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 64px;
  padding: 4px;
  display: flex; flex-direction: column;
  text-align: left;
  position: relative;
}
.cal-cell.disabled { background: #f1f5f9; opacity: 0.55; pointer-events: none; }
.cal-cell.today { border-color: var(--primary); border-width: 2px; }
.cal-cell .d { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.cal-cell.today .d { color: var(--primary); }
.cal-cell .slots {
  display: flex; gap: 3px; margin-top: auto;
}
.cal-cell .slot {
  flex: 1;
  font-size: 10px;
  text-align: center;
  padding: 4px 2px;
  border-radius: 5px;
  background: #f1f5f9;
  color: #94a3b8;
  font-weight: 600;
  letter-spacing: 0.4px;
  cursor: pointer;
  user-select: none;
}
.cal-cell .slot.av-disponibile    { background: var(--ok-bg);   color: #14532d; }
.cal-cell .slot.av-forse          { background: var(--maybe-bg);color: #78350f; }
.cal-cell .slot.av-non_disponibile{ background: var(--err-bg);  color: #7f1d1d; }
/* slot CONFERMATO dall'admin: badge "turno" */
.cal-cell .slot.turno {
  background: var(--ok);
  color: #fff;
  box-shadow: inset 0 0 0 2px #15803d;
  font-weight: 800;
}
.cal-cell .slot.turno::after { content: " ✓"; }
.cal-cell .slot.escluso {
  background: #cbd5e1;
  color: #475569;
  text-decoration: line-through;
}
.cal-cell .slot.locked { cursor: not-allowed; opacity: 0.95; }
@media (min-width: 700px) {
  .cal-cell { min-height: 88px; padding: 6px; }
  .cal-cell .d { font-size: 13px; }
  .cal-cell .slot { font-size: 11px; padding: 6px 4px; }
}

/* ============ admin month calendar (con totali) ============ */
.adm-cal-cell {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 90px;
  padding: 6px;
  position: relative;
  cursor: pointer;
}
.adm-cal-cell.disabled { background: #f1f5f9; opacity: 0.5; pointer-events: none; }
.adm-cal-cell .d { font-size: 12px; font-weight: 700; color: var(--muted); }
.adm-cal-cell .totals { display: flex; gap: 4px; margin-top: 6px; }
.adm-cal-cell .tt {
  flex: 1;
  background: #f1f5f9;
  border-radius: 4px;
  padding: 3px 4px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}
.adm-cal-cell .tt b { font-size: 14px; color: var(--text); display: block; }
.adm-cal-cell .mansione-dots { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 3px; }
.adm-cal-cell .m-dot {
  width: 14px; height: 14px;
  border-radius: 999px;
  font-size: 9px;
  line-height: 14px;
  color: #fff;
  text-align: center;
  font-weight: 700;
}
.adm-cal-cell.alert { box-shadow: inset 0 0 0 2px var(--warn); }

/* ============ KPI tiles ============ */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 700px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }
.kpi {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.kpi .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; font-weight: 700; }
.kpi .n { font-size: 26px; font-weight: 800; margin-top: 4px; }
.kpi.alert .n { color: var(--warn); }
.kpi.danger .n { color: var(--err); }

/* ============ modal ============ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: fadein 0.15s ease-out;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%; max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}
.modal-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 16px; }
.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}
.modal .close-x {
  background: transparent; border: 0; font-size: 22px;
  color: var(--muted); cursor: pointer;
  width: 30px; height: 30px; border-radius: 8px;
}
.modal .close-x:hover { background: var(--bg); color: var(--text); }

/* ============ login ============ */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: linear-gradient(180deg, var(--primary-light) 0%, var(--bg) 60%);
}
.login-box {
  width: 100%; max-width: 420px;
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.08);
}
.login-box .brand {
  text-align: center;
  margin-bottom: 20px;
}
.login-box .brand .logo {
  width: 44px; height: 44px;
  background: var(--primary);
  border-radius: 12px;
  margin: 0 auto 10px;
  position: relative;
}
.login-box .brand .logo::after {
  content: '';
  position: absolute; inset: 9px;
  border-radius: 6px;
  background: #fff;
  opacity: 0.85;
}
.login-box h1 { margin: 0; font-size: 20px; text-align: center; }
.login-box .sub { color: var(--muted); font-size: 13px; text-align: center; margin-bottom: 18px; }

/* ============ misc ============ */
.hide-mobile { display: none; }
@media (min-width: 900px) { .hide-mobile { display: revert; } .show-mobile { display: none; } }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }

.filterbar {
  display: flex; gap: 8px; flex-wrap: wrap;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 14px;
}
.filterbar select, .filterbar input { padding: 8px 10px; font-size: 14px; }

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}
.empty .ico { font-size: 32px; opacity: 0.5; margin-bottom: 8px; }

/* color swatches */
.swatch-row { display: flex; flex-wrap: wrap; gap: 4px; }
.color-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}
