/*
 * Copyright (c) 2026 Leonardo Marchi. Tutti i diritti riservati.
 * Coerenza cromatica e contrasto del tema moderno desktop.
 */

body:not(.theme-classic) {
  --modern-canvas: #0b1220;
  --modern-surface: #111b2d;
  --modern-surface-raised: #16233a;
  --modern-surface-input: #0d1727;
  --modern-line: rgba(126, 166, 235, 0.3);
  --modern-line-strong: rgba(126, 166, 235, 0.54);
  --modern-text: #eef4ff;
  --modern-muted: #b2c2de;
  --modern-hover: #1b3150;
  --modern-active: #24466f;
}

body:not(.theme-classic) :is(
  .panel,
  .anagrafiche,
  .anag-card,
  .dashboard-panel,
  .mezzi-card
) {
  color: var(--modern-text);
}

body:not(.theme-classic) :is(
  .modal-note,
  .cell-helper-text,
  .muted,
  .settings-note,
  .agenda-week-meta,
  .agenda-item-text,
  .agenda-item-owner,
  .agenda-item-deadline,
  .ingressi-day-empty,
  .ingressi-card-field-label,
  .ingressi-cer-desc,
  .mezzi-scadenza-note,
  .mezzi-scadenza-meta,
  .mini-table td small
) {
  color: var(--modern-muted);
}

/* Omologhe in scadenza: segnala l'allerta senza spezzare la continuita del tema scuro. */
body:not(.theme-classic) section[data-panel="omologhe"] .data-table tr.omologhe-expired-row td,
body:not(.theme-classic) section[data-panel="omologhe"] .data-table td.omologhe-expired-cell {
  background: #131e31 !important;
  border-color: rgba(237, 100, 119, 0.5);
  color: var(--modern-text);
}

body:not(.theme-classic) section[data-panel="omologhe"] .data-table tr.omologhe-expired-row td:first-child {
  box-shadow: inset 4px 0 0 #ed6477;
}

body:not(.theme-classic) section[data-panel="omologhe"] .data-table tr.omologhe-expired-row .cell-input {
  background: var(--modern-surface-input) !important;
  border-color: rgba(237, 100, 119, 0.45) !important;
  color: var(--modern-text) !important;
}

body:not(.theme-classic) section[data-panel="omologhe"] .data-table td.omologhe-expired-cell .cell-input {
  background: #2a1d2a !important;
  border-color: #ed6477 !important;
}

body:not(.theme-classic) section[data-panel="omologhe"] .data-table tr.omologhe-expired-row .cell-input::placeholder {
  color: #b9c8e1;
}

body:not(.theme-classic) section[data-panel="omologhe"] .data-table tr.omologhe-expired-row .cell-input:focus {
  box-shadow: inset 0 0 0 1px #ff9aaa;
}

body:not(.theme-classic) :is(input, textarea)::placeholder {
  color: #a9bbd9 !important;
  opacity: 1;
}

body:not(.theme-classic) :is(
  .search,
  .date-input,
  .anag-form input,
  .anag-form textarea,
  .anag-form select,
  .modal-grid input,
  .modal-grid textarea,
  .modal-grid select,
  .users-form input,
  .users-form select,
  .dashboard-notes
) {
  border-color: var(--modern-line);
  background-color: var(--modern-surface-input);
  color: var(--modern-text);
  caret-color: var(--accent);
}

body:not(.theme-classic) :is(.cell-input, .cell-select, .status-select) {
  border-color: var(--modern-line);
  color: var(--modern-text);
  caret-color: var(--accent);
}

body:not(.theme-classic) :is(
  .search,
  .date-input,
  .cell-input,
  .cell-select,
  .status-select,
  .anag-form input,
  .anag-form textarea,
  .anag-form select,
  .modal-grid input,
  .modal-grid textarea,
  .modal-grid select,
  .users-form input,
  .users-form select
):focus {
  border-color: #6fa5ff;
  outline: 2px solid rgba(79, 140, 255, 0.2);
  outline-offset: 0;
  box-shadow: none;
}

body:not(.theme-classic) :is(input, textarea, select):disabled,
body:not(.theme-classic) :is(input, textarea)[readonly] {
  color: #c0cce0;
  opacity: 0.88;
}

body:not(.theme-classic) :is(
  select,
  .cell-select,
  .cell-combo-select,
  .anag-form select,
  .modal-grid select,
  .users-form select,
  .ingressi-color-select
) option {
  background: #111b2d;
  color: #eef4ff;
}

body:not(.theme-classic) .cell-combo-select {
  border-left-color: var(--modern-line);
  background: #17253d;
  color: var(--modern-text);
}

body:not(.theme-classic) .cell-combo-select:hover,
body:not(.theme-classic) .cell-combo-select:focus-visible {
  background: #203657;
  color: #ffffff;
  outline: none;
}

