/* Spain Map Styles */

.spainmap-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
}

/* Legend styles - horizontal above map */
.spainmap-legend {
    width: 100%;
    max-width: 1282.91px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.spainmap-legend-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0 0 16px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid #e0e0e0;
}

.spainmap-legend-items {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.spainmap-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.spainmap-legend-color {
    width: 24px;
    height: 24px;
    border: 1px solid #ccc;
    border-radius: 4px;
    flex-shrink: 0;
}

.spainmap-legend-label {
    font-size: 12px;
    color: #333;
    line-height: 1.4;
    flex: 1;
}

.spainmap-container {
    width: 100%;
    max-width: 1282.91px;
    margin: 0 auto;
    padding: 0;
}

.spainmap-svg-wrapper,
#spainmap-svg-container {
    width: 100%;
    display: block;
    padding-top: 0 !important;
    margin-top: 0 !important;
    pointer-events: auto !important;
}

.spainmap-svg-wrapper svg,
#spainmap-svg-container svg {
    width: 100%;
    height: auto;
    max-width: 100%;
    display: block !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

/* Remove top padding/spacing for um-layer-canvas-background */
/* Target any element with um-layer-canvas-background in class or id */
.spainmap-svg-wrapper svg [class*="um-layer-canvas-background"],
.spainmap-svg-wrapper svg [id*="um-layer-canvas-background"],
.spainmap-svg-wrapper svg [class*="canvas-background"],
.spainmap-svg-wrapper svg [id*="canvas-background"],
.spainmap-svg-wrapper svg rect[id*="um-layer-canvas-background"],
.spainmap-svg-wrapper svg rect[id*="canvas-background"] {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    transform: translateY(0) !important;
}

/* Move the canvas background rect up to remove top spacing */
.spainmap-svg-wrapper svg rect[id="um-layer-canvas-background"] {
    y: 0 !important;
    transform: translateY(0) !important;
}

/* Hover effects for paths - border highlight and cursor */
.spainmap-svg-wrapper svg path[id],
#spainmap-svg-container svg path[id] {
    transition: stroke-width 0.2s ease;
    pointer-events: all !important;
    cursor: pointer !important;
    stroke: #ffffff;
    stroke-width: 1px;
}

/* Hover state - subtle border increase */
.spainmap-svg-wrapper svg path[id]:hover,
#spainmap-svg-container svg path[id]:hover {
    stroke-width: 2.5px;
}

/* Ensure all paths are hoverable, including those with fill="none" */
.spainmap-svg-wrapper svg path[id][fill="none"],
#spainmap-svg-container svg path[id][fill="none"] {
    pointer-events: all !important;
}

/* Groups containing paths should also be hoverable */
.spainmap-svg-wrapper svg g[id] path[id],
#spainmap-svg-container svg g[id] path[id] {
    pointer-events: all !important;
}

/* Make sure text elements don't block path interactions */
.spainmap-svg-wrapper svg text {
    pointer-events: none;
}

/* Region marker circles (for Melilla, Ceuta, etc.) */
.spainmap-svg-wrapper svg circle.spainmap-region-marker {
    cursor: pointer;
    transition: r 0.2s ease, fill 0.2s ease;
}

.spainmap-svg-wrapper svg circle.spainmap-region-marker:hover {
    r: 5;
    fill: #4a90e2;
}

/* Ensure custom labels are visible and on top of all other elements */
.spainmap-svg-wrapper svg text[id^="spainmap-label-"],
.spainmap-svg-wrapper svg text.spainmap-region-label {
    fill: #000000 !important;
    font-size: 10px !important;
    font-weight: bold !important;
    font-family: Arial, sans-serif !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
    pointer-events: none !important;
    cursor: default;
    /* Add white stroke to make text stand out above borders */
    stroke: #ffffff;
    stroke-width: 0.5px;
    stroke-linejoin: round;
    paint-order: stroke fill;
}

/* Info panel */
.spainmap-info-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border: 2px solid #4a90e2;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 300px;
    z-index: 1000;
}

.spainmap-info-panel h3 {
    margin-top: 0;
    color: #4a90e2;
}

.spainmap-info-panel p {
    margin-bottom: 0;
    line-height: 1.6;
}

/* Modal Styles */
.spainmap-modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.6) !important;
    z-index: 999999 !important;
    display: none;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* Show overlay when it has the 'show' class or inline style */
.spainmap-modal-overlay.show,
.spainmap-modal-overlay[style*="display: flex"],
.spainmap-modal-overlay[style*="display:block"] {
    display: flex !important;
}

.spainmap-modal {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
    position: relative;
    z-index: 1000000;
    margin: 0;
}

.spainmap-modal.active {
    transform: scale(1);
    opacity: 1;
}

.spainmap-modal-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.spainmap-modal-header h2 {
    margin: 0;
    font-size: 24px;
    color: #333;
}

