/* --- Tab Bar & Content --- */
.tab-bar { display: flex; border-bottom: 2px solid var(--border-color); background: var(--bg-light); flex-shrink: 0; align-items: center; }
.tab-btn { padding: 0.75rem 1rem; border: none; background: transparent; cursor: pointer; font-size: 0.875rem; font-weight: 500; color: var(--text-light); border-bottom: 3px solid transparent; }
.tab-btn.active { color: var(--primary-color); border-bottom-color: var(--primary-color); }
.tab-btn:hover { background: var(--border-color); }
.tab-content-wrapper { flex: 1; position: relative; overflow: hidden; }
.tab-content { display: none; height: 100%; width: 100%; }
.tab-content.active { display: flex; flex-direction: column; }

/* --- Space Editor Layout --- */
.space-editor-container,
.digital-space-container,
.display-editor-container { display: flex; height: 100%; }
.space-canvas {
    flex: 1;
    position: relative;
    background-color: #fdfdfd;
    background-image: linear-gradient(rgba(0, 0, 0, 0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
    overflow: hidden; /* Important for containing rectangles */
    cursor: crosshair; /* Default cursor for drawing */
}
.space-canvas.is-dragging { cursor: grabbing; }

/* --- Zoom Controls --- */
.zoom-controls {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

.zoom-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: var(--text-dark);
    font-size: 18px;
    font-weight: 600;
}

.zoom-btn:hover {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

.zoom-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.zoom-icon {
    line-height: 1;
    user-select: none;
}

/* --- World Styling --- */
.space-world {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
}

/* --- Location Rectangle Styles --- */
.location-rect {
    position: absolute;
    background: rgba(59, 130, 246, 0.2);
    border: 2px solid var(--primary-color);
    border-radius: 4px;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--primary-dark);
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    padding: 0 5px;
    user-select: none;
    transition: left 0.05s ease, top 0.05s ease;
}

/* Ensure child content doesn't intercept mouse events; the rect handles dragging */
.location-rect * {
    pointer-events: none;
}

/* Dynamic font scaling for location labels - uses adjusted zoom scale for slower increase curve */
.location-rect .location-text {
    font-size: calc(12px / var(--current-font-zoom-scale, 1));
    line-height: calc(1.2 / var(--current-font-zoom-scale, 1));
    transform-origin: center;
}

/* --- 3D Cube Styles --- */
.location-rect.cube-3d {
    position: relative;
}

.location-rect.cube-3d::before {
    content: '';
    position: absolute;
    top: -6px;
    right: -6px;
    width: 100%;
    height: 6px;
    background: linear-gradient(45deg, rgba(59, 130, 246, 0.4), rgba(59, 130, 246, 0.1));
    border: 1px solid var(--primary-color);
    border-bottom: none;
    transform: skew(45deg, 0deg);
    transform-origin: bottom left;
}

.location-rect.cube-3d::after {
    content: '';
    position: absolute;
    top: -6px;
    right: -6px;
    width: 6px;
    height: 100%;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(59, 130, 246, 0.1));
    border: 1px solid var(--primary-color);
    border-left: none;
    transform: skew(0deg, 45deg);
    transform-origin: bottom left;
}
.location-rect.selected { 
    border-style: dashed; 
    background: rgba(59, 130, 246, 0.3); 
    transition: none; /* Ensure no CSS transitions cause delays */
}
.location-rect.colliding { border-color: #ffc107; background: rgba(255, 193, 7, 0.3); }

/* --- Hierarchical Relationship Styles --- */
.location-rect.has-parent { border-left-width: 4px; }
.location-rect.has-children { 
    box-shadow: inset 0 0 0 2px rgba(34, 197, 94, 0.3);
}
.location-rect.has-children::before {
    border-color: #22c55e;
}
.location-rect.has-children::after {
    border-color: #22c55e;
}

/* --- Transition Zone Styles --- */
.location-rect.transition-zone {
    border-style: dotted;
    background: rgba(168, 85, 247, 0.2);
    border-color: #a855f7;
}

.location-rect.transition-zone.cube-3d::before {
    border-color: #a855f7;
    background: linear-gradient(45deg, rgba(168, 85, 247, 0.4), rgba(168, 85, 247, 0.1));
}

.location-rect.transition-zone.cube-3d::after {
    border-color: #a855f7;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.3), rgba(168, 85, 247, 0.1));
}

/* --- Connection Management Styles --- */
.connection-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0.5rem;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 0.25rem;
    font-size: 0.8rem;
}

.remove-connection {
    background: none;
    border: none;
    color: var(--error-color);
    cursor: pointer;
    padding: 0 0.25rem;
    font-weight: bold;
}

.remove-connection:hover {
    background: rgba(220, 53, 69, 0.1);
}

.btn.btn-sm, .btn.btn-secondary {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    border: 1px solid var(--border-color);
    background: white;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-weight: 500;
    color: var(--text-color);
    transition: all var(--transition-fast);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn.btn-sm:hover, .btn.btn-secondary:hover {
    background: var(--bg-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn.full-width {
    width: 100%;
}

/* --- Options Panel Styles --- */
.options-panel-container { 
    border-top: 1px solid var(--border-color); 
    background: white;
    flex-shrink: 0;
}

.options-panel-header { 
    padding: 12px; 
    border-bottom: 1px solid var(--border-color); 
    background: var(--bg-light);
}

.options-panel-header h4 { 
    margin: 0; 
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
}

#options-panel-content, #digital-options-panel-content, #display-options-panel-content { 
    padding: 12px;
}

.option-field { 
    margin-bottom: 10px; 
}

.option-field label { 
    display: flex; 
    align-items: center; 
    gap: 6px; 
    font-size: 12px;
    font-weight: 500;
    color: var(--text-color);
    cursor: pointer;
}

.option-field input[type="checkbox"] { 
    margin: 0; 
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.option-field input[type="number"] { 
    width: 80px; 
    padding: var(--spacing-xs) var(--spacing-sm); 
    border: 1px solid var(--border-color); 
    border-radius: var(--border-radius-sm); 
    font-size: var(--font-size-sm);
    background: white;
    transition: all var(--transition-fast);
}

.option-field input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb), 0.1);
}

/* Enhanced number input spinner controls for better usability */
.option-field input[type="number"]::-webkit-outer-spin-button,
.option-field input[type="number"]::-webkit-inner-spin-button {
    opacity: 1;
    height: 20px;
    width: 20px;
    cursor: pointer;
    margin: 0;
}

/* Enhanced number input spinner controls for Firefox */
.option-field input[type="number"] {
    -moz-appearance: textfield;
}

.option-field input[type="number"]:hover::-webkit-outer-spin-button,
.option-field input[type="number"]:hover::-webkit-inner-spin-button {
    background: rgba(var(--primary-color-rgb), 0.1);
    border-radius: var(--border-radius-sm);
}

/* Global number input spinner enhancement for display editor and other number inputs */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    opacity: 1;
    height: 18px;
    width: 18px;
    cursor: pointer;
    margin: 0;
}

