@import url("variables.css");

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  background: var(--color-bg-dark);
  color: var(--color-text-light);
  line-height: 1.5;
}

a {
  color: var(--color-secondary);
}

.admin-layout {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
}

@media (min-width: 900px) {
  .admin-layout {
    grid-template-columns: 240px 1fr;
  }
}

.admin-sidebar {
  background: var(--color-black);
  border-bottom: 1px solid var(--color-bg-card);
  padding: 1rem;
}

@media (min-width: 900px) {
  .admin-sidebar {
    border-bottom: none;
    border-right: 1px solid var(--color-bg-card);
    position: sticky;
    top: 0;
    align-self: start;
    min-height: 100vh;
  }
}

.admin-brand {
  font-weight: 800;
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--color-text-light);
}

.admin-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.admin-nav a {
  display: block;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--color-text-muted);
}

.admin-nav a:hover,
.admin-nav a.is-active {
  background: var(--color-bg-card);
  color: var(--color-secondary);
  text-decoration: none;
}

.admin-main {
  padding: 1.25rem;
  max-width: 1200px;
  width: 100%;
}

.admin-main--wide {
  max-width: 1400px;
}

.admin-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.admin-top h1 {
  margin: 0;
  font-size: 1.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 44px;
  padding: 0.5rem 1rem;
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
}

.btn--primary {
  background: var(--color-primary);
  color: var(--color-text-light);
}

.btn--secondary {
  background: var(--color-secondary);
  color: var(--color-black);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-light);
  border: 1px solid var(--color-bg-card);
}

.btn--danger {
  background: #7a1e14;
  color: var(--color-text-light);
}

.card {
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  border: 1px solid rgba(239, 235, 228, 0.08);
  margin-bottom: 1rem;
}

.grid-stats {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.stat {
  text-align: center;
}

.stat strong {
  display: block;
  font-size: 1.75rem;
  color: var(--color-secondary);
}

.table-wrap {
  overflow-x: auto;
}

table.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

table.admin-table th,
table.admin-table td {
  padding: 0.65rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--color-black);
}

table.admin-table th {
  color: var(--color-text-muted);
  font-weight: 600;
}

.form-grid {
  display: grid;
  gap: 1rem;
}

.form-grid label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
}

.form-grid input,
.form-grid textarea,
.form-grid select {
  width: 100%;
  min-height: 48px;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-black);
  font: inherit;
  font-size: 1rem;
  background: var(--color-text-light);
  color: var(--color-black);
}

.form-grid textarea {
  min-height: 110px;
  resize: vertical;
}

.form-grid input[type="range"] {
  min-height: 28px;
  padding: 0;
  cursor: pointer;
  accent-color: var(--color-primary, #b31b0d);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(29, 11, 8, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 300;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal {
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  padding: 2rem;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid rgba(239, 235, 228, 0.12);
}

#modal-prodotto .modal {
  max-width: 720px;
  padding: 2rem 2.5rem;
}

#form-prodotto {
  grid-template-columns: 1fr 1fr;
}

#form-prodotto > div:has(#prodotto-desc),
#form-prodotto > div:has(#prodotto-img),
#form-prodotto > #ai-gen-wrap,
#form-prodotto > label:has(#prodotto-disp),
#form-prodotto > div:last-child {
  grid-column: 1 / -1;
}

@media (max-width: 600px) {
  #form-prodotto {
    grid-template-columns: 1fr;
  }
  #modal-prodotto .modal {
    padding: 1.25rem;
  }
}

.modal h2 {
  margin-top: 0;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: radial-gradient(circle at top, var(--color-bg-card), var(--color-bg-dark));
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-bg-card);
  padding: 2rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(239, 235, 228, 0.1);
}

.login-card h1 {
  margin-top: 0;
  font-size: 1.35rem;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge--ok {
  background: #2d6a4f;
  color: #fff;
}

.badge--off {
  background: var(--color-text-muted);
  color: var(--color-black);
}

.adv-list {
  display: grid;
  gap: 1rem;
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.quick-links a {
  text-decoration: none;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--color-black);
  color: var(--color-text-light);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.gallery-admin-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 600px) {
  .gallery-admin-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1000px) {
  .gallery-admin-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.gallery-admin-card {
  background: var(--color-black);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.gallery-admin-thumb {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: var(--color-bg-card);
}

.gallery-admin-info {
  padding: 0.85rem;
  flex: 1;
}

.cat-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: var(--color-black);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239, 235, 228, 0.06);
}

.cat-item__name {
  font-weight: 600;
  font-size: 1rem;
}

.cat-item__actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.cat-item__actions .btn {
  min-height: 34px;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
}

.cat-item__actions .btn[disabled] {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ── Display monitor block ── */

.display-monitor-block {
  margin-bottom: 2rem;
}

.display-preview-panel {
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  border: 1px solid rgba(239, 235, 228, 0.08);
  overflow: hidden;
}

.display-preview-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  background: var(--color-black);
  border-bottom: 1px solid rgba(239, 235, 228, 0.08);
  font-size: 0.9rem;
}

.display-preview-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2d6a4f;
  flex-shrink: 0;
}