body:not(.theme-classic) .cell-combo-menu {
  border-color: var(--modern-line-strong);
  background: #0d1727;
  box-shadow: 0 18px 38px rgba(2, 8, 20, 0.52);
}

body:not(.theme-classic) .cell-combo-item {
  border-bottom-color: rgba(126, 166, 235, 0.18);
  background: transparent;
  color: #e6efff;
}

body:not(.theme-classic) .cell-combo-item:hover,
body:not(.theme-classic) .cell-combo-item:focus {
  background: var(--modern-hover);
  color: #ffffff;
  outline: none;
}

body:not(.theme-classic) .cell-combo-item.is-active {
  background: var(--modern-active);
  color: #ffffff;
  box-shadow: inset 3px 0 0 var(--accent);
}

body:not(.theme-classic) .cell-combo-item-hint {
  color: var(--modern-muted);
  background: #101b2e;
}

body:not(.theme-classic) .viaggio-producer-site-header {
  border-bottom-color: var(--modern-line);
  background: #16233a;
  color: #c1d1eb;
}

body:not(.theme-classic) .viaggio-producer-site-item,
body:not(.theme-classic) .viaggio-producer-site-combo .cell-combo-menu {
  background: #0d1727;
}

body:not(.theme-classic) .viaggio-producer-site-item.is-active {
  background: var(--modern-active);
}

body:not(.theme-classic) .viaggio-context-menu {
  border-color: var(--modern-line-strong);
  background: #0d1727;
  box-shadow: 0 18px 38px rgba(2, 8, 20, 0.52);
}

body:not(.theme-classic) .viaggio-context-menu-item {
  border-bottom-color: rgba(126, 166, 235, 0.18);
  color: #e6efff;
}

body:not(.theme-classic) .viaggio-context-menu-item:hover,
body:not(.theme-classic) .viaggio-context-menu-item:focus {
  background: var(--modern-active);
  color: #ffffff;
}

body:not(.theme-classic) .datebox {
  border-color: var(--modern-line);
  background: #111b2d;
}

body:not(.theme-classic) .datebox :is(span, .date-label) {
  background: #1a2b47;
  color: #eef4ff;
}

body:not(.theme-classic) :is(.table-wrap, .mini-table-wrap) {
  border-color: rgba(126, 166, 235, 0.24);
  background: rgba(8, 14, 27, 0.46);
}

body:not(.theme-classic) :is(.data-table, .mini-table) th {
  border-color: rgba(126, 166, 235, 0.22);
  background: #172640;
  color: #d8e7ff;
}

body:not(.theme-classic) :is(.data-table, .mini-table) td {
  border-color: rgba(126, 166, 235, 0.16);
  color: #e9f1ff;
}

body:not(.theme-classic) :is(.data-table, .mini-table) tbody tr:hover td {
  background-color: rgba(79, 140, 255, 0.1);
}

/* Le note mantengono il significato cromatico rosso senza perdere contrasto sul fondo scuro. */
body:not(.theme-classic) section[data-panel="viaggio"] .data-table td.note-cell .cell-input {
  color: #ff9aaa !important;
}

body:not(.theme-classic) :is(.modal-card, .agenda-warning-card, .chat-file-card) {
  border-color: var(--modern-line);
  background: #111b2d;
  color: var(--modern-text);
}

body:not(.theme-classic) :is(.modal-card, .agenda-warning-card, .chat-file-card) h3,
body:not(.theme-classic) :is(.modal-card, .agenda-warning-card, .chat-file-card) h4,
body:not(.theme-classic) :is(.modal-card, .agenda-warning-card, .chat-file-card) label {
  color: var(--modern-text);
}

body:not(.theme-classic) .agenda-warning-dialog:not(.chat-forward-dialog) .agenda-warning-card {
  border-color: rgba(255, 112, 133, 0.4);
  background: #111b2d;
}

body:not(.theme-classic) .agenda-warning-dialog:not(.chat-forward-dialog) .agenda-warning-head {
  border-bottom-color: rgba(255, 112, 133, 0.22);
  background: #16233a;
}

body:not(.theme-classic) .agenda-warning-dialog:not(.chat-forward-dialog) .agenda-warning-head h3,
body:not(.theme-classic) .agenda-warning-dialog:not(.chat-forward-dialog) .agenda-warning-head h4 {
  color: #ff9aaa;
}

body:not(.theme-classic) .agenda-warning-dialog:not(.chat-forward-dialog) .agenda-warning-message {
  color: #e4edfc;
}

body:not(.theme-classic) .agenda-warning-dialog:not(.chat-forward-dialog) .agenda-warning-actions {
  background: #0d1727;
}

body:not(.theme-classic) .agenda-warning-dialog:not(.chat-forward-dialog) .agenda-warning-actions .btn-alt {
  border-color: var(--modern-line);
  background: #17253d;
  color: var(--modern-text);
}

