/* ====================================
   Solar Genius - PV Module Component
   Version: 2.0.1
   Full-Black Photovoltaic Module Visualization
   Fullscreen Design with Enhanced 3D Tilt
   ==================================== */

/* ====================================
   PV Module Screen Container - FULLSCREEN
   ==================================== */
.pv-module-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-sizing: border-box;
    overflow: hidden;
    background: linear-gradient(180deg, #0a0a0a 0%, #1a1a1a 50%, #0a0a0a 100%);
    /* Enable 3D perspective for child elements */
    perspective: 1000px;
    perspective-origin: center center;
}

/* ====================================
   Main PV Module - ENHANCED 3D
   ==================================== */
.pv-module {
    position: relative;
    width: 90vw;
    max-width: 400px;
    height: 85vh;
    max-height: 650px;
    border-radius: 6px;
    overflow: visible;
    /* Allow 3D overflow */
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.8),
        0 40px 100px rgba(0, 0, 0, 0.5);
    /* Enhanced 3D tilt effect */
    transform-style: preserve-3d;
    transition: transform 0.15s ease-out, box-shadow 0.15s ease-out;
    will-change: transform;
}

/* Dynamic shadow that changes with tilt */
.pv-module.tilted-left {
    box-shadow:
        20px 20px 60px rgba(0, 0, 0, 0.8),
        40px 40px 100px rgba(0, 0, 0, 0.5);
}

.pv-module.tilted-right {
    box-shadow:
        -20px 20px 60px rgba(0, 0, 0, 0.8),
        -40px 40px 100px rgba(0, 0, 0, 0.5);
}

/* ====================================
   Black Aluminum Frame
   ==================================== */
.pv-frame {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg,
            #2a2a2a 0%,
            #1a1a1a 10%,
            #252525 50%,
            #1a1a1a 90%,
            #2a2a2a 100%);
    padding: 12px;
    border-radius: 6px;
    box-shadow:
        inset 2px 2px 4px rgba(80, 80, 80, 0.3),
        inset -2px -2px 4px rgba(0, 0, 0, 0.5);
    border: 2px solid #333;
}

/* Inner bezel around cells */
.pv-frame::before {
    content: '';
    position: absolute;
    top: 11px;
    left: 11px;
    right: 11px;
    bottom: 11px;
    border: 1px solid #0a0a0a;
    border-radius: 3px;
    pointer-events: none;
}

/* ====================================
   Cell Grid Container - 6x11 Grid
   ==================================== */
.pv-cell-grid {
    position: relative;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(11, 1fr);
    gap: 2px;
    background: #4a4a4a;
    border-radius: 3px;
    overflow: hidden;
}

/* Horizontal divider line in the middle */
.pv-cell-grid::after {
    content: '';
    position: absolute;
    top: calc((5 / 11) * 100% - 2px);
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(180deg,
            #2a2a2a 0%,
            #555 50%,
            #2a2a2a 100%);
    z-index: 5;
}

/* ====================================
   Individual Solar Cell
   ==================================== */
.pv-cell {
    position: relative;
    background: linear-gradient(180deg,
            #0f0f0f 0%,
            #0a0a0a 30%,
            #080808 70%,
            #0c0c0c 100%);
    overflow: hidden;
}

/* Subtle wafer texture */
.pv-cell::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(0deg,
            transparent 0px,
            transparent 3px,
            rgba(40, 40, 45, 0.12) 3px,
            rgba(40, 40, 45, 0.12) 4px);
    opacity: 0.9;
}

/* Diagonal texture */
.pv-cell::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(135deg,
            transparent 0px,
            transparent 5px,
            rgba(30, 30, 35, 0.08) 5px,
            rgba(30, 30, 35, 0.08) 6px);
    opacity: 0.6;
}

/* ====================================
   Dynamic Sun Reflection
   ==================================== */
.pv-reflection {
    position: absolute;
    pointer-events: none;
    z-index: 10;
    width: 180px;
    height: 100px;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(ellipse at center,
            rgba(255, 255, 255, 0.3) 0%,
            rgba(255, 255, 255, 0.18) 30%,
            rgba(255, 255, 255, 0.06) 60%,
            transparent 80%);
    border-radius: 50%;
    filter: blur(20px);
    opacity: 0.9;
    transition:
        top 0.12s ease-out,
        left 0.12s ease-out,
        opacity 0.25s ease-out,
        transform 0.12s ease-out;
    will-change: top, left, opacity, transform;
}

.pv-reflection.weak {
    opacity: 0.25;
    width: 120px;
    height: 60px;
}

.pv-reflection.strong {
    opacity: 1;
    width: 250px;
    height: 140px;
    filter: blur(25px);
}

/* ====================================
   Data Overlay - TOP
   ==================================== */
.pv-data-overlay {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 100;
    pointer-events: none;
}

/* Efficiency Badge */
.pv-efficiency-badge {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff;
    font-size: 3rem;
    font-weight: 800;
    padding: 14px 32px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    min-width: 120px;
    text-align: center;
}

.pv-efficiency-badge.excellent {
    background: rgba(52, 199, 89, 0.85);
    border-color: rgba(52, 199, 89, 0.4);
}

.pv-efficiency-badge.good {
    background: rgba(255, 204, 0, 0.85);
    border-color: rgba(255, 204, 0, 0.4);
    color: #000;
}

.pv-efficiency-badge.poor {
    background: rgba(255, 59, 48, 0.85);
    border-color: rgba(255, 59, 48, 0.4);
}

