/* ==========================================================================
   URP Whiletech - Portale Cittadino
   CSS override e integrazione con Bootstrap Italia v2.12.0
   ========================================================================== */

/* Fix: le floating labels di Bootstrap Italia richiedono un markup specifico
   ed entity lifecycle complesso. Le disabilitiamo e usiamo label statiche
   sopra l'input, che è sempre leggibile e accessibile. */

.form-group {
  margin-bottom: 1rem;
  position: relative;
}

.form-group label,
.form-group .form-label {
  position: static !important;
  display: block;
  transform: none !important;
  padding: 0 !important;
  margin-bottom: 0.4rem !important;
  font-size: 14px;
  font-weight: 600;
  color: #17324D;
  background: transparent !important;
  z-index: auto !important;
  line-height: 1.3 !important;
  opacity: 1 !important;
}

/* Input, select, textarea: reset degli stili floating + design pulito */
.form-group .form-control,
.form-group .form-select,
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="datetime-local"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
  border: 1px solid #d5d8dc;
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 15px;
  background: #fff;
  color: #17324D;
  height: auto;
  width: 100%;
  transition: border-color 0.15s;
}

.form-group .form-control:focus,
.form-group .form-select:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--bs-primary, #0066CC);
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.15);
}

.form-group textarea {
  min-height: 90px;
  resize: vertical;
}

.form-group .form-text {
  display: block;
  margin-top: 0.35rem;
  font-size: 12px;
  color: #5B6F82;
}

/* Input-group (es. search + button) */
.input-group .form-control {
  border-radius: 4px 0 0 4px;
}
.input-group .btn {
  border-radius: 0 4px 4px 0;
}

/* ==========================================================================
   Bottoni
   ========================================================================== */
.btn {
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 4px;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  border: 1px solid transparent;
}
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }

