/**
 * NACHEL Affiliates - Map Styles
 * Zoom Controls and Container Styles
 */

/* Map Container */
.namap-container {
    position: relative;
    width: 100%;
    height: 70vh; /* 70% of viewport height - responsive! */
    min-height: 500px; /* Don't get too small on short screens */
    max-height: 900px; /* Don't get too tall on large screens */
    overflow: hidden;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* SVG Container */
#namap-svg {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#namap-svg svg {
    max-width: 100%;
    max-height: 100%;
    display: block;
    margin: auto;
    cursor: grab;
}

#namap-svg svg:active {
    cursor: grabbing;
}

/* Text Labels in SVG - Make them larger and more visible */
#namap-svg text {
    font-size: 24px !important;
    font-weight: bold !important;
    fill: #000000 !important;
    stroke: none !important;
    font-family: Arial, sans-serif !important;
    pointer-events: none; /* So clicks pass through to the region below */
    transform: translateX(-2px); /* Shift left by 2 pixels */
}

/* Loading State */
.namap-loading {
    position: relative;
    text-align: center;
    padding: 40px 20px;
    min-height: 150px;
}

.namap-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2271b1;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: namap-spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes namap-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.namap-loading p {
    color: #666;
    font-size: 14px;
}

/* Zoom Controls Overlay */
.namap-zoom-controls {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 100;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    padding: 5px;
}

.namap-zoom-controls button {
    width: 36px;
    height: 36px;
    border: none;
    background: white;
    color: #2271b1;
    cursor: pointer;
    border-radius: 3px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

.namap-zoom-controls button:hover {
    background: #f0f7ff;
    color: #135e96;
}

.namap-zoom-controls button:active {
    background: #d4e8ff;
}

.namap-zoom-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Font Awesome icon sizing in buttons */
.namap-zoom-controls button i {
    font-size: 16px;
    line-height: 1;
}

/* Modal Overlay */
.namap-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.namap-modal.namap-modal-visible {
    display: block;
    opacity: 1;
}

.namap-modal-content {
    position: relative;
    background-color: #fefefe;
    margin: 5% auto;
    padding: 0;
    border: 1px solid #888;
    border-radius: 8px;
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    animation: namap-slideDown 0.3s ease;
}

/* Loading state - ensure adequate padding */
.namap-modal-content:has(.namap-loading) {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Wider modal for multiple organizations */
.namap-modal-content:has(.namap-multi-org[data-org-count="2"]) {
    max-width: 1100px;
}

.namap-modal-content:has(.namap-multi-org[data-org-count="3"]) {
    max-width: 1400px;
}

@keyframes namap-slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.namap-modal-close {
    position: sticky;
    top: 0;
    right: 0;
    float: right;
    color: #aaa;
    font-size: 32px;
    font-weight: bold;
    line-height: 1;
    padding: 10px 15px;
    cursor: pointer;
    z-index: 1;
    background: white;
    border-radius: 0 8px 0 0;
}

.namap-modal-close:hover,
.namap-modal-close:focus {
    color: #000;
}

/* Modal Content Styles */
.namap-details {
    padding: 30px;
}

.namap-details h2 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 2em;
}

.namap-details h3 {
    margin-top: 20px;
    margin-bottom: 15px;
    color: #34495e;
    font-size: 1.5em;
}

.namap-details h4 {
    margin-top: 15px;
    margin-bottom: 10px;
    color: #555;
    font-size: 1.2em;
}

/* Error State */
.namap-error {
    color: #e74c3c;
    padding: 20px;
    text-align: center;
    font-size: 1.1em;
}

/* Multi-Organization Layout */
.namap-multi-org {
    display: grid;
    gap: 20px;
    margin-top: 20px;
}

.namap-multi-org[data-org-count="2"] {
    grid-template-columns: repeat(2, 1fr);
}

.namap-multi-org[data-org-count="3"] {
    grid-template-columns: repeat(3, 1fr);
}

.namap-org-card {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .namap-multi-org[data-org-count="3"] {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .namap-zoom-controls {
        left: 10px;
        top: 50%;
        transform: translateY(-50%);
    }
    
    .namap-zoom-controls button {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    /* Adjust map height on tablets */
    .namap-container {
        height: 60vh;
        min-height: 400px;
    }
    
    .namap-modal-content {
        width: 95%;
        margin: 5% auto;
    }
    
    .namap-details {
        padding: 20px;
    }
    
    .namap-multi-org[data-org-count="2"],
    .namap-multi-org[data-org-count="3"] {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .namap-zoom-controls {
        left: 10px;
        top: 50%;
        transform: translateY(-50%);
        padding: 3px;
        gap: 3px;
    }
    
    .namap-zoom-controls button {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    
    /* Adjust map height on mobile phones */
    .namap-container {
        height: 50vh;
        min-height: 350px;
    }
    
    .namap-details h2 {
        font-size: 1.5em;
    }
    
    .namap-details h3 {
        font-size: 1.3em;
    }
}

/* Map Legend */
.namap-legend {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: white;
    padding: 12px 16px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    border: 1px solid #ddd;
    z-index: 100;
}

.namap-legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.namap-legend-swatch {
    width: 60px;
    height: 24px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.namap-legend-label {
    font-size: 14px;
    color: #333;
    font-weight: 500;
    white-space: nowrap;
}

/* Responsive legend */
@media (max-width: 768px) {
    .namap-legend {
        bottom: 10px;
        right: 10px;
        padding: 8px 12px;
    }
    
    .namap-legend-swatch {
        width: 50px;
        height: 20px;
    }
    
    .namap-legend-label {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .namap-legend {
        bottom: 70px; /* Move up to avoid zoom controls */
        right: 10px;
        padding: 6px 10px;
    }
    
    .namap-legend-item {
        gap: 8px;
    }
    
    .namap-legend-swatch {
        width: 45px;
        height: 18px;
    }
    
    .namap-legend-label {
        font-size: 11px;
    }
}