.display-preview-label {
  font-weight: 700;
  color: var(--color-text-light);
  text-decoration: none;
}

.display-preview-label:hover {
  color: var(--color-secondary);
}

.display-preview-count {
  margin-left: auto;
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.display-size-select {
  min-height: 28px;
  padding: 0.15rem 0.35rem;
  border: 1px solid rgba(239, 235, 228, 0.15);
  border-radius: var(--radius-sm);
  background: var(--color-bg-card);
  color: var(--color-text-light);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.display-bg-ctrl {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  cursor: pointer;
}

.display-bg-ctrl span {
  flex-shrink: 0;
}

.display-bg-color {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(239, 235, 228, 0.2);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
}

.display-bg-brightness {
  width: 70px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.bg-brightness-val {
  min-width: 2.2em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.display-preview-screen {
  position: relative;
  width: 50%;
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  background:
    radial-gradient(ellipse at center, rgba(229, 57, 53, 0.3) 0%, transparent 60%),
    linear-gradient(135deg, #D32F2F 0%, #C62828 40%, #B71C1C 100%);
  overflow: hidden;
  border: 4px solid #1a1210;
  border-top: none;
  transition: width 0.3s ease;
  border-radius: 0 0 6px 6px;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.3);
}

.display-preview-stage {
  position: absolute;
  inset: 0;
  display: flex;
  gap: 2px;
  padding: 4px;
  overflow: hidden;
}

.display-preview-section {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  border-right: 1px solid rgba(255, 193, 7, 0.35);
  padding-right: 2px;
}

.display-preview-section:last-child {
  border-right: none;
  padding-right: 0;
}

.display-preview-section-title {
  color: #FFC107;
  font-weight: 900;
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 0.03em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  padding: 1px 0;
  border-bottom: 1px solid rgba(240, 186, 87, 0.4);
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.display-preview-grid {
  display: grid;
  flex: 1;
}

.display-preview-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.25);
  overflow: hidden;
  transform-origin: center center;
}

.display-preview-item img {
  width: 90%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  border-radius: 0;
  display: block;
  background: transparent;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.4));
}

.display-preview-item-name {
  color: #FFC107;
  font-weight: 800;
  margin-top: 1px;
  line-height: 1.15;
  text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.display-preview-item-desc {
  color: rgba(255, 255, 255, 0.7);
  font-size: clamp(0.2rem, 0.5vw, 0.35rem);
  margin-top: 0;
  max-width: 95%;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.display-preview-item-price {
  color: #fff;
  font-weight: 700;
  line-height: 1.2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.display-preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.8rem;
  font-style: italic;
}

/* ── Sections toolbar & list ── */

.display-sections-toolbar {
  margin: 0.75rem 0 0.5rem;
}

.display-global-ctrls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn--sm {
  min-height: 34px;
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
}

.display-sections-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.section-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  border: 1px solid rgba(239, 235, 228, 0.08);
  padding: 0.85rem;
}

.section-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}

.section-card-header input[type="text"] {
  flex: 1;
  min-width: 100px;
  min-height: 34px;
  padding: 0.3rem 0.5rem;
  border: 2px solid var(--color-black);
  border-radius: var(--radius-sm);
  background: var(--color-text-light);
  color: var(--color-black);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
}

.section-card-header .btn {
  min-height: 30px;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
}

.section-sliders {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.25rem 1rem;
  margin-bottom: 0.5rem;
}

.section-slider-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.section-slider-row label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
  min-width: 6rem;
}

.btn-stepper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--color-secondary);
  background: transparent;
  color: var(--color-secondary);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.btn-stepper:hover {
  background: var(--color-secondary);
  color: #fff;
}

.btn-stepper--sm {
  width: 24px;
  height: 24px;
  font-size: 0.9rem;
}

