:root {
    --bb-admin-theme-color: #2271b1;
    --bb-admin-theme-color-darker: #135e96;
    --bb-admin-bar-bg: #1d2327;
    --bb-admin-menu-bg: #1d2327;
    --bb-admin-menu-submenu-bg: #2c3338;
    --bb-admin-menu-text: #fff;
    --bb-admin-menu-text-hover: #72aee6;
    --bg-color: #f0f0f1;
    --block-bg: #ffffff;
    --border-color: #dcdcde;
    --text-color: #3c434a;
    --danger-color: #d63638;
}

body {
    background-color: var(--bg-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    color: var(--text-color);
    margin: 0;
    padding-top: 32px; /* For Top Bar */
}

/* --- Layout Wrapper --- */
.admin-wrapper {
    display: flex;
    min-height: calc(100vh - 32px);
}

/* --- Admin Sidebar (Left) --- */
.admin-menu {
    width: 180px;
    background: var(--bb-admin-menu-bg);
    flex-shrink: 0;
    color: #fff;
    /* Make main menu sticky */
    position: sticky;
    top: 32px; /* Admin bar height */
    height: calc(100vh - 32px);
    overflow-y: auto;
}

.admin-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.admin-menu li a {
    display: block;
    padding: 10px 12px;
    color: rgba(240, 246, 252, 0.6);
    text-decoration: none;
    font-size: 13px;
    transition: color 0.1s, background 0.1s;
}

.admin-menu .menu-section {
    padding: 10px 12px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgba(240, 246, 252, 0.45);
}

.admin-menu li a.menu-subitem {
    padding-left: 22px;
}

.admin-menu li a:hover, .admin-menu li a.active {
    color: var(--bb-admin-menu-text-hover);
    background: rgba(255,255,255,0.05);
}

.admin-menu li a.active {
    font-weight: 600;
    color: #fff;
    background: var(--bb-admin-theme-color);
    position: relative;
}

/* --- Top Bar --- */
.admin-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 32px;
    background: var(--bb-admin-bar-bg);
    color: #fff;
    z-index: 9999;
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-sizing: border-box;
    font-size: 13px;
}

.admin-bar a {
    color: #fff;
    text-decoration: none;
    margin-right: 20px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.admin-bar a:hover {
    color: var(--bb-admin-menu-text-hover);
}

/* --- Main Content Area --- */
.admin-content {
    flex-grow: 1;
    padding: 20px;
    box-sizing: border-box;
    overflow-x: hidden;
}

h1 {
    font-size: 24px;
    font-weight: 400;
    color: #1d2327;
    margin-bottom: 20px;
    margin-top: 10px;
}

/* Spinner animation */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Layout */
.block-editor-layout {
    display: flex;
    flex-wrap: nowrap;
    gap: 30px;
    max-width: 1400px;
    margin: 0 auto; /* Centered in content area */
    align-items: flex-start; /* Crucial for sticky sidebar */
}

.block-editor-layout > form {
    display: flex;
    flex-wrap: nowrap;
    gap: 30px;
    flex: 1;
    min-width: 0;
}

/* Tables (WP List Table Style) */
.wp-list-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #c3c4c7;
    box-shadow: 0 1px 1px rgba(0,0,0,.04);
}

.wp-list-table th, .wp-list-table td {
    padding: 10px;
    text-align: left;
    color: #50575e;
}

.wp-list-table thead th {
    border-bottom: 1px solid #c3c4c7;
    font-weight: 600;
    font-size: 14px;
}

.wp-list-table tbody tr:nth-child(odd) {
    background-color: #f9f9f9;
}

.wp-list-table tbody tr:hover {
    background-color: #f0f0f1;
}

.wp-list-table td a {
    text-decoration: none;
    color: var(--bb-admin-theme-color);
    font-weight: 500;
}

.wp-list-table td a:hover {
    color: var(--bb-admin-theme-color-darker);
}

.row-actions {
    visibility: hidden;
    font-size: 13px;
    margin-top: 4px;
}

.wp-list-table tr:hover .row-actions {
    visibility: visible;
}

.row-actions span {
    color: #a7aaad;
    margin: 0 4px;
}

.row-actions a {
    font-weight: 400;
}

