/* ══════════════════════════════════════════════════════════════
   BEAMS PAGE BUILDER — stili visibili solo in modalità editing
   ══════════════════════════════════════════════════════════════ */

/* ── Zona blocchi liberi ───────────────────────────────────── */
#pageBlocks { min-height: 0; }
#pageBlocks:empty { min-height: 0; }

/* In editing: zona blocchi evidenziata */
.inline-editing #pageBlocks {
  min-height: 60px;
  border: 2px dashed rgba(76,175,101,.3);
  border-radius: 16px;
  padding: 8px;
  margin: 16px 0;
  transition: background .2s;
}
.inline-editing #pageBlocks:empty::after {
  content: 'Trascina qui un blocco dalla barra laterale →';
  display: flex; align-items: center; justify-content: center;
  height: 60px; color: rgba(76,175,101,.6); font-size:.9rem;
  font-family: 'DM Sans', sans-serif;
}

/* ── Sidebar page builder ──────────────────────────────────── */
#pb-sidebar {
  display: none;
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: 244px;
  background: #0d1a10;
  color: #fff;
  z-index: 8000;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0,0,0,.35);
  font-family: 'DM Sans', Arial, sans-serif;
  overflow: hidden;
}
.inline-editing #pb-sidebar { display: flex; }

/* Shift main content left to make room for sidebar */
.inline-editing body { padding-right: 244px; }
.inline-editing .inline-toolbar { right: 260px; }

#pb-sidebar-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  font-size: .82rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .12em;
  color: rgba(255,255,255,.55);
  flex-shrink: 0;
}
#pb-sidebar-header strong {
  display: block; font-size: .95rem; color: #fff;
  font-weight: 700; margin-bottom: 2px; text-transform: none; letter-spacing: 0;
}

.pb-block-list { padding: 10px 12px; flex: 1; overflow-y: auto; }
.pb-block-list h4 {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .14em;
  color: rgba(255,255,255,.4); margin: 8px 0 6px;
}

/* Draggable block palette items */
.pb-palette-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.08);
  cursor: grab; margin-bottom: 6px;
  font-size: .84rem; color: rgba(255,255,255,.9);
  transition: background .15s, transform .1s;
  user-select: none;
}
.pb-palette-item:hover { background: rgba(76,175,101,.2); border-color: rgba(76,175,101,.3); }
.pb-palette-item:active { cursor: grabbing; transform: scale(.97); }
.pb-palette-item svg { width: 16px; height: 16px; flex-shrink: 0; color: #4caf65; }

#pb-page-selector {
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
#pb-page-selector select {
  width: 100%; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  color: #fff; border-radius: 8px; padding: 7px 10px; font-size: .82rem;
  font-family: inherit;
}

/* ── Blocchi renderizzati ──────────────────────────────────── */
.pb-block {
  position: relative;
  margin: 0 0 24px 0;
}

/* In editing: ogni blocco ha controlli */
.inline-editing .pb-block {
  border: 1px solid rgba(76,175,101,.2);
  border-radius: 12px;
  padding: 8px;
  cursor: default;
}
.inline-editing .pb-block:hover { border-color: rgba(76,175,101,.5); }

