/* ==========================================================================
   Changarnier DPE & GES - Front-end Styles (Widget + Modal)
   ========================================================================== */

.cdpe-widget-wrapper {
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #1a1a1a;
    background: #ffffff;
    padding: 24px 0;
    margin: 10px 0 20px 0;
    box-sizing: border-box;
    text-align: left;
}

.cdpe-widget-wrapper *,
.cdpe-widget-wrapper *::before,
.cdpe-widget-wrapper *::after,
.cdpe-modal-overlay *,
.cdpe-modal-overlay *::before,
.cdpe-modal-overlay *::after {
    box-sizing: border-box;
}

.cdpe-main-title {
    font-size: 20px !important;
    font-weight: 600 !important;
    color: #1a1a1a !important;
    margin: 0 0 24px 0 !important;
    padding: 0 !important;
    line-height: 1.35 !important;
    letter-spacing: -0.01em;
}

.cdpe-summary-grid {
    display: grid;
    grid-template-columns: minmax(280px, 430px) minmax(280px, 430px);
    gap: 28px 56px;
    align-items: start;
}

@media (max-width: 860px) {
    .cdpe-summary-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}

.cdpe-summary-col {
    display: flex;
    flex-direction: column;
}

.cdpe-col-title {
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #1a1a1a !important;
    margin: 0 0 18px 0 !important;
    padding: 0 !important;
    line-height: 1.4 !important;
}

/* Horizontal 7-segment bar (Screenshot 1) */
.cdpe-hbar {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 36px;
    user-select: none;
}

.cdpe-hbar-seg {
    flex: 1 1 0;
    max-width: 50px;
    min-width: 34px;
    height: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    line-height: 1;
    transition: transform 0.15s ease;
}

.cdpe-hbar-seg:first-child:not(.is-active) {
    border-radius: 999px 0 0 999px;
}

.cdpe-hbar-seg:last-child:not(.is-active) {
    border-radius: 0 999px 999px 0;
}

.cdpe-hbar-seg.is-active {
    height: 36px;
    max-width: 48px;
    min-width: 42px;
    border-radius: 3px !important;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.cdpe-hbar.is-vierge .cdpe-hbar-seg {
    opacity: 0.35;
}

/* Excessive energy warning text below bars (Screenshot 1) */
.cdpe-excessive-notice {
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #1a1a1a !important;
    margin: 22px 0 0 0 !important;
    padding: 0 !important;
    line-height: 1.4 !important;
}

.cdpe-vierge-notice {
    font-size: 14.5px !important;
    font-weight: 500 !important;
    color: #555555 !important;
    margin: 16px 0 0 0 !important;
    padding: 0 !important;
}

/* "Voir le détail" button (Screenshot 1) */
.cdpe-btn-wrap {
    margin-top: 20px;
}

.cdpe-detail-btn {
    display: inline-block;
    background: #ffffff;
    color: #2b2b2b;
    border: 1px solid #1a1a1a;
    border-radius: 0;
    padding: 10px 18px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.cdpe-detail-btn:hover,
.cdpe-detail-btn:focus {
    background: #1a1a1a;
    color: #ffffff;
    outline: none;
}

/* ==========================================================================
   Modal (Screenshot 2: "Détails des diagnostics énergétiques")
   ========================================================================== */

.cdpe-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 20, 0.58);
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.2s ease;
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.cdpe-modal-overlay.is-open {
    display: flex;
    opacity: 1;
}

.cdpe-modal-dialog {
    background: #ffffff;
    color: #1a1a1a;
    width: 100%;
    max-width: 570px;
    max-height: 92vh;
    overflow-y: auto;
    position: relative;
    padding: 38px 42px 36px 42px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
    border-radius: 2px;
    text-align: left;
}

@media (max-width: 600px) {
    .cdpe-modal-dialog {
        padding: 28px 20px 24px 20px;
        max-height: 94vh;
    }
}

.cdpe-modal-close {
    position: absolute;
    top: 16px;
    right: 18px;
    width: 34px;
    height: 34px;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666666;
    transition: color 0.15s ease, transform 0.15s ease;
}

.cdpe-modal-close:hover {
    color: #111111;
    transform: scale(1.08);
}

.cdpe-modal-title {
    text-align: center !important;
    font-size: 26px !important;
    font-weight: 600 !important;
    color: #1a1a1a !important;
    line-height: 1.25 !important;
    margin: 0 0 28px 0 !important;
    padding: 0 !important;
}

.cdpe-modal-section {
    margin: 0;
    padding: 0;
}

.cdpe-modal-divider {
    border: 0;
    border-top: 1px solid #eaeaea;
    margin: 22px 0;
}

.cdpe-section-title {
    font-size: 16.5px !important;
    font-weight: 600 !important;
    color: #1a1a1a !important;
    margin: 0 0 12px 0 !important;
    padding: 0 !important;
    line-height: 1.35 !important;
}

/* Facture d'énergie estimée */
.cdpe-bill-highlight {
    display: inline-block;
    background: #f2eadf;
    color: #1a1a1a;
    font-size: 16px;
    font-weight: 600;
    padding: 10px 16px;
    margin: 2px 0 12px 0;
    line-height: 1.35;
}

.cdpe-bill-desc {
    font-size: 13.5px !important;
    color: #333333 !important;
    line-height: 1.55 !important;
    margin: 0 !important;
}

/* Vertical Scale + Callout Box (DPE & GES) */
.cdpe-scale-caption-top {
    font-size: 12px;
    color: #333333;
    margin: 0 0 8px 0;
    line-height: 1.3;
}

.cdpe-scale-caption-bottom {
    font-size: 12px;
    color: #333333;
    margin: 8px 0 12px 0;
    line-height: 1.35;
}

.cdpe-scale-layout {
    display: flex;
    align-items: stretch;
    position: relative;
}

.cdpe-scale-rows {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 245px;
    flex-shrink: 0;
}

.cdpe-scale-row {
    display: flex;
    align-items: center;
    height: 26px;
    width: 100%;
    position: relative;
}

.cdpe-scale-letter {
    width: 22px;
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    flex-shrink: 0;
    line-height: 1;
}

.cdpe-scale-bar {
    height: 26px;
    display: inline-flex;
    align-items: center;
    padding-left: 8px;
    padding-right: 14px;
    font-size: 11px;
    font-weight: 400;
    white-space: nowrap;
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%);
    flex-shrink: 0;
}