.row-actions button.btn-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--danger-color);
    cursor: pointer;
    font-size: 13px;
}

.row-actions button.btn-link:hover {
    color: #b32d2e;
    text-decoration: underline;
}

/* ... Existing styles ... */

.editor-canvas {
    flex: 1;
    min-width: 0;
    margin-right: 310px; /* sidebar width (280) + padding (15+15) */
}

/* Sidebar */
.editor-sidebar {
    width: 280px;
    flex-shrink: 0;
    position: fixed;
    top: 52px;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    background: var(--bg-color);
    border-left: 1px solid #c3c4c7;
    padding: 15px;
    box-sizing: border-box;
    z-index: 100;
}

.inserter-card {
    background: #fff;
    border: 1px solid #c3c4c7;
    box-shadow: 0 1px 1px rgba(0,0,0,.04);
    border-radius: 4px;
    overflow: hidden;
}

.inserter-header {
    padding: 10px 15px;
    border-bottom: 1px solid #c3c4c7;
    background: #f6f7f7;
    font-size: 13px;
    font-weight: 600;
}

.inserter-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    margin: 0;
}

.inserter-button {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border: none;
    border-bottom: 1px solid #f0f0f1;
    background: #fff;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
    gap: 10px;
}

.inserter-button:hover {
    background: #f6f7f7;
}

.inserter-button:last-child {
    border-bottom: none;
}

.inserter-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #50575e;
}

.inserter-button span {
    font-size: 13px;
    font-weight: 500;
    color: #1d2327;
}

/* Responsive: Stack layout on smaller screens */
@media (max-width: 1024px) {
    .block-editor-layout {
        flex-direction: column;
    }

    .editor-canvas {
        margin-right: 0;
    }

    .editor-sidebar {
        width: 100%;
        position: relative;
        top: 0;
        right: auto;
        bottom: auto;
        border-left: none;
        border-top: 1px solid #c3c4c7;
        padding: 15px;
        order: -1;
    }
}

/* Block Item Card */
.block-item {
    background: var(--block-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px; /* WordPress uses slightly smaller radius */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s, border-color 0.2s;
    overflow: hidden;
    position: relative;
    margin-bottom: 24px;
}

.block-item:hover {
    border-color: #8c8f94;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

.block-item.sortable-ghost {
    background: #f0f0f1;
    border: 1px dashed #8c8f94;
    opacity: 0.8;
}

/* Navigation menu structure (WordPress-like) */
[data-menu-structure-item].sortable-ghost {
    background: #f0f0f1;
    border: 1px dashed #8c8f94;
    opacity: 0.8;
}

[data-menu-structure-handle] {
    user-select: none;
}

/* Make empty child lists act like a visible drop zone */
[data-menu-structure-children] > [data-menu-structure-list]:empty {
    border-left: 2px dashed #c3c4c7;
    padding-top: 8px;
    padding-bottom: 8px;
}

/* Hidden Block Styling */
.block-item.block-hidden {
    opacity: 0.6;
    background: #f9f9f9;
}

.block-item.block-hidden .block-header {
    background: #f5f5f5;
}

.block-item.block-hidden .block-preview {
    filter: grayscale(0.5);
}

/* Block Header */
.block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    background: #fff;
    border-bottom: 1px solid var(--bg-color);
}

.block-title-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.block-type-label {
    font-weight: 600;
    font-size: 13px;
    color: #1e1e1e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f0f0f1;
    padding: 2px 6px;
    border-radius: 2px;
}

/* Drag Handle */
.drag-handle {
    cursor: grab;
    color: #a7aaad;
    padding: 4px;
    border-radius: 2px;
    display: flex;
    align-items: center;
}

.drag-handle:hover {
    color: #1e1e1e;
    background-color: #f0f0f1;
}

.drag-handle:active {
    cursor: grabbing;
}

/* Actions */
.block-actions {
    display: flex;
    gap: 4px;
}

.icon-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    color: #787c82;
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background-color 0.2s;
}

.icon-btn:hover {
    color: var(--bb-admin-theme-color);
    background-color: #f0f0f1;
}

.icon-btn.is-destructive:hover {
    color: var(--danger-color);
    background-color: #fcebeb;
}