.stepper-val {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  min-width: 2.5rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.section-products-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0.4rem 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.section-products-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.section-prod-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  background: var(--color-black);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.section-prod-row img {
  width: 32px;
  height: 24px;
  object-fit: cover;
  border-radius: 2px;
  background: var(--color-bg-card);
  flex-shrink: 0;
}

.section-prod-row span {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.section-prod-row .prod-price {
  color: var(--color-secondary);
  font-weight: 600;
  flex: none;
}

.section-prod-row .prod-span-ctrl {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.section-prod-row .prod-span-ctrl label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.section-prod-row .prod-span-ctrl .stepper-val {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  min-width: 2.2rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.section-prod-row .btn {
  min-height: 24px;
  padding: 0.1rem 0.35rem;
  font-size: 0.7rem;
}

.section-empty {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-style: italic;
  padding: 0.3rem 0;
}

/* ── Product pick modal ── */

.modal--lg {
  max-width: 700px;
}

.product-pick-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 50vh;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.product-pick-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--color-black);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s;
}

.product-pick-card:hover {
  border-color: var(--color-text-muted);
}

.product-pick-card.is-selected {
  border-color: var(--color-secondary);
  background: rgba(240, 186, 87, 0.08);
}

.product-pick-card.is-disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.product-pick-card img {
  width: 40px;
  height: 32px;
  object-fit: cover;
  border-radius: 3px;
  background: var(--color-bg-card);
  flex-shrink: 0;
}

.product-pick-card-info {
  flex: 1;
  min-width: 0;
  font-size: 0.8rem;
  line-height: 1.3;
}

.product-pick-card-name {
  font-weight: 600;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-pick-card-price {
  color: var(--color-secondary);
  font-weight: 600;
}

.pick-category-header {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.6rem 0 0.3rem;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 0.4rem;
}

.pick-category-header:first-child {
  padding-top: 0;
}

.pick-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

/* ── Orari grid (admin contatti) ── */

.orari-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.orario-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  background: var(--color-black);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}

.orario-row > label:first-child {
  font-weight: 600;
  min-width: 6.5rem;
}

.orario-row input[type="time"] {
  min-height: 36px;
  padding: 0.25rem 0.4rem;
  border: 2px solid var(--color-bg-card);
  border-radius: var(--radius-sm);
  background: var(--color-text-light);
  color: var(--color-black);
  font: inherit;
  font-size: 0.9rem;
  width: 7.5rem;
}

.orario-row span {
  color: var(--color-text-muted);
}

.orario-chiuso {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  cursor: pointer;
  margin-left: auto;
}

.orario-chiuso input[type="checkbox"] {
  accent-color: var(--color-primary);
  cursor: pointer;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--color-bg-card);
  border-radius: 28px;
  cursor: pointer;
  transition: background 0.25s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 22px;
  height: 22px;
  background: var(--color-text-light);
  border-radius: 50%;
  transition: transform 0.25s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--color-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(24px);
}

/* ── Pubblicità: Tabs ── */

.pub-tabs {
  display: flex;
  gap: 0;
  margin-top: 0.75rem;
  border-bottom: 2px solid var(--color-bg-card);
}

.pub-tab {
  padding: 0.6rem 1.2rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.pub-tab:hover {
  color: var(--color-text-light);
}

.pub-tab.is-active {
  color: var(--color-secondary);
  border-bottom-color: var(--color-secondary);
}

.pub-panels {
  margin-top: 0;
}

.pub-panel {
  display: none;
  padding: 0.75rem 0;
}

.pub-panel.is-active {
  display: block;
}

/* ── Pubblicità: Modalità base (solo prodotti) ── */

body.pubblicita-mode-basic .btn-autolayout,
body.pubblicita-mode-basic .btn-copy-layout {
  display: none;
}

body.pubblicita-mode-basic .display-preview-panel {
  display: none;
}

.pubblicita-side-basic {
  margin-top: 0;
}

.pub-basic-display-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}

.pub-basic-display-title {
  font-size: 1rem;
}

.pub-basic-display-link {
  font-size: 0.85rem;
  color: var(--color-secondary);
  text-decoration: none;
}

.pub-basic-display-link:hover {
  text-decoration: underline;
}

.pub-basic-toolbar {
  margin-bottom: 0.5rem;
}

.pub-basic-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.pub-basic-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.6rem;
  background: var(--color-bg-card);
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

.pub-basic-item-name {
  font-size: 0.9rem;
}

.pub-basic-empty {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.pub-basic-slot {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.5rem;
}

.pub-basic-slot-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.pub-basic-slot-title {
  font-size: 0.9rem;
  color: var(--color-text);
}

.pub-basic-slot-title-input {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-text-light);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.4rem;
  min-width: 0;
  flex: 1;
  max-width: 280px;
  font-family: inherit;
  transition: border-color 0.2s, background 0.2s;
}

.pub-basic-slot-title-input:hover {
  border-color: var(--color-border);
}

.pub-basic-slot-title-input:focus {
  outline: none;
  border-color: var(--color-secondary);
  background: var(--color-bg-card);
}

/* ── Pubblicità: varianti layout AI ── */

.ai-layout-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
}

