/* pb_public/css/app.css */

body {
  padding-bottom: max(3rem, env(safe-area-inset-bottom));
}


/* Static labels above inputs. We dropped Bootstrap Italia's floating
   labels (position:absolute + transform) because they conflicted with
   every non-native context (form.io dialogs, modal prompts, quick-add,
   new tabs) and required a new CSS patch each time. Static labels are
   more accessible, need zero maintenance, and PA guidelines support
   both patterns.

   Bootstrap Italia is loaded in a CSS @layer (see index.html), so
   these unlayered rules win automatically — no !important needed. */
.form-group {
  margin-bottom: 1rem;
}
/* Only .form-label, not generic `label` or .form-check-label,
   so form.io / BI checkbox layout is unaffected. */
.form-group .form-label {
  position: static;
  transform: none;
  transition: none;
  display: block;
  margin-bottom: 0.25rem;
  padding: 0;
  font-size: 0.85rem;
  color: #435a70;
  font-weight: 600;
}
/* Restore Bootstrap 5 defaults that BI overrides for floating labels.
   Scoped away from checkbox/radio so .form-check-input is untouched. */
.form-group .form-control:not([type=checkbox]):not([type=radio]),
.form-group .form-select {
  padding-top: 0.375rem;
  padding-bottom: 0.375rem;
  color: inherit;
  opacity: 1;
  border: 1px solid #ced4da;
  border-radius: 0.25rem;
  background-color: #fff;
}

/* form.io 5 uses Bootstrap 5 .form-label on its labels — undo our
   stylistic overrides so the builder and renderer look as intended.
   The structural fixes (position/transform) are harmless since form.io 5
   already uses static labels; only color/size need reverting. */
#formio-builder .form-group .form-label,
#formio-config .form-group .form-label,
.formio-dialog .form-group .form-label {
  font-size: 1rem;
  font-weight: 400;
  color: inherit;
  margin-bottom: 0.5rem;
}

/* ── Toast notification ───────────────────────────────────────────
   Self-contained — no Bootstrap Italia classes, immune to @layer. */
#toast-success {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  min-width: 260px;
  max-width: 360px;
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  font-size: 0.875rem;
  line-height: 1.4;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
#toast-success.success { background: #1a6e3c; }
#toast-success.error   { background: #9e2a2b; }
#toast-success strong  { font-size: 0.9rem; }
#toast-success a       { color: #fff; text-decoration: underline; }

.status-transitorio {
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.filter-bar {
  background: #f8f9fa;
  border-radius: 8px;
}

th[data-sort] {
  cursor: pointer;
  user-select: none;
}
th[data-sort]:hover {
  background: #e9ecef;
}
th[data-sort].sort-asc::after { content: " \25B2"; font-size: 0.7em; }
th[data-sort].sort-desc::after { content: " \25BC"; font-size: 0.7em; }

.config-section {
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 1.5rem;
  background: #fafafa;
}

/* Placeholder più chiaro per distinguerlo dai valori reali */
.form-control::placeholder {
  color: #b0bec5 !important;
  opacity: 1;
}

/* Log output block — white bg + subtle border, no harsh gray box */
.log-pre {
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: .25rem;
  padding: .75rem;
  max-height: 420px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Truncate long tenant names in tables */
.text-truncate-name {
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: middle;
}

.action-buttons .btn { min-width: 120px; }

.loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}

/* ── Tabelle responsive: colonne nascoste su mobile ────────────────────────
   Tenants:   Nome (2) + Stato (6)
   Customers: Nome (1) + Tenant count (5)
   Partners:  Nome (1) + Clienti (3)   — slug nascosto, 2 col leggibili
   Schemas:   Applicativo (1) + Versione (2)                                */
@media (max-width: 767.98px) {
  #tenants-table  :is(th, td):not(:nth-child(2)):not(:nth-child(6))  { display: none; }
  #customers-table :is(th, td):not(:nth-child(1)):not(:nth-child(5)) { display: none; }
  #partners-table  :is(th, td):not(:nth-child(1)):not(:nth-child(3)) { display: none; }
  #schemas-table   :is(th, td):not(:nth-child(1)):not(:nth-child(2)) { display: none; }

  /* Log output: shorter on mobile so it doesn't fill the whole screen */
  .log-pre { max-height: 220px; }

  /* Lifecycle transition buttons: 44px min tap target */
  .transition-btn { min-height: 44px; }
}

/* Toast: prevent overflow on narrow screens */
@media (max-width: 575.98px) {
  #toast-success { max-width: calc(100vw - 2rem); min-width: 0; }
}