body:not(.theme-classic) .agenda-warning-dialog:not(.chat-forward-dialog) .agenda-warning-actions .btn-danger {
  border-color: #c84d64;
  background: #8f3045;
  color: #ffffff;
}

/* Rubrica: la versione moderna non deve ereditare le superfici chiare del modulo Agenda. */
body:not(.theme-classic) .agenda-rubrica-view {
  border-color: var(--modern-line);
  border-radius: 8px;
  background: var(--modern-canvas);
  color: var(--modern-text);
}

body:not(.theme-classic) .agenda-rubrica-head {
  border-bottom-color: var(--modern-line);
}

body:not(.theme-classic) .agenda-rubrica-head h3 {
  color: var(--modern-text);
}

body:not(.theme-classic) .agenda-rubrica-head p {
  color: var(--modern-muted);
}

body:not(.theme-classic) .agenda-rubrica-form {
  border-color: var(--modern-line);
  border-radius: 8px;
  background: var(--modern-surface);
}

body:not(.theme-classic) .agenda-rubrica-form label {
  color: #d9e6fa;
}

body:not(.theme-classic) .agenda-rubrica-form .cell-input {
  border-color: var(--modern-line);
  background: var(--modern-surface-input);
  color: var(--modern-text);
}

body:not(.theme-classic) .agenda-rubrica-form .cell-input::placeholder {
  color: #a9bbd9;
}

body:not(.theme-classic) .agenda-rubrica-card {
  border-color: var(--modern-line);
  border-radius: 8px;
  background: var(--modern-surface);
}

body:not(.theme-classic) .agenda-rubrica-card-main strong {
  color: var(--modern-text);
}

body:not(.theme-classic) :is(
  .agenda-rubrica-card-main span,
  .agenda-rubrica-card-contacts span,
  .agenda-rubrica-card-contacts a
) {
  color: #c7d7ef;
}

body:not(.theme-classic) .agenda-rubrica-card-contacts .muted {
  color: var(--modern-muted);
}

body:not(.theme-classic) .agenda-rubrica-empty {
  border-color: var(--modern-line);
  border-radius: 8px;
  background: var(--modern-surface-input);
  color: var(--modern-muted);
}

/* Ingressi: campi e card devono restare leggibili anche con i colori categoria. */
body:not(.theme-classic) section[data-panel="ingressi"] .ingressi-day-col {
  border-color: rgba(126, 166, 235, 0.2);
  background: #09111f;
}

body:not(.theme-classic) section[data-panel="ingressi"] .ingressi-card {
  border-color: rgba(126, 166, 235, 0.34);
  background-color: #152137 !important;
  color: var(--modern-text);
  box-shadow: 0 6px 14px rgba(2, 8, 20, 0.3);
}

body:not(.theme-classic) section[data-panel="ingressi"] .ingressi-card:hover,
body:not(.theme-classic) section[data-panel="ingressi"] .ingressi-card:focus-within {
  border-color: rgba(126, 166, 235, 0.62);
  background-color: #1a2a45 !important;
}

body:not(.theme-classic) section[data-panel="ingressi"] .ingressi-card.is-completed {
  opacity: 0.82;
}

body:not(.theme-classic) section[data-panel="ingressi"] .ingressi-card :is(.cell-input, .cell-select) {
  border-color: rgba(126, 166, 235, 0.28);
  background-color: #0d1727;
  color: #eef4ff;
  opacity: 1;
}

body:not(.theme-classic) section[data-panel="ingressi"] :is(
  .ingressi-card-field-label,
  .ingressi-cer-desc,
  .ingressi-card small
) {
  color: #b8c8e3;
}

body:not(.theme-classic) section[data-panel="ingressi"] .ingressi-day-empty {
  border-color: rgba(126, 166, 235, 0.24);
  background: rgba(17, 27, 45, 0.72);
  color: #aebfda;
}

body:not(.theme-classic) .ingressi-color-select {
  border-color: var(--modern-line);
  background: var(--modern-surface-input);
  color: var(--modern-text);
}

body:not(.theme-classic) .ingressi-color-manager {
  border-color: var(--modern-line);
  background: #0d1727;
}

body:not(.theme-classic) .ingressi-color-manager-item {
  border-color: var(--modern-line);
  background: #111b2d;
}

body:not(.theme-classic) .ingressi-color-manager :is(.cell-input, input[readonly]) {
  border-color: var(--modern-line);
  background: #0b1423;
  color: var(--modern-text);
  opacity: 1;
}

body:not(.theme-classic) .ingressi-color-manager small {
  color: var(--modern-muted);
}

body:not(.theme-classic) input[type="checkbox"],
body:not(.theme-classic) input[type="radio"] {
  accent-color: #4f8cff;
}

body:not(.theme-classic) :focus-visible {
  outline-color: #79aaff;
}
