/*
 * Animations CSS
 * PRWSolar
 */

/* ============================================================
   CORE ANIMATIONS
   ============================================================ */

/* Fade In Up */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.8s ease forwards;
}

/* Fade In Down */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-down {
    animation: fadeInDown 0.8s ease forwards;
}

/* Fade In Left */
@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.fade-in-left {
    animation: fadeInLeft 0.8s ease forwards;
}

/* Fade In Right */
@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.fade-in-right {
    animation: fadeInRight 0.8s ease forwards;
}

/* Scale In */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.scale-in {
    animation: scaleIn 0.6s ease forwards;
}

/* Pulse */
@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.pulse {
    animation: pulse 2s ease infinite;
}

/* Spin */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.spin {
    animation: spin 10s linear infinite;
}

/* Blink */
@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.blink {
    animation: blink 1.5s ease infinite;
}

/* Grow Bar */
@keyframes growBar {
    from {
        height: 0;
    }
    to {
        height: var(--target-height);
    }
}

.grow-bar {
    animation: growBar 2s ease forwards;
}

/* Grow Pie */
@keyframes growPie {
    from {
        stroke-dasharray: 0 100;
    }
    to {
        stroke-dasharray: var(--percentage) 100;
    }
}

.grow-pie {
    animation: growPie 3s ease forwards;
}

/* Draw Line */
@keyframes drawLine {
    from {
        stroke-dashoffset: 1000;
    }
    to {
        stroke-dashoffset: 0;
    }
}

.draw-line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawLine 4s ease forwards;
}

