/*
 * Copyright 2020-2026 Gotoproject platform B.V., Marnix Hamelberg <marnix.hamelberg@gotoproject.nl>, in the Netherlands.
 * 
 *     Licensed under 'All Rights Reserved' (the "License");
 *     you may not use or replicate this software, or derivatives thereof, except in compliance with the License.
 */

﻿/**
 * Block Editor Styles
 * External stylesheet for the <block-editor> Web Component.
 * Styles for the <block-editor> Web Component.
 */

/* Web Component base display */
block-editor {
    display: block;
}
/* Block Editor Styles */
.block-editor {
    max-width: var(--editor-max-width, 800px);
    margin: 0 auto;
    position: relative;
}

/* Paste Loading Overlay */
.paste-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.paste-loading-spinner {
    background: var(--white);
    padding: 2rem 3rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.paste-loading-spinner i {
    font-size: 2.5rem;
    color: var(--accent-color);
    display: block;
}

.spinner-wrapper {
    display: inline-block;
    width: 1em;
    height: 1em;
    line-height: 1;
    text-align: center;
    vertical-align: -.05em;
    -webkit-animation: spin 2s linear infinite;
    animation: spin 2s linear infinite;
    margin-right: 0.25rem;
}

.spinner-wrapper i {
    display: block;
    line-height: 1;
}

@-webkit-keyframes spin {
    0% {
        -webkit-transform: rotate(0deg);
        transform: rotate(0deg);
    }
    100% {
        -webkit-transform: rotate(360deg);
        transform: rotate(360deg);
    }
}

@keyframes spin {
    0% {
        -webkit-transform: rotate(0deg);
        transform: rotate(0deg);
    }
    100% {
        -webkit-transform: rotate(360deg);
        transform: rotate(360deg);
    }
}

.paste-loading-spinner p {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-color);
}

/* Video Compression Overlay */
.video-compression-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
    transition: opacity 0.3s ease-out;
}

.compression-spinner {
    background: var(--white);
    padding: 2.5rem 3rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: var(--shadow);
    animation: slideUp 0.3s ease;
    min-width: 350px;
    max-width: 90%;
}

.compression-spinner i {
    font-size: 3rem;
    color: var(--accent-color);
    margin-bottom: 1.5rem;
    display: block;
}

.compression-spinner .compression-title {
    margin: 0;
    font-size: 1.35rem;
    color: var(--text-color);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.compression-spinner .compression-subtitle {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-color);
    margin-bottom: 1.5rem;
}

.compression-cancel-btn {
    margin-top: 1.5rem;
    padding: 0.65rem 1.5rem;
    background: var(--primary-color);
    border: 2px solid var(--card-border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.compression-cancel-btn:hover {
    background: var(--white);
    border-color: var(--secondary-color-light);
    color: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.compression-cancel-btn:active {
    transform: translateY(0);
}

.compression-cancel-btn i {
    font-size: 1rem;
}

/* Compression Progress Bar */
.compression-progress-container {
    width: 100%;
    max-width: 300px;
    margin: 20px 0;
    margin-bottom: 0;
}

.compression-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--card-border-color, #e9ecef);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.compression-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color, #007bff), var(--accent-color, #007bff));
    border-radius: 10px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(0, 123, 255, 0.5);
}

.compression-progress-text {
    text-align: center;
    margin-top: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color, #333);
}

/* Back to Projects Button */
.project-back-button {
    position: absolute;
    top: -60px;
    left: 20px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.back-to-projects-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    text-decoration: none;
    background: var(--white);
    border: 2px solid var(--card-border-color);
    border-radius: 50%;
    color: var(--text-color);
    transition: all 0.2s ease;
}

.back-to-projects-link:hover {
    background-color: var(--primary-color-light);
    color: var(--accent-color);
    border-color: var(--accent-color);
    transform: translateX(-2px);
}

.back-to-projects-link i {
    font-size: 1rem;
    transition: transform 0.2s ease;
}

/* .back-to-projects-link:hover i {
    transform: translateX(-3px);
} */

/* Project Menu */
.project-menu-container {
    position: absolute;
    top: -60px;
    right: 20px;
    z-index: 100;
}

@media (max-width: 992px) {
    .block-editor {
        top: 55px;
    }

    .project-back-button {
        top: -59.5px;
        left: 12px;
    }

    .project-menu-container {
        top: -59.5px;
        right: 15px;
    }

}

.project-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--white);
    border: 2px solid var(--card-border-color);
    border-radius: 6px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.project-menu-btn:hover {
    background-color: var(--primary-color-light);
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.project-menu-btn.active {
    background-color: var(--accent-color);
    color: var(--white);
    border-color: var(--accent-color);
}

.project-menu-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--white);
    border: 1.5px solid var(--card-border-color);
    border-radius: 6px;
    box-shadow: var(--shadow-sm);
    min-width: 250px;
    overflow: hidden;
    animation: slideDown 0.2s ease;
}

.project-menu-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--white);
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 0.9rem;
    color: var(--text-color);
    font-weight: 500;
}

.project-menu-option:hover {
    background-color: var(--primary-color-light);
}

.project-menu-option.delete-project {
    color: #dc3545;
}

.project-menu-option.delete-project:hover {
    background-color: #fee;
}

.project-menu-option.enable-edit-mode {
    color: var(--accent-color);
    font-weight: 600;
    border-bottom: 1.5px solid var(--card-border-color);
}

.project-menu-option.enable-edit-mode:hover {
    color: var(--text-color);
    background-color: color-mix(in srgb, var(--accent-color) 12%, transparent);
}

.project-menu-option.enable-edit-mode i {
    color: var(--accent-color);
}

.project-menu-option.disable-edit-mode {
    color: var(--text-color);
    font-weight: 600;
    border-bottom: 1.5px solid var(--card-border-color);
}

.project-menu-option.disable-edit-mode:hover {
    background-color: var(--primary-color);
}

.project-menu-option.disable-edit-mode i {
    color: var(--text-color);
}

.project-menu-option i {
    font-size: 1rem;
    min-width: 1.25rem;
}

/* Global Alignment Section */
.global-align-section {
    padding: 1rem;
    border-bottom: 1.5px solid var(--card-border-color);
}

.global-align-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.global-align-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.global-align-btn {
    flex: 1;
    padding: 0.625rem;
    background: var(--white);
    border: 2px solid var(--card-border-color);
    border-radius: 6px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.global-align-btn:hover {
    background-color: var(--primary-color-light);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.global-align-btn.active {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--white);
}

.global-align-btn.active:hover {
    background-color: var(--accent-color);
    opacity: 0.9;
}

.global-align-btn i {
    font-size: 1.125rem;
}

/* Privacy toggle option styling */
.privacy-toggle-option {
    padding: 0.875rem 1rem !important;
    cursor: default !important;
}

.privacy-toggle-option:hover {
    background-color: transparent !important;
}

.privacy-toggle-option .toggle-switch {
    cursor: pointer;
}

/* Share toggle option styling */
.share-toggle-option {
    padding: 0.875rem 1rem !important;
    cursor: default !important;
}

.share-toggle-option:hover {
    background-color: transparent !important;
}

.share-toggle-option .toggle-switch {
    cursor: pointer;
}

.privacy-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.privacy-status-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color);
    transition: color 0.2s ease;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
    display: inline-block;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: var(--white);
    transition: 0.3s;
    border-radius: 50%;
}

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

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

.toggle-switch:hover .toggle-slider {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.blocks-container {
    margin-bottom: 2rem;
}

/* Empty Project State */
.empty-project-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 68vh;
    padding: 6rem 1.5rem;
}

.empty-project-content {
    text-align: center;
    max-width: 100%;
}

/* Hide blocks container when empty state is shown */
.block-editor.show-empty-state .blocks-container {
    display: none;
}

.block-item {
    position: relative;
    padding: 1.5rem;
    border: 1.5px solid transparent;
    border-radius: var(--card-border-radius);
    transition: all 0.2s ease;
    scroll-margin-top: 25vh;
    scroll-margin-bottom: 50vh;
}

/* Reduce spacing for headings (less bottom padding) */
.block-item[data-block-type="heading"] {
    margin-bottom: -2rem;
}

/* Reduce spacing for subtitles (less top padding) */
.block-item[data-block-type="subtitle"] {
    margin-top: -1.6rem;
}

@media (max-width: 768px) {
    /* Reduce spacing for headings (less bottom padding) */
    .block-item[data-block-type="heading"] {
        margin-bottom: -1.5rem;
    }

    /* Reduce spacing for subtitles (less top padding) */
    .block-item[data-block-type="subtitle"] {
        margin-top: -0.7rem;
    }
}

/* Block hover effect - only in edit mode and only on devices with hover capability */
@media (hover: hover) and (pointer: fine) {
    .block-editor.edit-mode .block-item:hover {
        border-color: var(--card-border-color);
    }
}

/* Block active effect on touch devices when toggled via mobile-edit-toggle */
.block-editor.edit-mode .block-item.mobile-edit-active {
    border-color: var(--card-border-color);
    background-color: var(--primary-color-light);
}

/* Block moved highlight animation */
.block-item.block-moved {
    animation: blockMoveHighlight 0.6s ease;
}

@keyframes blockMoveHighlight {
    0% {
        background-color: var(--accent-color);
        transform: scale(1.02);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    50% {
        background-color: color-mix(in srgb, var(--accent-color) 50%, var(--primary-color-light));
    }
    100% {
        background-color: transparent;
        transform: scale(1);
        box-shadow: none;
    }
}

.block-content {
    margin: 0;
    padding: 0;
}

/* Inline Editing - Only active in edit mode */
.block-editor.edit-mode .block-content .editable-text {
    position: relative;
    transition: background-color 0.2s ease;
    border-radius: 8px;
    padding: 0.75rem;
    margin: -0.75rem;
    outline-color: color-mix(in srgb, var(--accent-color) 10%, transparent);
}

.block-editor.edit-mode .block-content .editable-text:hover {
    background-color: color-mix(in srgb, var(--accent-color) 8%, transparent);
    cursor: text;
}

.block-editor.edit-mode .block-content .editable-text:focus {
    background-color: color-mix(in srgb, var(--accent-color) 4%, transparent) !important;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-color) 4%, transparent) !important;
}

.block-editor.edit-mode .block-content [contenteditable="true"]:not(.list-item-text):not(.checklist-item-text) {
    outline: none !important;
    cursor: text;
}

.block-editor.edit-mode .block-content [contenteditable="true"]:not(.list-item-text):not(.checklist-item-text):focus {
    outline: none !important;
    box-shadow: none !important;
}

.block-editor.edit-mode .block-content .editable-text:empty:before {
    content: attr(data-placeholder);
    color: color-mix(in srgb, var(--font-color) 50%, transparent);
}

/* Block Type Displays */
.block-title-display {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--font-color);
    margin: 0;
    padding: 0;
}

.block-heading-display {
    font-weight: 600;
    color: var(--font-color);
    margin: 0;
    padding: 0;
}

.block-heading-display.level-1 { font-size: 2rem; }
.block-heading-display.level-2 { font-size: 1.75rem; }
.block-heading-display.level-3 { font-size: 1.5rem; }
.block-heading-display.level-4 { font-size: 1.25rem; }
.block-heading-display.level-5 { font-size: 1.1rem; }
.block-heading-display.level-6 { font-size: 1rem; }

.block-paragraph-display {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-color);
    margin: 0;
    padding: 0;
    padding-left: .1rem;
    padding-right: .1rem;
}

.block-subtitle-display {
    font-size: 1.25rem;
    line-height: 1.5;
    color: var(--dark-color);
    margin: 0;
    padding: 0;
    opacity: 0.85;
    font-weight: 300 !important;
    padding-left: .1rem;
    padding-right: .1rem;
}

/* Inline Editing - Only active in edit mode */
.block-editor.edit-mode .block-content .block-paragraph-display.editable-text, .block-editor.edit-mode .block-content .block-subtitle-display.editable-text {
    padding: 0.75rem 0.85rem;
}

