/* Calendario Solèo — palette affine a Plane, mobile-first */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1f2329;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #3b82f6;
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --started: #f59e0b;
  --waiting: #8b5cf6;
  --review: #ec4899;
  --done: #10b981;
  --personale: #8b5cf6;
  --lavoro: #3b82f6;
  --call: #f59e0b;
  --cliente: #ec4899;
  --radius: 10px;
  --shadow: 0 1px 3px rgb(16 24 40 / 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: #0f172a; color: #fff;
}
.brand { font-weight: 700; font-size: 16px; }
.brand-name { letter-spacing: 0.2px; }
.pill {
  background: #1e293b; color: #e2e8f0;
  padding: 4px 12px; border-radius: 999px; font-size: 13px;
}

/* ---------- toolbar ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 10px 12px; background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.view-switch { display: flex; background: #eef1f4; border-radius: 8px; padding: 3px; gap: 2px; }
.view-switch button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 6px;
  cursor: pointer; font-size: 14px; color: var(--muted);
}
.view-switch button.active { background: #fff; color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.nav { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.nav button {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 6px 10px; cursor: pointer; font-size: 14px;
}
.period-label { min-width: 130px; text-align: center; font-weight: 600; font-size: 14px; }
.actions { display: flex; gap: 8px; margin-left: auto; }
button.primary {
  background: var(--accent); color: var(--accent-ink); border: 0;
  padding: 8px 14px; border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 14px;
}
button.secondary {
  background: #fff; border: 1px solid var(--line); color: var(--ink);
  padding: 8px 14px; border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 14px;
}
button.danger { background: #fff; border: 1px solid #fecaca; color: var(--danger); padding: 8px 14px; border-radius: 8px; font-weight: 600; cursor: pointer; }
button.icon-btn { border: 0; background: transparent; font-size: 16px; cursor: pointer; color: var(--muted); }

/* ---------- calendario ---------- */
#calendar-root { padding: 12px; max-width: 1180px; margin: 0 auto; }

/* mese */
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.dow { text-align: center; font-size: 12px; color: var(--muted); text-transform: uppercase; padding: 4px 0; }
.day-cell {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  min-height: 96px; padding: 6px; cursor: pointer; position: relative;
  transition: box-shadow 0.12s ease;
}
.day-cell:hover { box-shadow: 0 2px 10px rgb(16 24 40 / 0.12); }
.day-cell.outside { background: transparent; border-style: dashed; opacity: 0.55; }
.day-cell.today { border-color: var(--accent); border-width: 2px; }
.day-num { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.event-chip {
  display: block; border-radius: 6px; padding: 2px 6px; margin: 2px 0;
  font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: #fff; cursor: pointer; border: 0; width: 100%; text-align: left;
}
.event-chip.privato-other { background: #94a3b8; }
.event-chip.lavoro { background: var(--lavoro); }
.event-chip.call { background: var(--call); }
.event-chip.cliente { background: var(--cliente); }
.event-chip.personale { background: var(--personale); }
.more-chip { font-size: 11px; color: var(--muted); padding: 0 4px; }

/* settimana */
.week-grid { display: grid; grid-template-columns: 52px repeat(7, 1fr); gap: 4px; }
.week-head { text-align: center; font-size: 12px; color: var(--muted); padding: 6px 0; }
.week-head.today { color: var(--accent); font-weight: 700; }
.week-col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-height: 460px; position: relative; }
.week-event {
  position: absolute; left: 2px; right: 2px; border-radius: 6px; padding: 3px 6px;
  font-size: 11px; color: #fff; overflow: hidden; cursor: pointer; border: 0; text-align: left;
}
.hour-label { font-size: 11px; color: var(--muted); text-align: right; padding-top: 2px; }

/* giorno */
.day-list { display: flex; flex-direction: column; gap: 8px; }
.day-events { display: flex; flex-direction: column; gap: 6px; }
.day-event {
  display: flex; gap: 10px; align-items: flex-start; background: var(--panel);
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 8px; padding: 10px 12px;
}
.day-event.personale { border-left-color: var(--personale); }
.day-event.call { border-left-color: var(--call); }
.day-event.cliente { border-left-color: var(--cliente); }
.day-event.lavoro { border-left-color: var(--lavoro); }
.day-time { font-weight: 700; min-width: 86px; font-size: 14px; }
.day-body { flex: 1; }
.day-title { font-weight: 600; }
.day-meta { font-size: 12px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.empty-day { text-align: center; color: var(--muted); padding: 32px 0; }

/* ---------- modali ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgb(15 23 42 / 0.45);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.modal { width: 100%; max-width: 460px; max-height: 92vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body label { display: block; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.modal-body input, .modal-body select, .modal-body textarea {
  width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 15px; color: var(--ink); background: #fff; font-family: inherit;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label.switch { display: flex; align-items: center; gap: 8px; margin-top: 24px; color: var(--ink); cursor: pointer; }
label.switch input { width: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.conflicts { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; border-radius: 8px; padding: 10px; font-size: 13px; margin-bottom: 10px; }
.slots-result { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.slot-pill {
  background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46;
  border-radius: 8px; padding: 8px 12px; font-weight: 600; text-align: center; font-size: 15px;
}

/* login */
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); }
.login-card { max-width: 420px; margin: 12vh auto; padding: 28px; text-align: center; }
.login-card h1 { margin-top: 0; }

/* toast */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 14px; z-index: 90; max-width: 88vw;
}

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  .toolbar { padding: 8px; }
  .view-switch button { padding: 6px 10px; font-size: 13px; }
  .actions .secondary { display: none; }
  .day-cell { min-height: 60px; padding: 4px; }
  .event-chip { font-size: 11px; padding: 1px 4px; }
  .week-grid { grid-template-columns: 38px repeat(7, 1fr); }
  .week-col { min-height: 420px; }
  .row2 { grid-template-columns: 1fr; }
  label.switch { margin-top: 0; }
}