/* =============================================================================
   ENOVRA SOLAR — Frontend Installations Map Styles
   ============================================================================= */

/* ── Wrapper ─────────────────────────────────────────────────────────────────── */
#enovra-map-wrapper {
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 2rem 0;
}

/* ── Filter Bar ──────────────────────────────────────────────────────────────── */
#enovra-map-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.filter-label {
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 4px;
}

.filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border: 2px solid var(--cat-color, #6b7280);
    border-radius: 999px;
    background: transparent;
    color: #374151;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    user-select: none;
}

.filter-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
}

.filter-btn.active {
    background: var(--cat-color, #6b7280);
    color: #ffffff;
}

.filter-btn:not(.active) {
    opacity: 0.6;
}

.filter-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background 0.2s;
}

.filter-btn.active .filter-dot {
    background: #ffffff !important;
}

/* "Show All" button */
#filter-all-btn {
    margin-left: auto;
    padding: 7px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 999px;
    background: #f9fafb;
    color: #374151;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

#filter-all-btn:hover {
    background: #111827;
    color: #ffffff;
    border-color: #111827;
}

/* ── Map Container ───────────────────────────────────────────────────────────── */
#enovra-frontend-map {
    width: 100%;
    height: 580px;
    border-left: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;
    z-index: 1;
}

/* ── Installation Count Badge ────────────────────────────────────────────────── */
#enovra-map-count {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-top: none;
    border-radius: 0 0 12px 12px;
    font-size: 13px;
    color: #6b7280;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

#enovra-count-number {
    font-weight: 700;
    font-size: 16px;
    color: #111827;
}

/* ── Modal Overlay ───────────────────────────────────────────────────────────── */
#enovra-modal-overlay {
    display: none !important;
    position: fixed !important;
    inset: 0;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(0, 0, 0, 0.60) !important;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999999 !important;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.25s ease;
}

#enovra-modal-overlay.visible {
    display: flex !important;
    opacity: 1 !important;
}

/* Prevent body scroll when modal is open */
body.enovra-modal-open {
    overflow: hidden;
}

/* ── Modal Card ──────────────────────────────────────────────────────────────── */
#enovra-modal {
    background: #ffffff;
    border-radius: 16px;
    width: 100%;
    max-width: 460px;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
    animation: modalSlideIn 0.28s cubic-bezier(0.34, 1.4, 0.64, 1);
    display: flex;
    flex-direction: column;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* ── Modal Header ────────────────────────────────────────────────────────────── */
/* X button lives INSIDE the header as a flex item — can never overlap the badge */
#enovra-modal-header {
    padding: 16px 16px 14px 20px;
    border-bottom: 1px solid #f3f4f6;
    transition: border-top 0.3s;
    flex-shrink: 0;
}

/* Top row: title on the left, X on the right — in document flow, no absolute */
#enovra-modal-top-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

#enovra-modal-title {
    font-size: 17px;
    font-weight: 700;
    color: #111827;
    margin: 0;
    flex: 1;
    line-height: 1.3;
}

/* ── Close Button — in-flow, never absolute ──────────────────────────────────── */
#enovra-modal-close {
    background: #f3f4f6;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    min-width: 28px;
    font-size: 12px;
    font-weight: 800;
    font-family: Arial, sans-serif;
    line-height: 1;
    cursor: pointer;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, color 0.2s;
    margin-top: 2px;
}

#enovra-modal-close:hover {
    background: #e5e7eb;
    color: #111827;
}

/* Badge sits on its own line — completely clear of the X button */
#enovra-modal-type-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

#enovra-modal-client {
    margin: 6px 0 0;
    font-size: 13px;
    color: #6b7280;
    font-style: italic;
}

/* ── Stats Grid ──────────────────────────────────────────────────────────────── */
#enovra-modal-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: #f3f4f6;
    border-bottom: 1px solid #f3f4f6;
    flex-shrink: 0;
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 13px 8px;
    background: #ffffff;
    text-align: center;
    transition: background 0.15s;
}

.stat-card:hover {
    background: #f9fafb;
}

.stat-icon {
    font-size: 17px;
    line-height: 1;
}

.stat-value {
    font-size: 13px;
    font-weight: 700;
    color: #111827;
    word-break: break-word;
    line-height: 1.2;
}

.stat-label {
    font-size: 10px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

/* ── Modal Body (stats left, image right) ────────────────────────────────────── */
#enovra-modal-body {
    display: flex;
    flex-direction: row;
    flex: 1;
    min-height: 0;
    border-radius: 0 0 16px 16px;
    overflow: hidden;
}

/* Stats: fills remaining width; 3 cols by default, 2 cols when image is showing */
#enovra-modal-stats {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: #f3f4f6;
    align-content: start;
    min-width: 0;
}

/* JS adds this class to the stats grid when an image is present */
#enovra-modal-stats.has-image {
    grid-template-columns: repeat(2, 1fr);
}

/* ── Image Panel ─────────────────────────────────────────────────────────────── */
#enovra-modal-image-panel {
    width: 150px;
    min-width: 150px;
    flex-shrink: 0;
    background: #f1f5f9;
    border-left: 1px solid #f3f4f6;
    overflow: hidden;
}

#enovra-modal-hero-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ── Scrollbar styling inside modal ─────────────────────────────────────────── */
#enovra-modal::-webkit-scrollbar        { width: 4px; }
#enovra-modal::-webkit-scrollbar-track  { background: #f9fafb; }
#enovra-modal::-webkit-scrollbar-thumb  { background: #d1d5db; border-radius: 99px; }

/* ── Responsive — stack vertically on small screens ─────────────────────────── */
@media (max-width: 500px) {

    #enovra-map-filters { gap: 8px; }

    .filter-btn {
        font-size: 12px;
        padding: 6px 11px;
    }

    #filter-all-btn { margin-left: 0; }

    #enovra-frontend-map { height: 400px; }

    #enovra-modal-body {
        flex-direction: column;
    }

    /* On mobile, image sits below the stats, full width, fixed height */
    #enovra-modal-image-panel {
        width: 100%;
        min-width: unset;
        height: 160px;
        border-left: none;
        border-top: 1px solid #f3f4f6;
    }

    /* Stats always 2-col on mobile */
    #enovra-modal-stats,
    #enovra-modal-stats.has-image {
        grid-template-columns: repeat(2, 1fr);
    }

    #enovra-modal-header {
        padding: 14px 14px 12px 16px;
    }
}