/* Button block styles */
.block-button-display {
    padding: 0.5rem 0;
    position: relative;
}

.block-button-display .btn {
    position: relative;
}

.button-edit-overlay {
    position: absolute !important;
    background: var(--white) !important;
    border: 2px solid var(--edit-color) !important;
    color: var(--edit-color) !important;
    box-shadow: var(--edit-shadow-sm) !important;
    transition: all 0.2s ease !important;
    width: 32px !important;
    height: 32px !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 50% !important;
    padding: 0 !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    top: -10px !important;
    right: -12px !important;
    z-index: 20 !important;
    min-width: unset !important;
    max-width: 32px !important;
    line-height: 1 !important;
    font-size: 0 !important;
    cursor: pointer;
}

.button-edit-overlay i {
    font-size: 0.85rem !important;
    margin: 0 !important;
    line-height: 1 !important;
}

.button-edit-overlay:hover {
    background: var(--edit-color) !important;
    border-color: var(--edit-color) !important;
    color: white !important;
    transform: scale(1.15) !important;
    box-shadow: var(--edit-shadow);
}

.button-edit-overlay:active {
    transform: scale(0.95) !important;
}

/* Show edit button on hover */
.block-editor.edit-mode .block-button-display:hover .button-edit-overlay,
.block-editor.edit-mode .block-button-display .btn:hover ~ .button-edit-overlay {
    display: flex !important;
}

/* Always show on mobile/touch devices in edit mode */
@media (hover: none), (pointer: coarse), (max-width: 992px) {
    .block-editor.edit-mode .button-edit-overlay {
        display: flex !important;
    }

    .block-subtitle-display {
        line-height: 1.6 !important;
    }
}

/* Embed block styles */
.block-embed-display {
    padding: 0;
    display: block;
}

.block-embed-display:not(.full-width) {
    max-width: 100%;
    width: fit-content;
}

.block-embed-display iframe {
    border-radius: var(--card-border-radius);
    display: block;
}

.block-embed-display.full-width iframe {
    border-radius: 0;
}

.embed-caption {
    font-size: 0.875rem;
    color: var(--text-color);
    opacity: 0.7;
    text-align: center;
    margin-top: 0.5rem;
}

/* OpenStad Widget block styles */
.block-openstad-display {
    padding: 0;
    display: block;
}

.block-openstad-display:not(.full-width) {
    max-width: 100%;
    width: fit-content;
}

.block-openstad-display .openstad-widget-container {
    min-height: auto !important;
    height: auto !important;
    max-height: unset !important;
    position: relative;
    background-color: white;
    padding: 1rem;
}

.block-openstad-display .openstad-widget-content {
    width: 100%;
}

.block-openstad-display.full-width {
    width: 100%;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    width: 100vw;
    max-width: 100vw;
}

.block-openstad-display.align-left {
    margin-left: 0;
    margin-right: auto;
}

.block-openstad-display.align-center {
    margin-left: auto;
    margin-right: auto;
}

.block-openstad-display.align-right {
    margin-left: auto;
    margin-right: 0;
}

/* On mobile, OpenStad widgets should fit their content instead of using custom height */
@media (max-width: 992px) {
    .block-openstad-display .openstad-widget-container {
        height: auto !important;
        min-height: 100px !important;
        max-height: unset !important;
        padding: 0.25rem;
    }
}

/* Divider block styles */
.block-divider-display {
    padding: 0.5rem 0.9rem;
    width: 100%;
}

.block-divider-line {
    border: none;
    border-top: 1.5px solid var(--secondary-color-light) !important;
    margin: 0 !important;
    margin-left: -0.5rem !important;
    margin-right: -0.5rem !important;
    opacity: 0.7 !important;
    transition: opacity 0.2s ease !important;
}

.block-editor.edit-mode .block-item[data-block-type="divider"]:hover .block-divider-line {
    border-color: var(--secondary-color) !important;
    opacity: 1 !important;
}

/* Spacer block styles */
.block-spacer-display {
    position: relative;
    width: 100%;
    min-height: 20px;
    transition: background-color 0.2s ease;
}

.block-editor.edit-mode .block-spacer-display {
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 5px,
        rgba(var(--edit-color-rgb, 59, 130, 246), 0.03) 5px,
        rgba(var(--edit-color-rgb, 59, 130, 246), 0.03) 10px
    );
    border-radius: 4px;
    margin: 0 0.9rem;
    width: calc(100% - 1.8rem);
}

.block-editor.edit-mode .block-item[data-block-type="spacer"]:hover .block-spacer-display {
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 5px,
        rgba(var(--edit-color-rgb, 59, 130, 246), 0.08) 5px,
        rgba(var(--edit-color-rgb, 59, 130, 246), 0.08) 10px
    );
}

.spacer-height-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--accent-color) !important;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    touch-action: none;
    aspect-ratio: 1 / 1;
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.block-editor.edit-mode .block-item[data-block-type="spacer"]:hover .spacer-height-indicator {
    opacity: 1;
}

/* List block styles */
.block-list-display {
    padding: 0.5rem 0.9rem;
    width: 100%;
    position: relative;
    text-align: left !important;
}

.block-list-items {
    margin: 0;
    padding: 0;
    list-style: none;
}

@media (min-width: 992px) {
    .block-list-items {
        min-width: 500px;
    }
}

/* Lists are always left-aligned - override any alignment classes */
.block-list-display.align-center,
.block-list-display.align-right {
    text-align: left !important;
}

.block-list-display.align-center .block-list-items,
.block-list-display.align-center .block-list-items-view,
.block-list-display.align-right .block-list-items,
.block-list-display.align-right .block-list-items-view {
    display: block;
    text-align: left;
}

/* View mode list styles */
.block-list-items-view {
    margin: 0;
    padding-left: 1.5rem;
    list-style-position: outside;
}

.block-list-items-view li {
    padding: 0.25rem 0;
    line-height: 1.6;
}

/* View mode checklist styles */
.block-checklist-items-view {
    margin: 0;
    padding: 0;
    list-style: none;
}

.block-checklist-items-view .checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.5rem 0;
    line-height: 1.6;
}

