/**
 * Phanera Builder - Styles
 * Scene composition tool UI
 */

/* Builder wrapper - fills the game surface */
.builder-wrapper {
    --user-color: #88aaff;
    display: flex;
    width: 100%;
    height: 100%;
    background: rgba(15, 10, 25, 0.95);
    color: rgba(220, 230, 255, 0.9);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 12px;
}

/* ========== SIDEBAR ========== */
.builder-sidebar {
    width: 220px;
    min-width: 220px;
    height: 100%;
    background: rgba(20, 15, 35, 0.9);
    border-right: 1px solid rgba(100, 120, 180, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Scrollable sections container */
.sidebar-sections {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Sidebar locked state (play mode) */
.builder-sidebar.locked {
    pointer-events: none;
    opacity: 0.5;
}

.builder-sidebar.locked .sidebar-footer {
    pointer-events: auto;
    opacity: 1;
}

/* Collapsible sections like VS Code */
.sidebar-section {
    border-bottom: 1px solid rgba(100, 120, 180, 0.15);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    cursor: pointer;
    user-select: none;
    transition: background 0.1s ease;
}

.section-header:hover {
    background: rgba(60, 55, 90, 0.3);
}

.section-chevron {
    width: 16px;
    height: 16px;
    transition: transform 0.15s ease;
    opacity: 0.6;
}

.section-chevron svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.sidebar-section.collapsed .section-chevron {
    transform: rotate(-90deg);
}

.section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(180, 195, 240, 0.8);
    flex: 1;
}

.section-content {
    padding: 8px 10px 10px;
    overflow: hidden;
    transition: max-height 0.2s ease, padding 0.2s ease;
}

.sidebar-section.collapsed .section-content {
    max-height: 0 !important;
    padding-top: 0;
    padding-bottom: 0;
}

/* Upload section */
.upload-section .section-content {
    max-height: 120px;
}

.upload-dropzone {
    border: 2px dashed rgba(100, 140, 200, 0.3);
    border-radius: 6px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
    border-color: var(--user-color);
    background: rgba(100, 140, 200, 0.1);
}

.dropzone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: rgba(150, 170, 220, 0.7);
    font-size: 11px;
}

.dropzone-content svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    stroke-width: 1.5;
    fill: none;
    opacity: 0.6;
}

/* Library section */
.library-section .section-content {
    max-height: 200px;
    overflow-y: auto;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.library-item {
    aspect-ratio: 1;
    background: rgba(30, 25, 50, 0.8);
    border: 1px solid rgba(100, 120, 180, 0.2);
    border-radius: 3px;
    overflow: hidden;
    cursor: grab;
    transition: all 0.15s ease;
    position: relative;
}

.library-item:hover {
    border-color: rgba(150, 180, 255, 0.4);
    transform: scale(1.05);
}

.library-item.dragging {
    opacity: 0.5;
}

.library-item.is-background {
    border-color: var(--user-color);
    box-shadow: 0 0 6px color-mix(in srgb, var(--user-color) 40%, transparent);
}

.library-item.is-background::after {
    content: 'BG';
    position: absolute;
    bottom: 1px;
    right: 1px;
    font-size: 7px;
    font-weight: bold;
    background: var(--user-color);
    color: #000;
    padding: 1px 2px;
    border-radius: 2px;
}

.library-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    pointer-events: none;
}

/* Layers section */
.layers-section .section-content {
    max-height: 180px;
    overflow-y: auto;
}

.layer-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.layer-list-empty {
    color: rgba(150, 170, 220, 0.4);
    font-style: italic;
    text-align: center;
    padding: 15px 10px;
    font-size: 11px;
}

.layer-list-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    background: rgba(40, 35, 60, 0.5);
    border: 1px solid rgba(100, 120, 180, 0.15);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.1s ease;
    font-size: 11px;
}