/* Hover Scale */
.hover-scale {
    transition: var(--transition);
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* Hover Shadow */
.hover-shadow {
    transition: var(--transition);
}

.hover-shadow:hover {
    box-shadow: var(--shadow-lg);
}

/* Page Fade */
@keyframes pageFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.page-transition {
    animation: pageFadeIn 0.5s ease;
}

/* Ripple */
@keyframes ripple {
    from {
        transform: scale(0);
        opacity: 1;
    }
    to {
        transform: scale(4);
        opacity: 0;
    }
}

.ripple-effect {
    position: relative;
    overflow: hidden;
}

/* Text Glow */
@keyframes textGlow {
    0%, 100% {
        text-shadow: 0 0 10px rgba(46, 125, 50, 0.5);
    }
    50% {
        text-shadow: 0 0 20px rgba(46, 125, 50, 0.8);
    }
}

.text-glow {
    animation: textGlow 3s ease infinite;
}

/* Border Flow */
@keyframes borderFlow {
    0% {
        border-color: var(--primary-green);
    }
    33% {
        border-color: var(--accent-orange);
    }
    66% {
        border-color: var(--tech-blue);
    }
    100% {
        border-color: var(--primary-green);
    }
}

.border-flow {
    animation: borderFlow 3s linear infinite;
}

/* Gradient Move */
@keyframes gradientMove {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.gradient-move {
    background: linear-gradient(270deg, var(--primary-green), var(--accent-orange), var(--tech-blue));
    background-size: 300% 100%;
    animation: gradientMove 6s ease infinite;
}

/* Slide In Left */
@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

.slide-in-left {
    animation: slideInLeft 0.5s ease forwards;
}

/* Slide In Right */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.slide-in-right {
    animation: slideInRight 0.5s ease forwards;
}

/* Bounce */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.bounce {
    animation: bounce 2s ease infinite;
}

/* Shake */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

.shake {
    animation: shake 0.8s ease;
}

/* Typing */
@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

.typing-effect {
    overflow: hidden;
    white-space: nowrap;
    animation: typing 3s steps(40, end);
}

/* Float */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.float {
    animation: float 3s ease infinite;
}

/* Rotate In */
@keyframes rotateIn {
    from {
        transform: rotate(-180deg) scale(0);
        opacity: 0;
    }
    to {
        transform: rotate(0) scale(1);
        opacity: 1;
    }
}

.rotate-in {
    animation: rotateIn 0.6s ease forwards;
}

/* Flip In */
@keyframes flipIn {
    from {
        transform: perspective(400px) rotateX(90deg);
        opacity: 0;
    }
    to {
        transform: perspective(400px) rotateX(0);
        opacity: 1;
    }
}

.flip-in {
    animation: flipIn 0.8s ease forwards;
}

/* Zoom In */
@keyframes zoomIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.zoom-in {
    animation: zoomIn 0.5s ease forwards;
}

/* Zoom Out */
@keyframes zoomOut {
    from {
        transform: scale(1);
        opacity: 1;
    }
    to {
        transform: scale(0);
        opacity: 0;
    }
}

.zoom-out {
    animation: zoomOut 0.5s ease forwards;
}

/* ============================================================
   CURRENT FLOW
   Compatible for both block elements and SVG paths
   ============================================================ */

@keyframes flowBg {
    0% {
        background-position: 0% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

@keyframes strokeFlow {
    0% {
        stroke-dashoffset: 0;
    }
    100% {
        stroke-dashoffset: -24;
    }
}

/* Generic support */
.current-flow {
    animation-duration: 1.5s;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

/* SVG usage */
svg .current-flow,
.current-flow[stroke] {
    stroke-dasharray: 8 4;
    animation-name: strokeFlow;
}

/* Non-SVG usage */
.current-flow:not(svg *):not([stroke]) {
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--primary-green) 25%,
        var(--accent-orange) 50%,
        var(--primary-green) 75%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation-name: flowBg;
}

/* ============================================================
   SOLUTIONS SECTION - SYSTEM DIAGRAMS
   ============================================================ */

.solution-diagram-area {
    height: 380px;
    position: relative;
    background: #f8fafc;
    overflow: hidden;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.solution-diagram-area .diagram-label {
    position: absolute;
    top: 12px;
    left: 16px;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    background: rgba(255, 255, 255, 0.85);
    padding: 4px 12px;
    border-radius: 20px;
    z-index: 2;
    backdrop-filter: blur(4px);
}

.system-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.solution-diagram-title {
    display: block;
    margin-bottom: 16px;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.25;
    color: var(--gray-text-dark);
    text-align: center;
}

/* LED Blink */
@keyframes ledBlink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

.led-blink {
    animation: ledBlink 1.5s ease-in-out infinite;
}

/* Battery Charge Animation */
@keyframes batteryCharge {
    0% {
        width: 12px;
    }
    50% {
        width: 28px;
    }
    100% {
        width: 12px;
    }
}

.battery-charge-og,
.battery-charge-hyb {
    animation: batteryCharge 4s ease-in-out infinite;
}

/* Window Glow */
@keyframes windowGlowPulse {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 0.9;
    }
}

.window-glow {
    animation: windowGlowPulse 3s ease-in-out infinite;
}

/* SVG Label */
.svg-label {
    paint-order: stroke;
    stroke: white;
    stroke-width: 3px;
    stroke-linecap: butt;
    stroke-linejoin: miter;
    transition: fill 0.8s ease;
}

/* ============================================================
   RESIDENTIAL HYBRID SYSTEM - INTERACTIVE ANIMATION
   ============================================================ */

/* Sky Overlay */
.sky-overlay {
    border-radius: 16px;
    transition: background 1.2s ease !important;
    pointer-events: none;
}

.sky-day {
    background: linear-gradient(180deg, #bae6fd 0%, #e0f7fa 30%, #f0fdf4 100%) !important;
}

.sky-night {
    background: linear-gradient(180deg, #1e293b 0%, #334155 35%, #475569 100%) !important;
}

.sky-outage {
    background: linear-gradient(180deg, #1e293b 0%, #2d1b2e 35%, #4a1942 100%) !important;
}

/* SVG Wrapper */
.system-svg-wrapper {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.hybrid-system-svg {
    display: block;
    width: 100%;
    height: auto;
}

/* Mode Element */
.mode-element {
    transition: opacity 0.8s ease;
}

/* Flow Group */
.flow-group {
    transition: opacity 0.6s ease;
}

/* Layout */
.system-interactive-container {
    display: grid;
    grid-template-columns: 1.3fr 0.7fr;
    gap: 40px;
    align-items: start;
}

/* Sticky Controls */
.system-controls-panel {
    position: sticky;
    top: 100px;
}

/* Buttons */
.mode-buttons-group {
    display: flex;
    gap: 12px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.mode-btn-new {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 24px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: #94a3b8;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    min-width: 90px;
    font-family: inherit;
}

.mode-btn-new .mode-icon {
    font-size: 24px;
    line-height: 1;
}

.mode-btn-new .mode-label {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.mode-btn-new:hover {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    transform: translateY(-2px);
}

.mode-btn-new.active[data-mode="day"] {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.2);
}

.mode-btn-new.active[data-mode="night"] {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.2);
}

.mode-btn-new.active[data-mode="outage"] {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
    animation: outageButtonPulse 1.5s ease-in-out infinite;
}

@keyframes outageButtonPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
    }
    50% {
        box-shadow: 0 0 35px rgba(239, 68, 68, 0.45);
    }
}

/* Detail Panels */
.mode-detail {
    transition: opacity 0.3s ease;
}

.mode-detail-header {
    margin-bottom: 15px;
}

.mode-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.3px;
}

.day-badge {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.night-badge {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.outage-badge {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.mode-main-desc {
    color: #cbd5e1;
    font-size: 15px;
    line-height: 1.7;
    margin-bottom: 20px;
}

/* Flow List */
.mode-flow-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mode-flow-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    color: #e2e8f0;
    font-size: 14px;
    line-height: 1.5;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    transition: color 0.3s ease;
}

.mode-flow-list li:last-child {
    border-bottom: none;
}

.flow-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    position: relative;
}

.flow-dot::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: inherit;
    opacity: 0.4;
    filter: blur(4px);
}

/* Stats Bar */
.system-stats-bar {
    margin-top: 30px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.stat-mini {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 12px 10px;
    text-align: center;
    transition: all 0.3s ease;
}

.stat-mini:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.stat-mini-value {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: #22c55e;
    transition: color 0.3s ease;
}

.stat-mini-label {
    display: block;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1200px) {
    .system-interactive-container {
        grid-template-columns: 1fr 1fr !important;
        gap: 30px !important;
    }
}

@media (max-width: 1024px) {
    .system-interactive-container {
        grid-template-columns: 1fr !important;
        gap: 25px !important;
    }

    .system-controls-panel {
        position: static;
    }

    .solutions-grid {
        grid-template-columns: 1fr !important;
    }

    .solution-diagram-area {
        height: 280px;
    }
}

@media (max-width: 991px) {
    .solution-diagram-area {
        height: 340px;
    }
}

@media (max-width: 768px) {
    .mode-buttons-group {
        gap: 8px !important;
    }

    .mode-btn-new {
        padding: 10px 14px;
        min-width: 70px;
    }

    .mode-btn-new .mode-icon {
        font-size: 20px;
    }

    .mode-btn-new .mode-label {
        font-size: 11px;
    }

    .system-stats-bar {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px !important;
    }

    .stat-mini {
        padding: 10px 6px;
    }

    .stat-mini-value {
        font-size: 15px;
    }

    .stat-mini-label {
        font-size: 9px;
    }

    .solution-diagram-area {
        height: 220px;
    }

    .mode-main-desc {
        font-size: 14px;
    }

    .mode-flow-list li {
        font-size: 13px;
        padding: 6px 0;
    }
}

@media (max-width: 767px) {
    .solution-diagram-area {
        height: 300px;
    }

    .solution-diagram-title {
        font-size: 18px;
        margin-bottom: 14px;
    }
}

@media (max-width: 480px) {
    .mode-btn-new {
        padding: 8px 10px;
        min-width: 60px;
    }

    .mode-btn-new .mode-icon {
        font-size: 18px;
    }

    .mode-btn-new .mode-label {
        font-size: 10px;
    }

    .system-svg-wrapper {
        border-radius: 10px;
    }

    .sky-overlay {
        border-radius: 10px;
    }
}

/* ============================================================
   ACCESSIBILITY / PERFORMANCE
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }

    .current-flow {
        background-position: 0 0 !important;
        stroke-dashoffset: 0 !important;
    }
}