.block-checklist-items-view .checklist-checkbox, .block-checklist-items .checklist-checkbox {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 3px;
    border: 2px solid var(--card-border-color);
    border-radius: calc(var(--card-border-radius) * 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.block-checklist-items-view .checklist-item.checked .checklist-checkbox, .block-checklist-items .checklist-checkbox.checked {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
    transition: opacity 0.2s ease;
}

.block-checklist-items-view .checklist-item.checked:hover .checklist-checkbox, .block-checklist-items .checklist-checkbox.checked:hover {
    opacity: 0.8;
}

.block-checklist-items-view .checklist-item.checked .checklist-text, .block-checklist-items .checklist-checkbox.checked .checklist-text {
    text-decoration: line-through;
    opacity: 0.6;
}

/* Make checkboxes clickable for owners in view mode */
.block-checklist-items-view .checklist-checkbox.owner-clickable {
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
}

.block-checklist-items-view .checklist-checkbox.owner-clickable:hover {
    border-color: var(--accent-color);
    opacity: 0.8;
}

/* Editable list items in edit mode - match view mode spacing */
.list-item-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0;
    transition: background-color 0.3s ease;
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
}

.list-item-wrapper:hover,
.list-item-wrapper:focus,
.list-item-wrapper:focus-visible,
.list-item-wrapper:focus-within,
.list-item-wrapper.item-selected {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
}

.list-item-wrapper *:focus-visible {
    outline: none !important;
}

/* Animation for moved items */
@keyframes itemMoved {
    0% {
        transform: scale(1.03);
    }
    100% {
        transform: scale(1);
    }
}

.list-item-wrapper.item-moved,
.checklist-item-wrapper.item-moved {
    animation: itemMoved 0.7s ease-out;
    border-radius: var(--card-border-radius);
}

/* Indent levels for list items */
.list-item-wrapper.indent-0 { margin-left: 0; }
.list-item-wrapper.indent-1 { margin-left: 1.5rem; }
.list-item-wrapper.indent-2 { margin-left: 3rem; }
.list-item-wrapper.indent-3 { margin-left: 4.5rem; }

/* View mode list items */
.block-list-items-view {
    list-style: none;
    margin: 0;
    padding: 0;
}

.list-item-view {
    display: flex;
    align-items: flex-start;
    gap: 0.25rem;
    padding: 0.5rem 0;
}

.list-item-view.indent-0 { margin-left: 0; }
.list-item-view.indent-1 { margin-left: 1.5rem; }
.list-item-view.indent-2 { margin-left: 3rem; }
.list-item-view.indent-3 { margin-left: 4.5rem; }

.list-item-bullet-view {
    flex-shrink: 0;
    min-width: 1.5rem;
    width: auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    color: inherit;
    font-size: 1rem;
    line-height: 1.6;
    padding-right: 0.25rem;
}

.list-item-text-view {
    flex: 1;
    line-height: 1.6;
}

.list-item-bullet {
    flex-shrink: 0;
    min-width: 1.5rem;
    width: auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    color: inherit;
    font-size: 1rem;
    line-height: 1.6;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

.list-item-text {
    flex: 1;
    min-height: 1.6em;
    padding: 0.25rem 0.5rem;
    margin: -0.25rem -0.5rem;
    border: none !important;
    border-radius: 6px;
    outline: none !important;
    line-height: 1.6;
    background: transparent !important;
    transition: background-color 0.2s ease;
    box-shadow: none !important;
}

.list-item-text:hover {
    background-color: color-mix(in srgb, var(--accent-color) 8%, transparent) !important;
    outline: none !important;
    border: none !important;
    outline-color: color-mix(in srgb, var(--accent-color) 10%, transparent) !important;
}

/* Keep text highlighted when hovering over actions menu */
.list-item-wrapper:hover .list-item-text {
    background-color: color-mix(in srgb, var(--accent-color) 8%, transparent) !important;
}

.list-item-text:focus-visible {
    outline: none !important;
    border: none !important;
}

.list-item-text:focus {
    background-color: color-mix(in srgb, var(--accent-color) 4%, transparent) !important;
    outline: none !important;
    outline-offset: 0;
    box-shadow: none !important;
}

.list-item-text[data-placeholder]:empty:before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    opacity: 0.6;
}

.list-item-actions {
    position: absolute;
    top: -1rem;
    right: -2rem;
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    pointer-events: none;
    touch-action: none;
    transition: opacity 0.2s ease;
    background: var(--card-background, #fff);
    border-radius: 4px;
    padding: 1px 4px;
    z-index: 1000;
    border: 1.5px solid var(--card-border-color, #e5e7eb);
}

/* Only show on hover for devices with proper hover support */
@media (hover: hover) and (pointer: fine) {
    .list-item-wrapper:hover .list-item-actions {
        opacity: 1;
        pointer-events: auto;
        touch-action: auto;
    }
}

/* On touch devices, only show via item-selected class (managed by JS) */
@media (hover: none), (pointer: coarse) {
    .list-item-wrapper.item-selected .list-item-actions {
        opacity: 1;
        pointer-events: auto;
        touch-action: auto;
    }
}

@media (max-width: 992px) {
    .list-item-actions {
        top: -2rem;
        right: 2rem;
        transform: scale(1.3);
    }
}

/* Indent buttons group - horizontal */
.list-item-indent-group {
    display: flex;
    align-items: center;
    gap: 0;
}

/* Move buttons group - vertical stack */
.list-item-move-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.list-item-indent-left,
.list-item-indent-right,
.list-item-move-up,
.list-item-move-down,
.list-item-delete {
    flex-shrink: 0;
    width: 20px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease;
    padding: 0;
    font-size: 11px;
}

.list-item-delete {
    width: 24px;
    height: 24px;
    font-size: 14px;
}

.list-item-indent-left:hover,
.list-item-indent-right:hover,
.list-item-move-up:hover,
.list-item-move-down:hover {
    color: var(--accent-color) !important;
}

.list-item-indent-left[disabled],
.list-item-indent-right[disabled],
.list-item-move-up[disabled],
.list-item-move-down[disabled] {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.list-item-delete:hover {
    color: var(--danger-color, #ef4444);
}

/* Inline add button below item */
.list-item-add-below,
.checklist-item-add-below {
    position: absolute;
    bottom: -0.75rem;
    left: 10%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-background, #fff);
    border: 1.5px solid var(--card-border-color, #e5e7eb);
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    z-index: 5;
}

@media (max-width: 992px) {
    .list-item-add-below,
    .checklist-item-add-below {
        left: 20%;
        bottom: -1rem;
    }
}

/* Only show on hover for devices with proper hover support */
@media (hover: hover) and (pointer: fine) {
    .list-item-wrapper:hover .list-item-add-below,
    .checklist-item-wrapper:hover .checklist-item-add-below {
        opacity: 1;
        pointer-events: auto;
    }
}

/* On touch devices, only show via item-selected class (managed by JS) */
@media (hover: none), (pointer: coarse) {
    .list-item-wrapper.item-selected .list-item-add-below,
    .checklist-item-wrapper.item-selected .checklist-item-add-below {
        opacity: 1;
        pointer-events: auto;
    }
}

.list-item-add-below:hover,
.checklist-item-add-below:hover {
    color: var(--accent-color) !important;
    border-color: var(--accent-color) !important;
}

/* Make wrapper position relative for the add-below button */
.list-item-wrapper,
.checklist-item-wrapper {
    position: relative;
}

.list-add-item {
    position: absolute;
    bottom: -1.7rem;
    left: 0.65rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0;
    padding-left: 0.25rem;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    transition: opacity 0.2s ease, color 0.2s ease;
    z-index: 5;
    opacity: 0;
}

.block-list-display:hover .list-add-item,
.block-list-display:focus-within .list-add-item {
    opacity: 1;
}

/* On touch devices, always show */
@media (hover: none), (pointer: coarse) {
    .list-add-item {
        opacity: 1;
        position: relative;
        bottom: 0;
        left: 0;
        top: 1rem;
    }
}

.list-add-item:hover {
    color: var(--accent-color) !important;
}

.list-add-item i {
    width: 1.5rem;
    text-align: left;
}

/* List style toggle */
.list-style-toggle {
    position: absolute;
    top: -1.75rem;
    left: 0.65rem;
    display: flex;
    gap: 0.7rem;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.block-list-display:hover .list-style-toggle,
.block-list-display:focus-within .list-style-toggle {
    opacity: 1;
}

/* On touch devices, always show */
@media (hover: none), (pointer: coarse) {
    .list-style-toggle {
        opacity: 1;
        position: relative;
        top: 0;
        left: 0;
        margin-bottom: 0.5rem;
    }
}

.list-style-btn, .list-style-btn:focus {
    padding: 2px 8px;
    border: 1.5px solid var(--card-border-color);
    background: var(--white);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    outline: none;
    color: var(--text-color);
}

.list-style-btn:hover {
    border-color: var(--edit-color);
    color: var(--edit-color);
}

.list-style-btn.active {
    background: var(--edit-color);
    border-color: var(--edit-color);
    color: var(--white);
}

/* Checklist block styles */
.block-checklist-display {
    padding: 0.5rem 0.9rem;
    width: 100%;
    position: relative;
    text-align: left !important;
}

/* Checklists are always left-aligned */
.block-checklist-display.align-center,
.block-checklist-display.align-right {
    text-align: left !important;
}

.block-checklist-items {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Checklist item wrapper - edit mode, matches view mode spacing */
.checklist-item-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.5rem 0;
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
}

.checklist-item-wrapper:hover,
.checklist-item-wrapper:focus,
.checklist-item-wrapper:focus-visible,
.checklist-item-wrapper:focus-within,
.checklist-item-wrapper.item-selected {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
}

.checklist-item-wrapper *:focus-visible {
    outline: none !important;
}

/* Indent levels for checklist items */
.checklist-item-wrapper.indent-0 { margin-left: 0; }
.checklist-item-wrapper.indent-1 { margin-left: 1.5rem; }
.checklist-item-wrapper.indent-2 { margin-left: 3rem; }
.checklist-item-wrapper.indent-3 { margin-left: 4.5rem; }

.block-checklist-items-view .checklist-item.indent-0 { margin-left: 0; }
.block-checklist-items-view .checklist-item.indent-1 { margin-left: 1.5rem; }
.block-checklist-items-view .checklist-item.indent-2 { margin-left: 3rem; }
.block-checklist-items-view .checklist-item.indent-3 { margin-left: 4.5rem; }

.checklist-checkbox {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 3px;
    border: 2px solid var(--card-border-color);
    border-radius: calc(var(--card-border-radius) * 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.checklist-checkbox.checked {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.block-editor.edit-mode .checklist-checkbox {
    cursor: pointer;
}

.block-editor.edit-mode .checklist-checkbox:hover {
    border-color: var(--accent-color);
}

.checklist-item-text {
    flex: 1;
    min-height: 1.6em;
    padding: 0.25rem 0.5rem;
    margin: -0.25rem -0.5rem;
    border: none !important;
    border-radius: 6px;
    outline: none !important;
    line-height: 1.6;
    background: transparent !important;
    transition: background-color 0.2s ease;
    box-shadow: none !important;
}

.checklist-item-text.checked {
    text-decoration: line-through;
    opacity: 0.6;
}

.checklist-item-text:hover {
    background-color: color-mix(in srgb, var(--accent-color) 8%, transparent) !important;
    outline: none !important;
    border: none !important;
    outline-color: color-mix(in srgb, var(--accent-color) 10%, transparent) !important;
}

/* Keep text highlighted when hovering over actions menu */
.checklist-item-wrapper:hover .checklist-item-text {
    background-color: color-mix(in srgb, var(--accent-color) 8%, transparent) !important;
}

.checklist-item-text:focus-visible {
    outline: none !important;
    border: none !important;
}

.checklist-item-text:focus {
    background-color: color-mix(in srgb, var(--accent-color) 4%, transparent) !important;
    outline: none !important;
    outline-offset: 0;
    box-shadow: none !important;
}

.checklist-item-text[data-placeholder]:empty:before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    opacity: 0.6;
}

.checklist-item-actions {
    position: absolute;
    top: -1rem;
    right: -2rem;
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    pointer-events: none;
    touch-action: none;
    transition: opacity 0.2s ease;
    background: var(--card-background, #fff);
    border-radius: 4px;
    padding: 1px 4px;
    z-index: 10;
    border: 1.5px solid var(--card-border-color, #e5e7eb);
}

/* Only show on hover for devices with proper hover support */
@media (hover: hover) and (pointer: fine) {
    .checklist-item-wrapper:hover .checklist-item-actions {
        opacity: 1;
        pointer-events: auto;
        touch-action: auto;
    }
}

/* On touch devices, only show via item-selected class (managed by JS) */
@media (hover: none), (pointer: coarse) {
    .checklist-item-wrapper.item-selected .checklist-item-actions {
        opacity: 1;
        pointer-events: auto;
        touch-action: auto;
    }
}

@media (max-width: 992px) {
    .checklist-item-actions {
        top: -2rem;
        right: 2rem;
        transform: scale(1.3);
    }
}

/* Indent buttons group - horizontal */
.checklist-item-indent-group {
    display: flex;
    align-items: center;
    gap: 0;
}

/* Move buttons group - vertical stack */
.checklist-item-move-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.checklist-item-indent-left,
.checklist-item-indent-right,
.checklist-item-move-up,
.checklist-item-move-down,
.checklist-item-delete {
    flex-shrink: 0;
    width: 20px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease;
    padding: 0;
    font-size: 11px;
}

.checklist-item-delete {
    width: 24px;
    height: 24px;
    font-size: 14px;
}

.checklist-item-indent-left:hover,
.checklist-item-indent-right:hover,
.checklist-item-move-up:hover,
.checklist-item-move-down:hover {
    color: var(--accent-color) !important;
}

.checklist-item-indent-left[disabled],
.checklist-item-indent-right[disabled],
.checklist-item-move-up[disabled],
.checklist-item-move-down[disabled] {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.checklist-item-delete:hover {
    color: var(--danger-color, #ef4444);
}

.checklist-add-item {
    position: absolute;
    bottom: -1.7rem;
    left: 0.65rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    transition: opacity 0.2s ease, color 0.2s ease;
    z-index: 5;
    opacity: 0;
}

.block-checklist-display:hover .checklist-add-item,
.block-checklist-display:focus-within .checklist-add-item {
    opacity: 1;
}

/* On touch devices, always show */
@media (hover: none), (pointer: coarse) {
    .checklist-add-item {
        opacity: 1;
        position: relative;
        bottom: 0;
        left: 0;
        top: 1rem;
    }
}

.checklist-add-item:hover {
    color: var(--accent-color) !important;
}

.checklist-add-item i {
    width: 20px;
    text-align: center;
}

/* Table block styles */
.block-table-display {
    padding: 0.5rem 0.5rem;
    width: 100%;
    overflow: auto;
    text-align: left !important;
}

.block-table {
    width: 100%;
    min-width: fit-content;
    border-collapse: separate;
    border-spacing: 0;
    border: 1.5px solid color-mix(in srgb, var(--accent-color) 15%, transparent);
    border-radius: var(--card-border-radius);
    overflow: hidden;
    table-layout: auto;
}

/* Tables with 3 or fewer columns fill container width */
.block-table.fixed-width {
    width: 100%;
    min-width: 100%;
    table-layout: fixed;
}

.block-table th,
.block-table td {
    border: 1px solid color-mix(in srgb, var(--accent-color) 15%, transparent);
    border-top: none;
    border-left: none;
    padding: 0.5rem 0.75rem;
    text-align: left;
    min-width: 200px;
    height: 36px;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
}

/* Fixed-width tables don't need min-width on cells */
.block-table.fixed-width th,
.block-table.fixed-width td {
    min-width: 0;
}

/* On small devices, wider min-width for better touch targets */
@media (max-width: 992px) {

    .block-table-display {
        padding: 0.5rem 0.35rem;
    }

    .block-table th,
    .block-table td {
        min-width: 55vw;
    }
    
    /* On small screens, fixed-width tables also get min-width to limit columns shown */
    .block-table.fixed-width th,
    .block-table.fixed-width td {
        min-width: 55vw;
    }
    
    .block-table.fixed-width {
        width: auto;
        min-width: fit-content;
        table-layout: auto;
    }
}

/* First row cells need top border */
.block-table tr:first-child th,
.block-table tr:first-child td {
    border-top: none;
}

/* First column cells need left border */
.block-table th:first-child,
.block-table td:first-child {
    border-left: none;
}

/* Last column cells don't need right border (table border covers it) */
.block-table th:last-child,
.block-table td:last-child {
    border-right: none;
}

/* Last row cells don't need bottom border (table border covers it) */
.block-table tr:last-child th,
.block-table tr:last-child td {
    border-bottom: none;
}

.block-table.has-header th {
    background: color-mix(in srgb, var(--accent-color) 15%, transparent);
    font-weight: 600;
    border-color: transparent;
}

/* Tables are always left-aligned - override any alignment classes */
.block-table-display.align-center,
.block-table-display.align-right {
    display: block;
    justify-content: flex-start;
}

.block-table-display.align-center .block-table,
.block-table-display.align-right .block-table {
    width: 100%;
}

/* Editable table cells */
.block-editor.edit-mode .block-table th,
.block-editor.edit-mode .block-table td {
    padding: 0;
}

.table-cell-input {
    width: 100%;
    min-height: 36px;
    height: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    background: transparent;
    outline: none;
    font-size: inherit;
    font-family: inherit;
    color: var(--text-color);
    box-sizing: border-box;
    resize: none;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    line-height: 1.4;
    display: block;
}

.table-cell-input:focus {
    background: color-mix(in srgb, var(--accent-color) 5%, transparent);
}

.block-editor.edit-mode .block-table.has-header th .table-cell-input {
    font-weight: 600;
}

/* Table row/column insert highlight animation */
@keyframes tableInsertHighlight {
    0% {
        background-color: color-mix(in srgb, var(--accent-color) 35%, transparent);
    }
    100% {
        background-color: transparent;
    }
}

@keyframes tableInsertHighlightHeader {
    0% {
        background-color: color-mix(in srgb, var(--accent-color) 45%, transparent);
    }
    100% {
        background-color: color-mix(in srgb, var(--accent-color) 15%, transparent);
    }
}

.block-table tr.row-highlight td {
    animation: tableInsertHighlight 0.8s ease-out;
}

.block-table tr.row-highlight th,
.block-table.has-header th.col-highlight {
    animation: tableInsertHighlightHeader 0.8s ease-out;
}

.block-table td.col-highlight {
    animation: tableInsertHighlight 0.8s ease-out;
}

/* Delete hover highlight */
.block-table tr.delete-hover-highlight td,
.block-table tr.delete-hover-highlight th {
    background-color: color-mix(in srgb, #dc3545 20%, transparent) !important;
    transition: background-color 0.15s ease;
}

.block-table td.delete-hover-highlight,
.block-table th.delete-hover-highlight {
    background-color: color-mix(in srgb, #dc3545 20%, transparent) !important;
    transition: background-color 0.15s ease;
}

/* Table controls */
.table-controls {
    display: flex;
    gap: 0.7rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.table-control-btn {
    padding: 4px 10px;
    border: 1.5px solid var(--card-border-color);
    background: var(--white);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
    color: var(--text-color);
}

.table-control-btn:hover {
    border-color: var(--edit-color);
    color: var(--edit-color);
}

.table-control-btn.active {
    background: var(--edit-color);
    border-color: var(--edit-color);
    color: var(--white);
}

.table-control-btn i {
    font-size: 0.7rem;
}

/* Table wrapper for insert buttons */
.table-wrapper {
    display: block;
    position: relative;
    width: fit-content;
    max-width: 100%;
    overflow: visible;
}

/* Insert buttons container */
.table-insert-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
    overflow: visible;
}

.table-insert-btn {
    position: absolute;
    width: 16px;
    height: 16px;
    border: none;
    background: var(--white);
    border: 1.5px solid var(--card-border-color);
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
    transform: translate(-50%, -50%);
    color: var(--text-muted);
    font-size: 0.5rem;
}

.table-insert-btn i {
    font-size: 0.5rem;
    line-height: 1;
}

.table-wrapper:hover .table-insert-btn {
    opacity: 0.6;
}

.table-insert-btn:hover {
    opacity: 1 !important;
    background: var(--edit-color);
    border-color: var(--edit-color);
    color: var(--white);
    transform: translate(-50%, -50%) scale(1.15);
}

/* Table insert menu */
.table-insert-menu {
    position: relative;
    background: var(--white, #fff);
    border: 1.5px solid var(--card-border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 140px;
}

.table-insert-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 4px 6px 12px;
    border-bottom: 1px solid var(--card-border-color);
    margin-bottom: 4px;
}

.table-insert-menu-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted, #666);
}

.table-insert-menu-close {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted, #999);
    font-size: 0.75rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.table-insert-menu-close:hover {
    background: var(--card-border-color);
    color: var(--text-color);
}

.table-insert-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-color);
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.table-insert-menu-btn:hover {
    background: var(--edit-color);
    color: var(--white);
}

.table-insert-menu-btn i {
    font-size: 0.7rem;
    width: 14px;
}

.table-insert-menu-btn.delete-btn {
    color: var(--delete-color);
}

.table-insert-menu-btn.delete-btn:hover {
    background: color-mix(in srgb, var(--delete-color) 10%, transparent);
}

.table-insert-menu-divider {
    height: 1px;
    background: var(--card-border-color);
    margin: 4px 0;
}

/* Gallery block styles */
.block-gallery-display {
    padding: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.block-gallery-display.align-left {
    align-items: flex-start;
}

.block-gallery-display.align-center {
    align-items: center;
}

.block-gallery-display.align-right {
    align-items: flex-end;
}

.gallery-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    width: 100%;
}

/* Gallery alignment - affects image positioning when fewer images than columns */
.block-gallery-display.align-left .gallery-grid {
    justify-content: flex-start;
}

.block-gallery-display.align-center .gallery-grid {
    justify-content: center;
}

.block-gallery-display.align-right .gallery-grid {
    justify-content: flex-end;
}

.gallery-item {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: var(--card-border-radius);
    /* Calculate width based on columns: (100% - gaps) / columns */
    flex: 0 0 calc((100% - 1.25rem * (var(--gallery-columns, 3) - 1)) / var(--gallery-columns, 3));
    max-width: calc((100% - 1.25rem * (var(--gallery-columns, 3) - 1)) / var(--gallery-columns, 3));
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.block-editor:not(.edit-mode) .gallery-item img {
    cursor: pointer;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.gallery-item-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: none;
    gap: 0.5rem;
    z-index: 10;
}

.block-editor.edit-mode .gallery-item:hover .gallery-item-actions {
    display: flex;
}

.gallery-item-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.95);
    color: var(--danger-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.gallery-item-btn:hover {
    background: var(--danger-color);
    color: white;
    transform: scale(1.1);
}

.gallery-item-btn.gallery-item-crop {
    color: var(--accent-color);
}

.gallery-item-btn.gallery-item-crop:hover {
    background: var(--accent-color);
    color: white;
}

/* Gallery reorder buttons */
.gallery-reorder-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-color);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 5;
}

.gallery-reorder-btn.gallery-reorder-left {
    left: 0.35rem;
}

.gallery-reorder-btn.gallery-reorder-right {
    right: 0.35rem;
}

.block-editor.edit-mode .gallery-item:hover .gallery-reorder-btn:not([disabled]) {
    display: flex;
}

.gallery-reorder-btn:hover:not([disabled]) {
    background: var(--accent-color);
    color: white;
    transform: translateY(-50%) scale(1.1);
}

.gallery-reorder-btn[disabled] {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Responsive: on small screens, arrows go top/bottom */
@media (max-width: 480px) {
    .gallery-reorder-btn {
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%);
        width: 26px;
        height: 26px;
    }
    
    .gallery-reorder-btn.gallery-reorder-left {
        top: 0.35rem;
        transform: translateX(-50%) rotate(90deg);
    }
    
    .gallery-reorder-btn.gallery-reorder-right {
        top: auto;
        bottom: 0.35rem;
        transform: translateX(-50%) rotate(90deg);
    }
    
    .gallery-reorder-btn:hover:not([disabled]) {
        transform: translateX(-50%) rotate(90deg) scale(1.1);
    }
}

/* Touch devices - always show reorder buttons */
@media (hover: none), (pointer: coarse) {
    .block-editor.edit-mode .gallery-reorder-btn:not([disabled]) {
        display: flex;
    }
}

/* Gallery item moved animation */
@keyframes galleryItemMoved {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(var(--accent-color-rgb), 0.4);
    }
    30% {
        transform: scale(1.03);
        box-shadow: 0 0 0 8px rgba(var(--accent-color-rgb), 0.2);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(var(--accent-color-rgb), 0);
    }
}

.gallery-item.just-moved {
    animation: galleryItemMoved 0.4s ease-out;
}

.gallery-add-more {
    margin-top: 0.75rem;
    display: flex;
    justify-content: center;
}

.gallery-add-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: 2px dashed var(--card-border-color);
    border-radius: var(--card-border-radius);
    background: transparent;
    color: var(--text-color);
    opacity: 0.7;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.gallery-add-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    opacity: 1;
    background: rgba(var(--accent-color-rgb), 0.05);
}

.gallery-add-btn i {
    font-size: 1rem;
}

.gallery-placeholder {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--card-border-color);
    border-radius: var(--card-border-radius);
    background: var(--light-gray);
    cursor: pointer;
    transition: all 0.2s ease;
}

.gallery-placeholder:hover {
    border-color: var(--accent-color);
    background: rgba(var(--accent-color-rgb), 0.05);
}

.gallery-placeholder .media-placeholder-content {
    text-align: center;
    color: var(--text-color);
}

.gallery-placeholder .media-placeholder-content i {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.gallery-placeholder .media-placeholder-content p {
    margin: 0;
    /* font-size: 0.875rem; */
}

/* Responsive gallery columns */
@media (max-width: 992px) {
    .gallery-item {
        /* Max 3 columns on tablets */
        flex: 0 0 calc((100% - 1.25rem * (min(var(--gallery-columns, 3), 3) - 1)) / min(var(--gallery-columns, 3), 3));
        max-width: calc((100% - 1.25rem * (min(var(--gallery-columns, 3), 3) - 1)) / min(var(--gallery-columns, 3), 3));
    }
}

@media (max-width: 768px) {
    .gallery-item {
        /* Max 2 columns on mobile */
        flex: 0 0 calc((100% - 1.25rem) / 2);
        max-width: calc((100% - 1.25rem) / 2);
    }
}

@media (max-width: 480px) {
    .gallery-item {
        /* Single column on small screens */
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Gallery settings buttons for 5 columns */
.settings-align-buttons-5 {
    grid-template-columns: repeat(5, 1fr) !important;
}

/* Touch devices - always show gallery item actions */
@media (hover: none), (pointer: coarse) {
    .block-editor.edit-mode .gallery-item-actions {
        display: flex;
    }
}

/* Gallery uploading state */
.block-gallery-display.uploading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.block-gallery-display.uploading::after {
    content: 'Uploading...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--card-border-radius);
    font-size: 0.875rem;
    z-index: 10;
}

.block-image-display {
    padding: 0;
    display: block;
}

.block-image-display:not(.full-width) {
    max-width: 100%;
    width: fit-content;
}

/* Hide overflow only when not in edit mode to show full corners */
.block-editor:not(.edit-mode) .block-image-display:not(.full-width) {
    overflow: hidden;
}

.block-image-display img {
    max-width: 100%;
    height: auto;
    border-radius: var(--card-border-radius);
    display: block;
}

/* Make images clickable in non-edit mode */
.block-editor:not(.edit-mode) .block-image-display img.lightbox-trigger {
    cursor: pointer;
}

/* Media Resize Wrapper */
.media-resize-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border-radius: var(--card-border-radius);
}

/* Hide overflow only when not in edit mode to show full corners */
.block-editor:not(.edit-mode) .media-resize-wrapper {
    overflow: hidden;
}

/* In edit mode, allow visible overflow so corners are fully visible */
.block-editor.edit-mode .media-resize-wrapper {
    overflow: visible;
}

/* Remove width constraints in full-width mode */
.full-width .media-resize-wrapper {
    max-width: none;
    width: 100vw;
    display: block;
    border-radius: 0;
}

/* When no custom height is set, allow natural height */
.media-resize-wrapper:not([style*="height"]) {
    display: block;
}

.media-resize-wrapper:not([style*="height"]) img {
    width: 100%;
    height: auto;
    object-fit: initial;
    display: block;
    border-radius: var(--card-border-radius);
}

/* Videos should maintain their original aspect ratio and dimensions */
.media-resize-wrapper:not([style*="height"]) video {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--card-border-radius);
    background: transparent;
}

/* When custom height is set, use cover behavior for images but contain for videos */
.media-resize-wrapper[style*="height"] img,
.media-resize-wrapper[style*="height"] iframe {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: var(--card-border-radius);
}

/* Videos with custom dimensions should use their intrinsic aspect ratio */
.media-resize-wrapper[style*="height"] video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: var(--card-border-radius);
    background: transparent;
}

/* Iframes always need aspect-ratio behavior */
.media-resize-wrapper iframe {
    width: 100%;
    object-fit: cover;
    display: block;
    border-radius: var(--card-border-radius);
}

.media-resize-wrapper:not([style*="height"]) iframe {
    aspect-ratio: 16 / 9;
    height: auto;
}

/* Resize Handles */
.resize-handles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 15;
}

/* Hide width-related resize handles in full-width mode */
.full-width .resize-handle-e,
.full-width .resize-handle-w,
.full-width .resize-handle-ne,
.full-width .resize-handle-nw,
.full-width .resize-handle-se,
.full-width .resize-handle-sw {
    display: none;
}

/* Hide width-related resize handles on mobile/touch devices */
@media (max-width: 992px) {
    .resize-handle-e,
    .resize-handle-w,
    .resize-handle-ne,
    .resize-handle-nw,
    .resize-handle-se,
    .resize-handle-sw {
        display: none !important;
    }
    
    /* On mobile, media containers should span full width and use aspect-ratio */
    .media-resize-wrapper {
        width: 100% !important;
        /* height: auto is set by JavaScript along with aspect-ratio */
    }
    
    /* Images and videos fill container completely while maintaining aspect ratio */
    .media-resize-wrapper img,
    .media-resize-wrapper video {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
    
    /* Iframes fill container */
    .media-resize-wrapper iframe {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
    
    /* When no custom dimensions are set, allow natural sizing */
    .media-resize-wrapper:not([style*="width:"]):not([style*="height:"]) img,
    .media-resize-wrapper:not([style*="width:"]):not([style*="height:"]) video {
        height: auto !important;
        object-fit: initial !important;
    }
    
    /* Full-width images on mobile should be half the height */
    /* .full-width .media-resize-wrapper {
        max-height: 30vh !important;
    } */

    .full-width .media-resize-wrapper {
        min-height: 162.5px !important; /* Maintain 16:9 aspect ratio for full-width media on mobile */
    }
}

.block-editor.edit-mode .block-item:hover .resize-handles {
    opacity: 1;
}

.resize-handle {
    position: absolute;
    background: var(--accent-color);
    pointer-events: auto;
    transition: background-color 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 10;
    border: 2px solid var(--white);
    border-radius: 4px;
}

.resize-handle:hover {
    background: var(--accent-color);
    opacity: 1;
}

/* Edge handles */
.resize-handle-n,
.resize-handle-s {
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 8px;
    cursor: ns-resize;
}

.resize-handle-n {
    top: -4px;
}

.resize-handle-s {
    bottom: -4px;
}

.resize-handle-e,
.resize-handle-w {
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 60px;
    cursor: ew-resize;
}

.resize-handle-e {
    right: -4px;
}

.resize-handle-w {
    left: -4px;
}

/* Corner handles */
.resize-handle-ne,
.resize-handle-nw,
.resize-handle-se,
.resize-handle-sw {
    width: 10px;
    height: 10px;
}

.resize-handle-ne {
    top: -3px;
    right: -3px;
    cursor: nesw-resize;
}

.resize-handle-nw {
    top: -3px;
    left: -3px;
    cursor: nwse-resize;
}

.resize-handle-se {
    bottom: -3px;
    right: -3px;
    cursor: nwse-resize;
}

.resize-handle-sw {
    bottom: -3px;
    left: -3px;
    cursor: nesw-resize;
}

/* Active resizing state */
.media-resize-wrapper.resizing {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.media-resize-wrapper.resizing .resize-handles {
    opacity: 1;
}

/* Disable pointer events and touch actions on video/iframe during resize */
.media-resize-wrapper.resizing video,
.media-resize-wrapper.resizing iframe {
    pointer-events: none;
    touch-action: none;
}

/* Dimension indicator */
.resize-dimension-indicator {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: var(--white);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    z-index: 100;
}

/* Full-width media support */
.block-image-display.full-width,
.block-video-display.full-width {
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    width: 100vw !important;
    max-width: 100vw !important;
}

.block-image-display.full-width img {
    width: 100vw !important;
    border-radius: 0;
    max-width: none;
}

.block-image-display.full-width .media-resize-wrapper img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
}

.block-image-display.full-width .image-caption,
.block-video-display.full-width .video-caption {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.block-video-display.full-width iframe,
.block-video-display.full-width video {
    width: 100%;
    border-radius: 0;
}

.block-video-display.full-width .media-resize-wrapper {
    width: 100%;
}

.block-video-display.full-width .media-resize-wrapper iframe,
.block-video-display.full-width .media-resize-wrapper video {
    width: 100%;
    border-radius: 0;
}

.block-image-display .image-caption,
.block-video-display .video-caption {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-color);
    margin-top: .75rem;
    font-style: italic;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.block-video-display .video-caption {
    margin-top: 1.1rem;
}

/* Caption alignment based on parent alignment */
.block-image-display.align-left .image-caption,
.block-video-display.align-left .video-caption {
    text-align: left;
}

.block-image-display.align-center .image-caption,
.block-video-display.align-center .video-caption {
    text-align: center;
}

.block-image-display.align-right .image-caption,
.block-video-display.align-right .video-caption {
    text-align: right;
}

.block-video-display {
    padding: 0;
    display: block;
}

.block-video-display:not(.full-width) {
    max-width: 100%;
    width: fit-content;
}

/* Hide overflow only when not in edit mode to show full corners */
.block-editor:not(.edit-mode) .block-video-display:not(.full-width) {
    overflow: hidden;
}

/* In edit mode, allow visible overflow so resize handles are fully visible */
.block-editor.edit-mode .block-video-display:not(.full-width) {
    overflow: visible;
}

.block-video-display iframe {
    width: 100%;
    border-radius: var(--card-border-radius);
    display: block;
    background: #000;
}

.block-video-display video {
    width: 100%;
    border-radius: var(--card-border-radius);
    display: block;
    background: transparent;
    outline: none;
}

/* Only apply 16:9 aspect ratio to iframes (YouTube/Vimeo) when no custom height is set */
.block-video-display:not([style*="height"]) .media-resize-wrapper:not([style*="height"]) iframe {
    aspect-ratio: 16 / 9;
}

.block-file-display {
    margin: 0;
    padding: 0;
}

.block-file-display a {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background-color: color-mix(in srgb, var(--accent-color) 10%, transparent);
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: all 0.2s ease-in-out !important;
}

.block-file-display a:hover {
    color: white;
    background-color: var(--accent-color);
}

.file-info-text {
    margin: 0.5rem 0 0 0;
    font-size: 0.875rem;
    color: #6c757d;
    font-style: italic;
}

/* Media Placeholder Styles */
.media-placeholder {
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--white);
    border: 2px dashed var(--card-border-color);
    border-radius: var(--card-border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 1.5rem;
    width: 100% !important;  /* Force full width for placeholders */
    max-width: 100% !important;
    position: relative;
}

/* Media Placeholder Loading State */
.media-placeholder.uploading {
    pointer-events: none;
    border-color: var(--accent-color);
    background-color: var(--primary-color-light);
}

.media-placeholder.uploading .media-placeholder-content {
    opacity: 0.3;
}

.media-placeholder-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    border-radius: var(--card-border-radius);
    z-index: 10;
}

.media-placeholder-loading i {
    font-size: 2rem;
    color: var(--accent-color);
    margin-bottom: 0.75rem;
    animation: spin 1s linear infinite;
}

.media-placeholder-loading p {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-color);
}

/* Media loading state (for images/videos loading after upload) */
.media-resize-wrapper.media-loading {
    position: relative;
    min-height: 150px;
}

.media-resize-wrapper.media-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, var(--primary-color-light) 25%, var(--card-border-color) 50%, var(--primary-color-light) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    z-index: 5;
    border-radius: var(--card-border-radius);
}

.media-resize-wrapper.media-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    border: 3px solid var(--card-border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 6;
}

.media-resize-wrapper.media-loading img,
.media-resize-wrapper.media-loading video {
    opacity: 0;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Hide media placeholders when not in edit mode */
.block-editor:not(.edit-mode) .media-placeholder {
    visibility: hidden !important;
}

.block-editor.edit-mode .media-placeholder:hover {
    background-color: var(--primary-color-light);
    border-color: var(--accent-color);
    border-style: dashed;
}

/* Drag over state */
.block-editor.edit-mode .media-placeholder.drag-over {
    background-color: color-mix(in srgb, var(--accent-color) 15%, var(--white));
    border-color: var(--accent-color);
    border-style: solid;
    border-width: 3px;
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.block-editor.edit-mode .media-placeholder.drag-over .media-placeholder-content i {
    opacity: 1;
    transform: scale(1.2);
    color: var(--accent-color);
}

.block-editor.edit-mode .media-placeholder.drag-over .media-placeholder-content p {
    opacity: 1;
    font-weight: 600;
}

.media-placeholder-content {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: var(--text-color);
    min-height: 100px;
    margin: auto;
}

.media-placeholder-content div {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-color);
}

.media-placeholder-content i {
    font-size: 2rem;
    color: var(--accent-color);
    margin-bottom: 0;
    opacity: 0.8;
    transition: all 0.2s ease-in-out;
}

.media-placeholder-content p {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    opacity: 0.9;
    transition: all 0.2s ease-in-out;
}

.block-editor.edit-mode .media-placeholder:hover .media-placeholder-content i {
    opacity: 1;
    transform: scale(1.1);
}

.block-editor.edit-mode .media-placeholder:hover .media-placeholder-content p {
    opacity: 1;
}

/* File placeholder specific styles */
.media-placeholder.block-file-display {
    min-height: 120px;
}

/* Media Placeholder URL Button */
.media-placeholder-url-btn {
    display: block;
    margin-top: 0.75rem;
    color: var(--accent-color);
    font-size: 0.9rem;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.8;
    transition: all 0.2s ease-in-out;
}

.media-placeholder-url-btn:hover {
    text-decoration: none;
    color: color-mix(in srgb, var(--accent-color) 85%, black);
    opacity: 1;
}

.media-placeholder-url-btn:active {
    transform: translateY(0);
}

.media-placeholder-url-btn i {
    font-size: 0.9rem;
}

@media (max-width: 992px) {
    .media-placeholder-content i, .media-placeholder-content p, .media-placeholder-url-btn {
        opacity: 1;
    }
}

/* Media Hover Controls (Alignment buttons inside media) */
.media-hover-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
    pointer-events: none;
}

/* Hide alignment controls when media is full-width */
.full-width .media-alignment-controls {
    display: none;
}

/* Hide width switch button for videos (only images can be full-width) */
.block-video-display .media-width-switch {
    display: none;
}

.media-width-switch {
    display: flex;
    background: var(--white);
    padding: 0.375rem;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.media-width-switch-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    border: 2px solid var(--card-border-color);
    border-radius: 6px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    pointer-events: auto;
    font-size: 0.875rem;
    padding: 0;
}

.media-width-switch-btn:hover {
    background-color: var(--primary-color-light);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.media-width-switch-btn.active {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--white);
}

.media-width-switch-btn.active:hover {
    background-color: var(--accent-color);
    opacity: 0.9;
}

.media-alignment-controls {
    display: flex;
    gap: 0.25rem;
    background: var(--white);
    padding: 0.375rem;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.media-hover-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    border: 2px solid var(--card-border-color);
    border-radius: 6px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    pointer-events: auto;
    font-size: 0.875rem;
    padding: 0;
}

.media-hover-btn:hover {
    background-color: var(--primary-color-light);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.media-hover-btn.active {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--white);
}

.media-hover-btn.active:hover {
    background-color: var(--accent-color);
    opacity: 0.9;
}

/* Show media hover controls on hover for desktop devices only */
@media (hover: hover) and (pointer: fine) {
    .block-editor.edit-mode .block-image-display:not(.media-placeholder):hover .media-hover-controls,
    .block-editor.edit-mode .block-video-display:not(.media-placeholder):hover .media-hover-controls,
    .block-editor.edit-mode .block-embed-display:not(.media-placeholder):hover .media-hover-controls {
        opacity: 1;
    }
}

/* Hide media hover controls on mobile/touch devices */
@media (hover: none) and (pointer: coarse) {
    .media-hover-controls {
        display: none !important;
    }
    
    .media-width-switch:not(:has(.block-image-crop-btn)),
    .media-width-switch-btn:not(.block-image-crop-btn) {
        display: none !important;
    }
}

/* Also hide on small screens regardless of pointer type */
@media (max-width: 992px) {
    /* Hide media hover controls by default on mobile */
    .media-hover-controls {
        display: none !important;
    }
    
    /* Hide media-width-switch on mobile (but not crop button container) */
    .media-width-switch:not(:has(.block-image-crop-btn)),
    .media-width-switch-btn:not(.block-image-crop-btn) {
        display: none !important;
    }
    
    /* Show media-hover-controls container when mobile-edit-active */
    .block-item.mobile-edit-active .media-hover-controls {
        display: flex !important;
        opacity: 1 !important;
    }
    
    /* Keep media-alignment-controls hidden even when mobile-edit-active */
    .block-item.mobile-edit-active .media-alignment-controls {
        display: none !important;
    }
    
    /* Show crop button container when mobile-edit-active */
    .block-item.mobile-edit-active .media-width-switch:has(.block-image-crop-btn) {
        display: flex !important;
    }
    
    /* Show crop button when mobile-edit-active */
    .block-item.mobile-edit-active .block-image-crop-btn {
        display: flex !important;
    }
}

/* Media Edit Overlay */
.media-edit-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    cursor: pointer;
    z-index: 5;
    border-radius: var(--card-border-radius);
    pointer-events: none;
}

.media-edit-overlay i {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    width: 60px;
    height: 60px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.5rem;
    color: var(--accent-color);
    pointer-events: none;
    touch-action: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    line-height: 55px;
    text-align: center;
    vertical-align: middle;
}

.media-edit-overlay i::before {
    line-height: normal;
    vertical-align: middle;
}

/* Show on hover for desktop devices */
@media (hover: hover) and (pointer: fine) {
    .block-editor.edit-mode .block-image-display:not(.media-placeholder):hover .media-edit-overlay,
    .block-editor.edit-mode .block-video-display:not(.media-placeholder):hover .media-edit-overlay,
    .block-editor.edit-mode .block-file-display:not(.media-placeholder):hover .media-edit-overlay,
    .block-editor.edit-mode .block-openstad-display:not(.media-placeholder):hover .media-edit-overlay {
        opacity: 1;
    }
    
    /* Enable pointer events on hover for desktop */
    .block-editor.edit-mode .block-image-display:not(.media-placeholder):hover .media-edit-overlay i,
    .block-editor.edit-mode .block-video-display:not(.media-placeholder):hover .media-edit-overlay i,
    .block-editor.edit-mode .block-file-display:not(.media-placeholder):hover .media-edit-overlay i,
    .block-editor.edit-mode .block-openstad-display:not(.media-placeholder):hover .media-edit-overlay i {
        pointer-events: auto;
        touch-action: auto;
    }
    
    .media-edit-overlay:hover i {
        transform: scale(1.1);
        background: rgba(255, 255, 255, 1);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }
}

/* Only visible on touch devices when block is toggled for editing */
@media (hover: none) and (pointer: coarse) {
    .block-editor.edit-mode .block-item.mobile-edit-active .block-image-display:not(.media-placeholder) .media-edit-overlay,
    .block-editor.edit-mode .block-item.mobile-edit-active .block-video-display:not(.media-placeholder) .media-edit-overlay,
    .block-editor.edit-mode .block-item.mobile-edit-active .block-file-display:not(.media-placeholder) .media-edit-overlay,
    .block-editor.edit-mode .block-item.mobile-edit-active .block-openstad-display:not(.media-placeholder) .media-edit-overlay {
        opacity: 1;
    }
    
    /* Enable pointer events only when mobile-edit-active on touch devices */
    .block-editor.edit-mode .block-item.mobile-edit-active .block-image-display:not(.media-placeholder) .media-edit-overlay i,
    .block-editor.edit-mode .block-item.mobile-edit-active .block-video-display:not(.media-placeholder) .media-edit-overlay i,
    .block-editor.edit-mode .block-item.mobile-edit-active .block-file-display:not(.media-placeholder) .media-edit-overlay i,
    .block-editor.edit-mode .block-item.mobile-edit-active .block-openstad-display:not(.media-placeholder) .media-edit-overlay i {
        pointer-events: auto;
    }
}

/* Block Selection Checkbox */
.block-select-checkbox {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--white);
    border: 2px solid var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 10;
    color: var(--accent-color);
    font-size: 0.95rem;
    padding: 0;
}

.block-editor.edit-mode .block-item:hover .block-select-checkbox {
    opacity: 1;
}

.block-select-checkbox.selected {
    opacity: 1;
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--white);
}

@media (hover: hover) and (pointer: fine) {
    .block-select-checkbox:hover {
        border-color: var(--accent-color);
        color: var(--accent-color);
        transform: scale(1.1);
    }

    .block-select-checkbox.selected:hover {
        background: var(--accent-color);
        color: white;
        opacity: 0.9;
    }
}

.block-select-checkbox i::before {
    content: ""; /* fa-check */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
}

.block-select-checkbox.selected i::before {
    content: "\f00c"; /* fa-check */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
}

/* Mobile: position checkbox to the left and only show when toggled */
@media (max-width: 992px) {
    .block-select-checkbox {
        right: 0.5rem;
        top: 0.5rem;
        border-color: var(--card-border-color);
    }
}

/* Selected block state */
.block-item.block-selected {
    outline: 2px solid var(--accent-color);
    outline-offset: -2px;
    background-color: color-mix(in srgb, var(--accent-color) 8%, transparent);
    border-radius: var(--card-border-radius);
}

/* When blocks are selected (has-selection class on editor), hide all block-actions */
.block-editor.has-selection .block-item .block-actions {
    opacity: 0;
    pointer-events: none;
}

/* Show block-actions only for the first selected block */
.block-editor.has-selection .block-item.block-selected.first-selected .block-actions {
    opacity: 1;
    pointer-events: auto;
}

/* Hide settings button when block is selected, show delete instead */
.block-item.block-selected .settings-block {
    display: none;
}

/* Hide add-below button when blocks are selected */
.block-editor.has-selection .block-add-below {
    display: none;
}

/* Hide mobile-edit-toggle buttons when blocks are selected */
.block-editor.has-selection .mobile-edit-toggle {
    display: none;
}

/* Multi-Select Action Bar */
.multi-select-action-bar {
    position: fixed;
    bottom: 105px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--white);
    border: 2px solid var(--accent-color);
    border-radius: 12px;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-lg);
    z-index: 1050;
    animation: slideUpFromBottom 0.3s ease;
}

@keyframes slideUpFromBottom {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.multi-select-info {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.95rem;
    line-height: 1.2;
    padding-right: 0.75rem;
    border-right: 1.5px solid var(--card-border-color);
}

.multi-select-info .selected-count {
    color: var(--accent-color);
    font-weight: 700;
}

.multi-select-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.multi-select-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--white);
    border: 2px solid var(--card-border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-color);
    font-size: 0.95rem;
    padding: 0;
}

.multi-select-btn.delete-selected {
    color: #dc3545;
}

@media (hover: hover) and (pointer: fine) {
    .multi-select-btn:hover {
        background: var(--primary-color-light);
        border-color: var(--accent-color);
        color: var(--accent-color);
    }

    .multi-select-btn.delete-selected:hover {
        background: #fee;
        border-color: #dc3545;
        color: #dc3545;
    }
}

.multi-select-btn:disabled,
.multi-select-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

@media (max-width: 992px) {
    .multi-select-action-bar {
        bottom: 100px;
        padding: 0.625rem 1rem;
        gap: 0.75rem;
    }
    
    .multi-select-btn {
        width: 40px;
        height: 40px;
    }
    
    .block-select-checkbox {
        opacity: 1;
    }
}

/* Block Actions */
.block-actions {
    position: absolute;
    top: 0;
    right: -60px; /* Position outside the block to the right */
    display: flex;
    flex-direction: column;
    gap: 0;
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Invisible bridge to keep actions visible while mouse travels to them */
.block-actions::before {
    content: '';
    position: absolute;
    top: 0;
    right: 100%; /* Start from left edge of actions */
    width: 60px; /* Width of the gap between block and actions */
    height: 100%;
    background: transparent;
    pointer-events: auto; /* Ensure it captures hover events */
}

/* Block actions appear on hover - only in edit mode (but not when selection is active) */
.block-editor.edit-mode:not(.has-selection) .block-item:hover .block-actions {
    opacity: 1;
}

/* Keep actions visible when hovering over the actions themselves or the bridge */
.block-editor.edit-mode:not(.has-selection) .block-actions:hover {
    opacity: 1;
}

/* Keep actions visible and highlight block when settings menu is open */
.block-editor.edit-mode .block-item.settings-open .block-actions {
    opacity: 1;
}

.block-editor.edit-mode .block-item.settings-open {
    border-color: var(--accent-color);
    background-color: var(--primary-color-light);
}

.block-editor.edit-mode .block-item.settings-open .settings-block {
    background-color: var(--accent-color);
    color: var(--white);
    border-color: var(--accent-color);
}

/* Block settings dropdown */
.block-settings-menu {
    position: absolute;
    top: 0;
    right: -234px; /* Position to the right of block-actions */
    margin-top: 0;
    padding-left: 0.5rem;
    background: transparent;
    border: none;
    min-width: 220px;
    z-index: 100;
    animation: slideInRight 0.2s ease;
}

/* Left-positioned variant: anchored to right edge of block-item (inside content area) */
.block-settings-menu.position-left {
    right: 60px; /* 60px = block-actions offset from block-item edge, so menu aligns to block right edge */
    left: auto;
    padding-left: 0;
    padding-right: 0;
    animation: slideInLeft 0.2s ease;
}

.block-settings-menu.position-left::before {
    display: none; /* No hover bridge needed when inside the block */
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Invisible bridge between block-actions and settings menu to keep menu open while mouse travels */
.block-settings-menu::before {
    content: '';
    position: absolute;
    top: 0;
    right: 100%; /* Start from left edge of settings menu */
    width: 14px; /* Bridge the gap between actions and settings menu (14px = the gap) */
    height: 100%;
    background: transparent;
    pointer-events: auto; /* Ensure it captures hover events */
}

.block-settings-menu-content {
    background: var(--white);
    border: 1.5px solid var(--card-border-color) !important;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.block-settings-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    padding-right: .75rem;
    border-bottom: 1.5px solid var(--card-border-color);
    background: var(--white);
    border-radius: 12px 12px 0 0;
}

.block-settings-menu-title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
}

.block-settings-menu-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.block-settings-menu-close:hover {
    background-color: var(--primary-color);
    color: var(--accent-color);
}

.block-settings-menu-close i {
    font-size: 1rem;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.settings-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.625rem 1rem;
    background: var(--white);
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 0.875rem;
    color: var(--text-color);
}

.settings-option:first-child {
    border-radius: 4px 4px 0 0;
}

.settings-option:last-child {
    border-radius: 0 0 4px 4px;
}

.settings-option:hover {
    background-color: var(--primary-color-light);
}

.settings-option.delete-block, .settings-option.delete-block i {
    color: #d00;
}

.settings-option.delete-block:hover {
    background-color: #fee;
}

.settings-option i {
    font-size: 1rem;
    color: var(--accent-color);
    min-width: 1.4rem;
}

/* Settings Alignment Section (inside block settings menu) */
.settings-align-section {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--card-border-color);
}

.settings-align-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-align-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: stretch;
}

.settings-align-btn {
    flex: 1;
    padding: 0.5rem;
    background: var(--white);
    border: 2px solid var(--card-border-color);
    border-radius: 4px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-type-btn {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.625rem 0.5rem;
}

.settings-btn-label {
    font-size: 0.7rem;
    font-weight: 500;
    line-height: 1;
}

.settings-align-btn:hover {
    background-color: var(--primary-color);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.settings-align-btn.active {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--white);
}

.settings-align-btn.active:hover {
    background-color: var(--accent-color);
    opacity: 0.9;
}

.settings-align-btn i {
    font-size: 1rem;
}

/* 4-button layout for heading levels */
.settings-align-buttons-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
}

/* Action section (Bewerken, Verwijder) - no border at bottom, no label */
.settings-action-section {
    border-bottom: none;
    padding: 0.75rem 1rem;
}

.settings-action-section .settings-align-buttons {
    justify-content: flex-start;
}

.settings-action-btn {
    flex: 0 0 auto;
    width: 53.5px;
    padding: 0.625rem;
}

.settings-action-btn.delete-block {
    color: #dc3545;
    border-color: var(--card-border-color);
}

.settings-action-btn.delete-block:hover {
    background-color: #dc3545;
    border-color: #dc3545;
    color: var(--white);
}

.settings-action-btn.delete-block.active {
    background-color: #dc3545;
    border-color: #dc3545;
    color: var(--white);
}

/* Change Block Type Modal Styles */
.block-type-change-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.block-type-change-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem;
    background: var(--white);
    border: 2px solid var(--card-border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}

.block-type-change-option i {
    font-size: 1.5rem;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
}

.block-type-change-option span {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-color);
    display: block;
    margin-bottom: 0.25rem;
}

.block-type-change-option small {
    font-size: 0.875rem;
    color: var(--text-color);
}

.block-type-change-option:hover {
    border-color: var(--accent-color);
    background-color: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.block-type-change-option.current-type {
    border-color: var(--accent-color);
    background-color: rgba(var(--accent-color-rgb, 0, 123, 255), 0.05);
}

/* Change Heading Level Modal Styles */
.heading-level-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.heading-level-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem;
    background: var(--white);
    border: 2px solid var(--card-border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}

.heading-level-option .level-preview {
    font-weight: 600;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
}

.heading-level-option .h1-preview {
    font-size: 2rem;
}

.heading-level-option .h2-preview {
    font-size: 1.75rem;
}

.heading-level-option .h3-preview {
    font-size: 1.5rem;
}

.heading-level-option .h4-preview {
    font-size: 1.25rem;
}

.heading-level-option .level-label {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-color);
    display: block;
    margin-bottom: 0.25rem;
}

.heading-level-option small {
    font-size: 0.875rem;
    color: var(--text-color);
}

.heading-level-option:hover {
    border-color: var(--accent-color);
    background-color: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.heading-level-option.current-level {
    border-color: var(--accent-color);
    background-color: rgba(var(--accent-color-rgb, 0, 123, 255), 0.05);
}

/* Change Media Width Modal Styles */
.media-width-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.media-width-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem;
    background: var(--white);
    border: 2px solid var(--card-border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}

.media-width-option i {
    font-size: 1.5rem;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
}

.media-width-option .width-label {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-color);
    display: block;
    margin-bottom: 0.25rem;
}

.media-width-option small {
    font-size: 0.875rem;
    color: var(--text-color);
    display: block;
    margin-bottom: 0.75rem;
}

.media-width-option .width-preview {
    width: 100%;
    padding: 0.5rem;
    background: var(--primary-color-light);
    border-radius: 4px;
    display: flex;
    justify-content: center;
}

.media-width-option .preview-box {
    height: 40px;
    background: var(--accent-color);
    opacity: 0.3;
    border-radius: 2px;
}

.media-width-option .normal-preview {
    width: 60%;
}

.media-width-option .full-preview {
    width: 100%;
}

.media-width-option:hover {
    border-color: var(--accent-color);
    background-color: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.media-width-option:hover .preview-box {
    opacity: 0.5;
}

.media-width-option.current-width {
    border-color: var(--accent-color);
    background-color: rgba(var(--accent-color-rgb, 0, 123, 255), 0.05);
}

.media-width-option.current-width .preview-box {
    opacity: 0.6;
}

/* Change Media Alignment Modal Styles */
.media-align-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.media-align-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem;
    background: var(--white);
    border: 2px solid var(--card-border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}

.media-align-option i {
    font-size: 1.5rem;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
}

.media-align-option .align-label {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-color);
    display: block;
    margin-bottom: 0.25rem;
}

.media-align-option small {
    font-size: 0.875rem;
    color: var(--text-color);
    display: block;
    margin-bottom: 0.75rem;
}

.media-align-option .align-preview {
    width: 100%;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 4px;
    display: flex;
}

.media-align-option .align-preview.left-align {
    justify-content: flex-start;
}

.media-align-option .align-preview.center-align {
    justify-content: center;
}

.media-align-option .align-preview.right-align {
    justify-content: flex-end;
}

.media-align-option .preview-box {
    height: 40px;
    width: 60%;
    background: var(--accent-color);
    opacity: 0.3;
    border-radius: 2px;
}

.media-align-option .left-preview {
    margin-right: auto;
}

.media-align-option .center-preview {
    margin-left: auto;
    margin-right: auto;
}

.media-align-option .right-preview {
    margin-left: auto;
}

.media-align-option:hover {
    border-color: var(--accent-color);
    background-color: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.media-align-option:hover .preview-box {
    opacity: 0.5;
}

.media-align-option.current-align {
    border-color: var(--accent-color);
    background-color: rgba(var(--accent-color-rgb, 0, 123, 255), 0.05);
}

.media-align-option.current-align .preview-box {
    opacity: 0.6;
}

/* Block Edit Modal - Custom Positioning */
#blockEditModal.modal {
    background: transparent !important;
}

#blockEditModal.show {
    background: transparent !important;
}

#blockEditModal .modal-dialog {
    position: fixed;
    margin: 0;
    pointer-events: none;
    transform: none !important;
    max-width: calc(100vw - 40px);
    width: 400px;
    opacity: 0;
    transition: opacity 0.15s ease-in;
}