.layer-list-item:hover {
    background: rgba(60, 55, 90, 0.6);
    border-color: rgba(150, 180, 255, 0.3);
}

.layer-list-item.selected {
    background: rgba(80, 100, 160, 0.4);
    border-color: var(--user-color);
}

.layer-list-item.background-item {
    opacity: 0.6;
    border-style: dashed;
}

.layer-visibility {
    cursor: pointer;
    opacity: 0.5;
    font-size: 12px;
}

.layer-visibility.visible {
    opacity: 1;
}

.layer-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.layer-icon {
    opacity: 0.5;
    font-size: 10px;
}

.layer-tag {
    font-size: 8px;
    background: rgba(100, 120, 180, 0.3);
    padding: 1px 4px;
    border-radius: 2px;
    opacity: 0.7;
}

.layer-delete {
    opacity: 0.4;
    cursor: pointer;
    font-size: 14px;
    padding: 0 2px;
}

.layer-delete:hover {
    opacity: 1;
    color: #ff6b6b;
}

/* Properties section */
.props-section .section-content {
    max-height: 220px;
    overflow-y: auto;
}

.props-empty {
    color: rgba(150, 170, 220, 0.4);
    font-style: italic;
    text-align: center;
    padding: 12px;
    font-size: 11px;
}

.props-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.prop-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.prop-row label {
    flex: 0 0 55px;
    font-size: 10px;
    color: rgba(180, 195, 240, 0.7);
}

.prop-row input[type="text"],
.prop-row input[type="number"],
.prop-row select {
    flex: 1;
    background: rgba(30, 25, 50, 0.8);
    border: 1px solid rgba(100, 120, 180, 0.25);
    border-radius: 3px;
    padding: 4px 6px;
    color: rgba(220, 230, 255, 0.9);
    font-size: 10px;
    min-width: 0;
}

.prop-row input:focus {
    outline: none;
    border-color: var(--user-color);
}

.prop-unit {
    font-size: 9px;
    color: rgba(150, 170, 220, 0.5);
}

.prop-row.checkbox label {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 10px;
}

.prop-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.prop-btn {
    flex: 1;
    padding: 4px 8px;
    background: rgba(60, 80, 140, 0.3);
    border: 1px solid rgba(100, 140, 200, 0.3);
    border-radius: 3px;
    color: rgba(200, 215, 255, 0.8);
    font-size: 9px;
    cursor: pointer;
    transition: all 0.1s ease;
}

.prop-btn:hover {
    background: rgba(80, 100, 160, 0.4);
    border-color: var(--user-color);
}

/* ========== CANVAS AREA ========== */
.builder-canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 12px;
    gap: 8px;
    min-width: 0;
    background: 
        linear-gradient(45deg, rgba(20, 15, 30, 0.3) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(20, 15, 30, 0.3) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(20, 15, 30, 0.3) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(20, 15, 30, 0.3) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: rgba(12, 8, 20, 0.95);
}

/* ========== TITLE BAR ========== */
.canvas-title-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: calc((100vh - 100px) * (16/9));
    padding: 6px 10px;
    background: rgba(25, 20, 45, 0.9);
    border: 1px solid rgba(100, 120, 180, 0.2);
    border-radius: 4px;
    flex-shrink: 0;
}

.phanera-title {
    font-size: 13px;
    font-weight: 600;
    color: rgba(200, 215, 255, 0.9);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mode-toggle {
    display: flex;
    gap: 2px;
    background: rgba(15, 12, 28, 0.6);
    border-radius: 3px;
    padding: 2px;
}

.mode-btn {
    padding: 4px 10px;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.5px;
    border: none;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: transparent;
    color: rgba(150, 170, 220, 0.6);
}

.mode-btn:hover {
    color: rgba(200, 220, 255, 0.8);
}

.mode-btn.active {
    background: var(--user-color);
    color: rgba(10, 10, 20, 0.95);
}

/* Title bar controls container */
.title-bar-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ========== AS (PLAY AS) BUTTON ========== */
.as-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px 3px 4px;
    border: 1px solid rgba(100, 120, 180, 0.25);
    border-radius: 3px;
    background: rgba(40, 35, 60, 0.5);
    cursor: pointer;
    transition: all 0.15s ease;
}