input[type="number"]:hover::-webkit-outer-spin-button,
input[type="number"]:hover::-webkit-inner-spin-button {
    background: rgba(0, 123, 255, 0.1);
    border-radius: 3px;
}

/* Enhanced spinner controls for inline input groups (position & size inputs) */
.inline-input-group input[type="number"]::-webkit-outer-spin-button,
.inline-input-group input[type="number"]::-webkit-inner-spin-button {
    opacity: 1;
    height: 20px;
    width: 20px;
    cursor: pointer;
    margin: 0;
}

.inline-input-group input[type="number"]:hover::-webkit-outer-spin-button,
.inline-input-group input[type="number"]:hover::-webkit-inner-spin-button {
    background: rgba(var(--primary-color-rgb), 0.15);
    border-radius: var(--border-radius-sm);
}

/* Enhanced spinner controls for property field inputs (z-index, etc.) */
.prop-field input[type="number"]::-webkit-outer-spin-button,
.prop-field input[type="number"]::-webkit-inner-spin-button {
    opacity: 1;
    height: 22px;
    width: 22px;
    cursor: pointer;
    margin: 0;
}

.prop-field input[type="number"]:hover::-webkit-outer-spin-button,
.prop-field input[type="number"]:hover::-webkit-inner-spin-button {
    background: rgba(var(--primary-color-rgb), 0.15);
    border-radius: var(--border-radius-sm);
}

/* Fix for macOS Safari spinner visual feedback bug - reset active states */
#display-width::-webkit-outer-spin-button:active,
#display-width::-webkit-inner-spin-button:active,
#display-height::-webkit-outer-spin-button:active,
#display-height::-webkit-inner-spin-button:active {
    background: rgba(var(--primary-color-rgb), 0.2) !important;
}

/* Fix macOS spinner highlighting bug without removing spinners */
#display-width::-webkit-outer-spin-button,
#display-width::-webkit-inner-spin-button,
#display-height::-webkit-outer-spin-button,
#display-height::-webkit-inner-spin-button {
    opacity: 1;
    height: 18px;
    width: 18px;
    cursor: pointer;
    margin: 0;
}