#blockEditModal .modal-dialog.positioned {
    opacity: 1;
}

#blockEditModal .modal-content {
    pointer-events: auto;
    box-shadow: var(--shadow);
    border: 1.5px solid var(--card-border-color);
}

#blockEditModal .modal-body {
    max-height: calc(40vh - 60px) !important;
    overflow-y: auto;
}

/* Hide backdrop when blockEditModal is open */
body:has(#blockEditModal.show) > .modal-backdrop {
    display: none !important;
}

/* Allow scrolling when blockEditModal is open */
body.modal-open {
    overflow: auto !important;
    padding-right: 0 !important;
}

/* Mobile responsive adjustments */
@media (max-width: 992px) {
    #blockEditModal .modal-dialog {
        width: calc(100vw - 60px) !important;
        max-width: 400px !important;
    }
    
    #blockEditModal .modal-content {
        max-height: calc(100vh - 60px) !important;
        font-size: 0.9rem;
    }
    
    #blockEditModal .modal-header {
        padding: 0.75rem 1rem;
    }
    
    #blockEditModal .modal-body {
        padding: 1rem;
        max-height: calc(40vh - 60px) !important;
    }
    
    #blockEditModal .modal-footer {
        padding: 0.75rem 1rem;
    }
    
    #blockEditModal .form-group {
        margin-bottom: 0.75rem;
    }
}

