@import url("tokens.css");

/* Material Design 3 — dark theme (tonal surfaces, no custom glow/stripe) */

*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

body.m3-body {
  margin: 0;
  min-height: 100%;
  font-family: var(--dwc-font);
  font-size: 14px;
  line-height: 1.43;
  letter-spacing: 0.009em;
  color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-surface);
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }

/* —— Top app bar (full width, own surface — does not overlap main) —— */
.m3-top-app-bar {
  flex-shrink: 0;
  width: 100%;
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface);
}

.m3-top-app-bar__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  min-height: 64px;
}

.m3-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  font-size: 16px;
  color: var(--md-sys-color-on-surface);
}

.m3-brand:hover { opacity: 0.88; }

.m3-brand__logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  object-fit: contain;
}

.m3-top-app-bar__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.m3-nav-link {
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  border-radius: var(--md-sys-shape-corner-full);
  transition: background 0.2s ease;
}

.m3-nav-link:hover {
  color: var(--md-sys-color-on-surface);
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
}

/* —— Main: centered column (not full-bleed content) —— */
.m3-main {
  flex: 1 1 auto;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 24px 32px;
}

.m3-main--narrow { max-width: 440px; }
.m3-main--wide { max-width: 1120px; }
.m3-main--dashboard { max-width: 640px; }

.m3-main--dashboard .m3-card {
  padding: 28px 32px 32px;
}

.m3-main--dashboard .m3-card__head {
  margin-bottom: 28px;
}

.m3-main--dashboard .m3-title-large {
  font-size: 24px;
  margin-bottom: 8px;
}

.m3-main--dashboard .m3-body-medium {
  font-size: 15px;
}

.dashboard-kpi {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
}

.dashboard-kpi .pill {
  padding: 10px 14px;
  font-size: 13px;
}

.dashboard-message {
  margin-bottom: 24px;
  padding: 16px 18px;
  line-height: 1.5;
}

.dashboard-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.dashboard-actions .btn {
  min-height: 44px;
  font-size: 14px;
}

/* —— Surface container card —— */
.m3-card {
  padding: 24px;
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  border-radius: var(--md-sys-shape-corner-large);
  border: none;
}

.m3-card--auth { margin-top: 8px; }

.m3-card__logo {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.m3-card__head { margin-bottom: 20px; }

.m3-title-large {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 400;
  line-height: 1.27;
  letter-spacing: 0;
}

.m3-body-medium {
  margin: 0;
  font-size: 14px;
  line-height: 1.43;
}

.m3-text-muted { color: var(--md-sys-color-on-surface-variant); }

/* Legacy class aliases (admin / vecchie pagine) */
.app-shell, .app-body, .page-shell { display: block; max-width: none; margin: 0; padding: 0; min-height: 0; }
.container { max-width: none; margin: 0; padding: 0; }
.card, .page-card {
  padding: 24px;
  background: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-corner-large);
  border: none;
  box-shadow: none;
}
.admin-status-root { margin-top: 0; }
.sub, .sub--flush {
  color: var(--md-sys-color-on-surface-variant);
  margin: 0 0 16px;
  line-height: 1.55;
}

/* —— Filled text field (M3) —— */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 16px 0;
}

.field--tight { margin-top: 0; }

.label {
  font-size: 12px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  letter-spacing: 0.04em;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
textarea,
select {
  width: 100%;
  min-height: 56px;
  padding: 8px 16px;
  font-size: 16px;
  font-family: inherit;
  color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-surface-container-highest);
  border: none;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-extra-small) var(--md-sys-shape-corner-extra-small) 0 0;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

textarea {
  min-height: 120px;
  border-radius: var(--md-sys-shape-corner-extra-small);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

input::placeholder,
textarea::placeholder {
  color: var(--md-sys-color-on-surface-variant);
  opacity: 0.7;
}

input:not([type="checkbox"]):not([type="radio"]):hover,
textarea:hover,
select:hover {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 4%, var(--md-sys-color-surface-container-highest));
}

input:not([type="checkbox"]):not([type="radio"]):focus,
textarea:focus,
select:focus {
  border-bottom-width: 2px;
  border-bottom-color: var(--md-sys-color-primary);
  padding-bottom: 7px;
}

/* —— Auth form (login) —— */
.auth-form .field { margin: 12px 0; }

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.auth-actions__links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.btn--block {
  width: 100%;
  min-height: 48px;
}

.btn--text {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--md-sys-color-primary);
  background: transparent;
}

.btn--text:hover {
  background: color-mix(in srgb, var(--md-sys-color-primary) 10%, transparent);
}

/* —— Buttons —— */
.btnrow, .btnrow--spaced {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 20px;
}

