html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

body.idle-sensitive-locking main {
  visibility: hidden;
}

.comune-crest-navbar {
  width: 2rem;
  height: 2rem;
  object-fit: contain;
}

.fastwaylive-logo-navbar {
  width: 11.5rem;
  height: 2rem;
  object-fit: contain;
}

.home-heading {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.comune-crest-home {
  width: 5rem;
  height: 5rem;
  object-fit: contain;
}

.auth-landing {
  display: flex;
  justify-content: center;
  padding: 4rem 1rem;
}

.auth-landing-card {
  width: min(100%, 28rem);
}

.auth-landing-logo {
  width: min(100%, 16rem);
  height: auto;
}

.app-navbar {
  margin-bottom: 0;
  padding-bottom: 0;
}

.navbar-nav .nav-item {
  margin-right: 0.15rem;
  display: flex;
  align-items: flex-end;
}

.navbar-nav .nav-link {
  margin: 0 0 -1px 0;
  padding: 0.45rem 0.9rem;
  border: 1px solid #b8c7d9;
  border-bottom: 0;
  border-radius: 0.45rem 0.45rem 0 0;
  background: #eef3f9;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.85);
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link:focus {
  border-color: #6ea8fe;
  background: #fff;
  color: #0d6efd !important;
}

.navbar-nav .nav-link.active {
  position: relative;
  z-index: 1;
  border-color: #0d6efd;
  border-bottom-color: #fff;
  background: #fff;
  color: #0d6efd !important;
  box-shadow: inset 0 3px 0 #0d6efd;
  font-weight: 600;
}

.night-mode-nav-item {
  align-items: center !important;
  margin: 0 0.35rem 0 0.2rem !important;
}

.night-mode-button {
  display: inline-flex;
  width: 2.35rem;
  height: 2.35rem;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--theme-border, #b8c7d9);
  border-radius: 50%;
  color: var(--theme-primary, #0d6efd);
  background: var(--theme-surface-alt, #eef3f9);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.night-mode-button:hover,
.night-mode-button:focus-visible {
  border-color: var(--theme-primary, #0d6efd);
  background: var(--theme-surface, #fff);
  transform: translateY(-1px);
  outline: 0;
  box-shadow: 0 0 0 0.2rem rgba(var(--theme-primary-rgb, 13, 110, 253), 0.2);
}

.legacy-section {
  display: flex;
  border: 1px solid #b8c7d9;
  background: #fff;
}

.legacy-section-title {
  width: 2.5rem;
  padding: 1rem 0.45rem;
  color: #fff;
  background: #9fb8d4;
  font-weight: 600;
  letter-spacing: 0.05rem;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-align: center;
}

.legacy-section-body {
  flex: 1;
  min-width: 0;
  padding: 1.25rem;
}

.legacy-required {
  background-color: #fffde1;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.95);
  border-top: 1px solid #dee2e6;
}

.photo-review-image {
  display: block;
  width: 100%;
  height: min(70vh, 760px);
  object-fit: contain;
}

.photo-decision {
  padding: 1rem;
  border: 1px solid #ced4da;
  background: #f8f9fa;
}

.verbale-photo-thumb {
  display: block;
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  background: #f8f9fa;
  text-align: center;
}

.verbale-photo-thumb img {
  display: block;
  width: 100%;
  height: 12rem;
  object-fit: contain;
  margin-bottom: 0.5rem;
  background: #111827;
}

.verbale-photo-thumb span {
  color: #0d6efd;
  font-weight: 600;
}

.verbale-photo-fullscreen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 4.5rem);
}

.verbale-photo-fullscreen img {
  max-width: 100%;
  max-height: calc(100vh - 6rem);
  object-fit: contain;
}

.verbale-photo-pdf {
  width: 100%;
  height: calc(100vh - 6rem);
  border: 0;
  background: #fff;
}

.verbale-events-list {
  max-height: 11rem;
  overflow-y: auto;
  border: 1px solid #dee2e6;
}

.verbale-events-list thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8f9fa;
}

.permissions-scroll {
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
}

.permissions-table {
  min-width: 1100px;
  margin-bottom: 0;
}

.permissions-table th,
.permissions-table td {
  white-space: nowrap;
}

.permissions-collapse-toggle {
  color: inherit;
  font-weight: 700;
  text-decoration: none;
}

.permissions-collapse-toggle:hover,
.permissions-collapse-toggle:focus {
  color: inherit;
  text-decoration: underline;
}

.permissions-collapse-toggle[aria-expanded="false"] .permissions-collapse-icon {
  display: inline-block;
  transform: rotate(-90deg);
}

.permissions-collapse-icon {
  display: inline-block;
  width: 1rem;
  transition: transform 0.15s ease-in-out;
}

.user-config-link {
  color: #0d6efd;
  text-decoration: none;
}

.user-config-link:hover,
.user-config-link:focus {
  color: #0a58ca;
  text-decoration: underline;
}

.config-comune-tabs {
  row-gap: 0.15rem;
}

.config-comune-tabs .nav-link {
  padding: 0.4rem 0.85rem;
  border-color: #c8d3df #c8d3df #dee2e6;
  border-radius: 0.35rem 0.35rem 0 0;
  background: #f4f6f8;
  color: #111827;
}

.config-comune-tabs .nav-link.active {
  border-bottom-color: #fff;
  background: #fff;
  font-weight: 600;
}

.config-comune-tab-content {
  padding: 1rem;
  border: 1px solid #dee2e6;
  border-top: 0;
  background: #fff;
}

.config-field-card {
  border-color: #d7dee8;
}

@media (max-width: 767.98px) {
  .legacy-section {
    display: block;
  }

  .legacy-section-title {
    width: auto;
    padding: 0.5rem 1rem;
    writing-mode: horizontal-tb;
    transform: none;
    text-align: left;
  }
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* Temi globali FastWayLive */
.general-settings-form {
  display: grid;
  gap: 1.25rem;
}

.settings-section {
  padding: 1rem;
  border: 1px solid var(--theme-border, #d7dee8);
  border-radius: 0.5rem;
  background: var(--theme-surface-alt, #f7f9fb);
}

.settings-section-title {
  margin: 0 0 1rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--theme-border, #d7dee8);
  font-size: 1rem;
  font-weight: 700;
  color: var(--theme-text, #172b3f);
}

.settings-actions {
  display: grid;
  grid-template-columns: minmax(12rem, 24rem) 1fr;
  gap: 1rem;
  align-items: center;
}

.settings-actions .btn {
  width: 100%;
}

body[data-theme="civic-blue"] {
  --theme-page: #f3f7fb;
  --theme-surface: #ffffff;
  --theme-surface-alt: #eaf1f8;
  --theme-text: #172b3f;
  --theme-muted: #62758a;
  --theme-border: #b8c9da;
  --theme-primary: #1f5f99;
  --theme-primary-hover: #174a78;
  --theme-primary-rgb: 31, 95, 153;
  --theme-accent: #c62828;
  --theme-shadow: 0 0.25rem 0.85rem rgba(28, 69, 105, 0.1);
}

body[data-theme="road-safety"] {
  --theme-page: #f5f3ef;
  --theme-surface: #fffdf9;
  --theme-surface-alt: #e9e6df;
  --theme-text: #242424;
  --theme-muted: #68625b;
  --theme-border: #bdb7ae;
  --theme-primary: #b42318;
  --theme-primary-hover: #891b13;
  --theme-primary-rgb: 180, 35, 24;
  --theme-accent: #2d3338;
  --theme-shadow: 0 0.25rem 0.85rem rgba(43, 39, 35, 0.12);
}

body[data-theme="operations-center"] {
  --theme-page: #07141f;
  --theme-surface: #0d2233;
  --theme-surface-alt: #133147;
  --theme-text: #eaf6ff;
  --theme-muted: #a2bbcc;
  --theme-border: #31536b;
  --theme-primary: #28b7f5;
  --theme-primary-hover: #64ccf8;
  --theme-primary-rgb: 40, 183, 245;
  --theme-accent: #54d6a0;
  --theme-shadow: 0 0 0.9rem rgba(40, 183, 245, 0.12);
  color-scheme: dark;
}

body[data-theme="high-visibility"] {
  --theme-page: #f1f2e9;
  --theme-surface: #ffffff;
  --theme-surface-alt: #fff4a8;
  --theme-text: #172027;
  --theme-muted: #4d5961;
  --theme-border: #263238;
  --theme-primary: #263238;
  --theme-primary-hover: #11181c;
  --theme-primary-rgb: 38, 50, 56;
  --theme-accent: #f4cf20;
  --theme-shadow: 0.25rem 0.25rem 0 #f4cf20;
}

body[data-night-mode="true"] {
  --theme-page: #071018;
  --theme-surface: #101d27;
  --theme-surface-alt: #182a37;
  --theme-text: #edf5f9;
  --theme-muted: #a9bbc7;
  --theme-border: #3b5363;
  --theme-shadow: 0 0.35rem 1rem rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

body[data-theme="civic-blue"][data-night-mode="true"] {
  --theme-primary: #6bb8f3;
  --theme-primary-hover: #9bd2fb;
  --theme-primary-rgb: 107, 184, 243;
  --theme-accent: #ff6d6d;
}

body[data-theme="road-safety"][data-night-mode="true"] {
  --theme-primary: #ed665b;
  --theme-primary-hover: #ff9189;
  --theme-primary-rgb: 237, 102, 91;
}

body[data-theme="high-visibility"][data-night-mode="true"] {
  --theme-primary: #f4cf20;
  --theme-primary-hover: #ffe56e;
  --theme-primary-rgb: 244, 207, 32;
}

body[data-theme] {
  --bs-body-bg: var(--theme-page);
  --bs-body-color: var(--theme-text);
  --bs-primary: var(--theme-primary);
  --bs-primary-rgb: var(--theme-primary-rgb);
  min-height: 100vh;
  color: var(--theme-text);
  background-color: var(--theme-page);
}

body[data-theme] a {
  color: var(--theme-primary);
}

body[data-theme] a:hover {
  color: var(--theme-primary-hover);
}

body[data-theme] .app-navbar {
  border-color: var(--theme-border) !important;
  background: var(--theme-surface) !important;
  box-shadow: var(--theme-shadow);
}

body[data-theme] .navbar-nav .nav-link {
  border-color: var(--theme-border);
  color: var(--theme-text) !important;
  background: var(--theme-surface-alt);
  box-shadow: none;
}

body[data-theme] .navbar-nav .nav-link:hover,
body[data-theme] .navbar-nav .nav-link:focus {
  border-color: var(--theme-primary);
  color: var(--theme-primary) !important;
  background: var(--theme-surface);
}

body[data-theme] .navbar-nav .nav-link.active {
  border-color: var(--theme-primary);
  border-bottom-color: var(--theme-surface);
  color: var(--theme-primary) !important;
  background: var(--theme-surface);
  box-shadow: inset 0 3px 0 var(--theme-accent);
}

body[data-theme] .navbar-toggler {
  border-color: var(--theme-border);
  background-color: #fff;
}

body[data-theme] .card,
body[data-theme] .modal-content,
body[data-theme] .dropdown-menu,
body[data-theme] .legacy-section,
body[data-theme] .config-comune-tab-content {
  border-color: var(--theme-border);
  color: var(--theme-text);
  background: var(--theme-surface);
  box-shadow: var(--theme-shadow);
}

body[data-theme] .card-header,
body[data-theme] .modal-header,
body[data-theme] .modal-footer {
  border-color: var(--theme-border);
  color: var(--theme-text);
  background: var(--theme-surface-alt);
}

body[data-theme] .text-muted,
body[data-theme] .form-text {
  color: var(--theme-muted) !important;
}

body[data-theme] .form-control,
body[data-theme] .form-select,
body[data-theme] .input-group-text {
  border-color: var(--theme-border);
  color: var(--theme-text);
  background-color: var(--theme-surface);
}

body[data-theme] .form-control:focus,
body[data-theme] .form-select:focus,
body[data-theme] .form-check-input:focus {
  border-color: var(--theme-primary);
  box-shadow: 0 0 0 0.2rem rgba(var(--theme-primary-rgb), 0.22);
}

body[data-theme] .form-check-input:checked {
  border-color: var(--theme-primary);
  background-color: var(--theme-primary);
}

body[data-theme] .night-mode-toggle {
  min-height: 4.4rem;
  padding: 0.75rem 0.75rem 0.75rem 3.25rem;
  border: 1px solid var(--theme-border);
  border-radius: 0.4rem;
  background: var(--theme-surface-alt);
}

body[data-theme] .night-mode-toggle .form-check-input {
  margin-left: -2.5rem;
}

body[data-theme] .btn-primary {
  border-color: var(--theme-primary);
  color: #fff;
  background-color: var(--theme-primary);
}

body[data-theme="operations-center"] .btn-primary {
  color: #07141f;
}

body[data-night-mode="true"] .btn-primary,
body[data-night-mode="true"] .btn-outline-primary:hover,
body[data-night-mode="true"] .btn-outline-primary:focus {
  color: #071018;
}

body[data-theme="road-safety"][data-night-mode="true"] .btn-primary {
  color: #fff;
}

body[data-theme] .btn-primary:hover,
body[data-theme] .btn-primary:focus {
  border-color: var(--theme-primary-hover);
  background-color: var(--theme-primary-hover);
}

body[data-theme] .btn-outline-primary {
  border-color: var(--theme-primary);
  color: var(--theme-primary);
}

body[data-theme] .btn-outline-primary:hover,
body[data-theme] .btn-outline-primary:focus {
  border-color: var(--theme-primary);
  color: var(--theme-surface);
  background-color: var(--theme-primary);
}

body[data-theme] .btn-secondary,
body[data-theme] .btn-outline-secondary:hover {
  border-color: var(--theme-muted);
  color: var(--theme-surface);
  background-color: var(--theme-muted);
}

body[data-theme] .btn-outline-secondary {
  border-color: var(--theme-muted);
  color: var(--theme-muted);
}

body[data-theme] .table {
  --bs-table-color: var(--theme-text);
  --bs-table-bg: var(--theme-surface);
  --bs-table-border-color: var(--theme-border);
  --bs-table-striped-color: var(--theme-text);
  --bs-table-striped-bg: var(--theme-surface-alt);
  color: var(--theme-text);
}

body[data-theme] .table thead th,
body[data-theme] .verbale-events-list thead th {
  color: var(--theme-text);
  background: var(--theme-surface-alt);
}

body[data-night-mode="true"] .list-group-item,
body[data-night-mode="true"] .text-bg-light {
  border-color: var(--theme-border);
  color: var(--theme-text) !important;
  background: var(--theme-surface-alt) !important;
}

body[data-theme] .footer {
  border-color: var(--theme-border) !important;
  color: var(--theme-muted) !important;
  background: var(--theme-surface);
}

body[data-theme] .legacy-section-title {
  background: var(--theme-primary);
}

body[data-theme] .sticky-actions,
body[data-theme] .photo-decision,
body[data-theme] .verbale-photo-thumb,
body[data-theme] .config-comune-tabs .nav-link {
  border-color: var(--theme-border);
  color: var(--theme-text);
  background: var(--theme-surface-alt);
}

body[data-theme] .config-comune-tabs .nav-link.active {
  border-bottom-color: var(--theme-surface);
  color: var(--theme-primary);
  background: var(--theme-surface);
}

body[data-theme="road-safety"] .app-navbar {
  border-top: 0.3rem solid var(--theme-primary) !important;
}

body[data-theme="road-safety"] .card,
body[data-theme="road-safety"] .btn,
body[data-theme="road-safety"] .form-control,
body[data-theme="road-safety"] .form-select {
  border-radius: 0.15rem;
}

body[data-theme="operations-center"] .app-navbar,
body[data-theme="operations-center"] .footer {
  background-image: linear-gradient(90deg, #0d2233, #102b40) !important;
}

body[data-theme="operations-center"] .card-header {
  border-left: 0.25rem solid var(--theme-accent);
}

body[data-theme="operations-center"] .alert-success {
  border-color: #28795d;
  color: #bdf5dc;
  background: #123d31;
}

body[data-theme="operations-center"] .alert-danger {
  border-color: #914a54;
  color: #ffd9de;
  background: #48232a;
}

body[data-theme="high-visibility"] .app-navbar {
  border-bottom: 0.25rem solid var(--theme-accent) !important;
}

body[data-theme="high-visibility"] .card,
body[data-theme="high-visibility"] .form-control,
body[data-theme="high-visibility"] .form-select,
body[data-theme="high-visibility"] .btn {
  border-width: 2px;
}

body[data-theme="high-visibility"] .navbar-nav .nav-link.active {
  box-shadow: inset 0 0.3rem 0 var(--theme-accent);
}

.theme-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.theme-preview {
  position: relative;
  display: grid;
  gap: 0.2rem;
  min-height: 6.5rem;
  padding: 0.75rem;
  overflow: hidden;
  border: 1px solid var(--preview-border);
  border-radius: 0.5rem;
  color: var(--preview-text);
  background: var(--preview-page);
}

.theme-choice {
  width: 100%;
  appearance: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.theme-choice:hover,
.theme-choice:focus-visible {
  transform: translateY(-2px);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(var(--theme-primary-rgb, 13, 110, 253), 0.28);
}

.theme-choice.is-selected {
  box-shadow: 0 0 0 3px var(--theme-primary, #0d6efd);
}

.theme-choice-status {
  display: none;
  position: absolute;
  right: 0.55rem;
  bottom: 0.5rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  color: var(--preview-page);
  background: var(--preview-primary);
  font-size: 0.72rem;
  font-weight: 700;
}

.theme-choice.is-selected .theme-choice-status {
  display: inline-block;
}

.theme-preview-bar {
  display: block;
  height: 1.15rem;
  margin: -0.75rem -0.75rem 0.45rem;
  background: linear-gradient(90deg, var(--preview-primary) 0 68%, var(--preview-accent) 68%);
}

.theme-preview small {
  color: var(--preview-muted);
}

.theme-preview-civic-blue {
  --preview-page: #f3f7fb;
  --preview-text: #172b3f;
  --preview-muted: #62758a;
  --preview-border: #b8c9da;
  --preview-primary: #1f5f99;
  --preview-accent: #c62828;
}

.theme-preview-road-safety {
  --preview-page: #fffdf9;
  --preview-text: #242424;
  --preview-muted: #68625b;
  --preview-border: #bdb7ae;
  --preview-primary: #b42318;
  --preview-accent: #2d3338;
}

.theme-preview-operations-center {
  --preview-page: #0d2233;
  --preview-text: #eaf6ff;
  --preview-muted: #a2bbcc;
  --preview-border: #31536b;
  --preview-primary: #28b7f5;
  --preview-accent: #54d6a0;
}

.theme-preview-high-visibility {
  --preview-page: #ffffff;
  --preview-text: #172027;
  --preview-muted: #4d5961;
  --preview-border: #263238;
  --preview-primary: #263238;
  --preview-accent: #f4cf20;
}

@media (max-width: 991.98px) {
  .theme-preview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 575.98px) {
  .theme-preview-grid {
    grid-template-columns: 1fr;
  }

  .settings-actions {
    grid-template-columns: 1fr;
  }
}