@media (max-width: 480px) {
    #blockEditModal .modal-dialog {
        width: calc(100vw - 20px);
        max-width: calc(100vw - 20px);
    }
    
    #blockEditModal .modal-content {
        max-height: calc(100vh - 20px);
    }
    
    #blockEditModal .modal-title {
        font-size: 1rem;
    }
    
    #blockEditModal .btn {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }
    
    #blockEditModal .form-control {
        font-size: 0.875rem;
    }
    
    #blockEditModal .upload-method-toggle {
        gap: 0.5rem;
    }
    
    #blockEditModal .upload-method-btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
    }
}

/* Block Alignment Classes */
/* Media blocks (image, video) */
.block-image-display.align-left,
.block-video-display.align-left {
    margin-left: 0 !important;
    margin-right: auto !important;
}

.block-image-display.align-center,
.block-video-display.align-center {
    margin-left: auto !important;
    margin-right: auto !important;
}

.block-image-display.align-right,
.block-video-display.align-right {
    margin-left: auto !important;
    margin-right: 0 !important;
}

/* Tekst blocks (title, heading, paragraph, subtitle) */
.block-title-display.align-left,
.block-heading-display.align-left,
.block-paragraph-display.align-left,
.block-subtitle-display.align-left {
    text-align: left;
}

