/**
 * FABTECH Non-PLC Controller Installation Animation
 * Designed for fabtech.co.kr
 * Brand Colors: #1779BA (Primary Blue), #E8B931 (Accent Gold)
 *
 * Scoped for embedding in nonplc.php
 */

/* ========================================
   Variables (Scoped to wrapper)
   ======================================== */
.nonplc-animation-wrapper {
    --primary: #1779BA;
    --primary-dark: #12619A;
    --primary-light: #2A8CC4;
    --accent: #E8B931;
    --accent-dark: #C99E2A;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --success: #22c55e;
    --warning: #eab308;
    --danger: #ef4444;
    --border: rgba(255, 255, 255, 0.1);

    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-primary);
    line-height: 1.6;
}

/* ========================================
   Main Section
   ======================================== */
.nonplc-animation-wrapper .installation-section {
    position: relative;
    min-height: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: transparent;
}

/* ========================================
   Tech Background (Fabtech Style)
   ======================================== */
.nonplc-animation-wrapper .tech-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    display: none; /* Hidden in embedded mode */
}

.nonplc-animation-wrapper .tech-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(23, 121, 186, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(23, 121, 186, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: gridMove 20s linear infinite;
}

@keyframes gridMove {
    0% { transform: translate(0, 0); }
    100% { transform: translate(50px, 50px); }
}

.floating-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    animation: float 15s ease-in-out infinite;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(23, 121, 186, 0.15) 0%, transparent 70%);
    top: -100px;
    right: -100px;
}

.orb-2 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(232, 185, 49, 0.08) 0%, transparent 70%);
    bottom: 10%;
    left: -50px;
    animation-delay: -7s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* ========================================
   Section Header
   ======================================== */
.section-header {
    text-align: center;
    margin-bottom: 30px;
    position: relative;
    z-index: 10;
}

.section-title {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.title-accent {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.section-subtitle {
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    color: var(--text-secondary);
    font-weight: 300;
}

/* ========================================
   Step Navigation
   ======================================== */
.step-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    position: relative;
    z-index: 10;
}

.step-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--border);
    border-radius: 25px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.step-btn:hover {
    background: rgba(23, 121, 186, 0.1);
    border-color: var(--primary);
}

.step-btn.active {
    background: rgba(23, 121, 186, 0.2);
    border-color: var(--primary);
    color: var(--text-primary);
}

.step-btn.completed {
    background: rgba(34, 197, 94, 0.15);
    border-color: var(--success);
    color: var(--success);
}

.step-num {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.step-btn.active .step-num {
    background: var(--primary);
    color: white;
}

.step-btn.completed .step-num {
    background: var(--success);
    color: white;
}

.step-line {
    width: 30px;
    height: 2px;
    background: var(--border);
    border-radius: 1px;
}

.step-text {
    display: none;
}

@media (min-width: 768px) {
    .step-text {
        display: inline;
    }
    .step-line {
        width: 50px;
    }
}

/* ========================================
   Diagram Area
   ======================================== */
.diagram-area {
    position: relative;
    width: 100%;
    max-width: 1200px;
    height: 500px;
    min-width: 320px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    overflow-x: auto;
    overflow-y: hidden;
    margin-bottom: 30px;
}

/* 다이어그램 내부 컨텐츠 - 중앙 정렬 및 최소 크기 유지 */
.diagram-content {
    position: absolute;
    width: 1000px;
    min-width: 1000px;
    height: 100%;
    left: 50%;
    transform: translateX(-50%);
    transform-origin: center top;
}

/* 모바일에서 다이어그램 스케일 조정 및 중앙 정렬 */
@media (max-width: 768px) {
    .diagram-content {
        width: 1000px;
        min-width: 1000px;
        transform: translateX(-50%) scale(0.75);
    }

    .diagram-area {
        overflow-x: hidden;
    }
}

@media (max-width: 480px) {
    .diagram-content {
        transform: translateX(-50%) scale(0.5);
    }
}

@media (max-width: 1024px) {
    .diagram-area {
        height: 450px;
    }
}

@media (max-width: 768px) {
    .diagram-area {
        height: 400px;
    }
}

/* ========================================
   SVG Wiring
   ======================================== */
.wiring-svg {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.wire {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0;
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    transition: opacity 0.3s ease;
}

.wire.visible {
    opacity: 1;
    animation: drawWire 1.2s ease-out forwards;
}

@keyframes drawWire {
    to { stroke-dashoffset: 0; }
}

.power-wire {
    stroke: var(--danger);
    filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.5));
}

