/* Manody stylesheet, part 07 — Page builder (Pro plan): editor layout, canvas, block settings, template gallery.
   Loaded in order by core/templates/core/includes/stylesheets.html. */

/* ==========================================================================
   Page builder (Pro plan)
   ========================================================================== */

.page-builder { background: var(--bg-soft); }
.page-builder .site-header { background: color-mix(in srgb, var(--bg-soft) 80%, transparent); }

.bicon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.builder {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-h));
    min-height: 560px;
}

/* ---------- Top bar ---------- */
.builder-bar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.builder-bar-start,
.builder-bar-end {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.builder-bar-end { justify-content: flex-end; }

.builder-title {
    display: grid;
    min-width: 0;
    line-height: 1.3;
}

.builder-title strong,
.builder-title span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.builder-devices {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 999px;
}

.builder-icon-btn {
    display: grid;
    place-items: center;
    width: 34px;
    height: 30px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.builder-icon-btn:hover:not(:disabled) { color: var(--text); }
.builder-icon-btn.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.builder-icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.builder-sep {
    width: 1px;
    height: 18px;
    margin: 0 4px;
    background: var(--border);
}

/* ---------- Three panels ---------- */
.builder-body {
    flex: 1;
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr) 300px;
    min-height: 0;
}

.builder-panel {
    overflow-y: auto;
    padding: 14px;
    background: var(--surface);
}

.builder-library { border-right: 1px solid var(--border); }
.builder-inspector { border-left: 1px solid var(--border); }

.builder-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 14px;
    padding: 3px;
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
}

.builder-tabs button {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
}

.builder-tabs button .bicon { width: 15px; height: 15px; }
.builder-tabs button.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.10); }

.builder-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    height: 36px;
    margin-bottom: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
}

.builder-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    outline: none;
}

.builder-group-title {
    margin: 16px 0 8px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.block-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.block-card {
    display: grid;
    justify-items: center;
    gap: 6px;
    padding: 12px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 0.78rem;
    font-weight: 500;
    text-align: center;
    cursor: grab;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.block-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.block-card[hidden] { display: none; }
.builder-hint { margin-top: 14px; }

.layer-list {
    display: grid;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.layer-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
}

.layer-list li:hover { background: var(--bg-soft); }
.layer-list li.is-active { background: color-mix(in srgb, #6366f1 12%, transparent); color: #4f46e5; }

/* ---------- Canvas ---------- */
.builder-canvas {
    overflow: auto;
    padding: 32px 24px 64px;
    background:
        radial-gradient(circle at 1px 1px, var(--border) 1px, transparent 0) 0 0 / 20px 20px,
        var(--bg-soft);
}

.builder-stage {
    margin: 0 auto;
    transition: max-width 0.3s ease;
}

.builder-stage.is-mobile     { max-width: 390px; }
.builder-stage.is-tablet   { max-width: 720px; }
.builder-stage.is-desktop { max-width: 1040px; }

.builder-page {
    position: relative;
    min-height: 640px;
    padding: 40px 20px 32px;
    border: 1px solid var(--border);
    border-radius: 28px;
    background-color: var(--bg);
    color: var(--text);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.builder-stage.is-desktop .builder-page,
.builder-stage.is-tablet .builder-page { border-radius: 16px; padding-inline: 12%; }

.builder-page .public-profile { margin-bottom: 8px; }

/* Blocks: outline on hover, label and tools on the selected block. */
.bb {
    position: relative;
    margin: 0 -8px 14px;
    padding: 8px;
    border: 1px dashed transparent;
    border-radius: 12px;
    transition: border-color 0.15s ease;
}

.builder-stage:not(.is-preview) .bb { cursor: pointer; }
.builder-stage:not(.is-preview) .bb:hover { border-color: color-mix(in srgb, #6366f1 55%, transparent); }

.builder-stage:not(.is-preview) .bb.is-selected {
    border: 1px solid #6366f1;
    box-shadow: 0 0 0 3px color-mix(in srgb, #6366f1 18%, transparent);
}

.builder-stage:not(.is-preview) .bb.is-selected::before {
    content: attr(data-label);
    position: absolute;
    top: -11px;
    left: 10px;
    z-index: 2;
    padding: 1px 8px;
    border-radius: 999px;
    background: #6366f1;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 600;
}

.bb-tools {
    position: absolute;
    top: -15px;
    right: 8px;
    z-index: 2;
    display: none;
    gap: 2px;
    padding: 3px;
    border-radius: 999px;
    background: #18181b;
    box-shadow: var(--shadow);
}

.bb.is-selected .bb-tools { display: flex; }

.bb-tool {
    display: grid;
    place-items: center;
    width: 24px;
    height: 22px;
    border-radius: 999px;
    color: #e4e4e7;
}

.bb-tool .bicon { width: 14px; height: 14px; }
.bb-tool:hover { background: rgba(255, 255, 255, 0.12); }
.bb-tool-danger:hover { background: #dc2626; color: #fff; }
.bb-handle { cursor: grab; }

.bb-add {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    border: 1.5px dashed color-mix(in srgb, var(--text) 25%, transparent);
    border-radius: 12px;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}

.bb-add:hover { border-color: #6366f1; color: var(--text); }

/* Fake form fields in the editor */
.bb-input {
    flex: 1;
    display: flex;
    align-items: center;
    min-width: 0;
    height: 46px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ---------- Block settings ---------- */
.inspector-head {
    display: grid;
    margin-bottom: 12px;
}

.inspector-head strong { font-size: 1.05rem; letter-spacing: -0.02em; }

.inspector-fields {
    display: grid;
    gap: 14px;
}

.ifield {
    display: grid;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 500;
}

.ifield input[type="text"],
.ifield input[type="url"],
.ifield input[type="datetime-local"],
.ifield select {
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
}

.ifield input[type="color"] {
    width: 100%;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.ifield input[type="range"] { width: 100%; accent-color: #6366f1; }

.icheck {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.isegmented {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
}

.isegmented button {
    flex: 1;
    padding: 5px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
}

.isegmented button.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.10); }

/* ---------- Template gallery ---------- */
.template-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.template-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.template-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.template-thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 26px 22% 22px;
    background-color: var(--bg);
    color: var(--text);
}

.template-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent);
}

.template-line {
    width: 50%;
    height: 7px;
    margin-bottom: 6px;
    border-radius: 999px;
    background: var(--text-muted);
    opacity: 0.6;
}

.template-thumb .demo-link {
    display: block;
    width: 100%;
    height: 22px;
}

.template-body {
    display: grid;
    gap: 8px;
    padding: 16px;
}

.template-body h2 { font-size: 1.05rem; letter-spacing: -0.02em; }

.template-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.template-tags li {
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ---------- Full-screen preview ---------- */
.builder-preview { background: var(--bg-soft); }
.builder-preview .builder-stage { width: 100%; padding: 32px 16px 64px; box-sizing: content-box; }
.builder-preview .builder-stage.is-mobile { max-width: 390px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
    .builder-body { grid-template-columns: 240px minmax(0, 1fr); }
    .builder-inspector { display: none; }
    .template-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
    .builder { height: auto; }
    .builder-bar { grid-template-columns: 1fr; justify-items: stretch; }
    .builder-devices { justify-self: center; }
    .builder-bar-end { justify-content: flex-start; flex-wrap: wrap; }
    .builder-body { grid-template-columns: 1fr; }
    .builder-library { border-right: 0; border-bottom: 1px solid var(--border); max-height: 280px; }
    .builder-canvas { padding: 20px 12px 40px; }
    .template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
    .template-grid { grid-template-columns: 1fr; }
}