.block-title-display.align-center,
.block-heading-display.align-center,
.block-paragraph-display.align-center,
.block-subtitle-display.align-center {
    text-align: center;
}

.block-title-display.align-right,
.block-heading-display.align-right,
.block-paragraph-display.align-right,
.block-subtitle-display.align-right {
    text-align: right;
}

/* Button block alignment */
.block-button-display.align-left {
    text-align: left;
}

.block-button-display.align-center {
    text-align: center;
}

.block-button-display.align-right {
    text-align: right;
}

/* Embed block alignment */
.block-embed-display.align-left {
    margin-left: 0 !important;
    margin-right: auto !important;
}

.block-embed-display.align-center {
    margin-left: auto !important;
    margin-right: auto !important;
}

.block-embed-display.align-right {
    margin-left: auto !important;
    margin-right: 0 !important;
}

/* Full-width embed should ignore alignment */
.block-embed-display.full-width {
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
}

/* File block alignment */
.block-file-display.align-left {
    text-align: left;
}

.block-file-display.align-center {
    text-align: center;
}

.block-file-display.align-right {
    text-align: right;
}

/* Full-width media should ignore alignment */
.block-image-display.full-width,
.block-video-display.full-width {
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
}

/* Plus icon buttons for adding blocks above/below */
.block-add-above,
.block-add-below {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 32px;
    background: var(--white);
    border: 2px solid var(--accent-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.block-add-above {
    top: -16px;
    display: none !important;  /* Always hidden */
}

.block-add-below {
    bottom: -16px;
}

.block-editor.edit-mode .block-item:hover .block-add-below {
    opacity: 1;
}

.block-add-above:hover,
.block-add-below:hover {
    background-color: var(--accent-color);
    color: var(--white);
    transform: translateX(-50%) scale(1.1);
}

.block-add-above i,
.block-add-below i {
    font-size: 1rem;
    color: var(--accent-color);
    transition: color 0.2s ease;
}

.block-add-above:hover i,
.block-add-below:hover i {
    color: var(--white);
}

.btn-icon {
    background: var(--white);
    border: 2px solid var(--card-border-color);
    border-radius: 6px;
    padding: 0.375rem 0.5rem;
    margin-bottom: .25rem;
    cursor: pointer;
    color: var(--text-color);
    transition: all 0.2s ease;
    font-size: 0.875rem;
    width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background-color: var(--primary-color);
    color: var(--accent-color);
    border-color: var(--accent-color);
    z-index: 1;
}

.btn-icon.disabled,
.btn-icon:disabled {
    opacity: 0.35;
    pointer-events: none;
    cursor: not-allowed;
}

.btn-icon.settings-block:hover,
.btn-icon.settings-block.active {
    background-color: var(--accent-color);
    color: var(--white);
    z-index: 1;
}

/* Add Block Menu */
.add-block-menu {
    position: relative;
    text-align: center;
    margin-top: 2rem;
}

.add-block-menu-container {
    /* max-width: 500px; */
    margin: 0 1.5rem;
    padding: .8rem 1.2rem .6rem 1.2rem;
    background: color-mix(in srgb, var(--accent-color) 3%, transparent);
    border: 1.5px solid color-mix(in srgb, var(--accent-color) 4%, transparent);
    border-radius: var(--card-border-radius);
    margin-bottom: 4rem;
}

.add-block-description {
    color: var(--text-color);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    font-weight: 400;
}

/* Primary block buttons (Title, Tekst, Image) */
.primary-block-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-primary-block {
    width: 140px;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    background: var(--white);
    border: 1.5px solid var(--card-border-color);
    border-radius: var(--card-border-radius);
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease !important;
    cursor: pointer;
}

.btn-primary-block i {
    font-size: 1.5rem;
    color: var(--accent-color);
    transition: transform 0.2s ease;
}

.btn-primary-block:hover {
    background: var(--primary-color);
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.btn-primary-block:hover i {
    transform: scale(1.1);
}

.btn-primary-block:active, .btn-primary-block:focus {
    color: white !important;
    transform: translateY(0);
}

.btn-primary-block:active i, .btn-primary-block:focus i {
    color: white !important;
}

/* More blocks expandable section */
.more-blocks-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.more-blocks-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 0;
    transition: all 0.2s ease;
    cursor: pointer;
}

.more-blocks-link:hover {
    color: var(--accent-color);
    opacity: 0.8;
}

.more-blocks-link i.fa-plus-circle {
    font-size: 0.875rem;
}

#moreBlocksChevron {
    transition: transform 0.3s ease;
    font-size: 0.875rem;
}

#moreBlocksChevron.rotated {
    transform: rotate(180deg);
}