.as-btn:hover {
    background: rgba(60, 55, 90, 0.6);
    border-color: rgba(120, 150, 220, 0.4);
}

.as-btn.impersonating {
    border-color: rgba(255, 180, 100, 0.5);
    background: rgba(80, 60, 40, 0.4);
}

.as-avatar {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(100, 120, 180, 0.3);
    background-size: cover;
    background-position: center;
}

.as-avatar.has-avatar {
    border: 1px solid rgba(255, 180, 100, 0.6);
}

.as-label {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: rgba(150, 170, 220, 0.7);
}

.as-btn.impersonating .as-label {
    color: rgba(255, 200, 140, 0.9);
}

/* ========== PLAY AS DIALOG ========== */
.play-as-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(5, 5, 15, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(3px);
}

.play-as-dialog {
    background: rgba(25, 22, 45, 0.98);
    border: 1px solid rgba(100, 140, 200, 0.3);
    border-radius: 8px;
    width: 320px;
    max-width: 90vw;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}

.play-as-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(100, 120, 180, 0.2);
    font-size: 13px;
    font-weight: 600;
    color: rgba(200, 220, 255, 0.9);
}

.play-as-close {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    border: none;
    border-radius: 3px;
    background: transparent;
    color: rgba(180, 200, 240, 0.6);
    cursor: pointer;
}

.play-as-close:hover {
    background: rgba(200, 60, 60, 0.3);
    color: rgba(255, 120, 120, 0.9);
}

.play-as-body {
    padding: 14px;
}

.play-as-current {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(80, 60, 40, 0.3);
    border: 1px solid rgba(255, 180, 100, 0.3);
    border-radius: 4px;
    margin-bottom: 10px;
}

.play-as-current-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255, 180, 100, 0.5);
}

.play-as-current-info {
    flex: 1;
}

.play-as-current-name {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 220, 180, 0.95);
}

.play-as-current-handle {
    font-size: 10px;
    color: rgba(200, 180, 150, 0.7);
}

.play-as-status {
    font-size: 10px;
    color: rgba(150, 170, 220, 0.6);
    margin-bottom: 10px;
    text-align: center;
}

.play-as-status.impersonating {
    color: rgba(255, 180, 100, 0.8);
    font-weight: 500;
}

.play-as-field {
    margin-bottom: 10px;
}

.play-as-field label {
    display: block;
    font-size: 10px;
    color: rgba(160, 180, 220, 0.7);
    margin-bottom: 4px;
}

.play-as-field input {
    width: 100%;
    padding: 8px 10px;
    font-size: 12px;
    background: rgba(20, 18, 40, 0.8);
    border: 1px solid rgba(80, 100, 160, 0.3);
    border-radius: 4px;
    color: rgba(220, 230, 255, 0.95);
}

.play-as-field input:focus {
    outline: none;
    border-color: rgba(100, 140, 200, 0.5);
}

.play-as-result {
    min-height: 20px;
}

.play-as-loading {
    font-size: 11px;
    color: rgba(150, 180, 240, 0.7);
    text-align: center;
    padding: 10px;
}

.play-as-error {
    font-size: 11px;
    color: rgba(255, 120, 120, 0.9);
    text-align: center;
    padding: 10px;
}

.play-as-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(40, 50, 80, 0.4);
    border: 1px solid rgba(100, 140, 200, 0.3);
    border-radius: 4px;
    margin-bottom: 10px;
}

.play-as-preview-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(100, 140, 200, 0.4);
}

.play-as-preview-info {
    flex: 1;
}

