/* Blueprint Editor Styles */

body {
    overflow: hidden;
}

#mainApp {
    display: flex;
    height: 100vh;
    flex-direction: column;
}

/* Editor Container - 3 panel layout */
.editor-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Left Panel - Library & Metadata */
.left-panel {
    width: 260px;
    background: var(--bg-medium);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

/* Right Panel - Tools & Palette */
.right-panel {
    width: 280px;
    background: var(--bg-medium);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

/* Center Panel - Canvas */
.center-panel {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--bg-dark);
}

#blueprintCanvas {
    width: 100%;
    height: 100%;
}

#blueprintCanvas canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Panel Sections */
.panel-section {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

/* Override shared/components.css where .section-content defaults to display:none */
.panel-section > .section-content {
    display: block;
}

.panel-section h3 {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.panel-section h3::before {
    content: '\25BC';
    font-size: 8px;
    transition: transform var(--transition-fast);
}

.panel-section.collapsed h3::before {
    transform: rotate(-90deg);
}

.panel-section.collapsed > .section-content {
    display: none;
}

/* Library Browser */
.library-search {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.library-search input {
    flex: 1;
    padding: 6px 8px;
    background: var(--color-bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: var(--font-size-sm);
}

.library-search input:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

.library-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 50vh;
    overflow-y: auto;
}

.library-card {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-bg-input);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    padding: 4px 6px;
    cursor: pointer;
    text-align: left;
    transition: border-color var(--transition-fast);
}

.library-card:hover {
    border-color: var(--color-border-light);
}

.library-card.active {
    border-color: var(--color-accent);
}

.library-card-thumb {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    background: var(--bg-dark);
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.library-card-thumb img {
    max-width: 100%;
    max-height: 100%;
    image-rendering: pixelated;
}

.library-card-thumb .library-card-no-thumb {
    font-size: 24px;
    color: var(--text-muted);
}

.library-card-meta {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
}

.library-card-name {
    font-size: 11px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.library-card-dims {
    font-size: 9px;
    color: var(--text-muted);
}

/* Metadata Panel */
.metadata-field {
    margin-bottom: 8px;
}

.metadata-field label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 3px;
}

.metadata-field input,
.metadata-field select,
.metadata-field textarea {
    width: 100%;
    padding: 5px 7px;
    background: var(--color-bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: var(--font-size-sm);
    box-sizing: border-box;
}

.metadata-field textarea {
    resize: vertical;
    min-height: 40px;
}

.metadata-field input:focus,
.metadata-field select:focus,
.metadata-field textarea:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

/* Door State Toggle */
.door-state-toggle {
    display: flex;
    gap: 4px;
}

.door-state-btn {
    flex: 1;
    padding: 5px 8px;
    font-size: 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--color-bg-input);
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.door-state-btn:hover {
    background: var(--bg-light);
}

.door-state-btn.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 10px 12px;
}

.action-buttons .btn {
    width: 100%;
    padding: 7px 10px;
    font-size: var(--font-size-sm);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.btn-save {
    background: var(--color-success);
    color: white;
}

.btn-save:hover {
    background: #55bb55;
}

.btn-fork {
    background: var(--color-accent);
    color: white;
}

.btn-fork:hover {
    background: var(--color-accent-hover);
}

.btn-new {
    background: var(--color-btn-secondary);
    color: var(--text);
}

.btn-new:hover {
    background: var(--color-btn-secondary-hover);
}

.btn-delete {
    background: var(--color-btn-danger);
    color: white;
}

.btn-delete:hover {
    background: var(--color-btn-danger-hover);
}

/* Tool Bar */
.tool-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tool-btn {
    width: 36px;
    height: 36px;
    background: var(--color-bg-input);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all var(--transition-fast);
}

.tool-btn:hover {
    background: var(--color-bg-hover);
}

.tool-btn.active {
    border-color: var(--color-accent);
    background: rgba(74, 158, 255, 0.15);
}

/* ─── Tooltips (EditorTooltip.js, data-tip / data-tip-kbd) ─── */

.bp-tooltip {
    position: fixed;
    max-width: 260px;
    background: var(--bg-dark);
    border: 1px solid var(--color-border-light, var(--border));
    border-radius: var(--radius-sm);
    padding: 6px 9px;
    z-index: 10000;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity 0.12s ease;
}

.bp-tooltip.visible {
    opacity: 1;
}

.bp-tooltip-text {
    font-size: 11px;
    line-height: 1.45;
    color: var(--text);
    white-space: pre-line;
}

.bp-tooltip-kbds {
    display: flex;
    gap: 4px;
    margin-top: 5px;
}

.bp-tooltip-kbds kbd {
    font-family: inherit;
    font-size: 10px;
    color: var(--text-muted);
    background: var(--color-bg-input);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 3px;
    padding: 1px 5px;
}

/* Tile Palette */
.tile-palette-search {
    margin-bottom: 6px;
}

.tile-palette-search input {
    width: 100%;
    padding: 5px 7px;
    background: var(--color-bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: var(--font-size-sm);
    box-sizing: border-box;
}

.tile-palette-search input:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

.tile-palette-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

.tile-palette-item {
    aspect-ratio: 1;
    background: var(--bg-dark);
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.tile-palette-item:hover {
    border-color: var(--color-accent);
    transform: scale(1.05);
}

.tile-palette-item.selected {
    border-color: var(--color-warning, #ff9800);
    box-shadow: 0 0 8px rgba(255, 152, 0, 0.5);
}

.tile-palette-item canvas,
.tile-palette-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.tile-palette-item .tile-sprite-frame {
    image-rendering: pixelated;
    max-width: 100%;
    max-height: 100%;
}

.tile-palette-item .tile-color-fallback {
    width: 100%;
    height: 100%;
    border-radius: 2px;
}

/* Floor Controls */
.floor-tabs {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.floor-tab {
    padding: 4px 10px;
    background: var(--color-bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.floor-tab:hover {
    background: var(--color-bg-hover);
}

.floor-tab.active {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
}

.floor-tab.hidden-floor {
    opacity: 0.4;
    text-decoration: line-through;
}

.floor-tab .floor-tab-remove {
    display: inline-block;
    margin-left: 6px;
    padding: 0 2px;
    color: var(--text-muted);
    border-radius: 2px;
    font-size: 10px;
    line-height: 1;
}

.floor-tab .floor-tab-remove:hover {
    color: white;
    background: var(--color-btn-danger);
}

.floor-add-btn {
    padding: 4px 8px;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-size: var(--font-size-sm);
}

.floor-add-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.floor-hint {
    font-size: 10px;
    line-height: 1.5;
    color: var(--text-muted);
}

.floor-hint b {
    color: var(--text);
}

/* Floor stepper (canvas controls overlay) */
.floor-stepper .floor-stepper-caption {
    font-size: 10px;
    color: var(--text-muted);
    margin-right: 2px;
}

.floor-stepper .floor-stepper-label {
    min-width: 26px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-accent);
}

.floor-stepper button.stepper-disabled {
    opacity: 0.4;
}

/* Slice Controls */
.slice-control {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.slice-control label {
    font-size: 11px;
    color: var(--text-muted);
    width: 50px;
}

.slice-control input[type="range"] {
    flex: 1;
    accent-color: var(--color-accent);
}

.slice-control input[type="checkbox"] {
    accent-color: var(--color-accent);
}

.slice-control .slice-value {
    font-size: 11px;
    color: var(--text);
    width: 20px;
    text-align: right;
}

.slice-mode-toggle {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.slice-mode-btn {
    flex: 1;
    padding: 4px;
    background: var(--color-bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 10px;
    cursor: pointer;
    text-align: center;
}

.slice-mode-btn.active {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
}

/* Canvas Overlay Controls */
.canvas-controls {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    background: rgba(26, 26, 46, 0.9);
    padding: 6px 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    z-index: 10;
    align-items: center;
    max-width: calc(100% - 20px);
    box-sizing: border-box;
}

.canvas-controls .control-group {
    display: flex;
    gap: 3px;
    align-items: center;
}

.canvas-controls .control-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
}

.canvas-controls button {
    width: 28px;
    height: 28px;
    background: var(--color-bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.canvas-controls button:hover {
    background: var(--color-bg-hover);
}

.canvas-controls button.active {
    background: rgba(74, 158, 255, 0.2);
    border-color: var(--color-accent);
}

.canvas-controls input[type="range"] {
    width: 80px;
    accent-color: var(--color-accent);
}

.canvas-controls .zoom-label {
    font-size: 10px;
    color: var(--text-muted);
    width: 30px;
    text-align: center;
}

/* Status bar */
.status-bar {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(26, 26, 46, 0.85);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    z-index: 10;
}

.status-bar .status-item {
    display: flex;
    gap: 4px;
}

.status-bar .status-label {
    color: var(--text-muted);
}

.status-bar .status-value {
    color: var(--text);
}

/* Unsaved indicator */
.unsaved-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--color-warning);
    color: white;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    z-index: 10;
    display: none;
}

.unsaved-indicator.visible {
    display: block;
}

/* Lineage Tree */
.lineage-tree {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lineage-node {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    background: var(--color-bg-input);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 11px;
    color: var(--text);
    border: 1px solid transparent;
}

.lineage-node:hover {
    border-color: var(--color-border-light);
}

.lineage-node.current {
    border-color: var(--color-accent);
    background: rgba(74, 158, 255, 0.1);
}

.lineage-node-thumb {
    width: 24px;
    height: 24px;
    background: var(--bg-dark);
    border-radius: 2px;
    overflow: hidden;
}

.lineage-node-thumb img {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

.lineage-connector {
    width: 2px;
    height: 12px;
    background: var(--border);
    margin-left: 16px;
}

.lineage-label {
    font-size: 9px;
    color: var(--text-muted);
    padding-left: 8px;
    margin-top: 4px;
}

/* Resize Dialog */
.resize-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.resize-controls label {
    font-size: 11px;
    color: var(--text-muted);
}

.resize-controls input[type="number"] {
    width: 100%;
    padding: 4px 6px;
    background: var(--color-bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: var(--font-size-sm);
    box-sizing: border-box;
}

.resize-controls select {
    width: 100%;
    padding: 4px 6px;
    background: var(--color-bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: var(--font-size-sm);
}

/* Modal */
.bp-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal-backdrop);
}

.bp-modal {
    background: var(--color-bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    min-width: 320px;
    max-width: 500px;
    box-shadow: var(--shadow-modal);
}

.bp-modal h3 {
    margin: 0 0 12px 0;
    color: var(--text);
    font-size: var(--font-size-lg);
}

.bp-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

.empty-state.library-error {
    color: var(--color-error, #c0392b);
    font-size: var(--font-size-sm);
}

/* Copy/paste indicator */
.clipboard-indicator {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(74, 158, 255, 0.15);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius-sm);
    font-size: 10px;
    color: var(--color-accent);
}

.clipboard-indicator.visible {
    display: flex;
}

.placement-indicator {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(255, 136, 0, 0.15);
    border: 1px solid #ff8800;
    border-radius: var(--radius-sm);
    font-size: 10px;
    color: #ff8800;
    margin-top: 4px;
}

.placement-indicator.visible {
    display: flex;
}

.library-card.placing {
    outline: 2px solid #ff8800;
    outline-offset: -2px;
}

/* ─── Blueprint Picker (right panel, active during blueprint tool) ─── */

.bp-picker-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 8px;
    background: var(--bg-dark);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.bp-picker-tab {
    flex: 1;
    padding: 5px 8px;
    font-size: 11px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}

.bp-picker-tab:hover {
    color: var(--text);
    background: var(--color-bg-input);
}

.bp-picker-tab.active {
    background: var(--color-accent);
    color: white;
}

.bp-picker-hint {
    font-size: 11px;
    color: var(--color-accent);
    background: rgba(74, 158, 255, 0.1);
    border: 1px solid rgba(74, 158, 255, 0.25);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    margin-bottom: 8px;
    line-height: 1.4;
}

.bp-picker-search {
    margin-bottom: 8px;
}

.bp-picker-search input {
    width: 100%;
    padding: 5px 7px;
    background: var(--color-bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: var(--font-size-sm);
    box-sizing: border-box;
}

.bp-picker-search input:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

.bp-picker-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: calc(100vh - 480px);
    overflow-y: auto;
}

.bp-picker-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    background: var(--color-bg-input);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.bp-picker-card:hover {
    border-color: var(--color-border-light);
    background: var(--color-bg-hover);
}

.bp-picker-card.placing {
    border-color: #ff8800;
    background: rgba(255, 136, 0, 0.12);
    box-shadow: 0 0 8px rgba(255, 136, 0, 0.25);
}

.bp-picker-thumb {
    width: 40px;
    height: 40px;
    background: var(--bg-dark);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.bp-picker-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.bp-picker-no-thumb {
    font-size: 18px;
    color: var(--text-muted);
}

.bp-picker-info {
    flex: 1;
    min-width: 0;
}

.bp-picker-name {
    font-size: 12px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bp-picker-dims {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 1px;
}

/* ─── Placed Blueprints List ─── */

.bp-placed-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 200px;
    overflow-y: auto;
}

.bp-placed-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 6px;
    background: var(--color-bg-input);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.bp-placed-item:hover {
    border-color: var(--color-border-light);
}

.bp-placed-item.selected {
    border-color: var(--color-accent);
    background: rgba(74, 158, 255, 0.1);
}

.bp-placed-thumb {
    width: 28px;
    height: 28px;
    background: var(--bg-dark);
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.bp-placed-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.bp-placed-no-thumb {
    font-size: 14px;
    color: var(--text-muted);
}

.bp-placed-info {
    flex: 1;
    min-width: 0;
}

.bp-placed-name {
    font-size: 11px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bp-placed-pos {
    font-size: 9px;
    color: var(--text-muted);
}

.bp-placed-delete {
    width: 22px;
    height: 22px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.bp-placed-delete:hover {
    background: var(--color-btn-danger);
    border-color: var(--color-btn-danger);
    color: white;
}
