/* Campanella delle notifiche, log attività e sezioni email delle Impostazioni. Usa i token di app.css (temi chiaro e scuro). */

/* ---- Campanella (web/js/notifications.js) ------------------------------------------------------------------ */

/* Il contenitore della barra in alto (#notifications) centra la campanella nell'altezza della barra. */
.topbar-slot:has(> .notif) { display: flex; align-items: center; flex: none; min-height: 46px; }
.notif { position: relative; flex: none; align-self: center; margin: 0 6px 0 12px; }
.notif-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
}
.notif-bell:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.notif-bell[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }
.notif-bell svg { width: 20px; height: 20px; }
.notif-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--info);
  color: var(--surface);
  font-size: 11px;
  font-weight: 700;
  line-height: 19px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--surface);
}
.notif-badge[hidden] { display: none; }
.notif-badge.danger { background: var(--danger); }
.notif-badge.warn { background: var(--warn); }

.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: min(440px, calc(100vw - 24px));
  max-height: min(72vh, 640px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.18);
}
.notif-panel[hidden] { display: none; }
.notif-panel:focus { outline: none; }
.notif-panel:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.notif-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.notif-head h2 { margin: 0; font-size: 15px; }
.notif-head .notif-count { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.notif-head .spacer { flex: 1; }
.notif-close { width: 30px; height: 30px; padding: 0; justify-content: center; border: none; background: none; color: var(--muted); font-size: 20px; line-height: 1; }
.notif-body { overflow-y: auto; padding: 2px 0 8px; overscroll-behavior: contain; }
.notif-empty { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 28px 18px; color: var(--muted); text-align: center; }
.notif-body .alert { margin: 10px 14px 0; }
.notif-group-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 12px 14px 4px;
  color: var(--faint);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-item { --tone: var(--border); display: flex; align-items: flex-start; border-left: 3px solid var(--tone); }
.notif-item.tone-danger { --tone: var(--danger); }
.notif-item.tone-warn { --tone: var(--warn); }
.notif-item.tone-orange { --tone: var(--orange); }
.notif-item.tone-accent { --tone: var(--accent); }
.notif-item.tone-info { --tone: var(--info); }
.notif-item.tone-purple { --tone: var(--purple); }
.notif-item.tone-teal { --tone: var(--teal); }
.notif-item.tone-slate { --tone: var(--slate); }
.notif-item.tone-ok { --tone: var(--ok); }
.notif-item.read .notif-link { opacity: 0.72; }
.notif-link { display: block; flex: 1; min-width: 0; padding: 8px 6px 8px 11px; color: var(--text); }
.notif-link:hover { background: var(--surface-2); text-decoration: none; }
.notif-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.notif-title { display: flex; align-items: baseline; gap: 6px; font-weight: 450; overflow-wrap: anywhere; }
.notif-item.unread .notif-title { font-weight: 650; }
.notif-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--tone); transform: translateY(-1px); }
.notif-item.read .notif-dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--border); }
.notif-text { margin-top: 2px; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.notif-date { margin-top: 2px; color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.notif-item.tone-danger .notif-date { color: var(--danger); }
.notif-toggle { flex: none; align-self: center; width: 30px; height: 30px; margin-right: 8px; padding: 0; justify-content: center; border: none; background: none; color: var(--faint); border-radius: 50%; }
.notif-toggle:hover:not(:disabled) { color: var(--accent); background: var(--surface-2); }
.notif-toggle svg { width: 16px; height: 16px; }
.notif-more { margin: 8px 14px 0; color: var(--muted); font-size: 12.5px; }

:root[data-theme="dark"] .notif-panel { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .notif-panel { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); }
}
/* Telefono: il pannello occupa la larghezza dello schermo, sotto la barra del menu. */
@media (max-width: 760px) {
  .notif { margin-left: 4px; }
  .notif-panel { position: fixed; top: 64px; right: 12px; left: 12px; width: auto; max-height: calc(100vh - 80px); }
}

/* ---- Log attività (web/js/views/activity-log.js, activity-log-detail.js) ------------------------------------- */

.log-filters.card { padding: 14px 16px; margin-bottom: 14px; }
.log-filters .period-picker { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
.log-filters .period-card { padding: 7px 10px; }
.log-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); align-items: end; gap: 10px 12px; margin-top: 12px; }
.log-grid input, .log-grid select { width: 100%; height: 36px; }
.log-cell { min-width: 0; }
.log-cell.w-3 { grid-column: span 3; }
.log-cell.w-2 { grid-column: span 2; }
@media (max-width: 1100px) {
  .log-cell.w-3 { grid-column: span 4; }
  .log-cell.w-2 { grid-column: span 4; }
}
@media (max-width: 760px) {
  .log-cell.w-3, .log-cell.w-2 { grid-column: span 6; }
}
@media (max-width: 480px) {
  .log-cell.w-3, .log-cell.w-2 { grid-column: 1 / -1; }
}
.log-active { margin-top: 12px; align-items: center; }
.log-active:empty { display: none; }
.log-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; margin: 14px 0 8px; font-variant-numeric: tabular-nums; }
.log-summary:empty { display: none; }
.log-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.log-pager:empty { display: none; }
.log-note { margin: 8px 0 0; }

.log-table .data-table td { vertical-align: top; }
.log-table .data-table td, .log-table .data-table th { padding: 7px 10px; }
.log-time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.log-sub { display: block; color: var(--faint); font-size: 12px; overflow-wrap: anywhere; }
.log-sub.error { color: var(--danger); }
.log-event { font-family: var(--mono); font-size: 12.5px; font-weight: 600; overflow-wrap: anywhere; }
.log-method { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--muted); }
.log-route { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.log-clip { display: block; max-width: 30ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-table tr.log-denied td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.log-table tr.log-failed td:first-child { box-shadow: inset 3px 0 0 var(--orange); }
.log-table tr.log-error td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
@media (max-width: 760px) {
  .log-table .data-table .col-opt { display: none; }
}

.log-detail { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 0 18px; align-items: start; }
.log-detail > .card { margin-bottom: 18px; min-width: 0; }
.log-detail > .card.wide { grid-column: 1 / -1; }
.log-detail .kv { grid-template-columns: minmax(8em, max-content) minmax(0, 1fr); margin: 0; }
.log-detail .kv dd .mono { overflow-wrap: anywhere; }
.log-links { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 4px; font-size: 12.5px; }
.log-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.log-back { display: inline-block; margin-bottom: 10px; font-size: 13px; }
.log-payload + .log-payload { margin-top: 14px; }
.log-payload h3 { display: flex; align-items: center; gap: 8px; }
pre.log-pre { white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2; max-height: 420px; }
@media (max-width: 640px) {
  .log-detail .kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .log-detail .kv dt { margin-top: 8px; font-size: 12px; }
}

/* ---- Impostazioni: email e posta in uscita --------------------------------------------------------------------- */

.mail-source { margin-bottom: 12px; }
.mail-source p { margin: 0; }
.mail-test { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.mail-result { min-height: 1.4em; font-size: 13px; overflow-wrap: anywhere; }
.mail-result .badge { margin-right: 6px; }
.form-grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.outbox-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 14px; margin-bottom: 12px; }
.outbox-table .data-table td { vertical-align: top; }
.outbox-table .data-table td, .outbox-table .data-table th { padding: 7px 10px; }
.outbox-table details summary { color: var(--text); font-weight: 450; padding: 0; }
.outbox-table details[open] summary { margin-bottom: 6px; }
.outbox-error { display: block; margin-top: 2px; color: var(--danger); font-size: 12px; overflow-wrap: anywhere; }
.outbox-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