#display-width::-webkit-outer-spin-button:hover,
#display-width::-webkit-inner-spin-button:hover,
#display-height::-webkit-outer-spin-button:hover,
#display-height::-webkit-inner-spin-button:hover {
    background: rgba(var(--primary-color-rgb), 0.1);
    border-radius: 2px;
}

.option-field input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    cursor: pointer;
}

.option-field input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all var(--transition-fast);
}

.option-field input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

/* --- Properties Panel Styles --- */
.properties-panel-container { 
    width: 300px; 
    border-left: 1px solid var(--border-color); 
    background: white; 
    overflow-y: auto; 
    flex-shrink: 0; 
    display: flex;
    flex-direction: column;
}

.properties-panel-header { 
    padding: 12px; 
    border-bottom: 1px solid var(--border-color); 
    background: var(--bg-light);
    flex-shrink: 0;
}

.properties-panel-header h4 { 
    margin: 0; 
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

.properties-panel-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.properties-panel-header button { 
    padding: 6px 12px; 
    font-size: 13px; 
    border: 1px solid var(--primary-color);
    background: var(--primary-color);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.1s;
}

.properties-panel-header button:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.layer-controls { 
    display: flex; 
    align-items: center; 
    gap: 6px; 
    font-size: 12px;
    width: 100%;
}

.layer-controls label { 
    font-weight: 500; 
    color: var(--text-light);
    white-space: nowrap;
}

.layer-controls select { 
    flex: 1;
    padding: 4px 6px; 
    border: 1px solid var(--border-color); 
    border-radius: 4px; 
    font-size: 12px;
    background: white;
    cursor: pointer;
}

#properties-panel-content, #digital-properties-panel-content, #display-properties-panel-content {
    padding: 12px;
    flex: 1;
    overflow-y: auto;
}

.properties-panel-container .placeholder { 
    color: var(--text-lighter); 
    font-style: italic; 
    font-size: 13px; 
    text-align: center;
    padding: 16px;
    background: var(--bg-light);
    border-radius: 6px;
    border: 1px dashed var(--border-color);
    margin: 8px 0;
}

.prop-field { 
    margin-bottom: 12px; 
}

.prop-field label { 
    display: block; 
    font-size: 12px; 
    font-weight: 600; 
    margin-bottom: 4px; 
    color: var(--text-color);
}

.prop-field input, .prop-field select, .prop-field textarea { 
    width: 100%; 
    padding: 6px 8px; 
    border: 1px solid var(--border-color); 
    border-radius: 4px; 
    box-sizing: border-box; 
    font-size: 13px;
    background: white;
    transition: border-color 0.1s;
}

.prop-field input:focus, .prop-field select:focus, .prop-field textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px rgba(var(--primary-color-rgb), 0.2);
}

.prop-field .input-group { 
    display: flex; 
    align-items: center; 
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    background: white;
}

.prop-field .input-group input { 
    flex: 1; 
    border: none;
    border-radius: 0;
    padding: 6px 8px;
}

.prop-field .input-group span { 
    padding: 6px 8px; 
    background: var(--bg-light); 
    border-left: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-light);
    font-weight: 500;
}

/* --- Property Section Styles --- */
.prop-section { 
    margin-bottom: 16px;
    padding: 10px;
    background: var(--bg-light);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.prop-section .section-label { 
    display: block; 
    font-size: 11px; 
    font-weight: 700; 
    margin-bottom: 8px; 
    color: var(--text-color); 
    border-bottom: 1px solid var(--primary-color); 
    padding-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- Inline Input Styles --- */
.inline-inputs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

/* Specific grid layouts for different field counts */
.inline-inputs.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.inline-inputs.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.inline-inputs.cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Position & Size specific layouts */
.inline-inputs.position-size {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}

/* Appearance specific layout - all three fields evenly spaced in one row */
.inline-inputs.appearance {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}

.inline-input-group { 
    display: flex;
    flex-direction: column;
}

.inline-input-group label { 
    display: block; 
    font-size: 10px; 
    font-weight: 600; 
    margin-bottom: 2px; 
    color: var(--text-light); 
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.inline-input-group input { 
    width: 100%; 
    padding: 4px 6px; 
    border: 1px solid var(--border-color); 
    border-radius: 4px; 
    box-sizing: border-box; 
    font-size: 12px; 
    text-align: center;
    background: white;
    transition: border-color 0.1s;
}

.inline-input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px rgba(var(--primary-color-rgb), 0.2);
}

/* --- Digital Space & Display Editor Styles --- */

/* Digital Location Rectangles */
.digital-location-rect {
    position: absolute;
    border: 2px solid #4CAF50;
    background-color: rgba(76, 175, 80, 0.1);
    cursor: pointer;
    box-sizing: border-box;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--text-dark);
    font-weight: 500;
    text-align: center;
    overflow: hidden;
}

.digital-location-rect.selected {
    border-color: #2E7D32;
    background-color: rgba(46, 125, 50, 0.2);
    box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.3);
}

