/*
 * WebSiteBuilder – Editor-Styles (Filament-Panel).
 * Statische Regeln; die dynamischen Design-Tokens (--wsb-*) werden pro Website
 * inline am .wsb-canvas-Element gesetzt.
 */

/* Zwei-Spalten-Layout: links Palette/Seiten, rechts Arbeitsbereich. */
.wsb-editor-layout {
    display: grid;
    gap: 1rem;
}
@media (min-width: 1024px) {
    .wsb-editor-layout {
        grid-template-columns: 300px minmax(0, 1fr);
        align-items: start;
    }
    /* Linke Spalte bleibt beim Scrollen stehen — nur der Canvas rechts scrollt.
       Innerhalb der Spalte bleibt der Kopf (Tabs + Aktion) fix; nur der Inhalt
       (Seitenliste / Block-Palette) scrollt. */
    .wsb-aside {
        position: sticky;
        top: 4rem;
        align-self: start;
        /* Feste Hoehe: die Spalte fuellt die sichtbare Hoehe (statt nur bis zum
           Inhalt zu wachsen) — nur der Inhalt darunter scrollt. */
        height: calc(100vh - 4.5rem);
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
    .wsb-aside-head {
        flex-shrink: 0;
    }
    .wsb-aside-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
    }
    .wsb-editor-layout.wsb-fullscreen .wsb-aside {
        top: 1rem;
        height: calc(100vh - 2rem);
    }
    /* Eingeklappt: linke Spalte schrumpft auf eine schmale Leiste. */
    .wsb-editor-layout.wsb-aside-collapsed {
        grid-template-columns: 2.75rem minmax(0, 1fr);
    }
    .wsb-editor-layout.wsb-aside-collapsed .wsb-aside {
        height: auto;
    }
}

/* Ein-/Ausklapp-Schalter der linken Spalte. */
.wsb-aside-reopen,
.wsb-aside-collapse {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 2.25rem;
    width: 2.25rem;
    flex-shrink: 0;
    border-radius: 0.5rem;
    border: 1px solid rgb(228 228 231);
    background: #fff;
    color: rgb(82 82 91);
    transition: background 0.15s, color 0.15s;
}
.wsb-aside-reopen:hover,
.wsb-aside-collapse:hover {
    background: rgb(244 244 245);
    color: rgb(63 63 70);
}
/* Eingeklappte Leiste: vertikale Icon-Spalte (Seiten/Bloecke/Ausklappen). */
.wsb-aside-rail {
    position: sticky;
    top: 4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.wsb-aside-reopen.wsb-rail-active {
    border-color: rgb(var(--primary-500, 99 102 241));
    color: rgb(var(--primary-600, 79 70 229));
    background: rgb(var(--primary-50, 238 242 255));
}
.dark .wsb-aside-reopen,
.dark .wsb-aside-collapse {
    background: rgb(39 39 42);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgb(212 212 216);
}

/* Vollbild-Editor: legt sich ueber die Panel-Navigation (Sidebar/Topbar z-30),
   bleibt aber unter den Einstellungs-Modals (Filament z-40). Linke Spalte
   (Seiten & Bloecke) bleibt Teil des Grids. */
.wsb-editor-layout.wsb-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 35;
    margin: 0;
    padding: 1rem;
    overflow: auto;
    background: rgb(244 244 245);
}
.dark .wsb-editor-layout.wsb-fullscreen {
    background: rgb(24 24 27);
}

/* Geraete-Vorschau-Breite. */
.wsb-canvas-frame {
    margin-inline: auto;
    transition: max-width 0.2s ease;
}

/* Canvas: Inhalts-Farbmodus (Hell/Dunkel) je nach Hintergrund. */
.wsb-canvas {
    --wsb-text: var(--wsb-text-light);
    --wsb-heading: var(--wsb-heading-light);
    --wsb-btn-bg: var(--wsb-primary);
    --wsb-btn-fg: #ffffff;
    background-color: var(--wsb-bg);
}
.wsb-canvas .wsb-on-light {
    --wsb-text: var(--wsb-text-light);
    --wsb-heading: var(--wsb-heading-light);
    --wsb-btn-bg: var(--wsb-primary);
    --wsb-btn-fg: #ffffff;
}
.wsb-canvas .wsb-on-dark {
    --wsb-text: var(--wsb-text-dark);
    --wsb-heading: var(--wsb-heading-dark);
    --wsb-btn-bg: #ffffff;
    --wsb-btn-fg: var(--wsb-primary);
}