.spainmap-modal-close {
    background: none;
    border: none;
    font-size: 32px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    line-height: 32px;
    transition: color 0.2s ease;
}

.spainmap-modal-close:hover {
    color: #000;
}

.spainmap-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.spainmap-modal-section {
    margin-bottom: 30px;
}

.spainmap-modal-section:last-child {
    margin-bottom: 0;
}

.spainmap-modal-section h3 {
    display: none !important;
}

.spainmap-form-group {
    margin-bottom: 20px;
}

.spainmap-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.spainmap-form-group input[type="text"],
.spainmap-form-group input[type="color"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.spainmap-form-group input[type="text"]:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.spainmap-form-group input[type="color"] {
    height: 50px;
    cursor: pointer;
}

.spainmap-form-actions {
    margin-top: 20px;
    text-align: right;
}

.spainmap-form-actions .btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.spainmap-form-actions .btn-primary {
    background-color: #4a90e2;
    color: white;
}

.spainmap-form-actions .btn-primary:hover {
    background-color: #357abd;
}

.spainmap-items-container {
    min-height: 200px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: flex-start;
}

.spainmap-empty-message {
    text-align: center;
    color: #999;
    font-style: italic;
    margin: 0;
}

/* Agent (item) card */
.spainmap-agent-card {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px 20px;
    width: 220px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 320px;
    }
    
.spainmap-agent-tag {
    width: fit-content;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 8px;
    font-weight: bold;
    text-transform: uppercase;
    color: #ffffff;
    text-align: center;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
    }
    
.spainmap-agent-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #e0e0e0;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #9e9e9e;
    overflow: hidden;
    flex-shrink: 0;
    }
    
.spainmap-agent-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    }

/* Responsive: Dropdown selector for mobile devices */
.spainmap-accordion-container {
    display: none;
}

/* Mobile styles - show dropdown selector, hide map and legend */
@media screen and (max-width: 768px) {
    .spainmap-wrapper {
        display: none !important;
    }
    
    .spainmap-container {
        display: none !important;
    }
    
    .spainmap-legend {
        display: none !important;
    }
    
    .spainmap-accordion-container {
        display: block;
        width: 100%;
        padding: 10px;
    }
    
    
    .spainmap-accordion {
        width: 100%;
    }
    
    /* Dropdown selector styles */
    .spainmap-select-wrapper {
        margin-bottom: 20px;
    }
    
    .spainmap-region-select {
        width: 100%;
        padding: 12px 16px;
        font-size: 16px;
        border: 2px solid #e0e0e0;
        border-radius: 8px;
        background: #ffffff;
        color: #333;
        cursor: pointer;
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 16px center;
        background-size: 12px;
        padding-right: 40px;
        transition: border-color 0.2s ease;
    }
    
    .spainmap-region-select:hover {
        border-color: #4a90e2;
    }
    
    .spainmap-region-select:focus {
        outline: none;
        border-color: #4a90e2;
        box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
    }
    
    /* Results container */
    .spainmap-mobile-results {
        margin-top: 20px;
    }
    
    .spainmap-mobile-region-info {
        display: none; /* Hide region info section on mobile */
    }
    
    .spainmap-mobile-region-title {
        font-size: 20px;
        font-weight: 600;
        color: #333;
        margin: 0 0 12px 0;
    }
    
    .spainmap-accordion-agents {
        margin-top: 20px;
    }
    
    .spainmap-accordion-agents-title {
        display: none; /* Remove "Region Items" heading in mobile view */
    }
    
    /* Hide admin settings in modal on mobile for non-admin users */
    .spainmap-modal #spainmap-admin-settings {
        display: none !important;
    }
    
    /* Agent cards in mobile view - stack vertically */
    .spainmap-mobile-results .spainmap-items-container {
        flex-direction: column;
        gap: 12px;
    }
    
    .spainmap-mobile-results .spainmap-agent-card {
        width: 100%;
        max-width: 100%;
    }
}
    
.spainmap-agent-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 4px;
    color: #222222;
    }
    
.spainmap-agent-role {
    font-size: 13px;
    color: #757575;
    margin-bottom: 12px;
    }
    
.spainmap-agent-contact-btn {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    background-color: #1e88e5;
    color: #ffffff;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    margin-top: auto;
    }
    
.spainmap-agent-contact-btn:hover {
    background-color: #1669bb;
    color: #ffffff !important;
    }
    
/* Responsive design */
@media (max-width: 768px) {
    .spainmap-container {
        padding: 10px;
    }
    
    .spainmap-modal {
        width: 95%;
        max-height: 95vh;
    }
    
    .spainmap-modal-header h2 {
        font-size: 20px;
    }
    
    .spainmap-modal-body {
        padding: 15px;
    }
}
