/* RegistraAllaLista - Bootstrap Italia design system overlay
 * WCAG 2.2 compliant
 */

:root {
  --primary-color: #003882;
  --primary-hover: #002d6b;
  --secondary-color: #4a6691;
  /* Scurito per contrasto 4.5:1 su bianco */
  --bg-page: #f4f5f7;
  --bg-card: #ffffff;
  --text-main: #17324d;
  --text-muted: #495057;
  /* Scurito a 7.4:1 su bianco — WCAG 2.2 AAA 1.4.6 */
  --accent-color: #ff9900;
  --focus-color: #ff9900;
  /* Usato per outline focus — contrasto AAA su sfondo bianco e blu */
}

/* Fix for JQuery UI hidden accessible text that might overflow */
.ui-helper-hidden-accessible {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}

body.it-page-wrapper {
  background-color: var(--bg-page);
  font-family: 'Titillium Web', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* --- Legacy resets --- */
.RAFloatClear,
.RARow1px {
  display: none !important;
}

[class*="col-xs-"],
[class*="col-sm-"],
[class*="col-md-"],
[class*="col-lg-"] {
  float: none;
}

/* --- Header --- */
.it-header-center-wrapper {
  background-color: var(--primary-color);
  color: #fff;
  padding: 1.5rem 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
}

.it-header-center-content {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.it-brand-title {
  color: #fff !important;
  font-weight: 700;
  font-size: 1.5rem;
  margin: 0;
  text-decoration: none;
}

/* --- Main content container --- */
#main-content {
  max-width: 960px;
  margin: 0 auto;
  background: var(--bg-card);
  padding: 2.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 56, 130, 0.05);
}

/* --- Typography --- */
h1 {
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 1.5rem;
}

.CorpoPagina {
  font-size: 1.125rem;
  margin-bottom: 2rem;
}

/* --- Form elements --- */
.form-group {
  position: relative;
  margin-bottom: 2rem;
}

.form-label {
  color: var(--text-main);
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: block;
}

.form-group {
  margin-bottom: 2rem;
  position: relative;
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
}

/* Label statica sopra l'input — più chiara e accessibile del floating label
   Force static position and vertical flow to avoid overlap issues with Bootstrap Italia JS. */
.form-group .form-label,
.form-group .form-label.active,
.form-group label,
.form-group label.active {
  position: static !important;
  transform: none !important;
  color: var(--text-main);
  font-weight: 600;
  margin-bottom: 0.5rem !important;
  /* Spazio tra label e input */
  display: block !important;
  font-size: 0.95rem;
  opacity: 1 !important;
  width: auto !important;
  order: -1 !important;
  /* Forza la label ad apparire prima dell'input */
  transition: none !important;
  pointer-events: auto !important;
}

.form-group .form-control {
  width: 100%;
}

.input-group {
  display: flex;
  gap: 1rem;
  margin: 1rem 0;
}

.form-control {
  border: 2px solid var(--secondary-color);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  width: 100%;
  color: var(--text-main);
  background-color: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:disabled {
  background-color: #f0f0f0;
  border-color: #ccc;
  color: #555;
  cursor: not-allowed;
}

.form-control:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 56, 130, 0.2);
  /* WCAG 2.2 AAA 2.4.13: outline visibile, non rimosso */
  outline: 3px solid var(--focus-color);
  outline-offset: 2px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  padding: 0.75rem 1.5rem;
  /* WCAG 2.2 AAA 2.5.5: target minimo 44×44px */
  min-height: 44px;
  min-width: 44px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, transform 0.1s;
  font-size: 1rem;
  border: 2px solid transparent;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background-color: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 0 0 3px rgba(255, 153, 0, 0.4);
  /* WCAG 2.2 AAA 2.4.13: focus ring obbligatorio */
  outline: 3px solid var(--focus-color);
  outline-offset: 2px;
}

.btn-primary:active {
  background-color: #001d4a;
}

.btn-outline-secondary {
  background-color: transparent;
  color: var(--primary-color);
  border-color: var(--primary-color);
  /* Usiamo colore più scuro per contrasto */
}

.btn-outline-secondary:hover {
  background-color: #f0f5ff;
  border-color: var(--primary-hover);
  color: var(--primary-hover);
}

.btn-danger {
  background-color: #c00;
  color: #fff;
  border-color: #c00;
}

.btn-danger:hover {
  background-color: #a00;
  border-color: #a00;
}

/* Grouping buttons */
.it-button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 2rem;
}

