/**
 * Custom Divi Modules - Frontend Styles
 *
 * Styles for the System Contribution module and other custom modules.
 *
 * @package Custom_Divi_Modules
 * @since 1.0.0
 */

/* ==========================================================================
   System Contribution Module - Container
   ========================================================================== */

.cdm-system-contribution-wrapper {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    box-sizing: border-box;
    font-family: inherit;
}

.cdm-system-contribution-wrapper *,
.cdm-system-contribution-wrapper *::before,
.cdm-system-contribution-wrapper *::after {
    box-sizing: border-box;
}

/* ==========================================================================
   Header Section
   ========================================================================== */

.cdm-sc-header {
    margin-bottom: 40px;
}

.cdm-sc-title {
    font-size: 42px;
    font-weight: 400;
    line-height: 1.2;
    margin: 0 0 15px 0;
    padding: 0;
    color: #000000;
    font-family: Georgia, "Times New Roman", serif;
    letter-spacing: -0.5px;
}

.cdm-sc-description {
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    padding: 0;
    color: #333333;
    max-width: 800px;
}

/* ==========================================================================
   Statistics Boxes
   ========================================================================== */

.cdm-sc-stats-container {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -1px 40px -1px;
    border-top: 1px solid #FFFFFF;
    border-bottom: 1px solid #FFFFFF;
}

.cdm-sc-stat-box {
    flex: 1 1 25%;
    min-width: 150px;
    padding: 30px 20px;
    text-align: center;
    border-left: 1px solid #FFFFFF;
    border-right: 1px solid #FFFFFF;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.cdm-sc-stat-box:first-child {
    border-left: none;
}

.cdm-sc-stat-box:last-child {
    border-right: none;
}

.cdm-sc-stat-number {
    display: block;
    font-size: 48px;
    font-weight: 300;
    line-height: 1.1;
    margin-bottom: 10px;
    color: #000000;
    font-family: Georgia, "Times New Roman", serif;
}

.cdm-sc-stat-label {
    display: block;
    font-size: 14px;
    line-height: 1.3;
    color: #333333;
    max-width: 140px;
}

/* ==========================================================================
   Energy Mix Evolution Section
   ========================================================================== */

.cdm-sc-energy-section {
    margin-top: 30px;
}

.cdm-sc-energy-title {
    font-size: 24px;
    font-weight: 400;
    line-height: 1.3;
    margin: 0 0 15px 0;
    padding: 0;
    color: #000000;
    font-family: Georgia, "Times New Roman", serif;
}

.cdm-sc-energy-divider {
    height: 1px;
    background-color: #666666;
    margin: 0 0 25px 0;
    width: 100%;
}

/* ==========================================================================
   Energy Bars
   ========================================================================== */

.cdm-sc-energy-bar-wrapper {
    margin-bottom: 25px;
}

.cdm-sc-energy-bar-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.cdm-sc-energy-label-left,
.cdm-sc-energy-label-right {
    font-size: 14px;
    color: #666666;
}

.cdm-sc-energy-bar {
    display: flex;
    width: 100%;
    height: 24px;
    overflow: hidden;
    background-color: transparent;
}

.cdm-sc-bar-segment {
    height: 100%;
    transition: width 1s ease-in-out;
}

.cdm-sc-baseline-bar {
    display: flex;
}

.cdm-sc-baseline-bar .cdm-sc-fossil-segment {
    transition: width 1.2s ease-out;
}

.cdm-sc-baseline-bar .cdm-sc-empty-segment {
    background-color: #FFFFFF;
}

.cdm-sc-clean-bar {
    display: flex;
}

.cdm-sc-clean-bar .cdm-sc-fossil-segment,
.cdm-sc-clean-bar .cdm-sc-wind-segment,
.cdm-sc-clean-bar .cdm-sc-storage-segment {
    transition: width 1.2s ease-out;
}

/* Animation classes */
.cdm-sc-bar-animate {
    animation: cdmBarGrow 1.2s ease-out forwards;
}

@keyframes cdmBarGrow {
    from {
        transform: scaleX(0);
        transform-origin: left;
    }
    to {
        transform: scaleX(1);
        transform-origin: left;
    }
}

/* ==========================================================================
   Legend
   ========================================================================== */

.cdm-sc-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
    margin-top: 20px;
    padding-top: 15px;
}

.cdm-sc-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cdm-sc-legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cdm-sc-legend-text {
    font-size: 13px;
    color: #666666;
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

/* Tablet styles */
@media screen and (max-width: 980px) {
    .cdm-sc-title {
        font-size: 36px;
    }

    .cdm-sc-stat-box {
        flex: 1 1 50%;
        padding: 25px 15px;
        border-bottom: 1px solid #FFFFFF;
    }

    .cdm-sc-stat-box:nth-child(2) {
        border-right: none;
    }

    .cdm-sc-stat-box:nth-child(3) {
        border-left: none;
    }

    .cdm-sc-stat-number {
        font-size: 40px;
    }

    .cdm-sc-energy-title {
        font-size: 22px;
    }
}

/* Mobile styles */
@media screen and (max-width: 767px) {
    .cdm-system-contribution-wrapper {
        padding: 30px 20px;
    }

    .cdm-sc-title {
        font-size: 28px;
        margin-bottom: 10px;
    }

    .cdm-sc-description {
        font-size: 13px;
    }

    .cdm-sc-header {
        margin-bottom: 30px;
    }

    .cdm-sc-stats-container {
        flex-direction: column;
        margin: 0 0 30px 0;
    }

    .cdm-sc-stat-box {
        flex: 1 1 100%;
        border-left: none;
        border-right: none;
        border-bottom: 1px solid #FFFFFF;
        padding: 20px 15px;
    }

    .cdm-sc-stat-box:last-child {
        border-bottom: none;
    }

    .cdm-sc-stat-number {
        font-size: 36px;
    }

    .cdm-sc-stat-label {
        font-size: 13px;
        max-width: none;
    }

    .cdm-sc-energy-section {
        margin-top: 20px;
    }

    .cdm-sc-energy-title {
        font-size: 20px;
    }

    .cdm-sc-energy-bar {
        height: 20px;
    }

    .cdm-sc-energy-label-left,
    .cdm-sc-energy-label-right {
        font-size: 12px;
    }

    .cdm-sc-legend {
        flex-direction: column;
        gap: 12px;
    }

    .cdm-sc-legend-item {
        gap: 10px;
    }
}

/* Small mobile */
@media screen and (max-width: 480px) {
    .cdm-sc-title {
        font-size: 24px;
    }

    .cdm-sc-stat-number {
        font-size: 32px;
    }

    .cdm-sc-energy-title {
        font-size: 18px;
    }

    .cdm-sc-energy-bar-labels {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

/* ==========================================================================
   Visual Builder Specific Styles
   ========================================================================== */

.et-fb-modules-list .cdm_system_contribution .et-fb-icon svg {
    fill: currentColor;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .cdm-sc-stat-box {
        border-color: #000000;
    }

    .cdm-sc-energy-divider {
        background-color: #000000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .cdm-sc-bar-segment,
    .cdm-sc-bar-animate {
        transition: none;
        animation: none;
    }
}

/* Print styles */
@media print {
    .cdm-system-contribution-wrapper {
        background-color: #FFFFFF !important;
        color: #000000 !important;
    }

    .cdm-sc-stat-box {
        border-color: #CCCCCC !important;
    }

    .cdm-sc-energy-divider {
        background-color: #000000 !important;
    }

    .cdm-sc-bar-segment {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}