.play-as-preview-name {
    font-size: 12px;
    font-weight: 600;
    color: rgba(200, 220, 255, 0.95);
}

.play-as-preview-handle {
    font-size: 10px;
    color: rgba(150, 180, 220, 0.7);
}

.play-as-preview-octant {
    font-size: 9px;
    color: rgba(130, 160, 200, 0.6);
    text-transform: capitalize;
    margin-top: 2px;
}

.play-as-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 10px 14px;
    border-top: 1px solid rgba(100, 120, 180, 0.15);
}

.play-as-btn {
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid rgba(100, 140, 200, 0.3);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.play-as-btn.primary {
    background: rgba(60, 80, 140, 0.4);
    color: rgba(180, 200, 255, 0.95);
}

.play-as-btn.primary:hover {
    background: rgba(80, 100, 160, 0.5);
    border-color: rgba(120, 160, 220, 0.5);
}

.play-as-btn.secondary {
    background: transparent;
    color: rgba(150, 170, 220, 0.8);
}

.play-as-btn.secondary:hover {
    background: rgba(60, 60, 80, 0.3);
}

.play-as-btn.confirm {
    width: 100%;
    background: rgba(60, 120, 80, 0.4);
    border-color: rgba(100, 180, 120, 0.4);
    color: rgba(180, 255, 200, 0.95);
}

.play-as-btn.confirm:hover {
    background: rgba(80, 150, 100, 0.5);
    border-color: rgba(120, 200, 140, 0.6);
}

/* 16:9 Canvas Container - Fixed Aspect Ratio */
.canvas-container {
    position: relative;
    aspect-ratio: 16 / 9;
    width: 100%;
    max-width: calc((100vh - 100px) * (16/9));
    flex: 1;
    min-height: 0;
    background: rgba(10, 8, 20, 0.95);
    border: 1px solid rgba(100, 120, 180, 0.3);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 
        0 0 40px rgba(0, 0, 0, 0.5),
        inset 0 0 80px rgba(10, 10, 30, 0.6);
}

/* The actual scene layer container scaled within 16:9 */
.canvas-layers {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* Scene dimensions - will be scaled to fit */
    width: var(--scene-width, 320px);
    height: var(--scene-height, 240px);
    /* Scale to fit 16:9 container while maintaining scene aspect ratio */
    transform-origin: center center;
}

.canvas-layers.dragover {
    outline: 2px dashed var(--user-color);
    outline-offset: -4px;
}

.canvas-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    image-rendering: pixelated;
}

.canvas-layer {
    position: absolute;
    cursor: move;
    transition: box-shadow 0.15s ease;
}

.canvas-layer img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    image-rendering: pixelated;
    pointer-events: none;
}

.canvas-layer.selected {
    outline: 2px solid var(--user-color);
    outline-offset: 2px;
    box-shadow: 0 0 15px color-mix(in srgb, var(--user-color) 50%, transparent);
}

.canvas-layer:hover:not(.selected) {
    outline: 1px solid rgba(200, 220, 255, 0.4);
}

/* In play mode, hide selection and hover effects, disable pointer */
.canvas-layers.playing .canvas-layer {
    cursor: default;
}

.canvas-layers.playing .canvas-layer.selected,
.canvas-layers.playing .canvas-layer:hover:not(.selected) {
    outline: none;
    box-shadow: none;
}

/* In edit mode, show cursor grab */
.canvas-layers.editing .canvas-layer {
    cursor: grab;
}

.canvas-layers.editing .canvas-layer:active {
    cursor: grabbing;
}

/* Selection overlay (for future resize handles) */
.selection-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* WYSIWYG Controls inside canvas (from game surface) */
.canvas-container .game-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
}

.canvas-container .logout-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 100;
}

/* Avatar bubble in canvas - uses absolute positioning from game.css */
.canvas-container .avatar-bubble {
    z-index: 90;
}