.btnrow--spaced { margin-top: 24px; }

.tabbed-admin .btnrow {
  margin-top: 16px;
  padding-top: 8px;
}

.tabbed-admin .btnrow .btn.primary {
  order: -1;
}

.btn,
.m3-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  letter-spacing: 0.01em;
  color: var(--md-sys-color-primary);
  background: transparent;
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn:hover,
.m3-btn:hover {
  background: color-mix(in srgb, var(--md-sys-color-primary) 8%, transparent);
}

.btn.primary,
.m3-btn--filled {
  color: var(--md-sys-color-on-primary);
  background: var(--md-sys-color-primary);
}

.btn.primary:hover,
.m3-btn--filled:hover {
  filter: brightness(1.08);
  background: var(--md-sys-color-primary);
}

.m3-btn--compact {
  min-height: 32px;
  padding: 6px 16px;
  font-size: 13px;
}

.btn.danger {
  color: var(--md-sys-color-on-error);
  background: var(--md-sys-color-error);
}

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

/* —— Banners (M3) —— */
.m3-banner,
.alert {
  padding: 12px 16px;
  margin: 0 0 16px;
  border-radius: var(--md-sys-shape-corner-small);
  font-size: 14px;
  line-height: 1.43;
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
}

.m3-banner--success, .alert.success {
  background: color-mix(in srgb, var(--md-sys-color-tertiary) 24%, var(--md-sys-color-surface-container-high));
}

.m3-banner--error, .alert.danger {
  background: color-mix(in srgb, var(--md-sys-color-error) 20%, var(--md-sys-color-surface-container-high));
}

.m3-banner--info, .alert.info {
  background: color-mix(in srgb, var(--md-sys-color-primary) 16%, var(--md-sys-color-surface-container-high));
}

.alert--spaced { margin-top: 16px; }

/* —— Chips —— */
.kpi { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

.pill, .tag, .m3-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-small);
  border: none;
}

.tag.online {
  color: var(--md-sys-color-on-tertiary);
  background: color-mix(in srgb, var(--md-sys-color-tertiary) 32%, var(--md-sys-color-surface-container-high));
}

.tag.offline {
  color: var(--md-sys-color-on-error);
  background: color-mix(in srgb, var(--md-sys-color-error) 24%, var(--md-sys-color-surface-container-high));
}

/* —— Tables —— */
.tablewrap {
  overflow: auto;
  margin-top: 12px;
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-surface-container-high);
}

.table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.table th {
  font-size: 12px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
}

.table tbody tr:hover td {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 4%, transparent);
}

.muted { color: var(--md-sys-color-on-surface-variant); }

.m3-footer, .site-footer, .footer {
  flex-shrink: 0;
  padding: 16px 24px 24px;
  text-align: center;
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
}

.m3-footer p, .site-footer p { margin: 0; }

.section-title {
  margin: 20px 0 8px;
  font-size: 18px;
  font-weight: 500;
}

.tabbed-admin .tablist {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.tabbed-admin .tablist a.tab {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin: 0;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  text-decoration: none;
  cursor: pointer;
}

.tabbed-admin .tablist a.tab:hover {
  color: var(--md-sys-color-on-surface);
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 6%, transparent);
}

.tabbed-admin .tablist a.tab.is-active {
  color: var(--md-sys-color-primary);
  border-bottom-color: var(--md-sys-color-primary);
}

.tabbed-admin .tabpanel {
  display: none;
  padding-top: 20px;
}

.tabbed-admin .tabpanel--active {
  display: block;
}

.tabbed-admin .deps-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 20px;
}

.hint {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--md-sys-color-on-surface-variant);
}

.card--dashboard {
  margin-top: 20px;
}

.profile-form {
  margin-top: 8px;
}

.reg-form--disabled fieldset {
  opacity: 0.6;
  pointer-events: none;
}

.reg-form--disabled .btnrow a.btn { pointer-events: auto; opacity: 1; }

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 10px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
  color: var(--md-sys-color-on-surface-variant);
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 2px 0 0;
  padding: 0;
  flex-shrink: 0;
  accent-color: var(--md-sys-color-primary);
  border: none;
  border-radius: 2px;
  background: transparent;
  cursor: pointer;
}

.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 20px; }

@media (max-width: 600px) {
  .m3-top-app-bar__row { padding: 10px 16px; }
  .m3-main { padding: 16px; }
  .m3-card { padding: 20px 16px; }
  .m3-top-app-bar__actions { width: 100%; justify-content: flex-end; }
}

@media (max-width: 800px) {
  .tabbed-admin .deps-grid { grid-template-columns: 1fr; }
}