/* Digital World Container */
.digital-world {
    transform-origin: 0 0;
    transition: transform 0.1s ease;
}

/* Display Editor Styles */
.display-element-rect {
    position: absolute;
    border: 1px solid #cccccc;
    background-color: #f0f0f0;
    cursor: pointer;
    box-sizing: border-box;
    user-select: none;
    font-size: 12px;
    color: #333333;
    overflow: hidden;
}

.display-element-rect.selected {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.3);
}

.display-element-rect.drawing {
    border: 2px dashed #007bff;
    background-color: rgba(0, 123, 255, 0.1);
}

.display-viewport {
    position: absolute;
    border: 2px solid #333;
    background-color: #ffffff;
    z-index: 0;
    overflow: hidden;
}

.display-world {
    transform-origin: 0 0;
    transition: transform 0.1s ease;
}

/* Element Content Styling */
.element-content {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: calc(2px / var(--current-font-zoom-scale, 1));
    font-size: calc(12px / var(--current-font-zoom-scale, 1));
    overflow: hidden;
    transform-origin: center;
}

.element-icon {
    margin-right: calc(4px / var(--current-font-zoom-scale, 1));
    font-size: 14px; /* Keep icon size constant */
}

.element-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: calc(12px / var(--current-font-zoom-scale, 1)); /* Slower scaling curve - 40% reduction in increase rate */
}

/* Digital Objects List */
.digital-objects-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-light);
}

.object-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
}

.object-item.enhanced {
    flex-direction: column;
    align-items: stretch;
    padding: 10px;
    gap: 6px;
    background: white;
    margin: 4px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.object-item.enhanced:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

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

.object-item:not(.enhanced):hover {
    background: var(--border-color);
}

.object-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.object-icon {
    font-size: 14px;
    width: 16px;
    text-align: center;
}

.object-name {
    flex: 1;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-color);
}

.object-name:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.object-location {
    color: var(--text-light);
    font-size: 10px;
}

.object-details {
    margin: 4px 0;
}

.object-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
    font-size: 11px;
}

.detail-label {
    color: var(--text-light);
    font-weight: 500;
    min-width: 50px;
}

.detail-value {
    color: var(--text-color);
    font-weight: 400;
}

.detail-value.location-link {
    cursor: pointer;
    color: var(--primary-color);
    text-decoration: underline;
}

.detail-value.location-link:hover {
    color: var(--primary-dark);
}

.detail-value.encrypted {
    color: #28a745;
    font-weight: 500;
}

.object-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border-color);
}

.btn.btn-xs {
    padding: 2px 6px;
    font-size: 10px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: white;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.1s ease;
}

.btn.btn-xs:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.add-object-btn {
    padding: 4px 8px !important;
    font-size: 11px !important;
    margin: 0 !important;
}

.empty-state {
    text-align: center;
    color: var(--text-light);
    font-style: italic;
    padding: 20px;
    font-size: 12px;
}

/* Digital Object Visual Elements */
.digital-objects-container {
    pointer-events: auto;
    z-index: 1;
}

.digital-object-visual {
    user-select: none;
    position: relative;
    z-index: 2;
}

.digital-object-visual:hover {
    z-index: 3;
}

.digital-object-visual.dragging {
    opacity: 0.9;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4) !important;
    z-index: 1001;
}

/* Visual feedback for encrypted objects */
.digital-object-visual[style*="border: 1px solid #28a745"] {
    position: relative;
}

.digital-object-visual[style*="border: 1px solid #28a745"]::after {
    content: '🔒';
    position: absolute;
    top: -2px;
    right: -2px;
    font-size: 8px;
    line-height: 1;
    background: #28a745;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Visual feedback for large objects */
.digital-object-visual[style*="rgba(255, 193, 7, 0.3)"] {
    position: relative;
}

.digital-object-visual[style*="rgba(255, 193, 7, 0.3)"]::before {
    content: '⚠';
    position: absolute;
    top: -2px;
    left: -2px;
    font-size: 8px;
    line-height: 1;
    background: #ffc107;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #212529;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Drop Zone Overlays */
.drop-zone-overlay {
    animation: pulse-border 1.5s infinite;
}

@keyframes pulse-border {
    0%, 100% {
        border-width: 2px;
        opacity: 0.7;
    }
    50% {
        border-width: 3px;
        opacity: 1;
    }
}

/* Modal Enhancements */
.modal-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: 10000;
}

.modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-light);
    border-radius: 8px 8px 0 0;
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.1s ease;
}