/* Block-Auswahl + Werkzeugleiste. */
.wsb-block-wrap {
    position: relative;
    outline: 2px solid transparent;
    transition: outline-color 0.15s;
}
.wsb-block-wrap:hover {
    outline-color: rgba(99, 102, 241, 0.4);
}
.wsb-block-wrap.wsb-selected {
    outline-color: rgb(99, 102, 241);
}
.wsb-block-toolbar {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 20;
    display: none;
    gap: 2px;
    padding: 3px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
/* Nur sichtbar, wenn die Maus auf dem Block ist (oder er ausgewaehlt ist). */
.wsb-block-wrap:hover > .wsb-block-toolbar,
.wsb-block-wrap.wsb-selected > .wsb-block-toolbar {
    display: flex;
}
/* Eingeklappt zeigt die Leiste ausschliesslich das Zahnrad. */
.wsb-block-toolbar > :not(.wsb-tool-toggle) {
    display: none;
}
/* Aufgeklappt (Klick aufs Zahnrad): alle Werkzeuge nebeneinander in EINER
   Flex-Reihe — wie zuvor bei dauerhaft offener Leiste. */
.wsb-block-toolbar.wsb-open > * {
    display: inline-flex;
    align-items: center;
}
.wsb-block-toolbar button,
.wsb-block-toolbar .wsb-drag-handle {
    border-radius: 5px;
    padding: 4px;
    color: #374151;
    background: transparent;
}
.wsb-block-toolbar button:hover,
.wsb-block-toolbar .wsb-drag-handle:hover {
    background: rgba(99, 102, 241, 0.12);
    color: rgb(79, 70, 229);
}
/* Zahnrad-Umschalter: optisch betont, da Haupt-Einstieg der Leiste. */
.wsb-tool-toggle[aria-expanded='true'] {
    background: rgba(99, 102, 241, 0.16);
    color: rgb(79, 70, 229);
}
.wsb-block-toolbar .wsb-tool-danger:hover {
    background: rgba(239, 68, 68, 0.12);
    color: rgb(220, 38, 38);
}

/* 12er-Spalten-Lineal ueber dem Canvas (Mass-Linealoptik mit Tick-Marken). */
.wsb-ruler {
    position: relative;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    height: 26px;
    margin-bottom: 8px;
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 6px;
    background: repeating-linear-gradient(
        90deg,
        rgba(99, 102, 241, 0.04) 0,
        rgba(99, 102, 241, 0.04) calc(100% / 24),
        transparent calc(100% / 24),
        transparent calc(100% / 12)
    );
    user-select: none;
    overflow: hidden;
}
.wsb-ruler span {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 3px;
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    color: #6366f1;
}
/* Tick-Marke oben an jeder Spaltengrenze. */
.wsb-ruler span::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 9px;
    background: rgba(99, 102, 241, 0.55);
}
.wsb-ruler span:first-child::before {
    display: none;
}
/* Baseline am unteren Rand. */
.wsb-ruler::after {
    content: '';
    position: absolute;
    inset: auto 0 0 0;
    height: 2px;
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.45), rgba(99, 102, 241, 0.15));
}

/* Spalten-Layout (Editor + oeffentlich). */
.wsb-row,
.wsb-cols-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: var(--wsb-cols, 1fr);
    align-items: start;
}
.wsb-col {
    display: flex;
    flex-direction: column;
}
@media (max-width: 768px) {
    .wsb-row,
    .wsb-cols-grid {
        grid-template-columns: 1fr;
    }
}

/* Reihen-Drag. */
.wsb-editor-row {
    position: relative;
}
.wsb-editor-row.wsb-dragging {
    opacity: 0.4;
}
.wsb-editor-row.wsb-drop-target {
    box-shadow: inset 0 3px 0 0 rgb(99, 102, 241);
}

/* Spalten-Resize-Griff. */
.wsb-resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    right: -0.5rem;
    width: 11px;
    cursor: col-resize;
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: center;
}
.wsb-resize-handle::after {
    content: '';
    width: 3px;
    height: 38px;
    border-radius: 9999px;
    background: rgba(99, 102, 241, 0.35);
    transition: background 0.15s;
}
.wsb-resize-handle:hover::after,
.wsb-resizing .wsb-resize-handle::after {
    background: rgb(99, 102, 241);
}