.more-blocks-container {
    margin-top: -1rem;
    padding-top: 1rem;
    padding-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    max-width: calc(140px * 3 + 1rem * 2);
    margin-left: auto;
    margin-right: auto;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.more-blocks-container.expanded {
    max-height: 2000px;
    opacity: 1;
}

/* Secondary block buttons (for more blocks section) */
.btn-secondary-block {
    width: 140px;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    background: var(--white);
    border: 1.5px solid var(--card-border-color);
    border-radius: var(--card-border-radius);
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease !important;
    cursor: pointer;
}

.btn-secondary-block i {
    font-size: 1.5rem;
    color: var(--accent-color);
    transition: transform 0.2s ease;
}

.btn-secondary-block:hover {
    background: var(--primary-color);
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.btn-secondary-block:hover i {
    transform: scale(1.1);
}

.btn-secondary-block:active, .btn-secondary-block:focus {
    color: white !important;
    transform: translateY(0);
}

.btn-secondary-block:active i, .btn-secondary-block:focus i {
    color: white !important;
}

@media (max-width: 992px) {
    .add-block-menu-container {
        max-width: 100%;
        padding: 1rem 1rem;
        margin: auto 1rem;
        margin-bottom: 2rem;
    }

    .add-block-menu {
        padding-top: 1rem;
    }

    .primary-block-buttons, .more-blocks-container {
        gap: .75rem;
    }
}

/* Hidden block type menu for plus icon insertions */
.block-type-menu {
    position: fixed;
    background: var(--white);
    border: 1.5px solid var(--card-border-color);
    border-radius: var(--card-border-radius);
    box-shadow: var(--shadow);
    padding: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    min-width: 300px;
}

.block-type-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1.5px solid var(--card-border-color);
    background: var(--white);
    border-radius: var(--card-border-radius) var(--card-border-radius) 0 0;
}

.block-type-menu-title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
}