/* Block Preview Area */
.block-preview {
    padding: 0;
    background: #fff;
    /* Simulate iframe-like isolation */
    overflow: hidden;
    position: relative;
}

.block-preview-overlay {
    /* This overlay was blocking the preview (and could appear as a layer).
       Keep the element in DOM but disable it completely. */
    display: none;
}

/* Prevent accidental navigation from links inside the preview,
   without adding a blocking overlay layer. */
.block-preview a {
    pointer-events: none;
}

/* Sidebar Inserter - Removed (See Fixed Top Toolbar above) */

/* Main Page Form */
.page-settings-card {
    background: #fff;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 30px;
}

/* Modal */
dialog {
    border: none;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    padding: 0;
    min-width: 500px;
    max-width: 90vw;
}

dialog::backdrop {
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(2px);
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.block-instance-form {
    padding: 24px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* Utility buttons */
.btn-primary {
    background-color: var(--bb-admin-theme-color);
    color: white;
    border: 1px solid var(--bb-admin-theme-color);
    padding: 6px 14px;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
}

.btn-primary:hover {
    background-color: var(--bb-admin-theme-color-darker);
}

.btn-secondary {
    background-color: white;
    color: var(--bb-admin-theme-color);
    border: 1px solid var(--bb-admin-theme-color);
    padding: 6px 14px;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
}

.btn-secondary:hover {
    background-color: #f6f7f7;
}

/* Form inputs cleanup */
input[type="text"], input[type="url"], textarea, select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    margin-top: 5px;
    box-sizing: border-box;
}

input[type="text"]:focus, input[type="url"]:focus, textarea:focus, select:focus {
    border-color: var(--bb-admin-theme-color);
    outline: 1px solid var(--bb-admin-theme-color);
}

/* Sites checkbox grid for role form */
.sites-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 8px 16px;
    padding: 12px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-top: 8px;
}

.sites-checkbox-grid > div {
    display: flex;
    align-items: center;
}

.sites-checkbox-grid input[type="checkbox"] {
    margin-right: 8px;
    width: auto;
    flex-shrink: 0;
}

.sites-checkbox-grid label {
    cursor: pointer;
    font-weight: normal;
    margin-bottom: 0;
    display: inline;
}

/* Image Picker Modal */
.image-picker-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
}

.image-picker-modal.show {
    display: flex;
}

.image-picker-modal-content {
    background-color: #fff;
    border-radius: 8px;
    width: 90%;
    max-width: 900px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.image-picker-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #ddd;
}

.image-picker-modal-header h3 {
    margin: 0;
    font-size: 20px;
}

.image-picker-modal-header .btn-close {
    background: none;
    border: none;
    font-size: 32px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 32px;
    height: 32px;
    line-height: 1;
}

.image-picker-modal-header .btn-close:hover {
    color: #000;
}

.image-picker-breadcrumb {
    padding: 12px 20px;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    font-size: 14px;
}

.image-picker-breadcrumb a {
    color: var(--bb-admin-theme-color);
    text-decoration: none;
}

.image-picker-breadcrumb a:hover {
    text-decoration: underline;
}

.image-picker-grid {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    align-content: start;
}

.image-picker-item {
    border: 2px solid #ddd;
    border-radius: 6px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #fff;
}

.image-picker-item:hover {
    border-color: var(--bb-admin-theme-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.image-picker-item.folder {
    background: #f9f9f9;
}

.image-picker-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.image-picker-preview {
    width: 100%;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    overflow: hidden;
    border-radius: 4px;
    background: #f5f5f5;
}

.image-picker-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-picker-name {
    font-size: 12px;
    text-align: center;
    word-break: break-word;
    color: #333;
}

.image-picker-empty,
.image-picker-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.image-picker-controls {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-top: 8px;
}

/* Revisions Modal */
.revisions-modal {
    border: none;
    border-radius: 8px;
    padding: 0;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.revisions-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    background: #f9f9f9;
}

.revisions-modal .modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--text-color);
}

.revisions-modal .close-btn {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.revisions-modal .close-btn:hover {
    color: #000;
}

.revisions-modal .modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.revisions-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.revision-item {
    transition: box-shadow 0.2s;
}

.revision-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
