/* pb_public/css/app.css */

/* ── Layout shell ───────────────────────────────────────────────────────────
   Replica il layout di base-layout (app-wrapper + sidebar + content-wrapper).
   Bootstrap Italia è caricato in @layer, quindi queste regole unlayered vincono
   automaticamente senza !important. */
html, body { height: 100%; }

.app-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-main-content {
  display: flex;
  flex: 1;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.it-header-wrapper {
  position: sticky;
  top: 0;
  z-index: 1000;
}

.it-header-slim-wrapper.empty-slim-wrapper {
  height: auto;
  padding: 6.5px 0;
}

.it-header-center-wrapper.theme-light {
  border-bottom: 1px solid #e0e0e0;
  height: 80px;
  padding-bottom: 6px;
}

.it-right-zone {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ── Mobile nav bar ─────────────────────────────────────────────────────── */
.mobile-nav-bar {
  display: none;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 0.5rem 1rem;
  height: 48px;
}

@media (max-width: 991px) {
  .mobile-nav-bar { display: flex; }
}

.mobile-nav-toggle {
  width: 40px; height: 40px;
  border: none; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0; color: #17324d;
}

.mobile-nav-title {
  font-size: 1rem; font-weight: 600; color: #17324d; margin-left: 0.5rem;
}

/* ── Content area ───────────────────────────────────────────────────────── */
.content-wrapper {
  flex: 1;
  padding: 2rem;
  background-color: #f2f7fc;
  overflow-x: hidden;
}

@media (max-width: 991px) {
  .content-wrapper { padding: 1rem; }
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar-wrapper {
  background-color: #ffffff;
  border-right: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.sidebar {
  position: sticky;
  top: 0;
}

.sidebar-header {
  display: flex;
  justify-content: flex-end;
  padding: 10px 12px;
}

.sidebar-collapse-toggle {
  transition: transform 200ms ease;
  width: 36px; height: 36px;
  border: none; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #17324d; border-radius: 4px;
}
.sidebar-collapse-toggle:hover { background: #f0f0f0; }

.sidebar-wrapper.no-transition,
.sidebar-wrapper.no-transition * { transition: none !important; }

.sidebar-wrapper.is-collapsed .sidebar-collapse-toggle {
  transform: rotate(180deg);
}

.sidebar .link-list { padding: 0; margin: 0; list-style: none; }

.sidebar .list-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  color: #17324d;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background-color 0.15s ease;
  font-size: 1.1rem;
  line-height: 1.5;
}

.sidebar .list-item:hover { background-color: #e8f0fe; color: #0066cc; }

.sidebar .list-item.active {
  background-color: #e8f0fe;
  border-left-color: #0066cc;
  color: #0066cc;
  font-weight: 600;
}

.sidebar-item-icon {
  width: 36px;
  display: inline-flex;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.1rem;
}

.sidebar-item-label {
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 180ms ease, max-width 220ms ease;
}

/* Desktop: sidebar collassabile con animazione larghezza */
@media (min-width: 992px) {
  .sidebar-wrapper { transition: width 220ms ease; padding: 0 !important; }
  .sidebar { padding: 1rem 0; }
  .sidebar-wrapper.is-expanded { width: 260px; }
  .sidebar-wrapper.is-collapsed { width: 72px; }
  .sidebar-wrapper.is-collapsed .sidebar-item-label { opacity: 0; max-width: 0; }
  .sidebar-wrapper.is-collapsed .list-item { justify-content: center; padding-left: 0; padding-right: 0; }
}

/* Mobile: sidebar come drawer fisso */
@media (max-width: 991px) {
  .sidebar-wrapper {
    display: none;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 1040;
    padding-top: 48px;
    overflow-y: auto;
    width: 280px !important;
  }
  .sidebar-wrapper.mobile-open { display: block; }
}

/* ── Sidebar overlay mobile ─────────────────────────────────────────────── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0,0,0,.5);
  z-index: 1035;
  display: none;
}

/* ── Focus ring (keyboard navigation) ─────────────────────────────────── */
:focus:not([data-focus-mouse="true"]) {
  border-color: transparent !important;
  outline: 2px solid #4a90d9 !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 2px #fff, 0 0 0 5px #4a90d9 !important;
  border-radius: 3px;
}




/* 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; }
}
