/**
 * Eighth Amendment CPT Map - Frontend Styles
 */

/* Container */
.ea-map-container {
    position: relative;
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}

/* Legend */
.ea-map-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 5px;
}

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

.ea-map-legend-color {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid #ccc;
}

.ea-map-legend-label {
    font-size: 14px;
    color: #333;
    white-space: nowrap;
}

/* Map wrapper */
.ea-map-wrapper {
    position: relative;
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
}

/* SVG Map */
.ea-map-svg {
    width: 100%;
    height: auto;
    display: block;
}

/* State labels */
.ea-map-svg text {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
    user-select: none;
    text-anchor: middle;
}

/* Overlay */
.ea-map-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9998;
}

/* Popup */
.ea-map-popup {
    position: absolute;
    z-index: 9999;
    min-width: 280px;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    background-color: #F0C808;
    color: #000000;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    padding: 0;
}

.ea-map-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.ea-map-popup-title {
    margin: 0;
    font-size: 20px;
    font-weight: bold;
}

.ea-map-popup-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: inherit;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.ea-map-popup-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.ea-map-popup-count {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.ea-map-popup-content {
    padding: 15px 20px;
}

.ea-map-popup-campaigns {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ea-map-popup-campaigns li {
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.ea-map-popup-campaigns li:last-child {
    border-bottom: none;
}

.ea-map-popup-campaigns a {
    color: inherit;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s ease;
}

.ea-map-popup-campaigns a:hover {
    text-decoration: underline;
    opacity: 0.8;
}

.ea-map-popup-loading {
    padding: 20px;
    text-align: center;
    font-style: italic;
}

.ea-map-no-campaigns,
.ea-map-error {
    font-style: italic;
    opacity: 0.8;
}

/* Responsive Design */

/* Tablet */
@media (max-width: 768px) {
    .ea-map-container {
        padding: 15px;
    }

    .ea-map-legend {
        gap: 15px;
        padding: 12px;
    }

    .ea-map-legend-item {
        gap: 6px;
    }

    .ea-map-legend-color {
        width: 16px;
        height: 16px;
    }

    .ea-map-legend-label {
        font-size: 12px;
    }

    .ea-map-popup {
        min-width: 250px;
        max-width: 90%;
        left: 5% !important;
        right: 5%;
    }

    .ea-map-popup-title {
        font-size: 18px;
    }

    .ea-map-svg text {
        font-size: 10px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .ea-map-container {
        padding: 10px;
    }

    .ea-map-legend {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 10px;
    }

    .ea-map-legend-label {
        font-size: 13px;
    }

    .ea-map-popup {
        position: fixed;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%);
        width: 90%;
        max-width: none;
        max-height: 85vh;
    }

    .ea-map-popup-header {
        padding: 12px 15px;
    }

    .ea-map-popup-title {
        font-size: 16px;
    }

    .ea-map-popup-count {
        padding: 8px 15px;
        font-size: 13px;
    }

    .ea-map-popup-content {
        padding: 12px 15px;
    }

    .ea-map-popup-campaigns li {
        padding: 10px 0;
    }

    .ea-map-svg text {
        font-size: 8px;
    }
}

/* Very small screens */
@media (max-width: 360px) {
    .ea-map-popup {
        width: 95%;
    }

    .ea-map-svg text {
        font-size: 6px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .ea-map-svg path:hover {
        opacity: 1;
    }

    .ea-map-svg path {
        -webkit-tap-highlight-color: transparent;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .ea-map-svg {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Print styles */
@media print {
    .ea-map-overlay,
    .ea-map-popup {
        display: none !important;
    }

    .ea-map-container {
        padding: 0;
    }

    .ea-map-legend {
        background-color: transparent;
        border: 1px solid #000;
    }
}

/* Accessibility - Focus styles */
.ea-map-svg path:focus {
    outline: 2px solid #000;
    outline-offset: 1px;
}

.ea-map-popup:focus {
    outline: 2px solid #000;
    outline-offset: 2px;
}

.ea-map-popup-close:focus {
    outline: 2px solid #000;
    outline-offset: 2px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.ea-map-popup.show {
    animation: fadeIn 0.2s ease;
}
