/* Editor UI styles */

/* Property Panel Categories */
.property-category {
    margin-bottom: 20px;
}

.property-category:last-child {
    margin-bottom: 0;
}

.property-category-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 12px 0;
    padding: 8px 0 4px 0;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Collapsible category styles */
.property-category-toggle {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.property-category-toggle:hover {
    background: var(--color-hover, rgba(0, 0, 0, 0.05));
    padding-left: 8px;
    padding-right: 8px;
    margin-left: -8px;
    margin-right: -8px;
    border-radius: 4px;
}

.property-category-icon {
    font-size: 12px;
    transition: transform 0.2s ease;
    width: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.property-category-title {
    flex: 1;
}

.property-category-content {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease;
    max-height: 1000px;
    opacity: 1;
}

.property-category-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
}


/* Animation category styling */
.property-category:has(.property-group [data-category="Animation"]) .property-category-header {
    color: #9c27b0;
}


/* Enhanced property groups for animations */
.property-group {
    margin-bottom: 16px;
}

.property-group:last-child {
    margin-bottom: 0;
}

/* Range slider enhancements for animations */
.property-range-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

.property-range {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: var(--color-bg-secondary);
    border-radius: 3px;
    outline: none;
}

.property-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--color-accent);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.property-range::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(210, 141, 93, 0.2);
}

.property-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--color-accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.property-range::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(210, 141, 93, 0.2);
}

.property-range-value {
    min-width: 60px;
    text-align: right;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-accent);
    background: var(--color-accent-light);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Animation preview indicators */
.property-group[data-animation] .property-label::after {
    content: '✨';
    margin-left: 6px;
    opacity: 0.6;
}

/* Collapsible categories */
.property-category-header {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s ease;
}

.property-category-header:hover {
    color: var(--color-accent);
}

.property-category.collapsed .property-group {
    display: none;
}

.property-category-header::after {
    content: '▼';
    margin-left: auto;
    font-size: 10px;
    transition: transform 0.2s ease;
}

.property-category.collapsed .property-category-header::after {
    transform: rotate(-90deg);
}

/* Global Animation Controls */
.global-animation-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 320px;
    max-height: 80vh;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-lg);
    z-index: 1002;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.global-animation-controls.hidden {
    opacity: 0;
    transform: translateX(100%);
    pointer-events: none;
}

.global-controls-header {
    display: flex;
    align-items: center;
    padding: var(--spacing-md);
    background: linear-gradient(135deg, #9c27b0, #e91e63);
    color: white;
    border-bottom: 1px solid var(--color-border);
}

.global-controls-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    flex: 1;
}

.global-controls-toggle,
.global-controls-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    margin-left: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.global-controls-toggle:hover,
.global-controls-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.global-controls-content {
    max-height: calc(80vh - 70px);
    overflow-y: auto;
    padding: var(--spacing-md);
}

.global-control-section {
    margin-bottom: 24px;
}

.global-control-section:last-child {
    margin-bottom: 0;
}

.global-control-section-title {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    padding-bottom: 6px;
    border-bottom: 1px solid var(--color-border);
}

.global-control-group {
    margin-bottom: 16px;
}

.global-control-group:last-child {
    margin-bottom: 0;
}

.global-control-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 6px;
}

.global-control-input,
.global-control-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 13px;
    transition: border-color 0.2s ease;
}

.global-control-input:focus,
.global-control-select:focus {
    outline: none;
    border-color: var(--color-accent);
}

.global-control-input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
    transform: scale(1.2);
}

.global-control-range-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.global-control-range {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: var(--color-bg-secondary);
    border-radius: 3px;
    outline: none;
}

.global-control-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #9c27b0, #e91e63);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.global-control-range::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(156, 39, 176, 0.2);
}

.global-control-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #9c27b0, #e91e63);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.global-control-range::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(156, 39, 176, 0.2);
}