/* Controlli blocco (visibili solo in editing) */
.pb-controls {
  display: none;
  position: absolute;
  top: -14px; right: 8px;
  gap: 4px; z-index: 10;
}
.inline-editing .pb-controls { display: flex; }
.pb-btn {
  width: 26px; height: 26px;
  border-radius: 999px; border: 0;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
  transition: all .15s;
}
.pb-btn-move  { background: #1a5c2a; color: #fff; cursor: grab; }
.pb-btn-move:active { cursor: grabbing; }
.pb-btn-up    { background: rgba(26,92,42,.15); color: #1a5c2a; }
.pb-btn-down  { background: rgba(26,92,42,.15); color: #1a5c2a; }
.pb-btn-del   { background: #b3261e; color: #fff; }
.pb-btn:hover { opacity: .85; transform: scale(1.1); }

/* Drag-over indicator */
.pb-drop-over { background: rgba(76,175,101,.08) !important; border-color: #4caf65 !important; border-style: dashed !important; }
.pb-drop-placeholder {
  height: 4px; background: #4caf65; border-radius: 999px;
  margin: 4px 0; transition: height .1s;
}

/* ── Block types ───────────────────────────────────────────── */

/* Testo */
.pb-text-content {
  font-size: .96rem; color: #536858; line-height: 1.78;
  font-family: 'DM Sans', sans-serif;
}
.pb-text-content[contenteditable] { outline: none; min-height: 40px; }
.pb-text-content[contenteditable]:empty::before { content: 'Scrivi qui il testo...'; opacity: .4; }

/* Titolo */
.pb-title-content {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.8rem; color: #0d1a10; line-height: 1.25; margin: 8px 0;
}
.pb-title-content[contenteditable] { outline: none; min-width: 60px; }
.pb-title-content[contenteditable]:empty::before { content: 'Titolo sezione'; opacity: .4; }

.pb-kicker-content {
  display: block; font-size: .68rem; font-weight: 700; letter-spacing: .22em;
  text-transform: uppercase; color: #4caf65; margin-bottom: 6px;
  font-family: 'DM Sans', sans-serif;
}
.pb-kicker-content[contenteditable] { outline: none; }
.pb-kicker-content[contenteditable]:empty::before { content: 'Etichetta'; opacity: .4; }

/* Divisore */
.pb-divider { height: 1px; background: linear-gradient(90deg, transparent, rgba(26,92,42,.2), transparent); margin: 16px 0; }
.inline-editing .pb-block .pb-divider { height: 2px; background: rgba(76,175,101,.3); }

/* Immagine */
.pb-image-wrap { border-radius: 20px; overflow: hidden; box-shadow: 0 8px 32px rgba(13,26,16,.1); }
.pb-image-wrap img { width: 100%; display: block; object-fit: cover; }
.pb-image-caption {
  font-size: .82rem; color: #536858; text-align: center;
  margin-top: 8px; font-style: italic;
}
.pb-image-caption[contenteditable] { outline: none; }
.pb-image-caption[contenteditable]:empty::before { content: 'Didascalia (opzionale)'; opacity: .4; }

/* Video */
.pb-video-wrap { border-radius: 20px; overflow: hidden; box-shadow: 0 8px 32px rgba(13,26,16,.1); aspect-ratio: 16/9; background: #0d1a10; }
.pb-video-wrap video, .pb-video-wrap iframe { width: 100%; height: 100%; display: block; object-fit: cover; border: 0; }

/* PDF */
.pb-pdf-btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 20px; border-radius: 12px;
  background: #f0f9f1; border: 1.5px solid rgba(26,92,42,.18);
  color: #1a5c2a; font-size: .9rem; font-weight: 700;
  text-decoration: none; transition: all .2s;
  font-family: 'DM Sans', sans-serif;
}
.pb-pdf-btn:hover { background: #1a5c2a; color: #fff; }
.pb-pdf-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

/* Card griglia */
.pb-cards-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 18px; }
.pb-card {
  background: #fff; border-radius: 16px; padding: 20px;
  border: 1px solid rgba(26,92,42,.08); box-shadow: 0 4px 24px rgba(13,26,16,.08);
}
.pb-card h4 { font-family: 'DM Sans', sans-serif; font-size: .95rem; font-weight: 700; color: #0d1a10; margin-bottom: 6px; }
.pb-card p  { font-size: .85rem; color: #536858; line-height: 1.6; }
.pb-card h4[contenteditable],.pb-card p[contenteditable] { outline: none; }

/* Upload overlay in editing */
.pb-upload-overlay {
  display: none;
  position: absolute; inset: 0;
  background: rgba(26,92,42,.85);
  border-radius: 12px;
  align-items: center; justify-content: center;
  flex-direction: column; gap: 10px;
  cursor: pointer; color: #fff; font-size: .9rem; font-weight: 700;
  font-family: 'DM Sans', sans-serif;
}
.inline-editing .pb-block:hover .pb-upload-overlay { display: flex; }
