/* Pannello admin.bestiedev.it */

:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1d212a;
  --border: #272c37;
  --text: #e6e8ec;
  --muted: #8b93a3;
  --faint: #5d6577;
  --accent: #5b8cff;
  --accent-dim: #2a3d63;
  --ok: #3fb950;
  --warn: #d29922;
  --danger: #f85149;
  --shift: #a371f7;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- struttura ---------- */
.app { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 16px; }
.brand-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }
.brand strong { font-size: 14px; }
.brand span { font-size: 11px; color: var(--faint); display: block; }

.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 8px; color: var(--muted);
  cursor: pointer; border: none; background: none; width: 100%;
  font: inherit; text-align: left; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: #fff; }
.nav-item .count {
  font-size: 11px; background: rgba(255,255,255,.1); padding: 1px 6px; border-radius: 20px;
}
.nav-spacer { flex: 1; }

.main { padding: 24px 28px 64px; max-width: 1180px; }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- elementi ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.btn {
  padding: 7px 13px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); cursor: pointer;
  font: inherit; font-size: 13px; transition: background .12s, border-color .12s;
}
.btn:hover:not(:disabled) { background: #252a35; border-color: #333a48; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
.btn-primary:hover:not(:disabled) { background: #4d7ff0; border-color: #4d7ff0; }
.btn-ghost { background: none; border-color: transparent; color: var(--muted); padding: 5px 8px; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-danger { color: var(--danger); }

input, select, textarea {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 7px 10px; border-radius: 8px; font: inherit; font-size: 13px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type=time] { width: auto; min-width: 92px; }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
.field { margin-bottom: 12px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 2px 7px; border-radius: 20px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  white-space: nowrap;
}
.badge-urgente { background: rgba(248,81,73,.15); color: #ff8b82; border-color: rgba(248,81,73,.3); }
.badge-alta { background: rgba(210,153,34,.15); color: #e3b341; border-color: rgba(210,153,34,.3); }
.badge-media { background: rgba(91,140,255,.13); color: #7da2ff; border-color: rgba(91,140,255,.3); }
.badge-bassa { background: var(--surface-2); color: var(--faint); }
.badge-ok { background: rgba(63,185,80,.15); color: #56d364; border-color: rgba(63,185,80,.3); }
.badge-warn { background: rgba(210,153,34,.15); color: #e3b341; border-color: rgba(210,153,34,.3); }
.badge-danger { background: rgba(248,81,73,.15); color: #ff8b82; border-color: rgba(248,81,73,.3); }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.empty { color: var(--faint); text-align: center; padding: 28px 12px; font-size: 13px; }
.spacer { height: 14px; }

/* ---------- lista task ---------- */
.task {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 10px 4px; border-bottom: 1px solid var(--border);
}
.task:last-child { border-bottom: none; }
.task-check {
  width: 17px; height: 17px; border-radius: 50%; border: 1.5px solid var(--faint);
  background: none; cursor: pointer; flex: none; margin-top: 2px; padding: 0;
  transition: border-color .12s, background .12s;
}
.task-check:hover { border-color: var(--ok); }
.task.done .task-check { background: var(--ok); border-color: var(--ok); }
.task.done .task-title { text-decoration: line-through; color: var(--faint); }
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 13.5px; }
.task-meta { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; align-items: center; }
.task-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.task:hover .task-actions { opacity: 1; }

/* ---------- timeline della giornata ---------- */
.timeline { display: flex; flex-direction: column; gap: 3px; }
.tl-block {
  display: grid; grid-template-columns: 104px 1fr; gap: 12px; align-items: center;
  padding: 9px 12px; border-radius: 8px; border-left: 3px solid var(--border);
  background: var(--surface-2);
}
.tl-block .tl-time { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.tl-task { border-left-color: var(--accent); }
.tl-shift { border-left-color: var(--shift); background: rgba(163,113,247,.08); }
.tl-event { border-left-color: var(--warn); background: rgba(210,153,34,.07); }
.tl-break { border-left-color: var(--faint); background: none; }
.tl-free {
  border-left-color: var(--ok); background: rgba(63,185,80,.05);
  border: 1px dashed rgba(63,185,80,.25); border-left: 3px solid var(--ok);
}
.tl-note { font-size: 11.5px; color: var(--faint); margin-top: 2px; }

/* ---------- griglia turni ---------- */
.shift-week { display: flex; flex-direction: column; gap: 6px; }
.shift-day {
  display: grid; grid-template-columns: 132px 1fr auto; gap: 12px;
  align-items: center; padding: 9px 12px; background: var(--surface-2);
  border-radius: 8px; border: 1px solid transparent;
}
.shift-day.has-shift { border-color: rgba(163,113,247,.3); }
.shift-day.weekend .shift-label { color: var(--faint); }
.shift-label { font-size: 13px; }
.shift-label small { display: block; color: var(--faint); font-size: 11px; }
.shift-slots { display: flex; flex-direction: column; gap: 6px; }
.shift-slot { display: flex; align-items: center; gap: 6px; }
.shift-slot span { color: var(--faint); font-size: 12px; }

/* ---------- selettore orario a rotella ---------- */
.timefield {
  font-family: var(--mono); font-size: 13px; padding: 6px 11px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; cursor: pointer; min-width: 74px; text-align: center;
}
.timefield:hover { border-color: var(--accent); }
.timefield.empty { color: var(--faint); }

.wheel-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 60;
  display: grid; place-items: center; padding: 20px;
}
.wheel-pop {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; width: 100%; max-width: 280px;
}
.wheel-title { font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 12px; }
.wheels {
  position: relative; display: flex; align-items: stretch; justify-content: center;
  gap: 2px; height: 180px;
}
/* Banda centrale che indica il valore scelto */
.wheels::after {
  content: ''; position: absolute; left: 0; right: 0; top: 72px; height: 36px;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  background: rgba(91,140,255,.07); border-radius: 6px; pointer-events: none;
}
.wheel {
  flex: 1; overflow-y: scroll; scroll-snap-type: y mandatory;
  padding: 72px 0; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.wheel::-webkit-scrollbar { display: none; }
.wheel-item {
  height: 36px; scroll-snap-align: center; display: grid; place-items: center;
  font-family: var(--mono); font-size: 19px; color: var(--faint);
  transition: color .12s, transform .12s;
}
.wheel-item.sel { color: var(--text); transform: scale(1.06); }
.wheel-sep {
  display: grid; place-items: center; font-size: 19px; color: var(--muted);
  font-family: var(--mono); width: 12px;
}
.wheel-actions { display: flex; gap: 8px; margin-top: 14px; }
.wheel-actions .btn { flex: 1; }

/* ---------- pause dentro il turno ---------- */
.break-row {
  display: flex; align-items: center; gap: 6px; margin-left: 18px;
  padding-left: 10px; border-left: 2px solid var(--border);
}
.break-row .lbl { font-size: 11.5px; color: var(--faint); min-width: 44px; }

/* ---------- calendario mensile dei turni ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--faint); text-align: center; padding-bottom: 2px;
}
.cal-day {
  background: var(--surface-2); border: 1px solid transparent; border-radius: 8px;
  padding: 7px 8px; min-height: 80px; display: flex; flex-direction: column; gap: 3px;
  cursor: pointer; transition: border-color .12s;
}
.cal-day:hover { border-color: var(--accent); }
.cal-day.out { opacity: .3; }
.cal-day.has-shift { background: rgba(163,113,247,.08); border-color: rgba(163,113,247,.3); }
.cal-day.today { box-shadow: 0 0 0 1px var(--accent) inset; }
.cal-day .n { font-size: 12px; font-weight: 600; color: var(--muted); }
.cal-day.unknown .n::after { content: ' ?'; color: var(--warn); }
.cal-day .t { font-family: var(--mono); font-size: 10.5px; color: var(--text); line-height: 1.35; }
.cal-day .h { margin-top: auto; font-size: 10.5px; color: var(--ok); }
.cal-day .rest { font-size: 10.5px; color: var(--faint); }

.week-rows { display: flex; flex-direction: column; gap: 2px; }
.week-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center;
  padding: 7px 10px; border-radius: 7px; font-size: 12.5px;
}
.week-row:hover { background: var(--surface-2); }

/* ---------- chat ---------- */
.chat-wrap { display: grid; grid-template-columns: 220px 1fr; gap: 14px; height: calc(100vh - 150px); }
.chat-list { overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.chat-list-item {
  padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 12.5px;
  color: var(--muted); border: 1px solid transparent;
}
.chat-list-item:hover { background: var(--surface-2); color: var(--text); }
.chat-list-item.active { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.chat-list-item small { display: block; color: var(--faint); font-size: 11px; }

.chat-panel { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.chat-messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; max-width: 84%; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }
.msg-bubble { padding: 10px 13px; border-radius: 12px; background: var(--surface-2); white-space: pre-wrap; word-break: break-word; font-size: 13.5px; }
.msg-user .msg-bubble { background: var(--accent-dim); }
.msg-error .msg-bubble { background: rgba(248,81,73,.12); color: #ff8b82; }
.msg-avatar {
  width: 26px; height: 26px; border-radius: 50%; flex: none; font-size: 11px;
  display: grid; place-items: center; background: var(--surface-2); color: var(--muted);
}
.msg-user .msg-avatar { background: var(--accent); color: #fff; }
.chat-input { border-top: 1px solid var(--border); padding: 12px; display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea { min-height: 40px; max-height: 160px; }
.typing { display: inline-flex; gap: 3px; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: blink 1.4s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25 } 30% { opacity: 1 } }

/* ---------- vari ---------- */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.stat span { font-size: 11.5px; color: var(--muted); }

.banner {
  border-radius: var(--radius); padding: 11px 14px; font-size: 13px;
  border: 1px solid; display: flex; gap: 10px; align-items: flex-start; margin-bottom: 14px;
}
.banner-warn { background: rgba(210,153,34,.08); border-color: rgba(210,153,34,.35); color: #e3b341; }
.banner-danger { background: rgba(248,81,73,.08); border-color: rgba(248,81,73,.35); color: #ff8b82; }
.banner code { background: rgba(0,0,0,.35); padding: 1px 5px; border-radius: 4px; font-family: var(--mono); font-size: 12px; color: var(--text); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); padding: 0 8px 8px; font-weight: 500; }
td { padding: 9px 8px; border-top: 1px solid var(--border); vertical-align: top; }
tr:hover td { background: rgba(255,255,255,.015); }

.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50;
  display: grid; place-items: center; padding: 20px;
}
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto; }
.modal h2 { margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 16px; border-radius: 8px; z-index: 100; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.toast-error { border-color: rgba(248,81,73,.5); color: #ff8b82; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 340px; }
.login-card .brand { justify-content: center; padding-bottom: 22px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; overflow-x: auto;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .brand, .nav-spacer { display: none; }
  .nav-item { width: auto; white-space: nowrap; }
  .main { padding: 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .chat-wrap { grid-template-columns: 1fr; height: auto; }
  .chat-list { flex-direction: row; overflow-x: auto; }
  .chat-messages { min-height: 50vh; }
  .tl-block { grid-template-columns: 92px 1fr; }
  .shift-day { grid-template-columns: 1fr; gap: 8px; }
}
