/* =============================================
   Ecosystem Map — Styles
   ============================================= */

#ecosystem-map {
    font-family: inherit;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    background: #f0f0f0;
    border-radius: 12px;
}

/* ----- Filters ----- */
.eco-filters {
    background: #f8f8f8;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
}

.eco-filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.eco-filters-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.eco-filters-clear {
    background: none;
    border: 1px solid #ccc;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 13px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s;
}

.eco-filters-clear:hover {
    border-color: #76232f;
    color: #76232f;
}

.eco-filters-groups {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.eco-filter-group {
    position: relative;
    flex: 1 1 180px;
    min-width: 160px;
}

.eco-filter-toggle {
    width: 100%;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.2s;
    text-align: left;
}

.eco-filter-toggle:hover {
    border-color: #76232f;
}

.eco-filter-toggle.active {
    border-color: #76232f;
    color: #76232f;
}

.eco-filter-arrow {
    font-size: 12px;
    transition: transform 0.2s;
}

.eco-filter-group.open .eco-filter-arrow {
    transform: rotate(180deg);
}

.eco-filter-options {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-top: 4px;
    padding: 8px 0;
    z-index: 100;
    max-height: 240px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.eco-filter-group.open .eco-filter-options {
    display: block;
}

.eco-filter-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s;
}

.eco-filter-options label:hover {
    background: #f5f5f5;
}

.eco-filter-options input[type="checkbox"] {
    accent-color: #76232f;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ----- Results info ----- */
.eco-results-info {
    font-size: 14px;
    color: #666;
    margin-bottom: 16px;
    min-height: 20px;
}

/* ----- Category boxes (Muuri tetris) ----- */
.eco-categories {
    position: relative;
}

.eco-category,
.eco-hero-image {
    position: absolute;
    margin: 6px;
}

.eco-category {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    padding: 10px 12px 14px;
    overflow: hidden;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    position: absolute;
    /* width: cols * (150px logo + 4px gap) - gap + horizontal padding */
    width: calc(var(--eco-cols, 3) * 154px - 4px + 24px);
}

.eco-category-help {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #666;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    line-height: 1;
    z-index: 2;
}

.eco-category-help:hover {
    background: #76232f;
    color: #fff;
}

.eco-tooltip-floating {
    position: fixed;
    background: #333;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 6px;
    max-width: 280px;
    line-height: 1.4;
    z-index: 999999;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    word-wrap: break-word;
}

.eco-category.hidden {
    display: none;
}

.eco-category-title {
    font-size: 13px;
    font-weight: 700;
    margin: 0 0 6px 0;
    padding-bottom: 4px;
    border-bottom: 2px solid #76232f;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.eco-category-logos {
    display: grid;
    grid-template-columns: repeat(var(--eco-cols, 3), 150px);
    gap: 4px;
    justify-content: start;
    flex: 1;
    align-content: start;
}

.eco-category.single-logo .eco-category-logos {
    grid-template-columns: 150px;
    justify-content: center;
}

/* ----- Hero image ----- */
.eco-hero-image {
    width: 300px;
    height: 300px;
    border-radius: 10px;
    overflow: hidden;
}

.eco-hero-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

/* ----- Logo items ----- */
.eco-logo-item {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    transition: background 0.2s, transform 0.2s, opacity 0.3s;
    text-align: center;
}

.eco-logo-item:hover {
    background: #f5f5f5;
    transform: translateY(-2px);
}

.eco-logo-item.hidden {
    display: none;
}

.eco-logo-img {
    width: 150px;
    height: 150px;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
}

.eco-logo-fallback {
    width: 150px;
    height: 150px;
    border-radius: 8px;
    background: #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-align: center;
    padding: 4px;
    line-height: 1.2;
}

.eco-logo-name {
    display: none;
}

/* ----- Modal ----- */
.eco-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99999;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.eco-modal-overlay.open {
    display: flex;
}

.eco-modal {
    background: #fff;
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    padding: 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: ecoModalIn 0.25s ease;
}

@keyframes ecoModalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.eco-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}

.eco-modal-close:hover {
    color: #333;
    background: #f0f0f0;
}

.eco-modal-logo {
    width: 120px;
    height: 120px;
    object-fit: contain;
    margin-bottom: 16px;
}

.eco-modal-name {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: #222;
}

.eco-modal-blurb {
    font-size: 15px;
    line-height: 1.6;
    color: #444;
    margin-bottom: 20px;
}

.eco-modal-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.eco-modal-detail {
    display: flex;
    gap: 8px;
    font-size: 14px;
    line-height: 1.4;
}

.eco-modal-detail-label {
    font-weight: 600;
    color: #555;
    min-width: 120px;
    flex-shrink: 0;
}

.eco-modal-detail-value {
    color: #333;
}

.eco-modal-website a {
    color: #76232f;
    text-decoration: none;
}

.eco-modal-website a:hover {
    text-decoration: underline;
}

.eco-modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.eco-modal-tag {
    background: #f0f0f0;
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 12px;
    color: #555;
}

/* ----- Error ----- */
.eco-map-error {
    background: #fff3f3;
    border: 1px solid #fcc;
    border-radius: 8px;
    padding: 20px;
    color: #a00;
    text-align: center;
    font-size: 15px;
}

/* ----- Responsive ----- */
@media (max-width: 768px) {
    .eco-filters-groups {
        flex-direction: column;
    }

    .eco-filter-group {
        flex: 1 1 100%;
    }

    .eco-categories {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .eco-category {
        grid-column: unset !important;
        grid-row: unset !important;
    }

    .eco-logo-img,
    .eco-logo-fallback {
        width: 100px;
        height: 100px;
    }

    .eco-modal {
        padding: 24px 20px;
        margin: 10px;
    }

    .eco-modal-detail {
        flex-direction: column;
        gap: 2px;
    }

    .eco-modal-detail-label {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .eco-filters {
        padding: 14px;
    }

    .eco-category {
        padding: 14px;
        width: calc(100% - 12px) !important;
    }

    .eco-category-logos {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)) !important;
        gap: 8px;
        justify-content: center;
    }

    .eco-logo-item {
        padding: 2px;
    }

    .eco-hero-image {
        width: calc(100% - 12px) !important;
    }
}