.ai-layout-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 0.2rem;
}

.ai-layout-field select,
.ai-layout-field input[type="text"] {
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.88rem;
}

.ai-layout-field--grow {
  flex: 1;
  min-width: 200px;
}

.ai-layout-field--grow input {
  width: 100%;
  box-sizing: border-box;
}

.ai-layout-status {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  min-height: 1.25em;
}

.ai-layout-status.is-error {
  color: #e57373;
}

.ai-layout-variants-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
  max-height: min(55vh, 420px);
  overflow-y: auto;
}

.ai-variant-card {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 0.75rem;
  background: var(--color-bg-card);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ai-variant-card-title {
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.35;
  flex: 1;
}

/* ── Pubblicità: Property groups ── */

.pub-group {
  margin-bottom: 1rem;
}

.pub-group h4 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: var(--color-text-light);
  border-bottom: 1px solid rgba(239, 235, 228, 0.08);
  padding-bottom: 0.3rem;
}

.pub-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.pub-group-header h4 {
  margin: 0;
  border: none;
  padding: 0;
}

/* ── Pubblicità: Box model input ── */

.pub-box-wrap {
  margin-bottom: 0.5rem;
}

.pub-box-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

.pub-box-fields {
  display: flex;
  gap: 0.4rem;
}

.pub-box-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  cursor: default;
}

.pub-box-field span {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.pub-box-field input {
  width: 3.5rem;
  min-height: 28px;
  padding: 0.2rem 0.3rem;
  border: 1px solid var(--color-bg-card);
  border-radius: var(--radius-sm);
  background: var(--color-text-light);
  color: var(--color-black);
  font: inherit;
  font-size: 0.8rem;
  text-align: center;
}

/* ── Pubblicità: Collapsible ── */

.pub-collapse {
  margin-bottom: 0.5rem;
  border: 1px solid rgba(239, 235, 228, 0.08);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.pub-collapse-head {
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-light);
  user-select: none;
}

.pub-collapse-head:hover {
  background: rgba(255, 255, 255, 0.07);
}

.pub-collapse-arrow {
  display: inline-block;
  transition: transform 0.2s;
}

.pub-collapse.is-open .pub-collapse-arrow {
  transform: rotate(90deg);
}

.pub-collapse-body {
  display: none;
  padding: 0.5rem 0.75rem;
}

.pub-collapse.is-open .pub-collapse-body {
  display: block;
}

/* ── Pubblicità: Color input ── */

.pub-color-input {
  width: 36px;
  height: 36px;
  padding: 2px;
  border: 1px solid rgba(239, 235, 228, 0.2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: none;
}

/* ── Pubblicità: Element rows ── */

.pub-element-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  background: var(--color-black);
  border-radius: var(--radius-sm);
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
}

.pub-element-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pub-pos-field {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
  cursor: default;
}

.pub-pos-field span {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-text-muted);
}

.pub-pos-field input {
  width: 3.5rem;
  min-height: 26px;
  padding: 0.15rem 0.3rem;
  border: 1px solid var(--color-bg-card);
  border-radius: var(--radius-sm);
  background: var(--color-text-light);
  color: var(--color-black);
  font: inherit;
  font-size: 0.75rem;
  text-align: center;
}

.pub-element-row .btn {
  min-height: 24px;
  padding: 0.1rem 0.35rem;
  font-size: 0.7rem;
}

/* ── Pubblicità: Preview absolute elements ── */

.pub-abs-el {
  border: 1px dashed rgba(255, 193, 7, 0.25);
}

.pub-grid-el {
  border-color: rgba(255, 255, 255, 0.15);
}

/* ── Auto-Layout Modal ── */

.modal--xl {
  max-width: 860px;
}

.al-subtitle {
  color: var(--color-text-muted);
  margin-top: 0;
  font-size: 0.9rem;
}

.al-section {
  margin-bottom: 1.25rem;
}

.al-section h3 {
  font-size: 0.95rem;
  margin: 0 0 0.6rem;
  color: var(--color-secondary);
}

.al-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.65rem;
}

.al-tpl-card {
  background: var(--color-black);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  padding: 0.7rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  text-align: center;
}

.al-tpl-card:hover {
  border-color: var(--color-text-muted);
}

.al-tpl-card.is-selected {
  border-color: var(--color-secondary);
  background: rgba(240, 186, 87, 0.1);
}

