/* Bootstrap Blocks Layout Styles */

/* Admin interface enhancements for layout blocks */
.bootstrap-container-advanced-settings,
.bootstrap-row-advanced-settings,
.bootstrap-column-advanced-settings {
    border-left: 3px solid #007cba;
    margin-top: 1rem;
}

.bootstrap-spacing-block,
.bootstrap-radius-block,
.bootstrap-background-block,
.bootstrap-text-alignment-block,
.bootstrap-justify-content-block,
.bootstrap-attribute-block {
    background-color: #f9fafb !important;
    border: 1px solid #e5e7eb !important;
    padding: 0.75rem !important;
    border-radius: 0.375rem !important;
    margin-bottom: 0.75rem !important;
}

/* Debug mode styles */
.bootstrap-blocks-debug {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.875rem;
    line-height: 1.4;
    background-color: #f8f9fa;
    border-radius: 0.25rem;
    margin-bottom: 1rem;
}

/* Layout grid visualization (debug mode) */
.bootstrap-blocks-debug .container,
.bootstrap-blocks-debug .row,
.bootstrap-blocks-debug [class*="col-"] {
    position: relative;
}

.bootstrap-blocks-debug .container::before,
.bootstrap-blocks-debug .row::before,
.bootstrap-blocks-debug [class*="col-"]::before {
    content: attr(class);
    position: absolute;
    top: 0;
    left: 0;
    background: rgba(0, 123, 255, 0.1);
    color: #007bff;
    font-size: 0.75rem;
    padding: 0.125rem 0.25rem;
    border-radius: 0.125rem;
    z-index: 1000;
    pointer-events: none;
}