.comm-wire {
    stroke: var(--primary);
    filter: drop-shadow(0 0 4px rgba(23, 121, 186, 0.5));
}

.motor-wire {
    stroke: var(--accent);
    filter: drop-shadow(0 0 4px rgba(232, 185, 49, 0.5));
}

.sensor-wire {
    stroke: #818cf8;
    filter: drop-shadow(0 0 4px rgba(129, 140, 248, 0.5));
}

/* Current Flow */
.flow-group {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.flow-group.visible {
    opacity: 1;
}

.current {
    filter: url(#glow-blue);
}

.power-current {
    fill: #fca5a5;
}

.comm-current {
    fill: #93c5fd;
}

.motor-current {
    fill: #fcd34d;
}

.sensor-current {
    fill: #a5b4fc;
}

/* ========================================
   Power Supply Component
   ======================================== */
.component {
    position: absolute;
    z-index: 10;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.component.visible {
    opacity: 1;
    transform: scale(1);
}

.power-supply {
    left: 3%;
    top: 50%;
    transform: translateY(-50%) scale(0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.power-supply.visible {
    transform: translateY(-50%) scale(1);
}

.power-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--danger), #dc2626);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3);
    animation: powerGlow 2s ease-in-out infinite;
}

.power-icon svg {
    width: 28px;
    height: 28px;
    color: white;
}

@keyframes powerGlow {
    0%, 100% { box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 4px 30px rgba(239, 68, 68, 0.6); }
}

.power-label {
    text-align: center;
}

.power-value {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.power-name {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
}

/* ========================================
   Controllers - Based on Real FabTech Product
   ======================================== */
.controller {
    position: absolute;
    z-index: 10;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.controller.visible {
    opacity: 1;
    transform: translateY(0);
}

/* 단일 컨트롤러 중앙 배치 */
/* 컨트롤러: SVG X=500 기준 (중심), 220px 폭 → left = 39%, Y=200 → top = 40% */
.ctrl-1 { left: 39%; top: 40%; transform: translateX(0); }

.ctrl-box {
    position: relative;
    width: 220px;
    height: 120px;
    background: linear-gradient(180deg, #1a1a1a 0%, #0d0d0d 100%);
    border-radius: 6px;
    border: 1px solid #333;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

/* Controller Top Section - Logo and RJ45 Ports */
.ctrl-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid #333;
}

/* Controller ID Display */
.ctrl-id-display {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 11px;
    font-weight: 600;
    color: var(--primary-light);
    letter-spacing: 1px;
    padding: 2px 8px;
    background: rgba(23, 121, 186, 0.15);
    border: 1px solid rgba(23, 121, 186, 0.3);
    border-radius: 3px;
}

/* RJ45 Ports */
.rj45-port {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.port-label {
    font-size: 8px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.rj45-port::after {
    content: '';
    width: 14px;
    height: 10px;
    background: linear-gradient(180deg, #4a4a4a, #2a2a2a);
    border: 1px solid #555;
    border-radius: 2px;
}

/* Controller Middle Section */
.ctrl-middle {
    display: flex;
    justify-content: space-between;
    padding: 8px 10px;
    height: 50px;
}

.ctrl-left-section,
.ctrl-center-section,
.ctrl-right-section {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.ctrl-left-section {
    align-items: flex-start;
}

.ctrl-center-section {
    align-items: center;
    justify-content: center;
}

.ctrl-right-section {
    align-items: flex-end;
}

/* LED Indicators */
.led-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
}

.led-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #2a2a2a;
    border: 1px solid #444;
    transition: all 0.3s ease;
}

.led-label {
    font-size: 8px;
    color: var(--text-muted);
}

/* LED States */
.fault-led .led-dot.on {
    background: var(--danger);
    box-shadow: 0 0 8px var(--danger);
    animation: ledBlink 0.5s infinite;
}

.power-led .led-dot.on {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

@keyframes ledBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Serial Ports S1, S2 */
.serial-ports {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.serial-ports span {
    font-size: 7px;
    color: var(--text-muted);
    padding: 1px 4px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 2px;
}

/* Motor Port */
.motor-port {
    font-size: 8px;
    color: var(--text-muted);
}

/* Power Terminal */
.power-terminal {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
}

.power-terminal span {
    font-size: 7px;
    padding: 1px 4px;
    border-radius: 2px;
}

.power-terminal span:first-child {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.power-terminal span:last-child {
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.3);
}

/* Controller Bottom Section - DIP Switch */
.ctrl-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid #222;
}

.ctrl-id {
    font-size: 10px;
    font-weight: 600;
    color: var(--primary);
    padding: 2px 8px;
    background: rgba(23, 121, 186, 0.1);
    border-radius: 3px;
}

/* Active States for Animation */
.rj45-port.active::after {
    background: linear-gradient(180deg, var(--primary), #1565a0);
    box-shadow: 0 0 8px rgba(23, 121, 186, 0.6);
}

.rj45-port.active .port-label {
    color: var(--primary);
}

.led-dot.running {
    animation: ledPulse 1s ease-in-out infinite;
}

@keyframes ledPulse {
    0%, 100% {
        box-shadow: 0 0 8px var(--success);
        opacity: 1;
    }
    50% {
        box-shadow: 0 0 15px var(--success);
        opacity: 0.8;
    }
}

.power-terminal.active span:first-child {
    background: rgba(239, 68, 68, 0.3);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

/* ========================================
   DIP Switch - KSD08H Style
   ======================================== */
.dip-switch {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    background: #1a1a1a;
    padding: 4px 6px;
    border-radius: 3px;
    border: 1px solid #333;
}

.dip-label {
    font-size: 6px;
    color: var(--danger);
    letter-spacing: 0.3px;
    font-weight: 600;
    margin-bottom: 1px;
}

.dip-pins {
    display: flex;
    gap: 3px;
}

.dip-pin {
    width: 6px;
    height: 12px;
    background: #2a2a2a;
    border-radius: 1px;
    transition: all 0.3s ease;
    position: relative;
    border: 1px solid #444;
}

.dip-pin::before {
    content: '';
    position: absolute;
    width: 4px;
    height: 5px;
    left: 0;
    background: #888;
    border-radius: 1px;
    transition: all 0.2s ease;
    top: 1px;
}

.dip-pin.on::before {
    top: 5px;
    background: var(--success);
    box-shadow: 0 0 3px rgba(34, 197, 94, 0.5);
}

.dip-pin.off::before {
    top: 1px;
    background: #666;
}

/* DIP Switch Animation States */
.dip-switch.configuring {
    animation: dipPulse 0.8s ease-in-out infinite;
    box-shadow: 0 0 15px rgba(232, 185, 49, 0.6);
    border-color: var(--accent);
}

.dip-switch.active {
    border-color: var(--success);
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.4);
}

.dip-switch.active .dip-label {
    color: var(--success);
}

/* DIP Switch Highlight - 확대 후 위치 표시 */
.dip-switch.highlight {
    animation: dipHighlight 1.5s ease-in-out;
    border-color: var(--accent);
    box-shadow: 0 0 25px rgba(232, 185, 49, 0.8);
    transform: scale(1.1);
    z-index: 100;
}

@keyframes dipHighlight {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(232, 185, 49, 0);
    }
    20% {
        transform: scale(1.15);
        box-shadow: 0 0 30px rgba(232, 185, 49, 1);
    }
    40% {
        transform: scale(1.1);
        box-shadow: 0 0 20px rgba(232, 185, 49, 0.8);
    }
    60% {
        transform: scale(1.12);
        box-shadow: 0 0 25px rgba(232, 185, 49, 0.9);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 10px rgba(34, 197, 94, 0.4);
    }
}

/* 컨트롤러 전체 강조 효과 */
.controller.dip-focus {
    z-index: 50;
}

.controller.dip-focus .ctrl-box {
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.6),
        0 0 30px rgba(232, 185, 49, 0.3);
}

/* ========================================
   Step-specific Highlight Effects
   ======================================== */

/* Step 1: 전원 단자 강조 */
.power-terminal.highlight {
    animation: terminalPulse 1s ease-in-out infinite;
    position: relative;
}

.power-terminal.highlight::after {
    content: '← 전원 연결';
    position: absolute;
    right: -80px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: var(--danger);
    white-space: nowrap;
    animation: labelFade 1s ease-in-out infinite;
}

@keyframes terminalPulse {
    0%, 100% {
        background: rgba(239, 68, 68, 0.1);
        box-shadow: 0 0 0 rgba(239, 68, 68, 0);
    }
    50% {
        background: rgba(239, 68, 68, 0.3);
        box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
    }
}

@keyframes labelFade {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Step 2: RJ45 포트 강조 */
.rj45-port.highlight::after {
    box-shadow: 0 0 12px rgba(23, 121, 186, 0.8);
    animation: portPulse 0.8s ease-in-out infinite;
}

.rj45-port.highlight .port-label {
    color: var(--primary);
    font-weight: 600;
}

@keyframes portPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(23, 121, 186, 0.6); }
    50% { box-shadow: 0 0 15px rgba(23, 121, 186, 1); }
}

/* Step 2: 센서 포트 강조 */
.serial-ports.highlight span {
    background: rgba(129, 140, 248, 0.3) !important;
    color: #818cf8 !important;
    animation: sensorPortPulse 0.8s ease-in-out infinite;
}

@keyframes sensorPortPulse {
    0%, 100% { box-shadow: 0 0 5px rgba(129, 140, 248, 0.5); }
    50% { box-shadow: 0 0 10px rgba(129, 140, 248, 0.8); }
}

/* Step 3: 모터 포트 강조 */
.motor-port.highlight {
    color: var(--accent) !important;
    animation: motorPortPulse 0.8s ease-in-out infinite;
}

.motor-port.highlight span {
    background: rgba(232, 185, 49, 0.2);
    padding: 2px 6px;
    border-radius: 3px;
}

@keyframes motorPortPulse {
    0%, 100% { text-shadow: 0 0 5px rgba(232, 185, 49, 0.5); }
    50% { text-shadow: 0 0 10px rgba(232, 185, 49, 1); }
}

/* 연결 화살표 인디케이터 */
.connection-indicator {
    position: absolute;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: rgba(15, 23, 42, 0.95);
    border-radius: 15px;
    font-size: 11px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.connection-indicator.visible {
    opacity: 1;
    transform: translateY(0);
}

.connection-indicator.power {
    border: 1px solid var(--danger);
    color: var(--danger);
}

.connection-indicator.comm {
    border: 1px solid var(--primary);
    color: var(--primary);
}

.connection-indicator.sensor {
    border: 1px solid #818cf8;
    color: #818cf8;
}

.connection-indicator.motor {
    border: 1px solid var(--accent);
    color: var(--accent);
}

.connection-indicator .arrow {
    animation: arrowBounce 0.6s ease-in-out infinite;
}

@keyframes arrowBounce {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(3px); }
}

.dip-pin.setting {
    background: var(--accent);
    box-shadow: 0 0 8px rgba(232, 185, 49, 0.8);
}

.dip-pin.setting::before {
    background: var(--accent) !important;
    box-shadow: 0 0 6px rgba(232, 185, 49, 0.8);
}

@keyframes dipPulse {
    0%, 100% {
        box-shadow: 0 0 10px rgba(232, 185, 49, 0.4);
    }
    50% {
        box-shadow: 0 0 20px rgba(232, 185, 49, 0.8);
    }
}

/* DIP Switch Zoom Effect for Step 4 */
.dip-switch-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    backdrop-filter: blur(10px);
}

.dip-switch-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.dip-switch-zoom {
    transform: scale(4);
    background: linear-gradient(180deg, #1a1a1a 0%, #0d0d0d 100%);
    padding: 30px 40px;
    border-radius: 12px;
    border: 2px solid var(--accent);
    box-shadow: 0 0 60px rgba(232, 185, 49, 0.4);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dip-switch-zoom .dip-label {
    font-size: 10px;
    margin-bottom: 8px;
}

.dip-switch-zoom .dip-pins {
    gap: 8px;
}

.dip-switch-zoom .dip-pin {
    width: 12px;
    height: 24px;
    border-radius: 2px;
}

.dip-switch-zoom .dip-pin::before {
    width: 8px;
    height: 10px;
}

.dip-switch-zoom .dip-pin.on::before {
    top: 11px;
}

.dip-switch-zoom .dip-pin.off::before {
    top: 2px;
}

.dip-switch-zoom .dip-numbers {
    gap: 8px;
    margin-top: 6px;
}

.dip-switch-zoom .dip-numbers span {
    width: 12px;
    font-size: 8px;
}

/* Zoom DIP Pin Animation */
.dip-switch-zoom .dip-pin.setting {
    background: var(--accent);
    box-shadow: 0 0 15px rgba(232, 185, 49, 1);
    transform: scale(1.1);
}

.dip-switch-zoom .dip-pin.setting::before {
    animation: pinToggle 0.3s ease-out forwards;
}

@keyframes pinToggle {
    0% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
    100% { transform: translateY(0); }
}

/* Zoom Title */
.dip-zoom-title {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 30px;
    text-align: center;
}

.dip-zoom-title span {
    color: var(--accent);
}

/* Zoom Info */
.dip-zoom-info {
    margin-top: 30px;
    padding: 15px 25px;
    background: rgba(232, 185, 49, 0.1);
    border: 1px solid rgba(232, 185, 49, 0.3);
    border-radius: 8px;
    text-align: center;
    transition: all 0.3s ease;
}

.dip-zoom-info .info-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

.dip-zoom-info .info-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    margin-top: 5px;
    font-family: 'Consolas', 'Monaco', monospace;
}

/* Close animation */
.dip-switch-overlay.closing {
    animation: zoomOut 0.5s ease-in forwards;
}

@keyframes zoomOut {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.8);
    }
}

.dip-numbers {
    display: flex;
    gap: 3px;
    margin-top: 2px;
}

.dip-numbers span {
    width: 6px;
    text-align: center;
    font-size: 5px;
    color: var(--text-muted);
}

/* ========================================
   HMI Display
   ======================================== */
.hmi {
    right: 3%;
    top: 50%;
    transform: translateY(-50%) scale(0.8);
}

.hmi.visible {
    transform: translateY(-50%) scale(1);
}

.hmi-screen {
    width: 120px;
    height: 110px;
    background: linear-gradient(145deg, #1f2937, #111827);
    border-radius: 10px;
    border: 2px solid #374151;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.hmi-header {
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 6px;
    text-align: center;
    letter-spacing: 0.5px;
}

.hmi-body {
    padding: 10px;
}

.hmi-status {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    padding: 6px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
    margin-bottom: 8px;
    transition: all 0.3s ease;
}

.hmi-status.active {
    color: var(--success);
    text-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.hmi-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 9px;
    color: var(--text-muted);
}

.hmi-info span.running {
    color: var(--success);
}

/* ========================================
   Motors
   ======================================== */
.motor {
    position: absolute;
    z-index: 10;
    text-align: center;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.motor.visible {
    opacity: 1;
    transform: scale(1);
}

/* 모터: SVG X=680, Y=350 → 컨트롤러 오른쪽 아래 (ㄱ자 연결 끝점) */
.motor-1 { left: 65.5%; top: 62%; }

.motor-ring {
    width: 45px;
    height: 45px;
    background: linear-gradient(145deg, var(--accent), var(--accent-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #fcd34d;
    box-shadow: 0 0 15px rgba(232, 185, 49, 0.3);
    margin: 0 auto 6px;
    transition: all 0.3s ease;
}

.motor-ring.main {
    width: 55px;
    height: 55px;
}

.motor-ring span {
    font-size: 14px;
    font-weight: 700;
    color: var(--bg-dark);
}

.motor-ring.main span {
    font-size: 18px;
}

.motor-ring.running {
    animation: motorSpin 0.5s linear infinite;
    box-shadow: 0 0 25px rgba(232, 185, 49, 0.6);
}

@keyframes motorSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.motor-name {
    font-size: 10px;
    color: var(--text-muted);
}

/* ========================================
   Sensors (S1 Port Connection)
   ======================================== */
.sensor {
    position: absolute;
    z-index: 10;
    text-align: center;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sensor.visible {
    opacity: 1;
    transform: scale(1);
}

/* 센서: SVG X=500, Y=100 → 상단 왼쪽에 배치 (센서선이 위로 올라가므로) */
.sensor-1 { left: 47%; top: 12%; }

/* Industrial Square Sensor Design */
.sensor-box {
    width: 50px;
    height: 65px;
    background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
    border-radius: 4px;
    border: 1px solid #444;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    padding: 4px;
    margin: 0 auto 4px;
    transition: all 0.3s ease;
}

.sensor-leds {
    display: flex;
    justify-content: space-around;
    padding: 2px 0;
    border-bottom: 1px solid #333;
    margin-bottom: 4px;
}

.sensor-led {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.sensor-led .led-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #2a2a2a;
    border: 1px solid #444;
}

.sensor-led span:last-child {
    font-size: 5px;
    color: var(--text-muted);
}

.sensor-led.power-led .led-dot {
    background: var(--success);
    box-shadow: 0 0 4px var(--success);
}

.sensor-led.detect-led .led-dot {
    background: #2a2a2a;
}

/* Sensor Face (Detection Area) */
.sensor-face {
    flex: 1;
    background: linear-gradient(145deg, #3a3a3a, #2a2a2a);
    border-radius: 2px;
    border: 1px solid #555;
    position: relative;
}

.sensor-face::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background: radial-gradient(circle, #4a4a4a 0%, #2a2a2a 100%);
    border-radius: 2px;
    border: 1px solid #555;
}

/* Sensor Cable */
.sensor-cable {
    width: 8px;
    height: 12px;
    background: linear-gradient(90deg, #333, #444, #333);
    margin: 4px auto 0;
    border-radius: 0 0 2px 2px;
}

/* Sensor Active State */
.sensor-box.active .sensor-led.detect-led .led-dot {
    background: var(--warning);
    box-shadow: 0 0 6px var(--warning);
    animation: detectPulse 0.8s ease-in-out infinite;
}

.sensor-box.active .sensor-face::after {
    background: radial-gradient(circle, rgba(234, 179, 8, 0.3) 0%, #2a2a2a 100%);
    box-shadow: 0 0 8px rgba(234, 179, 8, 0.4);
}

@keyframes detectPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.sensor-name {
    font-size: 9px;
    color: var(--text-muted);
}

/* ========================================
   Serial Connection Indicators
   ======================================== */
.serial-indicator {
    position: absolute;
    z-index: 15;
    opacity: 0;
    transform: scale(0);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.serial-indicator.visible {
    opacity: 1;
    transform: scale(1);
}

/* 직렬 인디케이터 (단일 컨트롤러 모드에서 미사용) */

.serial-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: rgba(23, 121, 186, 0.2);
    border: 2px solid var(--primary);
    border-radius: 50%;
    color: var(--primary);
    font-size: 16px;
    font-weight: bold;
    animation: arrowPulse 1.5s ease-in-out infinite;
}

@keyframes arrowPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(23, 121, 186, 0.4);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 15px 5px rgba(23, 121, 186, 0.2);
        transform: scale(1.05);
    }
}

/* ========================================
   Power Line Component
   ======================================== */
.power-line {
    position: absolute;
    bottom: 8%;
    left: 3%;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 10;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease;
}

.power-line.visible {
    opacity: 1;
    transform: translateY(0);
}

.power-line-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--danger), #dc2626);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.power-line-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.power-line-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.power-line-value {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--danger);
}

/* ========================================
   Feature Bar
   ======================================== */
.feature-bar {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
    margin-top: 20px;
    padding: 16px 24px;
    background: rgba(30, 41, 59, 0.6);
    border-radius: 8px;
    border: 1px solid var(--border);
    position: relative;
    z-index: 10;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
}

.feature-icon {
    font-size: 18px;
}

.feature-text {
    font-weight: 500;
}

/* ========================================
   Info Bar (가로 배치 설명 패널)
   ======================================== */
.info-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    width: 100%;
    max-width: 1200px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 20px;
    backdrop-filter: blur(10px);
    margin-bottom: 15px;
    position: relative;
    z-index: 10;
}

.info-step-badge {
    flex-shrink: 0;
    font-size: 12px;
    color: white;
    font-weight: 600;
    padding: 6px 14px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.info-title {
    font-size: 15px;
    color: var(--text-primary);
    margin: 0 0 4px 0;
    font-weight: 600;
}

.info-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
}

.info-bar .info-list {
    display: flex;
    gap: 15px;
    list-style: none;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
}

.info-bar .info-list li {
    font-size: 11px;
    color: var(--text-muted);
    padding: 4px 10px;
    padding-left: 20px;
    position: relative;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
    white-space: nowrap;
}

.info-bar .info-list li::before {
    content: '→';
    position: absolute;
    left: 8px;
    color: var(--primary);
}

/* ========================================
   Control Buttons
   ======================================== */
.control-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
    position: relative;
    z-index: 10;
}

.ctrl-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.ctrl-button svg {
    width: 18px;
    height: 18px;
}

.ctrl-button:hover:not(:disabled) {
    background: rgba(23, 121, 186, 0.1);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.ctrl-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ctrl-button.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-color: var(--primary);
    min-width: 130px;
    justify-content: center;
}

.ctrl-button.primary:hover {
    box-shadow: 0 4px 20px rgba(23, 121, 186, 0.4);
    transform: translateY(-2px);
}

.ctrl-button.primary.playing {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    border-color: var(--danger);
}

/* ========================================
   Legend Bar
   ======================================== */
.legend-bar {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
    padding: 12px 20px;
    background: rgba(30, 41, 59, 0.6);
    border-radius: 8px;
    border: 1px solid var(--border);
    position: relative;
    z-index: 10;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.legend-line {
    width: 24px;
    height: 3px;
    border-radius: 2px;
}

.legend-line.power {
    background: var(--danger);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

.legend-line.comm {
    background: var(--primary);
    box-shadow: 0 0 6px rgba(23, 121, 186, 0.5);
}

.legend-line.motor {
    background: var(--accent);
    box-shadow: 0 0 6px rgba(232, 185, 49, 0.5);
}

.legend-line.sensor {
    background: #818cf8;
    box-shadow: 0 0 6px rgba(129, 140, 248, 0.5);
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 1024px) {
    /* 단일 컨트롤러 중앙 유지 */
    .ctrl-1 { left: 39%; top: 40%; }

    .ctrl-box {
        width: 200px;
        height: 110px;
    }

    /* 모터/센서 위치 유지 */
    .motor-1 { left: 65.5%; top: 62%; }
    .sensor-1 { left: 47%; top: 12%; }

    .info-bar {
        flex-wrap: wrap;
        gap: 12px;
        padding: 10px 15px;
    }

    .info-bar .info-list {
        flex-wrap: wrap;
        gap: 8px;
    }

    .ctrl-middle {
        padding: 6px 8px;
        height: 45px;
    }

    .led-label, .serial-ports span, .motor-port span {
        font-size: 7px;
    }
}

@media (max-width: 768px) {
    .installation-section {
        padding: 20px 15px;
    }

    .diagram-area {
        height: 380px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* 스크롤 힌트 추가 */
    .diagram-area::after {
        content: '← 좌우 스크롤 →';
        position: absolute;
        bottom: 5px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0,0,0,0.6);
        color: white;
        padding: 4px 12px;
        border-radius: 12px;
        font-size: 11px;
        z-index: 100;
        pointer-events: none;
        animation: fadeInOut 3s ease-in-out;
    }

    @keyframes fadeInOut {
        0%, 100% { opacity: 0; }
        20%, 80% { opacity: 1; }
    }

    /* 단일 컨트롤러 중앙 유지 */
    .ctrl-1 { left: 39%; top: 40%; }

    .ctrl-box {
        width: 200px;
        height: 100px;
    }

    .ctrl-title {
        font-size: 9px;
    }

    /* 모터/센서 위치 유지 */
    .motor-1 { left: 65.5%; top: 62%; }
    .sensor-1 { left: 47%; top: 12%; }

    .motor-ring {
        width: 35px;
        height: 35px;
    }

    .motor-ring span {
        font-size: 12px;
    }

    .sensor-box {
        width: 45px;
        height: 60px;
    }

    .info-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 10px 12px;
    }

    .info-bar .info-list {
        display: none;
    }

    .info-step-badge {
        font-size: 11px;
        padding: 4px 10px;
    }

    .info-title {
        font-size: 14px;
    }

    .info-desc {
        font-size: 11px;
    }

    .control-buttons {
        flex-wrap: wrap;
    }

    .ctrl-button {
        padding: 10px 16px;
        font-size: 13px;
    }

    .legend-bar {
        gap: 16px;
    }

    .legend-item {
        font-size: 11px;
    }

    .feature-bar {
        gap: 20px;
    }

    .feature-item {
        font-size: 12px;
    }

    .dip-switch {
        display: none;
    }
}

@media (max-width: 480px) {
    .step-btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    .step-num {
        width: 18px;
        height: 18px;
        font-size: 9px;
    }

    .step-line {
        width: 15px;
    }

    .diagram-area {
        height: 320px;
    }

    .diagram-area::after {
        font-size: 10px;
        padding: 3px 10px;
    }

    .ctrl-box {
        width: 120px;
        height: 60px;
    }

    .ctrl-header {
        margin-bottom: 4px;
    }

    .ctrl-led {
        width: 6px;
        height: 6px;
    }

    .ctrl-voltage,
    .ctrl-model {
        display: none;
    }

    .motor {
        transform: scale(0.8);
    }

    .motor.visible {
        transform: scale(0.8);
    }

    .power-line {
        display: none;
    }

    .feature-bar {
        gap: 15px;
        padding: 12px 16px;
    }

    .feature-icon {
        font-size: 16px;
    }

    .feature-text {
        font-size: 11px;
    }
}

/* ========================================
   Animation Enhancements
   ======================================== */
.controller.highlight {
    animation: highlightPulse 1s ease-in-out;
}

@keyframes highlightPulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.3); }
}

.wire.drawing {
    animation: drawWire 1.2s ease-out forwards, wireGlow 2s ease-in-out infinite 1.2s;
}

@keyframes wireGlow {
    0%, 100% { filter: drop-shadow(0 0 4px currentColor); }
    50% { filter: drop-shadow(0 0 8px currentColor); }
}

/* ========================================
   System Overview (Step 5 Multi-Controller View)
   ======================================== */
.system-overview {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

.system-overview.visible {
    opacity: 1;
    visibility: visible;
}

/* Overview Controller Bodies */
.overview-ctrl .ctrl-body {
    fill: #1a1a1a;
    stroke: #444;
    stroke-width: 2;
    transition: all 0.3s ease;
}

.overview-ctrl.active .ctrl-body {
    stroke: var(--primary);
    filter: drop-shadow(0 0 10px rgba(23, 121, 186, 0.4));
}

/* Overview LEDs */
.overview-ctrl .ctrl-led {
    fill: #2a2a2a;
    stroke: #444;
    stroke-width: 1;
    transition: all 0.3s ease;
}

.overview-ctrl .ctrl-led.on {
    fill: var(--success);
    filter: drop-shadow(0 0 8px var(--success));
}

.overview-ctrl .ctrl-led.running {
    fill: var(--success);
    animation: ledPulseSvg 1s ease-in-out infinite;
}

@keyframes ledPulseSvg {
    0%, 100% {
        filter: drop-shadow(0 0 8px var(--success));
        opacity: 1;
    }
    50% {
        filter: drop-shadow(0 0 15px var(--success));
        opacity: 0.8;
    }
}

/* Overview Labels */
.overview-ctrl .ctrl-label {
    fill: var(--text-secondary);
    font-size: 12px;
    font-family: 'Consolas', 'Monaco', monospace;
    text-anchor: middle;
}

.system-title {
    fill: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
}

.system-subtitle {
    fill: var(--danger);
    font-size: 14px;
    font-weight: 500;
}

/* Overview Wires */
.overview-wire {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
}

.overview-wire.visible {
    opacity: 1;
    animation: drawWire 1.5s ease-out forwards;
}

/* Communication Flow Animation */
.comm-flow {
    opacity: 0;
    filter: drop-shadow(0 0 6px rgba(147, 197, 253, 0.8));
}

.system-overview.visible .comm-flow {
    opacity: 1;
}

/* Single Controller Elements - Hide on Step 5 */
.controller.hidden,
.motor.hidden,
.sensor.hidden,
.power-line.hidden {
    opacity: 0 !important;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}
