/* ========================================
   PCB Layout 2.5D - Theme-aware Styles
   ======================================== */

/* ---- 3D Scene ---- */
.pcb-scene {
    perspective: 1200px;
    perspective-origin: 50% 50%;
}

.pcb-3d-wrapper {
    transform-style: preserve-3d;
    position: relative;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    /* Default: Showcase view */
    transform: rotateX(20deg) rotateY(-5deg);
}

/* Traditional board: 480 × 320 px (3:2 ratio, ~30×20cm) */
.pcb-traditional-wrapper {
    width: 480px;
    height: 320px;
}

/* Modern board: 288 × 272 px (~1.06:1 ratio, ~18×17cm) */
.pcb-modern-wrapper {
    width: 288px;
    height: 272px;
}

/* ---- PCB Faces ---- */

/* Top face - main board surface */
.pcb-face-top {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background: var(--pcb-traditional-bg);
    border: 2px solid var(--pcb-traditional-border);
    border-radius: 4px;
    overflow: hidden;
    backface-visibility: hidden;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.3);
    transition: background 0.5s ease, border-color 0.5s ease;
}

.pcb-face-top.pcb-modern {
    background: var(--pcb-modern-bg);
    border-color: var(--pcb-modern-border);
}

/* Front face (thickness) */
.pcb-face-front {
    position: absolute;
    left: 0;
    width: 100%;
    height: 18px; /* Traditional thickness */
    background: var(--pcb-traditional-front, #0f4a0f);
    border: 1px solid var(--pcb-traditional-border);
    border-top: none;
    border-radius: 0 0 4px 4px;
    transform-origin: top;
    transform: rotateX(-90deg);
    top: 100%;
    transition: background 0.5s ease, border-color 0.5s ease;
}

.pcb-modern-front {
    height: 9px; /* Modern - thinner */
    background: var(--pcb-modern-front, #5c0d0d);
    border-color: var(--pcb-modern-border);
}

/* Right face (thickness) */
.pcb-face-right {
    position: absolute;
    top: 0;
    right: 0;
    width: 18px; /* Traditional thickness */
    height: 100%;
    background: var(--pcb-traditional-right, #0d3d0d);
    border: 1px solid var(--pcb-traditional-border);
    border-left: none;
    border-radius: 0 4px 4px 0;
    transform-origin: left;
    transform: rotateY(90deg);
    left: 100%;
    transition: background 0.5s ease, border-color 0.5s ease;
}

.pcb-modern-right {
    width: 9px; /* Modern - thinner */
    background: var(--pcb-modern-right, #4a0a0a);
    border-color: var(--pcb-modern-border);
}

/* ---- PCB Surface Patterns ---- */

/* Trace patterns - Traditional */
.pcb-traditional .pcb-traces {
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 20px,
            var(--pcb-traditional-trace) 20px,
            var(--pcb-traditional-trace) 22px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 30px,
            var(--pcb-traditional-trace) 30px,
            var(--pcb-traditional-trace) 32px
        );
    pointer-events: none;
    transition: background-image 0.5s ease;
}

/* Trace patterns - Modern */
.pcb-modern .pcb-traces {
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 20px,
            var(--pcb-modern-trace) 20px,
            var(--pcb-modern-trace) 22px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 30px,
            var(--pcb-modern-trace) 30px,
            var(--pcb-modern-trace) 32px
        );
    pointer-events: none;
    transition: background-image 0.5s ease;
}

/* Solder mask dot pattern */
.pcb-traditional::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(
        circle at center,
        var(--pcb-traditional-dot) 1px,
        transparent 1px
    );
    background-size: 15px 15px;
    pointer-events: none;
    opacity: 0.5;
}

.pcb-modern::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(
        circle at center,
        var(--pcb-modern-dot) 1px,
        transparent 1px
    );
    background-size: 15px 15px;
    pointer-events: none;
    opacity: 0.5;
}

/* Silkscreen */
.pcb-silkscreen {
    font-family: 'Courier New', monospace;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 1px;
    z-index: 2;
}

