/* ============================================
   Advanced 3D Connection Diagram
   Phase 10: Animated energy flow visualization
   ============================================ */

.cd3d-wrapper {
    margin: 2rem 0;
    padding: 2rem;
    background: linear-gradient(145deg, #0f172a 0%, #1e293b 60%, #0f172a 100%);
    border-radius: 20px;
    border: 1px solid rgba(59, 130, 246, 0.2);
    box-shadow:
        0 0 40px rgba(59, 130, 246, 0.05),
        0 20px 60px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
}

.cd3d-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(245, 158, 11, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 60%, rgba(16, 185, 129, 0.04) 0%, transparent 40%),
        radial-gradient(ellipse at 50% 50%, rgba(59, 130, 246, 0.03) 0%, transparent 60%);
    pointer-events: none;
}

.cd3d-title {
    text-align: center;
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 2;
}

.cd3d-title h3 {
    color: #e2e8f0;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 4px;
    letter-spacing: -0.02em;
}

.cd3d-title p {
    color: #64748b;
    font-size: 0.875rem;
    margin: 0;
}

/* Diagram Container */
.cd3d-diagram {
    position: relative;
    width: 100%;
    aspect-ratio: 9 / 5;
    min-height: 320px;
    max-height: 500px;
}

.cd3d-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Wire styling */
.cd3d-wire {
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Component Nodes */
.cd3d-node {
    position: absolute;
    z-index: 10;
    text-align: center;
    padding: 14px 16px;
    border-radius: 16px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: default;
    opacity: 0;
    min-width: 120px;
}

.cd3d-node:hover {
    transform: translateY(-4px) scale(1.03);
    border-color: rgba(255, 255, 255, 0.2);
}

.cd3d-node-icon {
    font-size: 2rem;
    margin-bottom: 4px;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.3));
}

.cd3d-node-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    margin-bottom: 2px;
}

.cd3d-node-value {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #f1f5f9;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.cd3d-node-sub {
    font-size: 0.6875rem;
    color: #64748b;
    margin-top: 2px;
}

.cd3d-node-badge {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

/* Node positions */
.cd3d-node-solar {
    top: 6%;
    left: 6%;
    background: rgba(245, 158, 11, 0.08);
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.1);
}

.cd3d-node-solar:hover {
    box-shadow: 0 8px 32px rgba(245, 158, 11, 0.2);
}

.cd3d-node-solar .cd3d-node-badge {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.cd3d-node-inverter {
    top: 35%;
    left: 38%;
    transform: translateX(-50%);
    background: rgba(21, 101, 192, 0.1);
    box-shadow: 0 4px 20px rgba(21, 101, 192, 0.1);
    border-color: rgba(21, 101, 192, 0.2);
}

.cd3d-node-inverter:hover {
    box-shadow: 0 8px 32px rgba(21, 101, 192, 0.2);
}

.cd3d-node-inverter .cd3d-node-badge {
    background: rgba(21, 101, 192, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.cd3d-node-battery {
    bottom: 8%;
    left: 8%;
    background: rgba(59, 130, 246, 0.08);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.1);
}

.cd3d-node-battery:hover {
    box-shadow: 0 8px 32px rgba(59, 130, 246, 0.2);
}

.cd3d-node-battery .cd3d-node-badge {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.cd3d-node-load {
    top: 35%;
    right: 5%;
    background: rgba(16, 185, 129, 0.08);
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.1);
}

.cd3d-node-load:hover {
    box-shadow: 0 8px 32px rgba(16, 185, 129, 0.2);
}

.cd3d-node-load .cd3d-node-badge {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.cd3d-node-grid {
    top: 2%;
    left: 40%;
    transform: translateX(-50%);
    background: rgba(139, 92, 246, 0.06);
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.08);
    min-width: 90px;
    padding: 10px 14px;
}

.cd3d-node-grid .cd3d-node-icon {
    font-size: 1.5rem;
}

.cd3d-node-grid .cd3d-node-badge {
    display: none;
}

/* Particles */
.particle {
    filter: blur(0.5px);
}

.cd3d-particles circle {
    will-change: transform;
}

/* Wiring Specs Legend */
.cd3d-specs {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    position: relative;
    z-index: 2;
}

.cd3d-spec-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    opacity: 0;
}

.cd3d-spec-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px currentColor;
}

.cd3d-spec-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
}

.cd3d-spec-value {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 768px) {
    .cd3d-wrapper {
        padding: 1.25rem;
        border-radius: 16px;
    }

    .cd3d-diagram {
        aspect-ratio: 4 / 5;
        min-height: 400px;
    }

    .cd3d-node {
        min-width: 95px;
        padding: 10px 12px;
        border-radius: 12px;
    }

    .cd3d-node-icon {
        font-size: 1.5rem;
    }

    .cd3d-node-label {
        font-size: 0.6rem;
    }

    .cd3d-node-value {
        font-size: 0.8rem;
        max-width: 100px;
    }

    .cd3d-node-sub {
        display: none;
    }

    .cd3d-node-solar {
        top: 2%;
        left: 2%;
    }

    .cd3d-node-inverter {
        top: 40%;
        left: 30%;
    }

    .cd3d-node-battery {
        bottom: 4%;
        left: 2%;
    }

    .cd3d-node-load {
        top: 40%;
        right: 2%;
    }

    .cd3d-node-grid {
        top: 2%;
        left: 50%;
    }

    .cd3d-specs {
        flex-direction: column;
        gap: 8px;
    }

    .cd3d-title h3 {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .cd3d-diagram {
        aspect-ratio: 3 / 5;
        min-height: 360px;
    }

    .cd3d-node {
        min-width: 80px;
        padding: 8px 10px;
    }

    .cd3d-node-badge {
        display: none;
    }
}

/* Print styles */
@media print {
    .cd3d-wrapper {
        background: white !important;
        border: 2px solid #e2e8f0;
        box-shadow: none;
    }

    .cd3d-title h3 {
        color: #0f172a;
    }

    .cd3d-title p {
        color: #475569;
    }

    .cd3d-node {
        opacity: 1 !important;
        background: #f8fafc;
        border: 1px solid #e2e8f0;
    }

    .cd3d-node-label,
    .cd3d-node-value {
        color: #1e293b;
    }

    .cd3d-spec-item {
        opacity: 1 !important;
        background: #f8fafc;
    }

    .cd3d-spec-label,
    .cd3d-spec-value {
        color: #334155;
    }

    .cd3d-particles {
        display: none;
    }
}
