/* Zanpo Builder Styles */

#zanpo-builder-overlay {
    position: absolute;
    top: 33px;
    left: 0;
    width: 100%;
    height: calc(100% - 70px);
    z-index: 10;
    pointer-events: none;
    display: none;
}

#zanpo-builder-overlay.active {
    display: block;
    pointer-events: all;
}

.builder-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    font-family: 'Arial', sans-serif;
}

.builder-main {
    left: 50%;
    transform: translateX(calc(-50% - 1px));
    width: 745px;
    height: 404px;
    position: relative;
    display: flex;
}

/* Left Panel - Controls and Info */
.builder-left-panel {
    width: 165px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 10px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.2);
}

.builder-left-panel.theme-red {
    background: linear-gradient(135deg, #4a1a1a 0%, #2a0a0a 100%);
    border-color: #660000;
}

.builder-logo {
    width: 100%;
    height: 60px;
    background: url('../../../content/build.svg');
    background-repeat: no-repeat;
    display: absolute;
    align-items: center;
    justify-content: flex-start;
    padding-left: 8px;
    gap: 8px;
    margin-top: -38px;
    margin-left: 73px;
}

.arrow {
    background: url('../../../content/arrow.png');
    width: 50px;
    height: 50px;
    margin-left: 12px;
}

.minimap-container {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    margin-top: -15px;
    margin-left: -2px;
}

.builder-minimap {
    width: 130px;
    height: 130px;
    background: #000;
    border: 2px solid #666;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.minimap-grid {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
}

.minimap-cell {
    border: 1px solid #333;
    background: #000;
    transition: background-color 0.3s;
}

.minimap-cell.current {
    border: 2px solid #ffff00;
    box-shadow: 0 0 4px #ffff00;
}

.layer-indicator {
    display: flex;
    flex-direction: column;
    width: 20px;
}

.layer-cell {
    flex: 1;
    background: #000;
    border: 2px solid #333;
    position: relative;
    transition: background-color 0.2s, border-color 0.2s;
}

.layer-cell.filled {
    background: #4a9eff;
    border-color: #4a9eff;
}

.layer-cell.current {
    border: 2px solid #ffff00;
    box-shadow: 0 0 4px #ffff00;
}

.layer-cell::after {
    content: attr(data-layer);
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 8px;
    color: #666;
    font-weight: bold;
}

.layer-cell.filled::after {
    color: #000;
}

.layer-cell.current::after {
    color: #ffff00;
}

.builder-tips-button {
    width: 100%;
    padding: 10px;
    background: linear-gradient(180deg, #7733cc 0%, #5511aa 100%);
    border: 2px solid #9944dd;
    border-radius: 6px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
    margin-bottom: 10px;
    transition: all 0.2s;
}

.builder-tips-button:hover {
    background: linear-gradient(180deg, #8844dd 0%, #6622bb 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

.builder-visibility-control {
    width: 80%;
    padding: 10px;
    background: rgba(0,0,0,0.5);
    border: 2px solid #666;
    border-radius: 6px;
    margin-top: auto;
}

.visibility-label {
    color: #ccc;
    font-size: 11px;
    margin-bottom: 5px;
    text-align: center;
}

.visibility-slider {
    width: 100%;
    height: 4px;
    background: #333;
    border-radius: 2px;
    position: relative;
    cursor: pointer;
    transition: opacity 0.3s;
}

.visibility-slider.animating {
    cursor: not-allowed;
    opacity: 0.6;
}

.visibility-slider.animating .visibility-thumb {
    cursor: not-allowed;
}

.visibility-track {
    height: 100%;
    background: linear-gradient(90deg, #444 0%, #4a9eff 100%);
    border-radius: 2px;
    position: relative;
}

.visibility-thumb {
    width: 12px;
    height: 12px;
    background: #fff;
    border: 2px solid #4a9eff;
    border-radius: 50%;
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    cursor: grab;
}

.visibility-thumb:active {
    cursor: grabbing;
}

.builder-section-control {
    margin-top: 15px;
}

.section-buttons {
    display: flex;
    gap: 5px;
    justify-content: center;
    margin-top: 5px;
}

.section-button {
    flex: 1;
    padding: 8px;
    background: rgba(0,0,0,0.5);
    border: 2px solid #666;
    border-radius: 4px;
    color: #ccc;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.section-button:hover {
    background: rgba(50,50,50,0.7);
    border-color: #999;
}

.section-button.selected {
    background: rgba(74, 158, 255, 0.3);
    border-color: #4a9eff;
    color: #fff;
}

/* Center Panel - 3D View */
.builder-center {
    flex: 1;
    height: 100%;
    position: relative;
    background: transparent;
    overflow: hidden;
}

.builder-center.theme-red {
    background: transparent;
}

.builder-viewport {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 40px;
}

#iso-canvas {
    cursor: crosshair;
    image-rendering: smooth;
    width: 520px;
    height: 490px;
}

#iso-canvas.light-beam-active {
    cursor: none;
}

.isometric-grid {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transform-style: preserve-3d;
}

.grid-cell {
    position: absolute;
    cursor: pointer;
}

.grid-cell-base {
    width: 32px;
    height: 16px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(100,100,100,0.1);
    transform-origin: center;
}

.grid-cell-base:hover {
    background: rgba(150,150,255,0.3);
    border-color: rgba(255,255,255,0.5);
}

.grid-cell.has-block .grid-cell-base {
    border-color: rgba(255,255,0,0.3);
}

.block-sprite {
    position: absolute;
    pointer-events: none;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.block-placement-guide {
    position: absolute;
    width: 32px;
    height: 60px;
    background: linear-gradient(180deg, rgba(255,255,0,0.6) 0%, rgba(255,255,0,0) 100%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.block-placement-guide.active {
    opacity: 1;
}

.rotation-button {
    position: absolute;
    top: 65%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(0,0,0,0.7);
    border: 2px solid #666;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.rotation-button.rotation-left {
    left: 10px;
}

.rotation-button.rotation-right {
    right: 10px;
}

.rotation-button:hover {
    background: rgba(50,50,50,0.9);
    border-color: #999;
    transform: translateY(-50%) scale(1.1);
}

/* Tool buttons */
.builder-bottom-tools {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    z-index: 15;
}

.tool-button {
    width: 60px;
    height: 60px;
    background: rgba(0,0,0,0.7);
    border: 3px solid #666;
    border-radius: 8px;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.tool-button:hover {
    background: rgba(50,50,50,0.9);
    border-color: #999;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}

.tool-button.selected {
    background: rgba(74, 158, 255, 0.5);
    border-color: #4a9eff;
    box-shadow: 0 0 15px rgba(74, 158, 255, 0.6);
}

/* Right Panel - Block Selection */
.builder-right-panel {
    width: 260px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 10px;
    box-sizing: border-box;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
}

.builder-right-panel.theme-red {
    background: linear-gradient(135deg, #4a1a1a 0%, #2a0a0a 100%);
    border-color: #660000;
}

.block-info-panel {
    margin-bottom: 10px;
}

.block-title-input {
    width: 100%;
    padding: 8px;
    background: rgba(0,0,0,0.5);
    border: 2px solid #666;
    border-radius: 4px;
    color: #4a9eff;
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 10px;
    outline: none;
}

.block-title-input:focus {
    border-color: #4a9eff;
}

.block-description-input {
    width: 100%;
    height: 60px;
    padding: 8px;
    background: rgba(0,0,0,0.5);
    border: 2px solid #666;
    border-radius: 4px;
    color: #ccc;
    font-size: 11px;
    resize: none;
    outline: none;
}

.block-description-input:focus {
    border-color: #4a9eff;
}

.panel-section-title {
    color: #ccc;
    font-size: 12px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 5px;
    padding: 5px;
    background: rgba(0,0,0,0.3);
    border: 1px solid #666;
    border-radius: 4px;
}

/* --- Block Families/Variants Container --- */
.block-family-variant-container {
    background: linear-gradient(135deg, #222 60%, #111 100%);
    border-radius: 18px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.5);
    padding: 12px 18px 12px 18px;
    margin-bottom: 18px;
    position: relative;
    clip-path: polygon(8% 0, 92% 0, 100% 25%, 100% 75%, 92% 100%, 8% 100%, 0 75%, 0 25%);
}

.block-family-section-label,
.block-variant-section-label {
    color: #fff;
    font-size: 15px;
    font-weight: bold;
    text-align: center;
    letter-spacing: 1px;
    margin-bottom: 8px;
    text-shadow: 0 1px 4px #000;
}

.block-families {
    display: block;
    white-space: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 8px;
    margin-bottom: 0;
    scrollbar-width: thin;
    scrollbar-color: #333 #222;
}

.family-button {
    width: 30px;
    height: 30px;
    background: #222;
    border: 2px solid #444;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s, box-shadow 0.2s;
    overflow: hidden;
    margin-right: 6px;
    vertical-align: top;
}

.family-button.selected {
    border-color: #4a9eff;
    box-shadow: 0 0 10px #4a9eff88;
}

.family-button img {
    width: 100%;
    height: 225%;
    padding: 0;
    margin-top: var(--block-margin-top, -45px);
    background: #222;
    display: block;
}

.block-variants {
    display: block;
    white-space: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 8px;
    margin-bottom: 0;
    scrollbar-width: thin;
    scrollbar-color: #333 #222;
}

.variant-button {
    width: 48px;
    height: 48px;
    background: #222;
    border: 2px solid #444;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    cursor: pointer;
    display: inline-block;
    position: relative;
    transition: border-color 0.2s, box-shadow 0.2s;
    overflow: hidden;
    margin-right: 12px;
    vertical-align: top;
}

.variant-button.selected {
    border-color: #ffff00;
    box-shadow: 0 0 10px #ffff0088;
}

.variant-button img {
    position: absolute;
    left: 50%;
    top: calc(25% + var(--block-margin-top, 0px) * 0.5);
    transform: translate(-50%, -50%) scaleX(3);
    width: 16px !important;
    height: 112px !important;
    max-width: none !important;
    min-width: 16px !important;
    background: #222;
    display: block;
}

/* --- Arrow Buttons --- */
.block-family-arrow,
.block-variant-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    background: #222;
    border: 2px solid #444;
    border-radius: 50%;
    color: #fff;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.block-family-arrow.left { left: 0; }
.block-family-arrow.right { right: 0; }
.block-variant-arrow.left { left: 0; }
.block-variant-arrow.right { right: 0; }

.block-family-arrow:hover,
.block-variant-arrow:hover {
    border-color: #4a9eff;
    box-shadow: 0 0 10px #4a9eff88;
}

/* Close button */
.builder-close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    background: rgba(0,0,0,0.7);
    border: 2px solid #666;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: all 0.2s;
}

.builder-close-button:hover {
    background: rgba(170,0,0,0.9);
    border-color: #ff0000;
    transform: scale(1.1);
}

/* Scrollbar styling */
.block-variants::-webkit-scrollbar {
    width: 8px;
}

.block-variants::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
}

.block-variants::-webkit-scrollbar-thumb {
    background: #666;
    border-radius: 4px;
}

.block-variants::-webkit-scrollbar-thumb:hover {
    background: #888;
}

/* Theme color customization */
.theme-red .grid-cell-base:hover {
    background: rgba(255,100,100,0.3);
}

/* Color selector */
.color-selector {
    display: flex;
    gap: 5px;
    margin-bottom: 8px;
    justify-content: center;
}

.color-option {
    width: 30px;
    height: 30px;
    border: 2px solid #666;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.color-option:hover {
    border-color: #999;
    transform: scale(1.1);
}

.color-option.selected {
    border-color: #fff;
    box-shadow: 0 0 10px rgba(255,255,255,0.5);
}

/* Loading indicator */
.builder-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 18px;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Action buttons */
.builder-action-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

.action-buttons-row {
    display: flex;
    gap: 8px;
}

.action-button {
    width: 100%;
    padding: 8px 12px;
    border: 3px outset #999;
    border-radius: 3px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.1s ease;
    letter-spacing: 0.5px;
    position: relative;
    box-shadow: 2px 2px 4px rgba(0,0,0,0.4);
    background: linear-gradient(180deg, #e0e0e0 0%, #b0b0b0 100%);
    color: #000;
    text-shadow: 1px 1px 0px rgba(255,255,255,0.5);
    font-family: 'Arial', sans-serif;
    text-align: center;
}

.action-button:hover {
    background: linear-gradient(180deg, #f0f0f0 0%, #c0c0c0 100%);
    border-color: #aaa;
}

.action-button:active {
    border-style: inset;
    background: linear-gradient(180deg, #b0b0b0 0%, #d0d0d0 100%);
    box-shadow: inset 1px 1px 3px rgba(0,0,0,0.3);
    transform: translateY(1px);
}

.action-button.hold,
.action-button.restore {
    flex: 1;
    min-width: 0;
    letter-spacing: 0;
    text-indent: -3px;
}

.action-button.submit {
    background: linear-gradient(180deg, #90d0ff 0%, #4080c0 100%);
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    border-color: #5090d0;
    font-size: 13px;
    padding: 10px 12px;
}

.action-button.submit:hover {
    background: linear-gradient(180deg, #a0e0ff 0%, #5090d0 100%);
    border-color: #60a0e0;
}

.action-button.submit:active {
    background: linear-gradient(180deg, #4080c0 0%, #70b0e0 100%);
}

.action-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-button:disabled:hover {
    background: linear-gradient(180deg, #e0e0e0 0%, #b0b0b0 100%);
}

.action-button:disabled:active {
    border-style: outset;
    transform: none;
}

/* Left panel action buttons */
.builder-action-buttons-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

/* Color buttons */
.action-button.color-prev,
.action-button.color-next {
    flex: 0 0 40px;
    min-width: 40px;
    padding: 8px 4px;
    font-size: 16px;
}

.action-button.color-label-btn {
    flex: 1;
    font-size: 10px;
    letter-spacing: 1px;
    padding: 8px 4px;
    cursor: default;
    pointer-events: none;
    text-align: center;
}

.action-button.color-label-btn:hover {
    background: linear-gradient(180deg, #e0e0e0 0%, #b0b0b0 100%);
    border-color: #999;
}

.action-button.color-label-btn:active {
    border-style: outset;
    background: linear-gradient(180deg, #e0e0e0 0%, #b0b0b0 100%);
    box-shadow: 2px 2px 4px rgba(0,0,0,0.4);
    transform: none;
}

.action-button.color-label-btn:disabled {
    opacity: 1.0;
}