.global-control-range-value {
    min-width: 50px;
    text-align: right;
    font-size: 12px;
    font-weight: 600;
    color: #9c27b0;
    background: rgba(156, 39, 176, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
}

.global-control-button {
    width: 100%;
    padding: 10px 16px;
    background: linear-gradient(135deg, #9c27b0, #e91e63);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.global-control-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(156, 39, 176, 0.3);
}

.global-control-button:active {
    transform: translateY(0);
}

.global-control-description {
    margin: 6px 0 0 0;
    font-size: 11px;
    color: var(--color-text-light);
    line-height: 1.4;
}


/* Disabled state for controls */
.global-control-input:disabled,
.global-control-select:disabled,
.global-control-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.global-control-button:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Toggle Switch Styles */
.toggle-switch-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-switch-input {
    display: none;
}

.toggle-switch-slider {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-switch-slider-inner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.toggle-switch-slider-circle {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Toggle switch checked state */
.toggle-switch-input:checked + .toggle-switch-slider {
    background: linear-gradient(135deg, #9c27b0, #e91e63);
    border-color: #9c27b0;
}

.toggle-switch-input:checked + .toggle-switch-slider .toggle-switch-slider-circle {
    transform: translateX(20px);
    box-shadow: 0 2px 8px rgba(156, 39, 176, 0.3);
}

/* Toggle switch hover effects */
.toggle-switch-slider:hover {
    transform: scale(1.05);
}

.toggle-switch-input:checked + .toggle-switch-slider:hover .toggle-switch-slider-circle {
    box-shadow: 0 0 0 4px rgba(156, 39, 176, 0.2), 0 2px 8px rgba(156, 39, 176, 0.3);
}

.toggle-switch-input:not(:checked) + .toggle-switch-slider:hover .toggle-switch-slider-circle {
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Toggle switch disabled state */
.toggle-switch-input:disabled + .toggle-switch-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

.toggle-switch-input:disabled + .toggle-switch-slider:hover {
    transform: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .global-animation-controls {
        width: calc(100vw - 40px);
        right: 20px;
        max-height: 70vh;
    }
    
}

/* Property Panel */
.property-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 420px;
    max-height: calc(100vh - 120px);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-lg);
    z-index: 1002;
    overflow: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease;
    animation: fadeInPanel 0.3s ease;
}

.property-panel.hidden {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

.property-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    border-top-left-radius: var(--border-radius-large);
    border-top-right-radius: var(--border-radius-large);
    cursor: move;
    user-select: none;
    position: relative;
}

.property-panel-title {
    font-weight: 600;
    color: var(--color-text);
    font-size: var(--font-size-base);
}

.property-panel-content {
    padding: var(--spacing-lg);
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    background: var(--color-bg);
}

@keyframes fadeInPanel {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Block menu */
.block-menu {
    position: fixed;
    bottom: 110px; /* Adjusted to be above the FAB */
    right: 40px; /* Aligned with the FAB */
    width: 380px;
    max-height: 520px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    overflow: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease;
    animation: fadeInPanel 0.3s ease;
}

.block-menu.hidden {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

.block-menu-header {
    padding: var(--spacing-md);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    border-top-left-radius: var(--border-radius-large);
    border-top-right-radius: var(--border-radius-large);
    font-weight: 600;
    font-size: var(--font-size-base);
    color: var(--color-text);
    cursor: move;
    user-select: none;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}


/* Drag functionality styles */
.draggable-panel {
    transition: box-shadow 0.2s ease;
}

.draggable-panel.dragging {
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
    z-index: 1010;
    transition: none;
}

.draggable-panel.dragging .property-panel-header,
.draggable-panel.dragging .block-menu-header,
.draggable-panel.dragging .floating-panel-header {
    background: var(--color-accent-light);
    cursor: grabbing;
}

/* Constrain draggable panels to viewport */
.draggable-panel {
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
}

/* Drag handle cursor styles */
.property-panel-header,
.block-menu-header,
.floating-panel-header {
    cursor: grab;
}

.property-panel-header:active,
.block-menu-header:active,
.floating-panel-header:active {
    cursor: grabbing;
}

/* Dragging state visual feedback */
.draggable-panel.dragging {
    transform: rotate(0.5deg);
    border-color: var(--color-accent);
}

/* Prevent text selection during drag */
.draggable-panel.dragging * {
    user-select: none;
    pointer-events: none;
}

/* Re-enable pointer events for close buttons */
.draggable-panel.dragging .close-btn {
    pointer-events: auto;
}

/* Smooth transition when not dragging */
.draggable-panel:not(.dragging) {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.block-menu-items {
    max-height: 440px;
    overflow-y: auto;
}

.block-menu-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--color-border);
    position: relative;
}

.block-menu-item:last-child {
    border-bottom: none;
}

.block-menu-item:hover {
    background: var(--color-hover);
    transform: translateX(4px);
    border-left: 3px solid var(--color-accent);
    padding-left: calc(var(--spacing-md) - 3px);
}

.block-menu-item:hover .block-menu-icon {
    transform: scale(1.2);
    animation: iconBounce 0.3s ease;
}

@keyframes iconBounce {
    0%, 100% { transform: scale(1.2); }
    50% { transform: scale(1.4); }
}

.block-menu-item.dragging {
    opacity: 0.5;
}

.block-menu-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
    color: var(--color-text-light);
    transition: all 0.2s ease;
}

.block-menu-label {
    font-size: var(--font-size-sm);
    color: var(--color-text);
    font-weight: 500;
}

/* Floating Panel */
.floating-panel {
    position: absolute;
    width: 420px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-lg);
    z-index: 1002;
    transition: opacity 0.2s ease, transform 0.2s ease;
    animation: fadeInPanel 0.3s ease;
}

.floating-panel.hidden {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

.floating-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    border-top-left-radius: var(--border-radius-large);
    border-top-right-radius: var(--border-radius-large);
    cursor: move;
    user-select: none;
    position: relative;
}

.floating-panel-title {
    font-weight: 600;
    color: var(--color-text);
    font-size: var(--font-size-base);
}

.floating-panel-content {
    padding: var(--spacing-lg);
    max-height: 520px;
    overflow-y: auto;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1003;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal-dialog {
    width: 90%;
    max-width: 500px;
    background: var(--color-bg);
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-lg);
    z-index: 1;
}

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

.modal-title {
    font-weight: 600;
    color: var(--color-text);
}

.modal-content {
    padding: var(--spacing-lg);
}

/* Property groups */
.property-group {
    margin-bottom: var(--spacing-lg);
}

.property-group:last-child {
    margin-bottom: 0;
}

.property-label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text);
}

.property-input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    color: var(--color-text);
    background: white;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.property-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-light);
}