.modal-close:hover {
    background: var(--border-color);
    color: var(--text-color);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-light);
    border-radius: 0 0 8px 8px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    color: var(--text-color);
    font-size: 13px;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.checkbox-label input[type="checkbox"] {
    width: auto !important;
    flex-shrink: 0;
}

.required {
    color: var(--error-color);
}

.btn-danger-small {
    width: 22px;
    height: 22px;
    border: none;
    border-radius: var(--border-radius-sm);
    background: var(--error-color);
    color: white;
    font-size: var(--font-size-xs);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(220, 53, 69, 0.2);
}

.btn-danger-small:hover {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
}

/* Display Controls */
.display-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.display-controls label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-light);
}

.display-controls select {
    padding: 4px 6px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    background: white;
}

/* Element Quick Buttons */
.element-quick-btn {
    padding: var(--spacing-xs) var(--spacing-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: white;
    cursor: pointer;
    font-size: var(--font-size-xs);
    color: var(--text-color);
    transition: all var(--transition-fast);
    white-space: nowrap;
    flex: 1;
    min-width: 0;
    text-align: center;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.element-quick-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(var(--primary-color-rgb), 0.2);
}

.element-quick-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(var(--primary-color-rgb), 0.2);
}

/* Element List Styling */
.elements-list .element-item:hover {
    background: var(--border-color);
}

.elements-list .element-item:last-child {
    border-bottom: none;
}

/* Improved Location Labels */
.location-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: calc(4px / var(--current-font-zoom-scale, 1));
    font-size: calc(12px / var(--current-font-zoom-scale, 1));
    font-weight: 500;
    text-align: center;
    width: 100%;
    height: 100%;
    padding: calc(4px / var(--current-font-zoom-scale, 1));
    box-sizing: border-box;
    transform-origin: center;
}

.location-icon {
    font-size: calc(14px / var(--current-font-zoom-scale, 1));
    line-height: 1;
}

.location-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
}

.object-count-badge {
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    width: calc(16px / var(--current-font-zoom-scale, 1));
    height: calc(16px / var(--current-font-zoom-scale, 1));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(9px / var(--current-font-zoom-scale, 1));
    font-weight: 600;
    margin-left: calc(4px / var(--current-font-zoom-scale, 1));
    min-width: calc(16px / var(--current-font-zoom-scale, 1));
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Improved Digital Location Styling */
.digital-location-rect {
    border-radius: 6px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.digital-location-rect:hover:not(.dragging) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.digital-location-rect.selected:not(.dragging) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
}

.digital-location-rect.dragging {
    transition: none !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Display Element Improvements */
.display-element-rect {
    border-radius: 4px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.display-element-rect:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.display-element-rect.selected {
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
    transform: translateY(-1px);
}

.display-element-rect.dragging {
    transition: none !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Grid Toggle Improvements */
.space-canvas {
    transition: background 0.3s ease;
}

/* Better Color Input Styling */
input[type="color"] {
    width: 100%;
    height: 32px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    background: white;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

/* Prevent default browser dragging for display elements */
.display-element-rect,
.display-element-rect *,
.element-content,
.element-content * {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

body.digital-space-panning .digital-world *,
body.space-panning .space-world *,
body.disable-animations * {
    transition: none !important;
    animation: none !important;
}

/* Override disable-animations for elements that should keep their transitions */
.location-rect.enable-transitions {
    transition: left 0.05s ease, top 0.05s ease !important;
}

/* --- Resize Size Indicator Styles --- */
.dimension-text {
    position: absolute;
    top: -25px;
    left: 0px;
    background: rgba(0, 0, 0, 0.8);
    color: #ffffff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    user-select: none;
    letter-spacing: 0.3px;
    line-height: 1.2;
}

/* Different colors for different resize contexts */
.location-rect .dimension-text {
    background: rgba(59, 130, 246, 0.9);
    color: #ffffff;
}

.display-element-rect .dimension-text {
    background: rgba(0, 123, 255, 0.9);
    color: #ffffff;
}

.display-viewport .dimension-text {
    background: rgba(255, 107, 53, 0.9);
    color: #ffffff;
}