.btn-primary {
  background: var(--bs-primary, #0066CC);
  border-color: var(--bs-primary, #0066CC);
  color: #fff;
}
.btn-primary:hover, .btn-primary:focus {
  filter: brightness(0.9);
  color: #fff;
}

.btn-outline-primary {
  background: transparent;
  border-color: var(--bs-primary, #0066CC);
  color: var(--bs-primary, #0066CC);
}
.btn-outline-primary:hover {
  background: var(--bs-primary, #0066CC);
  color: #fff;
}

.btn-light {
  background: #fff;
  color: #17324D;
  border-color: #fff;
}
.btn-outline-light {
  background: transparent;
  border-color: #fff;
  color: #fff;
}
.btn-outline-light:hover {
  background: #fff;
  color: #17324D;
}

.btn-outline-secondary {
  background: transparent;
  border-color: #5B6F82;
  color: #5B6F82;
}

.btn:disabled, .btn.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ==========================================================================
   Navbar
   ========================================================================== */
.it-header-navbar-wrapper .nav-link {
  color: rgba(255,255,255,0.9);
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 3px solid transparent;
  transition: border-color 0.15s;
}
.it-header-navbar-wrapper .nav-link:hover {
  color: #fff;
  text-decoration: none;
}
.it-header-navbar-wrapper .nav-link.active {
  color: #fff;
  font-weight: 700;
  border-bottom-color: #fff;
}
.it-header-navbar-wrapper .navbar-nav {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  padding: 0;
  margin: 0;
}

/* ==========================================================================
   Breadcrumb
   ========================================================================== */
.breadcrumb {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  padding: 0;
  margin: 0;
}
.breadcrumb-item {
  font-size: 14px;
}
.breadcrumb-item + .breadcrumb-item::before {
  content: "/";
  color: #5B6F82;
  margin: 0 8px;
}
.breadcrumb-item a {
  text-decoration: none;
}
.breadcrumb-item a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Card e accordion
   ========================================================================== */
.card {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
}
.card-body {
  padding: 1.5rem;
}
.shadow-sm {
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.accordion-item {
  background: #fff;
  border-radius: 4px;
  overflow: hidden;
}
.accordion-button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 14px 18px;
  background: #fff;
  border: none;
  text-align: left;
  color: #17324D;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}
.accordion-button::after {
  content: '▼';
  font-size: 11px;
  margin-left: 10px;
  transition: transform 0.2s;
  color: #5B6F82;
}
.accordion-button.collapsed::after {
  transform: rotate(-90deg);
}
.accordion-button:hover {
  background: #f5f5f5;
}
.accordion-body {
  padding: 0 18px 18px;
  font-size: 14px;
  color: #5B6F82;
  line-height: 1.7;
  background: #fafafa;
}
.accordion-collapse:not(.show) { display: none; }

/* ==========================================================================
   Alert
   ========================================================================== */
.alert {
  padding: 12px 16px;
  border-radius: 4px;
  border: 1px solid transparent;
  margin-bottom: 1rem;
  font-size: 14px;
}
.alert-info {
  background: #E7F3FA;
  border-color: #90CAF9;
  color: #17324D;
}
.alert-success {
  background: #EAF3DE;
  border-color: #A4C78D;
  color: #3B6D11;
}
.alert-warning {
  background: #FFF6D9;
  border-color: #FFE082;
  color: #825C00;
}
.alert-danger {
  background: #FCEBEB;
  border-color: #E9A7A7;
  color: #A32D2D;
}

/* ==========================================================================
   Form check (checkbox/radio)
   ========================================================================== */
.form-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 0.5rem;
}
.form-check-input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex-shrink: 0;
}
.form-check-label {
  font-size: 14px;
  color: #17324D;
  line-height: 1.5;
}

/* ==========================================================================
   Tipografia
   ========================================================================== */
body {
  font-family: 'Titillium Web', 'Lucida Grande', Helvetica, Arial, Verdana, sans-serif;
  font-size: 15px;
  color: #17324D;
  background: #f5f5f5;
  line-height: 1.5;
  margin: 0;
  padding: 0;
}
h1, h2, h3, h4, h5, h6 {
  color: #17324D;
  line-height: 1.2;
  margin: 0;
}
a {
  color: var(--bs-primary, #0066CC);
  text-decoration: underline;
}
a:hover {
  text-decoration: none;
}

/* ==========================================================================
   Skip links (accessibilità)
   ========================================================================== */
.skiplinks a,
.visually-hidden-focusable {
  position: absolute;
  top: -40px;
  left: 8px;
  background: #0C447C;
  color: #fff;
  padding: 8px 16px;
  z-index: 9999;
  text-decoration: none;
  border-radius: 0 0 4px 4px;
}
.skiplinks a:focus,
.visually-hidden-focusable:focus {
  top: 0;
}

/* ==========================================================================
   Utilities Bootstrap-compatible (fallback se BI non carica)
   ========================================================================== */
.container-xxl {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 16px;
  width: 100%;
}
.row {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -12px;
}
.row > [class*="col-"] {
  padding: 0 12px;
}
.col-12 { flex: 0 0 100%; max-width: 100%; }
.col-md-6 { flex: 0 0 100%; max-width: 100%; }
.col-md-4 { flex: 0 0 100%; max-width: 100%; }
.col-md-8 { flex: 0 0 100%; max-width: 100%; }
.col-md-7 { flex: 0 0 100%; max-width: 100%; }
.col-md-5 { flex: 0 0 100%; max-width: 100%; }
.col-lg-3, .col-lg-4, .col-lg-5, .col-lg-7, .col-lg-8, .col-lg-9 { flex: 0 0 100%; max-width: 100%; }

@media (min-width: 768px) {
  .col-md-6 { flex: 0 0 50%; max-width: 50%; }
  .col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; }
  .col-md-8 { flex: 0 0 66.666%; max-width: 66.666%; }
  .col-md-7 { flex: 0 0 58.333%; max-width: 58.333%; }
  .col-md-5 { flex: 0 0 41.666%; max-width: 41.666%; }
  .d-md-block { display: block !important; }
  .d-md-none { display: none !important; }
  .d-md-flex { display: flex !important; }
}
@media (min-width: 992px) {
  .col-lg-3 { flex: 0 0 25%; max-width: 25%; }
  .col-lg-4 { flex: 0 0 33.333%; max-width: 33.333%; }
  .col-lg-5 { flex: 0 0 41.666%; max-width: 41.666%; }
  .col-lg-7 { flex: 0 0 58.333%; max-width: 58.333%; }
  .col-lg-8 { flex: 0 0 66.666%; max-width: 66.666%; }
  .col-lg-9 { flex: 0 0 75%; max-width: 75%; }
  .d-lg-block { display: block !important; }
  .d-lg-flex { display: flex !important; }
  .d-lg-none { display: none !important; }
}

/* ==========================================================================
   Spacing/utility helpers
   ========================================================================== */
.py-3 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
.py-4 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }
.py-5 { padding-top: 3rem !important; padding-bottom: 3rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }

.text-center { text-align: center; }
.text-end { text-align: right; }
.text-white { color: #fff !important; }

.d-none { display: none !important; }
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-block { display: block !important; }

.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.align-items-end { align-items: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }

.w-100 { width: 100% !important; }

/* Badge */
.badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 3px;
  line-height: 1.4;
}

/* Icone SVG responsive */
svg.icon, .icon {
  vertical-align: middle;
  display: inline-block;
}

/* Sticky sidebar */
.sticky-top {
  position: sticky;
  z-index: 10;
}

/* Hero */
.bg-primary { background-color: var(--bs-primary, #0066CC) !important; }

/* Visually hidden */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Fix: rimuovi evidenziazioni floating label di BI per input senza valore */
.form-floating > label,
[class*="form-group"] label::before,
[class*="form-group"] label::after {
  content: none !important;
  position: static !important;
}

/* Input range di BI può rompersi: reset */
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]) {
  font-family: inherit;
}

/* Tabelle (admin) */
.table-wrap { overflow-x: auto; }
table.table, .table-wrap table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table-wrap th, .table-wrap td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #e5e5e5; }
.table-wrap th { background: #f5f5f5; font-weight: 600; color: #17324D; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }

/* Print */
@media print {
  .it-header-slim-wrapper, .it-header-navbar-wrapper, .it-footer, .btn, .breadcrumb-container { display: none !important; }
  body { background: #fff; }
}