.al-tpl-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: rgba(180, 30, 15, 0.35);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 4px;
  overflow: hidden;
}

.al-tpl-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.al-tpl-cell {
  flex: 1;
  background: rgba(255, 193, 7, 0.3);
  border-radius: 2px;
  min-height: 4px;
}

.al-tpl-cell--accent {
  background: rgba(255, 193, 7, 0.55);
}

.al-tpl-name {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--color-text-light);
  margin-bottom: 0.15rem;
}

.al-tpl-desc {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  line-height: 1.3;
}

/* Products toolbar */

.al-products-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.al-products-toolbar span {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-left: auto;
}

.al-selected-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  max-height: 160px;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.al-selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.55rem;
  background: var(--color-black);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-light);
}

.al-selected-chip img {
  width: 20px;
  height: 16px;
  object-fit: cover;
  border-radius: 2px;
  flex-shrink: 0;
}

.al-selected-chip .al-chip-remove {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0 0.1rem;
  line-height: 1;
}

.al-selected-chip .al-chip-remove:hover {
  color: var(--color-primary);
}

.al-footer {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(239, 235, 228, 0.08);
}

.al-footer .btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Template preview variations */

.al-tpl-preview--categorie {
  flex-wrap: wrap;
}

.al-tpl-preview--categorie .al-tpl-col {
  flex: 0 0 calc(50% - 1px);
}

.al-tpl-preview--l .al-tpl-col:first-child {
  flex: 2.3;
}

.al-tpl-preview--l .al-tpl-col:last-child {
  flex: 1;
}

.al-tpl-preview--ristorante .al-tpl-col {
  gap: 3px;
}

.al-tpl-header-bar {
  height: 5px;
  background: rgba(255, 193, 7, 0.7);
  border-radius: 1px;
  flex-shrink: 0;
  flex-grow: 0;
}

.al-tpl-preview--compact {
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
}

.al-tpl-preview--compact .al-tpl-cell {
  flex: 0 0 calc(33.33% - 2px);
  min-height: 0;
  aspect-ratio: 1;
}

/* ── Drag & Drop: Preview interattivo ── */

.display-preview-stage {
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

.pub-draggable {
  cursor: grab;
  transition: box-shadow 0.15s, opacity 0.15s;
}

.pub-draggable:hover {
  box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.5);
  z-index: 5;
}

.pub-draggable.is-selected {
  box-shadow: 0 0 0 2px #FFC107;
  z-index: 10;
}

.pub-draggable.is-dragging {
  cursor: grabbing;
  opacity: 0.75;
  z-index: 100;
  box-shadow: 0 0 0 2px #FFC107, 0 4px 16px rgba(0, 0, 0, 0.5);
}

.pub-resize-handle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #fff;
  border: 1px solid #FFC107;
  border-radius: 1px;
  z-index: 20;
  pointer-events: auto;
}

.pub-resize-handle--nw { top: -4px; left: -4px; cursor: nw-resize; }
.pub-resize-handle--n  { top: -4px; left: 50%; margin-left: -4px; cursor: n-resize; }
.pub-resize-handle--ne { top: -4px; right: -4px; cursor: ne-resize; }
.pub-resize-handle--e  { top: 50%; margin-top: -4px; right: -4px; cursor: e-resize; }
.pub-resize-handle--se { bottom: -4px; right: -4px; cursor: se-resize; }
.pub-resize-handle--s  { bottom: -4px; left: 50%; margin-left: -4px; cursor: s-resize; }
.pub-resize-handle--sw { bottom: -4px; left: -4px; cursor: sw-resize; }
.pub-resize-handle--w  { top: 50%; margin-top: -4px; left: -4px; cursor: w-resize; }

.pub-guide-line {
  position: absolute;
  z-index: 50;
  pointer-events: none;
}

.pub-guide-line--h {
  left: 0;
  right: 0;
  height: 0;
  border-top: 1px dashed rgba(255, 80, 80, 0.7);
}

.pub-guide-line--v {
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 1px dashed rgba(255, 80, 80, 0.7);
}

.pub-center-guide {
  position: absolute;
  z-index: 1;
  pointer-events: none;
}

.pub-center-guide--h {
  left: 0;
  right: 0;
  top: 50%;
  height: 0;
  border-top: 1px dotted rgba(255, 255, 255, 0.08);
}

.pub-center-guide--v {
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0;
  border-left: 1px dotted rgba(255, 255, 255, 0.08);
}

.pub-drag-tooltip {
  position: absolute;
  z-index: 200;
  background: rgba(0, 0, 0, 0.85);
  color: #FFC107;
  font-size: 0.65rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -100%);
  margin-top: -6px;
}