/* Impersonating avatar bubble - visual indicator */
.canvas-container .avatar-bubble.impersonating {
    animation: impersonate-pulse 2s ease-in-out infinite;
}

.canvas-container .avatar-bubble.impersonating::before {
    content: '🎭';
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 12px;
    z-index: 10;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}

@keyframes impersonate-pulse {
    0%, 100% { 
        filter: drop-shadow(0 0 4px var(--user-color, #9966ff)); 
    }
    50% { 
        filter: drop-shadow(0 0 12px var(--user-color, #9966ff)) 
               drop-shadow(0 0 20px var(--user-color, #9966ff)); 
    }
}

/* ========== DETAILS SECTION ========== */
.details-section .section-content {
    max-height: 220px;
    overflow-y: auto;
}

.details-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.detail-row label {
    font-size: 10px;
    color: rgba(180, 195, 240, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.detail-row input[type="text"],
.detail-row textarea {
    background: rgba(30, 25, 50, 0.8);
    border: 1px solid rgba(100, 120, 180, 0.25);
    border-radius: 3px;
    padding: 5px 7px;
    color: rgba(220, 230, 255, 0.9);
    font-size: 11px;
    font-family: inherit;
    resize: none;
}

.detail-row input[type="text"]:focus,
.detail-row textarea:focus {
    outline: none;
    border-color: var(--user-color);
}

.detail-row input[readonly] {
    opacity: 0.6;
    cursor: not-allowed;
}

.detail-row textarea {
    min-height: 36px;
}

/* ========== SIDEBAR FOOTER ========== */
.sidebar-footer {
    margin-top: auto;
    padding: 10px;
    border-top: 1px solid rgba(100, 120, 180, 0.2);
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    background: rgba(15, 12, 28, 0.95);
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
}

.footer-btn {
    flex: 1;
    min-width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 8px;
    background: rgba(60, 80, 140, 0.25);
    border: 1px solid rgba(100, 140, 200, 0.25);
    border-radius: 3px;
    color: rgba(200, 215, 255, 0.85);
    font-size: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.footer-btn:hover {
    background: rgba(80, 100, 160, 0.4);
    border-color: var(--user-color);
}

.footer-btn.danger:hover {
    background: rgba(140, 60, 60, 0.4);
    border-color: rgba(255, 120, 120, 0.5);
}

.footer-btn svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    stroke-width: 1.5;
    fill: none;
}

/* ========== CANVAS FOOTER ========== */
.canvas-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: calc((100vh - 100px) * (16/9));
    padding: 4px 8px;
}

.canvas-size-indicator {
    font-size: 9px;
    color: rgba(150, 170, 220, 0.4);
    font-family: monospace;
}

.keyboard-hints {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.keyboard-hints .hint {
    font-size: 8px;
    color: rgba(150, 170, 220, 0.35);
    font-family: monospace;
    white-space: nowrap;
}

/* ========== CONTEXT MENU ========== */
.context-menu {
    position: fixed;
    background: rgba(30, 25, 50, 0.98);
    border: 1px solid rgba(100, 140, 200, 0.3);
    border-radius: 4px;
    padding: 3px 0;
    min-width: 130px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    font-size: 11px;
}

.context-menu-item {
    padding: 6px 12px;
    cursor: pointer;
    transition: background 0.1s ease;
}

.context-menu-item:hover {
    background: rgba(80, 100, 160, 0.4);
}

.context-menu-item.danger:hover {
    background: rgba(200, 60, 60, 0.3);
    color: #ff8888;
}

.context-menu-divider {
    height: 1px;
    background: rgba(100, 120, 180, 0.2);
    margin: 3px 0;
}

/* ========== MINIMAL SCROLLBARS ========== */
.sidebar-sections::-webkit-scrollbar,
.section-content::-webkit-scrollbar {
    width: 4px;
}

.sidebar-sections::-webkit-scrollbar-track,
.section-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-sections::-webkit-scrollbar-thumb,
.section-content::-webkit-scrollbar-thumb {
    background: rgba(100, 120, 180, 0.25);
    border-radius: 2px;
}

.sidebar-sections::-webkit-scrollbar-thumb:hover,
.section-content::-webkit-scrollbar-thumb:hover {
    background: rgba(120, 150, 220, 0.4);
}

/* Firefox scrollbar */
.sidebar-sections,
.section-content {
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 120, 180, 0.25) transparent;
}

/* ========== INTERACTIVE SECTION ========== */
.interactive-section {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(100, 120, 180, 0.15);
}

/* ========== CONDITION/COMMAND STACKS ========== */
.stack-section {
    margin-top: 8px;
}

.stack-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
}

.stack-label {
    font-size: 10px;
    font-weight: 600;
    color: rgba(180, 200, 240, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stack-add {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid rgba(100, 140, 200, 0.3);
    border-radius: 3px;
    background: rgba(60, 80, 140, 0.2);
    color: rgba(150, 180, 240, 0.8);
    cursor: pointer;
    transition: all 0.15s ease;
}

.stack-add:hover {
    background: rgba(80, 110, 180, 0.3);
    border-color: rgba(120, 160, 220, 0.5);
    color: rgba(200, 220, 255, 0.95);
}

.stack-list {
    background: rgba(15, 12, 30, 0.4);
    border: 1px solid rgba(80, 100, 160, 0.15);
    border-radius: 3px;
    min-height: 24px;
}

.stack-empty {
    font-size: 9px;
    color: rgba(130, 150, 200, 0.4);
    font-style: italic;
    padding: 6px 8px;
    text-align: center;
}

.stack-item {
    border-bottom: 1px solid rgba(80, 100, 160, 0.1);
}

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

.stack-item-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    background: rgba(50, 60, 100, 0.2);
    cursor: pointer;
}

.stack-item-type {
    font-size: 10px;
    font-weight: 600;
    color: rgba(180, 200, 240, 0.85);
}

.stack-item-summary {
    flex: 1;
    font-size: 9px;
    color: rgba(150, 170, 220, 0.6);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stack-item-remove {
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    border: none;
    border-radius: 2px;
    background: transparent;
    color: rgba(200, 100, 100, 0.5);
    cursor: pointer;
    opacity: 0;
    transition: all 0.1s ease;
}

.stack-item:hover .stack-item-remove {
    opacity: 1;
}

.stack-item-remove:hover {
    background: rgba(200, 60, 60, 0.2);
    color: rgba(255, 120, 120, 0.9);
}

.stack-item-editor {
    padding: 6px 8px;
    font-size: 10px;
}

/* Condition/Command Editor Fields */
.condition-field,
.command-field {
    margin-bottom: 6px;
}

.condition-field label,
.command-field label {
    display: block;
    font-size: 9px;
    color: rgba(160, 180, 220, 0.7);
    margin-bottom: 2px;
}

.condition-field.checkbox label,
.command-field.checkbox label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
}

.condition-input,
.condition-field select,
.condition-field input,
.command-field select,
.command-field input,
.command-field textarea {
    width: 100%;
    padding: 3px 5px;
    font-size: 10px;
    background: rgba(20, 18, 40, 0.6);
    border: 1px solid rgba(80, 100, 160, 0.25);
    border-radius: 2px;
    color: rgba(220, 230, 255, 0.9);
}

.command-field textarea {
    resize: vertical;
    min-height: 40px;
    font-family: inherit;
}

.condition-field.disabled,
.command-field.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.condition-hint {
    font-size: 8px;
    color: rgba(140, 160, 210, 0.5);
    font-style: italic;
    margin-top: 4px;
}

/* Spectrum Condition Styles */
.condition-spectrum-editor {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.spectrum-pair-label {
    font-size: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(140, 160, 200, 0.5);
    margin-top: 4px;
    margin-bottom: 2px;
    padding-left: 2px;
}

.spectrum-pair-label:first-child {
    margin-top: 0;
}

.condition-spectrum-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.spectrum-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 70px;
}

.spectrum-name {
    font-size: 10px;
    color: rgba(180, 200, 240, 0.8);
}

.spectrum-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.spectrum-controls.disabled {
    opacity: 0.35;
}

.spectrum-controls select {
    width: 36px;
    padding: 2px;
}

.spectrum-controls input[type="number"] {
    width: 45px;
    padding: 2px 4px;
}

/* ========== MODULE PICKER OVERLAY ========== */
.module-picker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(5, 5, 15, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(2px);
}

.module-picker {
    background: rgba(25, 22, 45, 0.98);
    border: 1px solid rgba(100, 140, 200, 0.3);
    border-radius: 6px;
    min-width: 240px;
    max-width: 320px;
    max-height: 400px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}

.picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(100, 120, 180, 0.2);
    font-size: 12px;
    font-weight: 600;
    color: rgba(200, 220, 255, 0.9);
}

.picker-close {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    border: none;
    border-radius: 3px;
    background: transparent;
    color: rgba(180, 200, 240, 0.6);
    cursor: pointer;
}

.picker-close:hover {
    background: rgba(200, 60, 60, 0.2);
    color: rgba(255, 120, 120, 0.9);
}

.picker-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

.picker-category {
    margin-bottom: 8px;
}

.picker-category-name {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(150, 170, 220, 0.5);
    padding: 4px 6px;
}

.picker-item {
    padding: 8px 10px;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.1s ease;
}

.picker-item:hover {
    background: rgba(80, 100, 160, 0.3);
}

.picker-item-name {
    font-size: 11px;
    font-weight: 500;
    color: rgba(200, 220, 255, 0.9);
}

.picker-item-desc {
    font-size: 9px;
    color: rgba(150, 170, 220, 0.6);
    margin-top: 2px;
}

/* ========== POPUP STYLES (for popup command) ========== */
.phanera-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(5, 5, 15, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.phanera-popup-overlay.visible {
    opacity: 1;
}

.phanera-popup {
    background: rgba(20, 18, 40, 0.95);
    border: 2px solid rgba(100, 140, 200, 0.4);
    border-radius: 4px;
    min-width: 180px;
    max-width: 80%;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.phanera-popup-overlay.visible .phanera-popup {
    transform: scale(1);
}

.phanera-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(100, 120, 180, 0.2);
    background: rgba(40, 35, 70, 0.5);
}

.phanera-popup-title {
    font-size: 12px;
    font-weight: 600;
    color: rgba(200, 220, 255, 0.9);
}

.phanera-popup-close {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border: none;
    border-radius: 2px;
    background: transparent;
    color: rgba(180, 200, 240, 0.6);
    cursor: pointer;
}

.phanera-popup-close:hover {
    background: rgba(200, 60, 60, 0.3);
    color: rgba(255, 120, 120, 0.9);
}

.phanera-popup-body {
    padding: 16px 20px;
    font-size: 11px;
    line-height: 1.5;
    color: rgba(200, 215, 255, 0.85);
    text-align: center;
}

.phanera-popup-footer {
    padding: 8px 12px;
    border-top: 1px solid rgba(100, 120, 180, 0.15);
    display: flex;
    justify-content: center;
}

.phanera-popup-btn {
    padding: 5px 16px;
    font-size: 10px;
    font-weight: 500;
    border: 1px solid rgba(100, 140, 200, 0.3);
    border-radius: 3px;
    background: rgba(60, 80, 140, 0.3);
    color: rgba(180, 200, 255, 0.9);
    cursor: pointer;
    transition: all 0.15s ease;
}

.phanera-popup-btn:hover {
    background: rgba(80, 110, 180, 0.4);
    border-color: rgba(120, 160, 220, 0.5);
}
