/**
 * ANIMATED INSTALLATION GUIDE STYLES
 * Professional animations for solar system visualization
 */

/* ========== MAIN CONTAINER ========== */
.animated-installation-guide {
    background: linear-gradient(135deg, #F0F9FF 0%, #E0F2FE 50%, #DBEAFE 100%);
    padding: 40px;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    min-height: 800px;
}

/* ========== ANIMATED SUN ========== */
.animated-sun-container {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 150px;
    height: 150px;
    z-index: 10;
}

.sun-core {
    width: 100px;
    height: 100px;
    background: radial-gradient(circle at 30% 30%, #FEF08A, #FCD34D, #F59E0B);
    border-radius: 50%;
    position: absolute;
    top: 25px;
    left: 25px;
    box-shadow: 
        0 0 30px rgba(252, 211, 77, 0.8),
        0 0 60px rgba(245, 158, 11, 0.6),
        0 0 90px rgba(245, 158, 11, 0.4);
    animation: sun-pulse 3s ease-in-out infinite;
}

@keyframes sun-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 
            0 0 30px rgba(252, 211, 77, 0.8),
            0 0 60px rgba(245, 158, 11, 0.6),
            0 0 90px rgba(245, 158, 11, 0.4);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 
            0 0 40px rgba(252, 211, 77, 1),
            0 0 80px rgba(245, 158, 11, 0.8),
            0 0 120px rgba(245, 158, 11, 0.6);
    }
}

.sun-rays {
    width: 150px;
    height: 150px;
    position: absolute;
    top: 0;
    left: 0;
    animation: sun-rotate 20s linear infinite;
}

@keyframes sun-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.sun-ray {
    position: absolute;
    width: 6px;
    height: 35px;
    background: linear-gradient(to bottom, #FCD34D, transparent);
    border-radius: 3px;
    left: 50%;
    top: 0;
    margin-left: -3px;
    transform-origin: center 75px;
}

.sun-ray:nth-child(1) { transform: rotate(0deg); }
.sun-ray:nth-child(2) { transform: rotate(45deg); }
.sun-ray:nth-child(3) { transform: rotate(90deg); }
.sun-ray:nth-child(4) { transform: rotate(135deg); }
.sun-ray:nth-child(5) { transform: rotate(180deg); }
.sun-ray:nth-child(6) { transform: rotate(225deg); }
.sun-ray:nth-child(7) { transform: rotate(270deg); }
.sun-ray:nth-child(8) { transform: rotate(315deg); }

/* ========== ENERGY PARTICLES ========== */
.energy-particles-container {
    position: absolute;
    top: 180px;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 200px;
    pointer-events: none;
    z-index: 5;
}

.energy-particle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: radial-gradient(circle, #FEF08A, #FCD34D);
    border-radius: 50%;
    box-shadow: 0 0 15px #FCD34D;
    animation: particle-fall 2s ease-in infinite;
    opacity: 0;
}

@keyframes particle-fall {
    0% {
        transform: translateY(0) translateX(0) scale(1);
        opacity: 1;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translateY(200px) translateX(var(--random-x, 0)) scale(0.5);
        opacity: 0;
    }
}

.energy-particle:nth-child(1) { --random-x: -20px; animation-delay: 0s; }
.energy-particle:nth-child(2) { --random-x: 20px; animation-delay: 0.2s; }
.energy-particle:nth-child(3) { --random-x: -10px; animation-delay: 0.4s; }
.energy-particle:nth-child(4) { --random-x: 10px; animation-delay: 0.6s; }
.energy-particle:nth-child(5) { --random-x: 0px; animation-delay: 0.8s; }
.energy-particle:nth-child(6) { --random-x: -15px; animation-delay: 1s; }
.energy-particle:nth-child(7) { --random-x: 15px; animation-delay: 1.2s; }
.energy-particle:nth-child(8) { --random-x: -5px; animation-delay: 1.4s; }

/* ========== COMPONENT BOXES ========== */
.component-box {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: relative;
    transition: all 0.3s ease;
}

.component-box:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.component-box.solar-panels {
    border: 3px solid #1565C0;
    background: linear-gradient(135deg, #ffffff 0%, #E0F2FE 100%);
}

.component-box.inverter {
    border: 3px solid #10B981;
    background: linear-gradient(135deg, #ffffff 0%, #D1FAE5 100%);
    animation: inverter-pulse 2s ease-in-out infinite;
}

@keyframes inverter-pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
        border-color: #10B981;
    }
    50% {
        box-shadow: 0 4px 30px rgba(16, 185, 129, 0.8), 0 0 40px rgba(16, 185, 129, 0.4);
        border-color: #059669;
    }
}

.component-box.batteries {
    border: 3px solid #F59E0B;
    background: linear-gradient(135deg, #ffffff 0%, #FEF3C7 100%);
}

.component-box.home {
    border: 3px solid #8B5CF6;
    background: linear-gradient(135deg, #ffffff 0%, #EDE9FE 100%);
}

.component-box.grid {
    border: 3px solid #F97316;
    background: linear-gradient(135deg, #ffffff 0%, #FFF7ED 100%);
}

/* ========== WIRE ANIMATIONS ========== */
.animated-wire {
    position: absolute;
    pointer-events: none;
    z-index: 3;
}

.wire-path {
    stroke-dasharray: 20 10;
    animation: wire-flow 2s linear infinite;
    filter: drop-shadow(0 0 4px currentColor);
}

@keyframes wire-flow {
    0% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: 150; }
}

.wire-path.dc-positive {
    stroke: #3B82F6;
    stroke-width: 8;
}

.wire-path.dc-negative {
    stroke: #EF4444;
    stroke-width: 8;
}

.wire-path.ac {
    stroke: #F97316;
    stroke-width: 8;
}

.wire-path.battery-positive {
    stroke: #EF4444;
    stroke-width: 8;
}

.wire-path.battery-negative {
    stroke: #1F2937;
    stroke-width: 8;
}

/* Wire labels */
.wire-label {
    font-size: 12px;
    font-weight: 700;
    fill: currentColor;
    text-shadow: 0 0 4px white, 0 0 8px white;
}

/* ========== BATTERY CHARGING ANIMATION ========== */
.battery-visual {
    position: relative;
    width: 100px;
    height: 140px;
    margin: 0 auto;
}

.battery-body {
    width: 100%;
    height: 120px;
    border: 4px solid #F59E0B;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    background: #FEF3C7;
}

.battery-terminal {
    width: 40px;
    height: 12px;
    background: #F59E0B;
    border-radius: 4px 4px 0 0;
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
}

.battery-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, #10B981, #34D399, #6EE7B7);
    animation: battery-charge 5s ease-in-out infinite alternate;
    transition: height 0.3s ease;
}

@keyframes battery-charge {
    0% { height: 20%; }
    100% { height: 95%; }
}

.battery-percentage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: 800;
    color: #065F46;
    z-index: 2;
    text-shadow: 0 0 4px white;
}

.charging-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    animation: charging-pulse 1.5s ease-in-out infinite;
    z-index: 3;
}