textarea.property-input {
    resize: vertical;
    min-height: 80px;
}

select.property-input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

/* Color picker styles */
.property-color-container {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.property-color-picker {
    width: 40px;
    height: 32px;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    background: none;
    cursor: pointer;
    transition: border-color 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.property-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
    border-radius: calc(var(--border-radius) - 1px);
}

.property-color-picker::-webkit-color-swatch {
    border: none;
    border-radius: calc(var(--border-radius) - 1px);
}

.property-color-picker::-moz-color-swatch {
    border: none;
    border-radius: calc(var(--border-radius) - 1px);
}

.property-color-picker:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-light);
}

.property-hex-input {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    font-family: monospace;
    font-size: var(--font-size-sm);
    color: var(--color-text);
    background: white;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.property-hex-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-light);
}

/* Range slider styles */
.property-range-container {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.property-range {
    flex: 1;
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.property-range::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--color-accent);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.property-range::-webkit-slider-thumb:hover {
    background: #b8754a;
    transform: scale(1.1);
}

.property-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--color-accent);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.property-range::-moz-range-thumb:hover {
    background: #b8754a;
    transform: scale(1.1);
}

.property-range::-moz-range-track {
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    border: none;
}

.property-range-value {
    min-width: 50px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text);
    text-align: right;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .block-menu {
        right: 20px; /* Aligned with the FAB on mobile */
        width: calc(100vw - 40px); /* Adjusted width for mobile */
        bottom: 90px; /* Adjusted to be above the FAB on mobile */
        max-height: calc(100vh - 120px); /* Prevent overflow on mobile */
    }
    
    .block-menu-items {
        max-height: calc(100vh - 200px); /* Adjusted for mobile */
    }
    
    .property-panel {
        width: calc(100vw - 40px);
        right: 20px;
        top: 60px;
        max-height: calc(100vh - 100px);
    }
    
    .property-panel-content {
        max-height: calc(100vh - 180px);
    }
    
    .floating-panel {
        width: calc(100vw - 40px);
        max-width: calc(100vw - 40px);
        max-height: calc(100vh - 100px);
    }
    
    .floating-panel-content {
        max-height: calc(100vh - 180px);
    }
}

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


/* Very small screens */
@media (max-width: 480px) {
    .block-menu {
        bottom: 80px;
        max-height: calc(100vh - 110px);
    }
    
    .block-menu-items {
        max-height: calc(100vh - 190px);
    }
    
    .property-panel,
    .floating-panel {
        top: 40px;
        max-height: calc(100vh - 80px);
    }
    
    .property-panel-content,
    .floating-panel-content {
        max-height: calc(100vh - 160px);
    }
}

.animation-triggered {
    display: block !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Tablet responsiveness */
@media (max-width: 1024px) and (min-width: 769px) {
    .block-menu {
        width: 350px; /* Slightly smaller on tablet */
        right: 30px;
        max-height: 480px;
    }
    
    .block-menu-items {
        max-height: 400px;
    }
    
    .property-panel,
    .floating-panel {
        width: 380px; /* Slightly smaller on tablet */
        right: 30px;
    }
    
    .floating-panel-content {
        max-height: 480px;
    }
}
    
    .add-block-btn {
        bottom: 20px;
        right: 20px;
    }

}