.block-type-menu-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.block-type-menu-close:hover {
    background-color: var(--primary-color);
    color: var(--accent-color);
}

.block-type-menu-close i {
    font-size: 1rem;
}

.block-type-menu-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    padding: 0.5rem;
    overflow-y: auto;
    max-height: 250px !important;
}

/* Block Editor Actions (Save/Cancel) */
.block-editor-actions {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 1rem;
    width: calc(100% - 8rem);
    max-width: calc(800px - 8rem);
    background: var(--white);
    border: 2px solid var(--accent-color);
    border-radius: var(--card-border-radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    z-index: 9999;
    animation: slideUpCenter 0.3s ease;
    box-shadow: var(--shadow-lg);
}

@keyframes slideUpCenter {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.unsaved-changes-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #f57c00;
    font-weight: 600;
}

.unsaved-changes-indicator i {
    font-size: 1.2rem;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    width: 100%;
}

.action-buttons .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    /* padding: 0.625rem 1.25rem; */
    font-weight: 700;
}

@media (max-width: 992px) {
    .block-editor-actions {
        flex-direction: column;
        text-align: center;
        left: 50%;
        transform: translateX(-50%);
        width: calc(100vw - 2rem);
        bottom: 15px;
    }
    
    .action-buttons {
        width: 100%;
        justify-content: center;
    }
}

/* Undo/Redo Buttons */
.undo-redo-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: auto;
}

.undo-redo-buttons .btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease !important;
    border: none !important;
    color: var(--text-color);
}

.undo-redo-buttons .btn i {
    margin: 0;
}

.undo-redo-buttons .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.undo-redo-buttons .btn:disabled:hover {
    transform: none !important;
}

.undo-redo-buttons .btn:not(:disabled):hover {
    background-color: var(--accent-color);
    color: var(--white);
    border: none !important;
    transform: none !important;
}

.history-counter {
    font-size: 0.75rem;
    color: var(--text-color);
    margin-left: 0.5rem;
    margin-right: 0.5rem;
    font-weight: 500;
    min-width: 2rem;
    text-align: center;
}

@media (max-width: 992px) {
    .undo-redo-buttons {
        gap: 0.25rem;
        margin-right: auto;
    }
    
    .undo-redo-buttons .btn {
        width: 10px !important;
        min-width: 0 !important;
        height: 10px !important;
        min-height: 0 !important;
        aspect-ratio: 1 / 1 !important;
        font-size: 0.875rem;
    }
    
    .history-counter {
        display: none;
    }
}

.block-type-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--white);
    border: 1.5px solid var(--card-border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color);
}

.block-type-option:hover {
    background-color: var(--primary-color-light);
    border-color: var(--accent-color);
}

.block-type-option i {
    font-size: 1.25rem;
    margin-right: .4rem;
    color: var(--accent-color);
}

/* Block Bewerken Form */
#block-edit-form .form-group {
    margin-bottom: 1rem;
}

#block-edit-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

#block-edit-form input[type="text"],
#block-edit-form input[type="url"],
#block-edit-form input[type="file"],
#block-edit-form textarea,
#block-edit-form select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
}

#block-edit-form textarea {
    min-height: 120px;
    resize: vertical;
}

/* Upload Method Toggle */
.upload-method-toggle {
    display: flex;
    gap: 1.5rem;
    margin-top: 1rem;
}

.upload-method-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 2px solid #ddd;
    background: var(--white);
    color: var(--text-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.upload-method-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.upload-method-btn.active {
    border-color: var(--accent-color);
    background-color: var(--accent-color);
    color: var(--white);
}

/* Upload Progress */
.progress {
    height: 1.5rem;
    background-color: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background-color: var(--accent-color);
    transition: width 0.3s ease;
}

/* Mobile Edit Toggle Button */
.mobile-edit-toggle {
    display: none; /* Hidden on desktop */
    position: absolute;
    top: 0.5rem;
    right: 45px;
    width: 30px;
    height: 30px;
    background: var(--primary-color-light);
    border: 2px solid var(--card-border-color);
    border-radius: 50%; /* Round button */
    color: var(--accent-color);
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 20;
    align-items: center;
    justify-content: center;
}

.mobile-edit-toggle.active {
    background-color: var(--accent-color);
    color: var(--white);
    border-color: var(--accent-color);
}

.mobile-edit-toggle i {
    font-size: .75rem;
}

/* Responsive */
@media (max-width: 992px) {
    .block-item {
        padding: 1rem;
    }
    
    /* Show mobile edit toggle button */
    .mobile-edit-toggle {
        display: flex;
    }
    
    /* Hide all edit tools by default on mobile */
    .block-actions,
    .block-add-above,
    .block-add-below,
    .resize-handles {
        display: none !important;
    }
    
    /* Show edit tools when block has mobile-edit-active class */
    .block-item.mobile-edit-active .block-actions {
        display: flex !important;
        opacity: 1 !important;
    }
    
    .block-item.mobile-edit-active .block-add-below {
        display: flex !important;
        opacity: 1 !important;
    }
    
    /* Keep resize handles hidden on mobile even when editing */
    /* .block-item.mobile-edit-active .resize-handles {
        display: block !important;
        opacity: 1 !important;
    } */
    
    /* Position add-below button and block-actions side by side on mobile */
    .block-item.mobile-edit-active .block-add-below {
        position: absolute !important;
        bottom: -59px;
        left: 30%;
        transform: translateX(-50%) !important;
        margin: 0;
        width: 36px;
        height: 36px;
        padding: 0;
        border-radius: 50%; /* Round button */
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    
    .block-item.mobile-edit-active .block-actions {
        position: absolute !important;
        top: auto !important;
        bottom: -63px !important;
        right: auto !important;
        left: 42% !important;
        margin: 0 !important;
        flex-direction: row !important;
        gap: 0.25rem !important;
    }
    
    /* Ensure all action buttons are same size as add button */
    .block-item.mobile-edit-active .block-actions .btn-icon {
        width: 36px;
        height: 36px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Add space at bottom of block to accommodate buttons */
    .block-item.mobile-edit-active {
        margin-bottom: 4rem;
    }
    
    .block-title-display {
        font-size: 2rem;
    }
    
    /* Block type menu (add section menu) on mobile - full-width bottom sheet */
    .block-type-menu {
        position: fixed !important;
        top: auto !important;
        bottom: 100px !important;
        right: 10px !important;
        left: 10px !important;
        margin: 0 !important;
        padding: 0 !important;
        min-width: calc(100% - 20px) !important;
        width: calc(100% - 20px) !important;
        max-width: calc(100% - 20px) !important;
        animation: slideUp 0.3s ease !important;
        z-index: 1000 !important;
        border-radius: 16px !important;
    }
    
    .block-type-menu-header {
        border-radius: 16px 16px 0 0 !important;
    }
    
    .block-type-menu-options {
        grid-template-columns: repeat(2, 1fr) !important;
        padding: 1rem !important;
        max-height: 60vh;
        overflow-y: auto;
    }
    
    /* Block buttons on mobile - max 3 per row */
    .primary-block-buttons {
        flex-direction: row;
        justify-content: center;
    }
    
    .btn-primary-block {
        width: calc(30% - 0.67rem); /* 3 per row with gaps */
        min-width: 100px;
        max-width: 180px;
        height: 90px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 1;
    }
    
    /* More blocks section on mobile */
    .more-blocks-container {
        flex-direction: row;
        justify-content: center;
    }
    
    .btn-secondary-block {
        width: calc(30% - 0.67rem); /* 3 per row with gaps */
        min-width: 100px;
        max-width: 180px;
        height: 90px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 1;
    }
    
    /* Disable the invisible bridge on mobile since it's not needed */
    .block-actions::before {
        display: none;
    }
    
    /* Block settings menu on mobile - keep below actions */
    .block-settings-menu {
        position: fixed !important;
        top: auto !important;
        bottom: 100px !important;
        right: 10px !important;
        left: 10px !important;
        margin: 0 !important;
        padding: 0 !important;
        min-width: calc(80% - 20px) !important;
        width: calc(80% - 20px) !important;
        max-width: calc(80% - 20px) !important;
        animation: slideUp 0.3s ease !important;
        z-index: 1000 !important;
    }
    
    .block-settings-menu-content {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 16px !important;
        max-height: 80vh;
        overflow-y: auto;
    }
    
    .block-settings-menu::before {
        display: none !important;
    }
    
    @keyframes slideUp {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

@media (min-width: 992px) {
    /* Full-width media should ignore alignment */
    .block-image-display.full-width,
    .block-video-display.full-width,
    .block-embed-display.full-width,
    .block-openstad-display.full-width {
        margin-left: calc(-50vw + 49%) !important;
    }
}