@keyframes charging-pulse {
    0%, 100% {
        opacity: 0.3;
        transform: translate(-50%, -50%) scale(0.9);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
}

/* ========== APPLIANCE ANIMATIONS ========== */
.appliances-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.appliance-item {
    text-align: center;
    padding: 12px;
    background: white;
    border-radius: 8px;
    border: 2px solid #E2E8F0;
    transition: all 0.3s ease;
}

.appliance-item:hover {
    border-color: #8B5CF6;
    transform: translateY(-2px);
}

.appliance-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 8px;
    animation: appliance-active 2s ease-in-out infinite;
}

@keyframes appliance-active {
    0%, 100% {
        opacity: 0.7;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.15);
    }
}

.appliance-item:nth-child(1) .appliance-icon { animation-delay: 0s; }
.appliance-item:nth-child(2) .appliance-icon { animation-delay: 0.3s; }
.appliance-item:nth-child(3) .appliance-icon { animation-delay: 0.6s; }
.appliance-item:nth-child(4) .appliance-icon { animation-delay: 0.9s; }
.appliance-item:nth-child(5) .appliance-icon { animation-delay: 1.2s; }

.appliance-name {
    font-size: 12px;
    font-weight: 600;
    color: #0D3B6E;
    margin-bottom: 4px;
}

.appliance-power {
    font-size: 11px;
    color: #64748B;
}

/* ========== SERIES/PARALLEL DIAGRAM ========== */
.wiring-diagram-svg {
    width: 100%;
    max-width: 800px;
    height: auto;
    margin: 20px auto;
    display: block;
}

.panel-rect {
    fill: #E0F2FE;
    stroke: #1565C0;
    stroke-width: 3;
    transition: all 0.3s ease;
}

.panel-rect:hover {
    fill: #BAE6FD;
    stroke: #0D47A1;
}