/* Reihen-/Spalten-Einstellungs-Zahnrad: heller Backdrop, damit es ueber
   beliebigen Reihen-/Spalten-Hintergruenden sichtbar bleibt. */
.wsb-row-gear,
.wsb-col-gear {
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

/* Zonen (Kopfzeile/Inhalt/Fusszeile): Platz oben fuer das persistente Etikett. */
.wsb-zone {
    padding-top: 1.25rem;
}

/* Drag-&-Drop-Einfuegezonen (zwischen Reihen). Unsichtbar, bis ein Block aus
   der Palette gezogen wird (body.wsb-adding). */
.wsb-dropzone {
    height: 4px;
    transition: height 0.12s, background 0.12s;
}
.wsb-palette-item {
    -webkit-user-drag: element;
}
body.wsb-adding .wsb-dropzone:not(.wsb-dropzone-empty) {
    height: 12px;
    margin: 4px 0;
    border: 1px dashed rgba(99, 102, 241, 0.35);
    border-radius: 6px;
}
.wsb-dropzone.wsb-dz-active:not(.wsb-dropzone-empty) {
    height: 44px;
    background: rgba(99, 102, 241, 0.14);
    border: 2px dashed rgb(99, 102, 241);
}
.wsb-dropzone-empty.wsb-dz-active {
    background: rgba(99, 102, 241, 0.1);
    outline: 2px dashed rgb(99, 102, 241);
    outline-offset: -4px;
}

/* Spalten-Einfuegezonen: links/rechts neben einem Block, um ihn zu einer Spalte
   zu machen. Unsichtbar, bis ein Block aus der Palette gezogen wird. */
.wsb-coldrop {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50%;
    z-index: 30;
    display: none;
}
.wsb-coldrop-before {
    left: 0;
}
.wsb-coldrop-after {
    right: 0;
}
body.wsb-adding .wsb-coldrop {
    display: block;
}
.wsb-coldrop.wsb-dz-active {
    background: rgba(99, 102, 241, 0.08);
}
/* Vertikaler Einfuge-Balken an der Spaltenkante. */
.wsb-coldrop.wsb-dz-active::before {
    content: '';
    position: absolute;
    top: 8px;
    bottom: 8px;
    width: 4px;
    border-radius: 9999px;
    background: rgb(99, 102, 241);
}
.wsb-coldrop-before.wsb-dz-active::before {
    left: -2px;
}
.wsb-coldrop-after.wsb-dz-active::before {
    right: -2px;
}

/* Klickbarer Block (oeffnet das Einstellungs-SlideOver). */
.wsb-editable {
    cursor: pointer;
}

/* Inline-editierbares Textfeld (direkt im Canvas). */
[data-wsb-field] {
    outline: none;
    cursor: text;
}
[data-wsb-field]:hover {
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.3);
    border-radius: 3px;
}
[data-wsb-field]:focus {
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.6);
    border-radius: 3px;
}

/* Schwebende Inline-Format-Leiste. */
.wsb-inline-toolbar {
    position: absolute;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    background: #1f2937;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}
.wsb-inline-toolbar button {
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    border-radius: 5px;
    color: #fff;
    background: transparent;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.wsb-inline-toolbar button:hover {
    background: rgba(255, 255, 255, 0.16);
}
.wsb-link-input {
    height: 28px;
    width: 180px;
    margin-left: 4px;
    padding: 0 8px;
    border-radius: 5px;
    border: 0;
    font-size: 13px;
    color: #111827;
}

/* RichEditor verpackt Inhalt in <p>; in Ueberschriften/Hero das nicht als
   Block mit Abstand rendern. */
.wsb-canvas h1 > p,
.wsb-canvas h2 > p,
.wsb-canvas h3 > p,
.wsb-canvas h4 > p {
    margin: 0;
    display: inline;
}

/* Prose im Canvas. */
.wsb-prose h2 { font-size: 1.5rem; font-weight: 700; margin: 1rem 0 0.5rem; }
.wsb-prose h3 { font-size: 1.25rem; font-weight: 600; margin: 0.75rem 0 0.5rem; }
.wsb-prose p { margin: 0.5rem 0; }
.wsb-prose ul { list-style: disc; padding-left: 1.5rem; }
.wsb-prose ol { list-style: decimal; padding-left: 1.5rem; }