/* --- Radio & Checkbox --- */
.form-check {
  /* Rimozione display: flex per evitare conflitti con i pseudo-elementi di Bootstrap Italia */
  margin-bottom: 0.5rem;
  cursor: pointer;
  position: relative;
  min-height: 44px;
  /* WCAG 2.2 AAA 2.5.5 */
  padding-left: 2.5rem;
  /* Spazio per il custom check di Bootstrap */
  display: block;
}

input[type="radio"].form-check-input,
input[type="checkbox"].form-check-input {
  /* Quando hanno la classe di Bootstrap, devono essere invisibili
     perché Bootstrap usa ::before/::after sulla label. */
  opacity: 0 !important;
  position: absolute !important;
  margin: 0 !important;
  z-index: -1 !important;
  width: 1px !important;
  /* Ridotto per non occupare spazio */
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
}

input[type="radio"]:not(.form-check-input),
input[type="checkbox"]:not(.form-check-input) {
  width: 1.25rem !important;
  height: 1.25rem !important;
  accent-color: var(--primary-color) !important;
  cursor: pointer !important;
  outline-offset: 2px !important;
}

input[type="radio"]:focus,
input[type="checkbox"]:focus {
  outline: 3px solid var(--focus-color);
  outline-offset: 2px;
}

/* Area di click ampliata per soddisfare 44×44px (2.5.5 AAA) */
.form-check label.form-check-label {
  padding-top: 5px;
  /* Allineamento verticale con il box custom */
  display: inline-block;
  cursor: pointer;
}

/* --- Privacy container --- */
.privacy-box {
  border: 1px solid var(--secondary-color);
  border-radius: 4px;
  padding: 1rem;
  background: #fdfdfd;
  margin-bottom: 1.5rem;
}

/* --- Footer --- */
.it-footer {
  margin-top: 4rem;
  padding: 2rem 0;
  border-top: 1px solid #e0e0e0;
  font-size: 0.875rem;
  color: #666;
}

.it-footer a {
  color: var(--primary-color);
  text-decoration: underline;
}

/* --- reCAPTCHA wrapper --- */
.captcha-container {
  margin: 2rem 0;
}

/* --- Autocomplete visibility and accessibility --- */
.ui-autocomplete {
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  margin: 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--secondary-color);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 56, 130, 0.15);
  z-index: 1050;
  /* Above modals if any */
}

.ui-autocomplete .ui-menu-item {
  padding: 0;
  margin: 0;
  border-bottom: 1px solid #f0f0f0;
}

.ui-autocomplete .ui-menu-item:last-child {
  border-bottom: none;
}

.ui-autocomplete .ui-menu-item-wrapper {
  padding: 0.75rem 1rem;
  cursor: pointer;
  display: block;
  font-size: 1rem;
  color: var(--text-main);
  transition: background-color 0.2s;
}

.ui-autocomplete .ui-menu-item-wrapper.ui-state-active {
  background-color: #f0f5ff;
  color: var(--primary-color);
  border: none;
  margin: 0;
  font-weight: 600;
}

/* --- Accessibility skip link --- */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary-color);
  color: #fff;
  padding: 8px;
  z-index: 9999;
  font-size: 1rem;
  border-radius: 0 0 4px 0;
  text-decoration: none;
}

.skip-link:focus {
  top: 0;
}

/* --- Inline style replacements --- */
.fw-bold {
  font-weight: bold !important;
}

.text-info-msg {
  font-family: sans-serif;
  font-size: 1.125rem;
  text-align: left;
  margin-top: 3.125rem;
  position: relative;
}

.text-desc-list {
  margin-right: 1.25rem;
  font-family: sans-serif;
  font-size: 0.825rem;
}

.text-label-bold {
  margin-top: 3.125rem;
  font-family: sans-serif;
  font-weight: bold;
}

.privacy-iframe {
  font-size: 0.625rem;
  border: none;
}

.footer-info {
  text-align: left;
  font-size: 0.825rem;
}

.text-center {
  text-align: center !important;
}

.brand-logo-img {
  max-height: 50px;
}

.breadcrumb-custom {
  background: none;
  padding: 0;
  margin: 0;
  font-size: 0.9rem;
  list-style: none;
  display: flex;
  gap: 0.5rem;
}

.text-muted-dark {
  color: #495057 !important;
}

.hint-text {
  font-size: 0.875rem;
  color: #495057;
  margin-top: 0.25rem;
}

.pin-hint-header {
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}

.pin-hint-footer {
  font-size: 0.875rem;
  color: #495057;
}

/* --- Responsive adjustments --- */
@media (max-width: 768px) {
  #main-content {
    margin: 0 1rem;
    padding: 1.5rem;
  }

  .input-group {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}