/* Nested row highlighting */
.bootstrap-blocks-debug .row .row::before {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

/* Container type indicators */
.bootstrap-blocks-debug .container-fluid::after {
    content: "FLUID";
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(255, 193, 7, 0.9);
    color: #212529;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 0.125rem 0.25rem;
    border-radius: 0.125rem;
    z-index: 1000;
    pointer-events: none;
}

/* Performance optimization: reduce animations in admin */
.bootstrap-blocks-admin {
    animation-duration: 0.1s;
    transition-duration: 0.1s;
}


/* Add Button */
button.c-sf-add-button {
    background: none;
}

/* Hide help text visually for bootstrap-blocks while keeping it accessible */
.bootstrap-blocks-help-hidden .w-field__help,
.bootstrap-blocks-help-hidden [data-field-help],
.bootstrap-blocks-help-hidden .c-sf-help {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ========================================
   ADVANCED SETTINGS STYLING
   ======================================== */

.bootstrap-advanced-settings {
    border: 1px solid #dce5ec;
    border-radius: 6px;
    margin: 1rem 0;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.advanced-settings-toggle {
    width: 100%;
    text-align: left;
    padding: 0.875rem 1rem;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 500;
    color: #0f172a;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.advanced-settings-toggle:hover {
    background: #f1f5f9;
    color: #334155;
}

.advanced-settings-toggle:focus {
    outline: 2px solid #0ea5e9;
    outline-offset: -2px;
}

.advanced-settings-toggle .icon {
    flex-shrink: 0;
}

.advanced-settings-toggle .toggle-indicator {
    transition: transform 0.2s ease;
}

.bootstrap-advanced-settings:not(.collapsed) .advanced-settings-toggle .toggle-indicator {
    transform: rotate(180deg);
}

.advanced-settings-content {
    padding: 1rem;
    border-top: 1px solid #e2e8f0;
    background: #fafafa;
}

.bootstrap-advanced-settings.collapsed .advanced-settings-content {
    display: none !important;
}

.bootstrap-advanced-settings:not(.collapsed) .advanced-settings-content {
    display: block !important;
}

/* Improve form field styling within advanced settings */
.advanced-settings-content .field {
    margin-bottom: 1rem;
}

.advanced-settings-content .field:last-child {
    margin-bottom: 0;
}

.advanced-settings-content .field__label {
    color: #374151;
    font-weight: 500;
    margin-bottom: 0.5rem;
    display: block;
}

.advanced-settings-content .help {
    font-size: 0.8125rem;
    color: #6b7280;
    margin-top: 0.25rem;
    line-height: 1.4;
}

/* StreamField block styling improvements */
.sequence-container .sequence-controls {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    padding: 0.5rem;
}

.sequence-container .sequence-controls .button {
    font-size: 0.8125rem;
    padding: 0.375rem 0.75rem;
}

/* Hide the "Advanced Settings" field label that appears above the container */
[data-contentpath="settings"] > .w-field__label {
    display: none !important;
}

/* Hide the "Settings" heading within the Advanced Settings content */
.advanced-settings-content .field__label {
    display: none !important;
}

/* More specific selector for the Settings heading */
.advanced-settings-content > div > .field__label:first-child {
    display: none !important;
}

/* ========================================
   ADVANCED SETTINGS POSITIONING
   ======================================== */

/* Move Advanced Settings to top of form using CSS flexbox order */
.struct-block:has([data-contentpath="settings"]) {
    display: flex;
    flex-direction: column;
}

[data-contentpath="settings"] {
    order: -1;
}

/* Alternative selector if :has() is not supported */
.struct-block [data-contentpath="settings"] {
    order: -1;
}

/* Ensure the parent container supports flexbox */
.struct-block {
    display: flex;
    flex-direction: column;
}

/* ========================================
   DARK MODE SUPPORT FOR ADVANCED SETTINGS
   ======================================== */

/* Dark theme (forced dark mode) */
.w-theme-dark .bootstrap-advanced-settings {
    background: #1f2937;
    border-color: #374151;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.w-theme-dark .advanced-settings-toggle {
    color: #e5e7eb;
}

.w-theme-dark .advanced-settings-toggle:hover {
    background: #374151;
    color: #f3f4f6;
}

.w-theme-dark .advanced-settings-toggle:focus {
    outline: 2px solid #3b82f6;
}

.w-theme-dark .advanced-settings-content {
    background: #111827;
    border-top-color: #374151;
}

.w-theme-dark .advanced-settings-content .field__label {
    color: #d1d5db;
}

.w-theme-dark .advanced-settings-content .help {
    color: #9ca3af;
}

.w-theme-dark .bootstrap-spacing-block,
.w-theme-dark .bootstrap-radius-block,
.w-theme-dark .bootstrap-background-block,
.w-theme-dark .bootstrap-text-alignment-block,
.w-theme-dark .bootstrap-justify-content-block,
.w-theme-dark .bootstrap-attribute-block {
    background-color: #1f2937 !important;
    border-color: #4b5563 !important;
}

.w-theme-dark .sequence-container .sequence-controls {
    background: #1f2937;
    border-top-color: #374151;
}

/* System theme with dark preference */
@media (prefers-color-scheme: dark) {
    .w-theme-system .bootstrap-advanced-settings {
        background: #1f2937;
        border-color: #374151;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    }

    .w-theme-system .advanced-settings-toggle {
        color: #e5e7eb;
    }

    .w-theme-system .advanced-settings-toggle:hover {
        background: #374151;
        color: #f3f4f6;
    }

    .w-theme-system .advanced-settings-toggle:focus {
        outline: 2px solid #3b82f6;
    }

    .w-theme-system .advanced-settings-content {
        background: #111827;
        border-top-color: #374151;
    }

    .w-theme-system .advanced-settings-content .field__label {
        color: #d1d5db;
    }

    .w-theme-system .advanced-settings-content .help {
        color: #9ca3af;
    }

    .w-theme-system .bootstrap-spacing-block,
    .w-theme-system .bootstrap-radius-block,
    .w-theme-system .bootstrap-background-block,
    .w-theme-system .bootstrap-text-alignment-block,
    .w-theme-system .bootstrap-justify-content-block,
    .w-theme-system .bootstrap-attribute-block {
        background-color: #1f2937 !important;
        border-color: #4b5563 !important;
    }

    .w-theme-system .sequence-container .sequence-controls {
        background: #1f2937;
        border-top-color: #374151;
    }
}
