/*
 * Tema grafico 2026-10: si applica sopra styles.css, solo CSS (markup e logica invariati).
 * Per tornare alla grafica precedente basta rimuovere il <link> a theme.css in index.html.
 */
:root {
  --ink: #142033;
  --ink-2: #33415a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --surface: #ffffff;
  --soft: #f8fafc;
  --canvas: #f3f5f8;
  --brand: #e3a92f;
  --brand-2: #c48a17;
  --brand-ink: #3d2a05;
  --brand-soft: #fdf6e7;
  --danger: #c0262d;
  --warning: #b45309;
  --ok: #16794a;
  --info: #2457a6;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(20, 32, 51, 0.05);
  --shadow-lg: 0 18px 48px rgba(20, 32, 51, 0.16);
  --focus: 0 0 0 3px rgba(227, 169, 47, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

/* Tipografia */
h1 {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.25;
}
h2 {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
h3 {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}
.muted { color: var(--muted); }
.topbar { margin-bottom: 24px; align-items: flex-end; }
.topbar p { margin-bottom: 0; }

/* Barra laterale chiara: il logo resta sui suoi colori, senza riquadro bianco */
.shell { grid-template-columns: 248px 1fr; }
.sidebar {
  background: var(--surface);
  color: var(--ink);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  gap: 26px;
}
.sidebar .brand { padding: 0 8px; }
.sidebar-logo {
  width: 150px;
  padding: 0;
  border-radius: 0;
  background: transparent;
}
.brand-payoff {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.nav { gap: 2px; }
.nav button,
.ghost {
  min-height: 38px;
  border-radius: var(--radius-sm);
  padding: 0 12px;
  color: var(--ink-2);
  font-weight: 500;
  position: relative;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav button:hover,
.ghost:hover {
  background: var(--soft);
  color: var(--ink);
}
.nav button.active {
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-weight: 600;
}
.nav button.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 3px;
  background: var(--brand);
}
.session {
  padding: 14px 8px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.brand span,
.session small,
.hint { color: var(--muted); }
.session .ghost {
  border: 1px solid var(--line);
  text-align: center;
}

.main {
  padding: 32px 36px;
  max-width: 1440px;
}

/* Superfici */
.panel {
  border-color: var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.panel > h2:first-child,
.panel > .split:first-child h2,
.panel > .toolbar:first-child h2 { margin-bottom: 14px; }
.grid { gap: 18px; }

.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat > span { order: -1; }
.stat > small { font-size: 12px; margin-top: -2px; }
.stat-link {
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.stat-link:hover,
.stat-link:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 6px 18px rgba(20, 32, 51, 0.08);
}
.panel > .split:first-child { justify-content: space-between; margin-bottom: 14px; }
.panel > .split:first-child h2 { margin: 0; }
.stat strong {
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.stat span {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Pulsanti: un'azione primaria in giallo, il resto neutro */
.button {
  min-height: 38px;
  border-radius: var(--radius-sm);
  padding: 0 14px;
  background: var(--brand);
  color: var(--brand-ink);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid var(--brand);
  box-shadow: 0 1px 1px rgba(20, 32, 51, 0.06);
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}
.button:hover {
  background: var(--brand-2);
  border-color: var(--brand-2);
  color: #fff;
}
.button.secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink-2);
}
.button.secondary:hover {
  background: var(--soft);
  border-color: #94a3b8;
  color: var(--ink);
}
.button.danger {
  background: var(--surface);
  border-color: #f1c4c6;
  color: var(--danger);
}
.button.danger:hover {
  background: #fdf1f1;
  border-color: var(--danger);
}
.button:focus-visible,
.nav button:focus-visible,
.ghost:focus-visible,
.text-button:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.text-button { color: var(--brand-2); font-weight: 600; }

/* Gruppi di azioni nelle schede: compatti e allineati */
.split > div { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.machine-card .split .button,
.document-actions .button,
.clinic-contacts .button,
.machine-photo .button,
.ticket-card .button {
  min-height: 32px;
  padding: 0 11px;
  font-size: 12.5px;
}
.topbar .button { min-height: 38px; }
.topbar > div:last-child:not(:first-child) { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

/* Campi */
.field label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--muted);
}
input,
select,
textarea {
  min-height: 38px;
  border-color: var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-size: 14px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input:hover,
select:hover,
textarea:hover { border-color: #94a3b8; }
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus);
}
input::placeholder,
textarea::placeholder { color: #94a3b8; }

/* Badge: piu piccoli, con pallino di stato */
.badge {
  min-height: 22px;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 11.5px;
  font-weight: 600;
  gap: 6px;
  border: 1px solid transparent;
}
.badge.ok,
.badge.warn,
.badge.danger { padding-left: 7px; }
.badge.ok::before,
.badge.warn::before,
.badge.danger::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge.ok { background: #ecf8f1; color: var(--ok); border-color: #c9ebd8; }
.badge.warn { background: #fff7e8; color: var(--warning); border-color: #f8dfae; }
.badge.danger { background: #fdf0f0; color: var(--danger); border-color: #f5cfd1; }
.badge.info { background: var(--soft); color: var(--ink-2); border-color: var(--line); }
.meta { gap: 6px; }

/* Liste macchine e ticket: righe pulite invece di riquadri pesanti */
.machine-list,
.ticket-list { gap: 10px; }
.machine-card,
.ticket-card {
  border-color: var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.machine-card.is-clickable:hover,
.machine-card.is-clickable:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 6px 18px rgba(20, 32, 51, 0.08);
}
.machine-card h3 { margin-bottom: 2px; }
.machine-card p.muted { font-size: 13px; margin-bottom: 0; }
.ticket-card.ticket-unread {
  border-left: 3px solid var(--brand);
  background: var(--surface);
}
.machine-photo { width: 112px; min-width: 112px; gap: 6px; }
.machine-photo img,
.machine-photo span { height: 84px; border-radius: var(--radius-sm); }
.machine-photo img { border-color: var(--line); }
.machine-photo .fallback-logo {
  border: 1px solid var(--line);
  background: var(--soft);
  padding: 22px;
  opacity: 0.55;
  filter: grayscale(1);
}
.machine-photo span { border-color: var(--line-strong); }

/* Documenti */
.documents { border-top-color: var(--line); margin-top: 16px; padding-top: 14px; }
.documents-head h3 { margin-bottom: 0; }
.document-item {
  min-height: 54px;
  border-color: var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.doc-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: #fdf0f0;
  color: var(--danger);
  font-size: 10px;
  letter-spacing: 0.03em;
}
.document-empty {
  border-color: var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--soft);
  font-size: 13px;
}
.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

/* Cliniche */
.clinic-card {
  border-color: var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.clinic-card.has-service { border-left: 3px solid var(--danger); }
.clinic-overview { gap: 12px; }
article.clinic-card { padding: 18px 20px; }
article.clinic-card h2 { margin-bottom: 2px; }
.clinic-contact-list { margin-bottom: 0; }
.clinic-contacts strong { font-size: 12px; color: var(--muted); font-weight: 600; }
.badge:empty { display: none; }
.clinic-summary { min-height: 68px; }
.clinic-summary:hover { background: var(--soft); }
.clinic-summary h2 { font-size: 15.5px; }
.clinic-contact-list,
.mini-row {
  border-color: var(--line);
  border-radius: var(--radius-sm);
  background: var(--soft);
}
.mini-machine-link:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  transform: none;
}
.mini-open-label { color: var(--brand-2); font-weight: 600; }

/* Conversazioni ticket */
.ai-response {
  border-left: 3px solid var(--info);
  border-radius: var(--radius-sm);
  background: #f1f5fb;
}
.ticket-reply {
  border-left: 3px solid var(--info);
  border-radius: var(--radius-sm);
  background: #f1f5fb;
}
.ticket-reply-clinic {
  border-left-color: var(--brand);
  background: var(--brand-soft);
}
.otp-box {
  border-radius: var(--radius-sm);
  background: #f1f5fb;
  border-color: #d3dff0;
  color: var(--info);
}

/* Tabelle */
th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--soft);
}
th,
td { border-bottom-color: var(--line); padding: 11px 12px; }
tbody tr:hover td { background: #fbfcfd; }

/* Accesso e pagina pubblica QR */
.login-page {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(227, 169, 47, 0.16), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(36, 87, 166, 0.10), transparent 60%),
    var(--canvas);
}
.public-assist { background: var(--canvas); }
.login-panel,
.public-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
}
.login-panel .brand-logo { width: 190px; }
.login-panel h1 { margin-top: 22px; }
.login-panel .button,
.public-card .button { min-height: 42px; }

/* Finestre modali */
.modal {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}
.modal .panel {
  border-radius: 14px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

.toast {
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}

@media (max-width: 940px) {
  .shell { grid-template-columns: 1fr; }
  /* In alto, non fissa: su telefono non deve coprire meta schermo durante lo scorrimento */
  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px 16px;
    gap: 10px 12px;
  }
  .sidebar .brand { padding: 0; }
  .sidebar-logo { width: 120px; }
  .sidebar .brand-payoff { display: none; }
  .nav {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0 -16px;
    padding: 2px 16px;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav button {
    flex: 0 0 auto;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0 14px;
    background: var(--surface);
  }
  .nav button.active { border-color: #f0d79e; }
  .nav button.active::before { display: none; }
  .session {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 0;
    border: 0;
  }
  .session > div { display: none; }
  .session .ghost { min-height: 32px; padding: 0 12px; }
  .main { padding: 24px 20px; }
}

@media (max-width: 620px) {
  .main { padding: 18px 16px; }
  h1 { font-size: 21px; }
  .topbar { align-items: stretch; margin-bottom: 18px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .grid > * { grid-column: 1 / -1; }
  .grid > .stat { grid-column: span 1; padding: 14px; }
  .stat strong { font-size: 24px; }
  .stat span { font-size: 10.5px; }
  .split > div { justify-content: stretch; }
  /* In colonna la base flessibile di 320px diventerebbe altezza: i campi filtro restano compatti */
  .filterbar .search-field { flex: 0 0 auto; }
  .filterbar .filters { flex-direction: column; }
  .filterbar .filters .field { width: 100%; }
  .machine-photo { width: 100%; min-width: 0; }
  .machine-photo img,
  .machine-photo span { height: 180px; }
  .login-panel,
  .public-card { padding: 24px 20px; }
}

/* MyPetClinic 2026-11-13: colori del logo (azzurro #22abe2, blu #206387) al posto del giallo VetPartners */
:root {
  --brand: #22abe2;
  --brand-2: #206387;
  --brand-ink: #174d69;
  --brand-soft: #e8f6fc;
  --focus: 0 0 0 3px rgba(34, 171, 226, 0.28);
}
.button { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.button:hover { background: #174d69; border-color: #174d69; color: #fff; }
.sidebar-logo { width: 190px; }
.login-panel .brand-logo { width: 240px; }
.login-page {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(34, 171, 226, 0.16), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(32, 99, 135, 0.12), transparent 60%),
    var(--canvas);
}
@media (max-width: 940px) {
  .sidebar-logo { width: 150px; }
  .nav button.active { border-color: #b5e2f5; }
}