/* ---- Drop Zones ---- */
.drop-zone {
    position: absolute;
    border: 2px dashed rgba(255, 215, 0, 0.4);
    border-radius: 4px;
    background: rgba(255, 215, 0, 0.05);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.drop-zone::before {
    content: attr(data-label);
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.drop-zone.highlight {
    border-color: rgba(255, 215, 0, 0.8);
    background: rgba(255, 215, 0, 0.15);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.drop-zone.occupied {
    border-color: rgba(45, 138, 45, 0.6);
    background: rgba(45, 138, 45, 0.1);
}

.drop-zone.occupied::before {
    display: none;
}

.drop-zone.zone-blocked {
    opacity: 0.2;
    border-color: rgba(255, 215, 0, 0.15);
    pointer-events: none;
}

/* ---- Components ---- */
.component {
    position: absolute;
    cursor: grab;
    user-select: none;
    z-index: 10;
}

.component:active {
    cursor: grabbing;
}

.component.dragging {
    z-index: 100;
}

.component img {
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Placement animation */
@keyframes componentPlaced {
    0% {
        transform: scale(1.1);
        filter: drop-shadow(0 0 12px rgba(255, 215, 0, 0.6));
    }
    100% {
        transform: scale(1);
        filter: none;
    }
}

.component.placed {
    animation: componentPlaced 0.4s ease-out;
    cursor: default;
}

.component.placed.stacked {
    z-index: 11;
}

/* ---- Filler Components (decorative SMD parts) ---- */
.filler-component {
    position: absolute;
    pointer-events: none;
    opacity: 0.7;
    z-index: 3;
}

.filler-component img {
    width: 100%;
    height: 100%;
}

/* ---- Component Tray ---- */
.component-tray-item {
    background: var(--tray-item-bg);
    border: 1px solid var(--tray-item-border);
    border-radius: 8px;
    padding: 10px;
    cursor: grab;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.component-tray-item:hover {
    border-color: var(--title-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.component-tray-item.used {
    opacity: 0.4;
    pointer-events: none;
}

.component-tray-item .icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(212, 175, 55, 0.15);
    border-radius: 4px;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

.component-tray-item .icon img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.component-tray-item .info {
    flex: 1;
    min-width: 0;
}

.component-tray-item .name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    transition: color 0.3s ease;
    white-space: nowrap;
}

.component-tray-item .desc {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 1px;
    transition: color 0.3s ease;
}

/* Board-specific badge */
.component-tray-item .badge {
    font-size: 8px;
    padding: 1px 4px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.badge-traditional {
    background: rgba(45, 138, 45, 0.2);
    color: #6dbe6d;
    border: 1px solid rgba(45, 138, 45, 0.3);
}

.badge-modern {
    background: rgba(255, 215, 0, 0.15);
    color: #ffd700;
    border: 1px solid rgba(255, 215, 0, 0.25);
}

/* ---- View Controls ---- */
.view-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #94a3b8;
    transition: all 0.2s ease;
    background: transparent;
    border: none;
    cursor: pointer;
}

.view-btn:hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.1);
}

.view-btn.active {
    color: var(--title-accent, #d4956a);
    background: rgba(255, 255, 255, 0.08);
}

/* ---- Trace Line ---- */
.trace-line {
    position: fixed;
    pointer-events: none;
    z-index: 50;
    stroke: #b87333;
    stroke-width: 3;
    stroke-linecap: round;
    fill: none;
    filter: drop-shadow(0 0 4px rgba(184, 115, 51, 0.6));
}

/* ---- Guide Banner ---- */
.guide-banner {
    position: relative;
    background: linear-gradient(90deg, rgba(26, 92, 26, 0.15) 0%, rgba(30, 41, 59, 0.6) 50%, rgba(139, 26, 26, 0.15) 100%);
    border-bottom: 1px solid rgba(184, 115, 51, 0.25);
    padding: 10px 40px 10px 20px;
    overflow: hidden;
    transition: all 0.4s ease;
}

.guide-banner.hidden {
    max-height: 0;
    padding: 0 40px 0 20px;
    border-bottom-color: transparent;
    opacity: 0;
}

.guide-banner-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.guide-banner-col {
    display: flex;
    align-items: center;
    gap: 8px;
}

.guide-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 3px;
    white-space: nowrap;
}

.guide-traditional .guide-label {
    background: rgba(45, 138, 45, 0.25);
    color: #6dbe6d;
    border: 1px solid rgba(45, 138, 45, 0.4);
}

.guide-modern .guide-label {
    background: rgba(255, 215, 0, 0.15);
    color: #ffd700;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.guide-detail {
    font-size: 11px;
    color: #94a3b8;
}

.guide-banner-vs {
    font-size: 11px;
    font-weight: 700;
    color: #d4956a;
    letter-spacing: 1px;
}

.guide-banner-hint {
    text-align: center;
    font-size: 11px;
    color: #64748b;
    margin-top: 4px;
    font-style: italic;
}

.guide-banner-close {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #64748b;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    transition: color 0.2s ease;
}

.guide-banner-close:hover {
    color: #e2e8f0;
}

/* ---- Guide Tooltips ---- */
.guide-tooltip {
    position: absolute;
    background: rgba(212, 149, 106, 0.95);
    color: #1a1a2e;
    font-size: 11px;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 200;
    pointer-events: none;
    opacity: 0;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}

.guide-tooltip::after {
    content: '';
    position: absolute;
    border: 5px solid transparent;
}

.guide-tooltip.arrow-down::after {
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-top-color: rgba(212, 149, 106, 0.95);
}

.guide-tooltip.arrow-left::after {
    top: 50%;
    right: 100%;
    transform: translateY(-50%);
    border-right-color: rgba(212, 149, 106, 0.95);
}

.guide-tooltip.arrow-right::after {
    top: 50%;
    left: 100%;
    transform: translateY(-50%);
    border-left-color: rgba(212, 149, 106, 0.95);
}

/* ---- Comparison Panel ---- */
#comparison-panel.show {
    transform: translateY(0);
}

/* ---- Responsive ---- */
@media (max-width: 1200px) {
    .pcb-traditional-wrapper {
        width: 380px;
        height: 253px;
    }
    .pcb-modern-wrapper {
        width: 228px;
        height: 215px;
    }
}

@media (max-width: 1024px) {
    .pcb-traditional-wrapper {
        width: 320px;
        height: 213px;
    }
    .pcb-modern-wrapper {
        width: 192px;
        height: 181px;
    }
}
