html[data-theme="dark"] {
  --dk-bg: #0d1117;
  --dk-input: #0d1117;
  --dk-surface: #151b23;
  --dk-surface-2: #1b222c;
  --dk-surface-3: #232b36;
  --dk-border: #2b323c;
  --dk-border-strong: #3d4550;
  --dk-text: #d1d7e0;
  --dk-text-strong: #f0f6fc;
  --dk-text-muted: #9198a1;
  --dk-placeholder: #5c6670;
  --dk-link: #4fa8f0;
  --dk-link-hover: #79bdf5;
  --dk-accent: #139acb;
  --dk-focus-ring: rgba(19, 154, 203, 0.25);
  color-scheme: dark;
}

html[data-theme="dark"] body {
  background: var(--dk-bg);
  isolation: isolate;
  color: var(--dk-text);
}

html[data-theme="dark"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: url('/assets/img/farfalla_sfondo.svg') right center no-repeat, url('/assets/img/background.svg') bottom no-repeat;
  opacity: 0.1;
  pointer-events: none;
}

html[data-theme="dark"][data-iframe] body::before {
  content: none;
}

html[data-theme="dark"][data-iframe] body {
  background: var(--dk-surface);
}

html[data-theme="dark"] .glass,
html[data-theme="dark"] .login-container > div > div {
  background: color-mix(in srgb, var(--dk-surface) 55%, transparent) !important;
  border-color: var(--dk-border) !important;
  border-bottom-color: #139acb !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55) !important;
  color: var(--dk-text);
}

html[data-theme="dark"][data-iframe] .glass {
  background: transparent !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .card-img-top,
html[data-theme="dark"] img[src*="utente_login_icon"] {
  filter: invert(1) hue-rotate(180deg);
}

html[data-theme="dark"] .text-dark,
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6,
html[data-theme="dark"] label {
  color: var(--dk-text-strong) !important;
}

html[data-theme="dark"] .text-gray,
html[data-theme="dark"] .text-muted,
html[data-theme="dark"] .text-secondary {
  color: var(--dk-text-muted) !important;
}

html[data-theme="dark"] hr {
  border-color: var(--dk-border) !important;
}

html[data-theme="dark"] hr[style*="#b9b9bb"] {
  background: var(--dk-border) !important;
}

html[data-theme="dark"] a {
  color: var(--dk-link);
}

html[data-theme="dark"] a:hover {
  color: var(--dk-link-hover);
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .custom-select {
  background-color: var(--dk-input);
  border-color: var(--dk-border-strong);
  color: var(--dk-text-strong);
}

html[data-theme="dark"] .form-control:focus {
  background-color: var(--dk-input);
  border-color: var(--dk-accent);
  box-shadow: 0 0 0 0.15rem var(--dk-focus-ring);
  color: var(--dk-text-strong);
}

html[data-theme="dark"] .form-control::placeholder {
  color: var(--dk-placeholder);
}

html[data-theme="dark"] .form-control:disabled,
html[data-theme="dark"] .form-control[readonly] {
  background-color: var(--dk-surface-3);
  color: var(--dk-text-muted);
}

html[data-theme="dark"] .input-group-text {
  background-color: var(--dk-surface-3);
  border-color: var(--dk-border-strong);
  color: var(--dk-text);
}

html[data-theme="dark"] .login-img,
html[data-theme="dark"] .input-group-text img {
  filter: invert(1) grayscale(100%) brightness(1.4) !important;
}

html[data-theme="dark"] .inp-g:has(input:not(:placeholder-shown)) img,
html[data-theme="dark"] .inp-g:focus-within img {
  filter: none !important;
}

html[data-theme="dark"] .alert-success {
  background-color: rgba(0, 173, 164, 0.15);
  border-color: rgba(0, 173, 164, 0.4);
  color: #7fd8d2;
}

html[data-theme="dark"] .alert-danger {
  background-color: rgba(237, 85, 101, 0.15);
  border-color: rgba(237, 85, 101, 0.4);
  color: #f4a1aa;
}

html[data-theme="dark"] .alert-warning {
  background-color: rgba(248, 172, 89, 0.15);
  border-color: rgba(248, 172, 89, 0.4);
  color: #f5c78f;
}

html[data-theme="dark"] .alert-info {
  background-color: rgba(35, 198, 200, 0.15);
  border-color: rgba(35, 198, 200, 0.4);
  color: #8ee0e1;
}

html[data-theme="dark"] .close {
  color: var(--dk-text-strong);
  text-shadow: none;
}

html[data-theme="dark"][data-palette="right"] {
  --dk-bg: #0b1020;
  --dk-input: rgba(4, 7, 18, 0.45);
  --dk-surface: rgba(255, 255, 255, 0.06);
  --dk-surface-2: rgba(255, 255, 255, 0.08);
  --dk-surface-3: rgba(255, 255, 255, 0.11);
  --dk-border: rgba(255, 255, 255, 0.1);
  --dk-border-strong: rgba(255, 255, 255, 0.18);
  --dk-text: #e2e8f4;
  --dk-text-strong: #f8fafc;
  --dk-text-muted: #a3aec4;
  --dk-placeholder: #6b7690;
  --dk-link: #6cc4ff;
  --dk-link-hover: #9ad7ff;
}

html[data-theme="dark"][data-palette="right"] body {
  background:
    radial-gradient(circle at 10% 15%, rgba(0, 173, 164, 0.14), transparent 45%),
    radial-gradient(circle at 90% 85%, rgba(61, 156, 239, 0.12), transparent 50%),
    #0b1020;
  background-attachment: fixed;
}

html[data-theme="dark"][data-palette="right"] .glass,
html[data-theme="dark"][data-palette="right"] .login-container > div > div {
  background: rgba(20, 27, 44, 0.7) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  border-bottom-color: #139acb !important;
  backdrop-filter: blur(12px) saturate(130%) !important;
}
