/**
 * CMS edit / structure mode helpers.
 *
 * django CMS 4/5 wraps plugins with:
 *   <script data-cms-plugin type="application/json">...</script>
 * and/or <template class="cms-plugin"> markers.
 * Parent grid rules like ".grid > * { display: flex }" force those markers
 * visible and dump raw JSON on the page. Always exclude/hide them.
 */

/* Only hide obvious stray Text blocks in card grids (live site). */
.page-home .home-stats .text-plugin,
.page-home .departments-grid .text-plugin,
.page-home .doctors-showcase-grid .text-plugin,
.page-home .testimonials-grid .text-plugin,
.page-home .news-grid .text-plugin,
body[data-page-slug="doctors"] .doctors-page-grid .text-plugin,
body[data-page-slug="doctors"] .inner-cards-wrap .text-plugin {
    display: none !important;
}

/* CMS edit: show a warning on stray Text blocks only (not cms-plugin templates). */
body.cms-editing .page-home .home-stats .text-plugin,
body.cms-editing .page-home .departments-grid .text-plugin,
body.cms-editing .page-home .doctors-showcase-grid .text-plugin,
body.cms-editing .page-home .testimonials-grid .text-plugin,
body.cms-editing .page-home .news-grid .text-plugin,
body.cms-editing[data-page-slug="doctors"] .doctors-page-grid .text-plugin,
body.cms-editing[data-page-slug="doctors"] .inner-cards-wrap .text-plugin {
    display: block !important;
    flex: 1 1 100% !important;
    max-width: 100% !important;
    padding: 0.85rem 1rem;
    margin-bottom: 0.75rem;
    border: 2px dashed #d97706;
    border-radius: 10px;
    background: #fffbeb;
    color: #92400e;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.45;
}

body.cms-editing .page-home .home-stats .text-plugin::before,
body.cms-editing .page-home .departments-grid .text-plugin::before,
body.cms-editing .page-home .doctors-showcase-grid .text-plugin::before,
body.cms-editing[data-page-slug="doctors"] .doctors-page-grid .text-plugin::before,
body.cms-editing[data-page-slug="doctors"] .inner-cards-wrap .text-plugin::before {
    content: "Remove this Text block. Use the Hospital card plugin for this section.";
    display: block;
}

/* Never force-display CMS plugin JSON markers (beats ".grid > * { display:flex }") */
html body.cms-toolbar-enabled script[data-cms-plugin],
html body.cms-structure-mode script[data-cms-plugin],
html body.cms-toolbar-edit-mode script[data-cms-plugin],
html body.cms-editing script[data-cms-plugin],
html body.cms-toolbar-enabled template.cms-plugin,
html body.cms-structure-mode template.cms-plugin,
html body.cms-toolbar-edit-mode template.cms-plugin,
html body.cms-editing template.cms-plugin,
html body script[data-cms-plugin][type="application/json"],
.departments-grid > script,
.doctors-showcase-grid > script,
.testimonials-grid > script,
.news-grid > script,
.auto-grid > script,
.reveal-stagger > script,
.inner-cards-wrap > script,
.home-stats > script,
.hero-media-slides > script {
    display: none !important;
    flex: 0 0 0 !important;
    width: 0 !important;
    max-width: 0 !important;
    min-width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    pointer-events: none !important;
}

/* Structure mode: keep motion from hiding content */
body.cms-editing .page-home .reveal-stagger,
body.cms-editing .page-home .auto-grid {
    min-height: 0;
}

body.cms-editing .motion-on-scroll,
body.cms-editing .reveal,
body.cms-editing .reveal-from-top,
body.cms-editing .reveal-stagger > :not(script):not(template),
body.cms-editing .page-home .motion-on-scroll,
body.cms-editing .page-home .reveal,
body.cms-editing .page-home .reveal-from-top {
    opacity: 1 !important;
    transform: none !important;
    visibility: visible !important;
}

/* CMS Structure: full-card hit layers block plugin drag on the page preview */
body.cms-toolbar-enabled .doctor-card-hit,
body.cms-toolbar-enabled .h-card-hit,
body.cms-structure-mode .doctor-card-hit,
body.cms-structure-mode .h-card-hit,
body.cms-toolbar-edit-mode .doctor-card-hit,
body.cms-toolbar-edit-mode .h-card-hit,
body.cms-editing .doctor-card-hit,
body.cms-editing .h-card-hit {
    pointer-events: none !important;
}

body.cms-toolbar-enabled .doctor-card-qr-badge,
body.cms-structure-mode .doctor-card-qr-badge,
body.cms-toolbar-edit-mode .doctor-card-qr-badge,
body.cms-editing .doctor-card-qr-badge {
    pointer-events: none !important;
}

/* Keep card hover/QR overlays from covering CMS drag handles */
body.cms-structure-mode .doctor-card-hover-panel,
body.cms-toolbar-edit-mode .doctor-card-hover-panel,
body.cms-editing .doctor-card--showcase .doctor-card-hover-panel {
    opacity: 0 !important;
    pointer-events: none !important;
}

body.cms-structure-mode .doctor-card--showcase,
body.cms-toolbar-edit-mode .doctor-card--showcase,
body.cms-editing .doctor-card--showcase {
    transform: none !important;
}

body.cms-editing .doctors-showcase-grid > .doctor-card--showcase,
body.cms-editing .departments-grid > .department-card,
body.cms-editing .testimonials-grid > .testimonial-card,
body.cms-editing .news-grid > .news-card,
body.cms-editing .auto-grid > .stat-card,
body.cms-editing .inner-cards-wrap > .doctor-card--showcase {
    position: relative;
}