/* Progressive widths for A-G arrows */
.cdpe-scale-bar[data-grade="A"] { width: 66px; }
.cdpe-scale-bar[data-grade="B"] { width: 84px; }
.cdpe-scale-bar[data-grade="C"] { width: 102px; }
.cdpe-scale-bar[data-grade="D"] { width: 120px; }
.cdpe-scale-bar[data-grade="E"] { width: 138px; }
.cdpe-scale-bar[data-grade="F"] { width: 162px; }
.cdpe-scale-bar[data-grade="G"] { width: 184px; }

/* Horizontal connector line from active arrow tip to callout card */
.cdpe-scale-connector {
    flex: 1 1 auto;
    height: 1.5px;
    margin-left: -1px;
    display: block;
}

/* Right-hand Callout Card */
.cdpe-callout-col {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 195px;
}

.cdpe-callout-card {
    border: 1.5px solid #cccccc;
    background: #ffffff;
    padding: 12px 15px;
    width: 100%;
    min-height: 212px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.cdpe-callout-card.cdpe-callout-ges {
    min-height: 212px;
}

.cdpe-callout-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 6px;
}

.cdpe-callout-grade {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.05;
}

.cdpe-passoire-badge {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cdpe-callout-line {
    font-size: 12.5px;
    color: #333333;
    line-height: 1.35;
    margin: 0;
}

.cdpe-callout-val {
    font-size: 13px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.35;
    margin: 1px 0 6px 0;
}

.cdpe-callout-val:last-child {
    margin-bottom: 0;
}

.cdpe-callout-subval {
    font-size: 12.5px;
    font-weight: 400;
    color: #333333;
    line-height: 1.35;
    margin: 1px 0 6px 0;
}

.cdpe-diag-meta-line {
    font-size: 13.5px !important;
    color: #222222 !important;
    margin: 8px 0 0 0 !important;
    line-height: 1.45 !important;
}

@media (max-width: 520px) {
    .cdpe-scale-rows {
        width: 185px;
    }
    .cdpe-scale-bar[data-grade="A"] { width: 46px; }
    .cdpe-scale-bar[data-grade="B"] { width: 58px; }
    .cdpe-scale-bar[data-grade="C"] { width: 72px; }
    .cdpe-scale-bar[data-grade="D"] { width: 86px; }
    .cdpe-scale-bar[data-grade="E"] { width: 100px; }
    .cdpe-scale-bar[data-grade="F"] { width: 130px; font-size: 9.5px; }
    .cdpe-scale-bar[data-grade="G"] { width: 146px; font-size: 9.5px; }
    .cdpe-callout-col {
        min-width: 140px;
    }
    .cdpe-callout-card {
        padding: 10px 10px;
    }
}