/* Orientation Info */
.pv-orientation-info {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    gap: 10px;
    align-items: center;
}

.pv-orientation-info span {
    font-weight: 700;
    color: #fff;
}

/* ====================================
   Guidance Text Overlay - Subtle on-module display
   ==================================== */
.pv-guidance-overlay,
#guidance-text.guidance-text {
    position: absolute !important;
    right: 20px !important;
    top: 50% !important;
    left: auto !important;
    bottom: auto !important;
    transform: translateY(-50%) !important;
    background: rgba(0, 0, 0, 0.4) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    color: rgba(255, 255, 255, 0.85) !important;
    font-size: 0.85rem !important;
    font-weight: 500 !important;
    padding: 10px 14px !important;
    border-radius: 12px !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    z-index: 90 !important;
    text-align: center !important;
    max-width: 140px !important;
    line-height: 1.3 !important;
    pointer-events: none !important;
    /* Subtle appearance */
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

/* Color variants for guidance types */
.pv-guidance-overlay.guidance-success,
#guidance-text.guidance-success {
    background: rgba(52, 199, 89, 0.3) !important;
    border-color: rgba(52, 199, 89, 0.3) !important;
}

.pv-guidance-overlay.guidance-warning,
#guidance-text.guidance-warning {
    background: rgba(255, 149, 0, 0.3) !important;
    border-color: rgba(255, 149, 0, 0.3) !important;
}

.pv-guidance-overlay.guidance-info,
#guidance-text.guidance-info {
    background: rgba(0, 0, 0, 0.4) !important;
}

/* ====================================
   Button Overlay - Below Guidance on Right
   ==================================== */
.pv-button-overlay {
    position: absolute;
    right: 20px;
    top: calc(50% + 60px);
    /* Below the guidance text */
    left: auto;
    bottom: auto;
    transform: translateY(0);
    z-index: 100;
    /* Delayed fade-in animation */
    opacity: 0;
    animation: fadeInDelayed 0.5s ease-out 3s forwards;
}

@keyframes fadeInDelayed {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Transparent overlay button - compact style */
.btn-overlay-finish {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 12px 18px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    white-space: nowrap;
}

.btn-overlay-finish:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-overlay-finish:active {
    transform: scale(0.96);
}

/* ====================================
   Efficiency Glow Effect on Module
   ==================================== */
.pv-module.glow-excellent {
    box-shadow:
        0 0 50px rgba(52, 199, 89, 0.5),
        0 0 100px rgba(52, 199, 89, 0.25),
        0 20px 60px rgba(0, 0, 0, 0.8);
    animation: pv-glow-pulse 2s ease-in-out infinite;
}

.pv-module.glow-good {
    box-shadow:
        0 0 40px rgba(255, 204, 0, 0.4),
        0 0 80px rgba(255, 204, 0, 0.2),
        0 20px 60px rgba(0, 0, 0, 0.8);
}

.pv-module.glow-poor {
    box-shadow:
        0 0 30px rgba(255, 59, 48, 0.3),
        0 0 60px rgba(255, 59, 48, 0.15),
        0 20px 60px rgba(0, 0, 0, 0.8);
}

/* ====================================
   Landscape Orientation
   ==================================== */
@media (orientation: landscape) {
    .pv-module {
        width: auto;
        height: 85vh;
        max-height: none;
        max-width: 60vw;
        aspect-ratio: 3 / 2;
    }

    .pv-cell-grid {
        grid-template-columns: repeat(11, 1fr);
        grid-template-rows: repeat(6, 1fr);
    }

    .pv-cell-grid::after {
        top: 0;
        bottom: 0;
        left: calc((5 / 11) * 100% - 2px);
        width: 4px;
        height: 100%;
    }

    .pv-data-overlay {
        top: 15px;
        flex-direction: row;
        gap: 20px;
    }

    .pv-efficiency-badge {
        font-size: 2.5rem;
        padding: 10px 24px;
    }

    .pv-guidance-overlay {
        bottom: 100px;
    }

    .pv-button-overlay {
        bottom: 30px;
    }
}

/* ====================================
   Small Screens
   ==================================== */
@media (max-height: 700px) {
    .pv-efficiency-badge {
        font-size: 2.2rem;
        padding: 10px 24px;
    }

    .pv-guidance-overlay {
        bottom: 100px;
        font-size: 0.9rem;
        padding: 10px 18px;
    }

    .pv-button-overlay {
        bottom: 30px;
    }

    .btn-overlay-finish {
        padding: 12px 30px;
        font-size: 1rem;
    }
}

/* ====================================
   Reduced Motion
   ==================================== */
@media (prefers-reduced-motion: reduce) {
    .pv-reflection {
        transition: none;
    }

    .pv-module {
        transition: none;
    }

    .pv-module.glow-excellent {
        animation: none;
    }

    .pv-button-overlay {
        animation: none;
        opacity: 1;
    }
}

/* ====================================
   Animation: Pulse effect
   ==================================== */
@keyframes pv-glow-pulse {

    0%,
    100% {
        box-shadow:
            0 0 50px rgba(52, 199, 89, 0.5),
            0 0 100px rgba(52, 199, 89, 0.25),
            0 20px 60px rgba(0, 0, 0, 0.8);
    }

    50% {
        box-shadow:
            0 0 70px rgba(52, 199, 89, 0.6),
            0 0 140px rgba(52, 199, 89, 0.35),
            0 20px 60px rgba(0, 0, 0, 0.8);
    }
}