/* Animated series wires */
.series-wire-animated {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: wire-draw 2s ease-out forwards, wire-pulse 3s ease-in-out infinite 2s;
}

@keyframes wire-draw {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes wire-pulse {
    0%, 100% {
        opacity: 1;
        stroke-width: 4;
    }
    50% {
        opacity: 0.7;
        stroke-width: 5;
    }
}

/* Animated parallel wires */
.parallel-wire-animated {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: wire-draw 2s ease-out forwards 0.5s, wire-pulse 3s ease-in-out infinite 2.5s;
}

/* DC wires to inverter */
.dc-plus-wire {
    filter: drop-shadow(0 0 8px #3B82F6);
    animation: wire-glow-blue 2s ease-in-out infinite;
}

.dc-minus-wire {
    filter: drop-shadow(0 0 8px #EF4444);
    animation: wire-glow-red 2s ease-in-out infinite;
}

@keyframes wire-glow-blue {
    0%, 100% {
        filter: drop-shadow(0 0 6px #3B82F6);
    }
    50% {
        filter: drop-shadow(0 0 12px #60A5FA);
    }
}

@keyframes wire-glow-red {
    0%, 100% {
        filter: drop-shadow(0 0 6px #EF4444);
    }
    50% {
        filter: drop-shadow(0 0 12px #FCA5A5);
    }
}

/* Energy flow dots */
.energy-dot {
    filter: drop-shadow(0 0 4px currentColor);
}

.energy-dot-main {
    filter: drop-shadow(0 0 6px currentColor);
}

/* Inverter pulse */
.inverter-pulse {
    animation: inverter-pulse-anim 2s ease-in-out infinite;
}

@keyframes inverter-pulse-anim {
    0%, 100% {
        filter: drop-shadow(0 0 8px #10B981);
    }
    50% {
        filter: drop-shadow(0 0 16px #34D399);
    }
}

.series-wire {
    stroke: #F59E0B;
    stroke-width: 4;
    stroke-dasharray: 20 5;
    animation: connection-flow 2s linear infinite;
}

.parallel-wire {
    stroke: #3B82F6;
    stroke-width: 6;
    stroke-dasharray: 20 5;
    animation: connection-flow 2s linear infinite;
    animation-delay: 0.5s;
}

@keyframes connection-flow {
    0% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: 100; }
}

/* ========== GRID CONNECTION ========== */
.grid-icon-animated {
    animation: grid-pulse 2s ease-in-out infinite;
}

@keyframes grid-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.9;
    }
    50% {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* ========== SYSTEM LAYOUT ========== */
.system-layout {
    position: relative;
    min-height: 700px;
    margin: 40px 0;
    padding: 20px;
}

.layout-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin: 40px 0;
    position: relative;
}

.layout-row.top {
    justify-content: center;
}

.layout-row.middle {
    justify-content: center;
}

.layout-row.bottom {
    justify-content: space-around;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .animated-installation-guide {
        padding: 20px;
    }
    
    .system-layout {
        min-height: 1200px;
    }
    
    .layout-row {
        flex-direction: column;
        gap: 40px;
    }
    
    .component-box {
        width: 100%;
        max-width: 400px;
    }
    
    .appliances-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ========== INSTALLATION STEPS ========== */
.installation-steps {
    margin-top: 60px;
}

.installation-step {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    border-left: 6px solid #3B82F6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.installation-step:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.step-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.step-number {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #3B82F6, #1D4ED8);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 800;
    flex-shrink: 0;
}

.step-title {
    font-size: 20px;
    font-weight: 700;
    color: #0D3B6E;
}

.step-content {
    padding-left: 64px;
}

/* ========== SAFETY WARNINGS ========== */
.safety-warning {
    background: linear-gradient(135deg, #FEF2F2, #FEE2E2);
    border: 3px solid #EF4444;
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
}

.safety-warning-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.safety-icon {
    font-size: 32px;
}

.safety-title {
    font-size: 18px;
    font-weight: 700;
    color: #991B1B;
}

.safety-content {
    color: #7F1D1D;
    line-height: 1.6;
}

/* ========== PRINT STYLES ========== */
@media print {
    .animated-installation-guide {
        background: white;
    }
    
    .sun-core,
    .sun-rays,
    .energy-particles-container,
    .animated-wire {
        display: none;
    }
    
    .component-box {
        page-break-inside: avoid;
    }
    
    .installation-step {
        page-break-inside: avoid;
    }
}
