/**
 * ULTIMATE INTERACTIVE MAP STYLES
 * Premium design with perfect functionality
 */

#interactiveVillageMap {
    position: relative;
    width: 100%;
    height: 700px;
    min-height: 700px;
    border-radius: 25px;
    background: 
        radial-gradient(ellipse at 20% 30%, rgba(45, 80, 22, 0.12) 0%, transparent 65%),
        radial-gradient(ellipse at 80% 70%, rgba(139, 105, 20, 0.12) 0%, transparent 65%),
        linear-gradient(135deg, rgba(8, 8, 18, 0.98) 0%, rgba(18, 18, 32, 0.98) 100%);
    overflow: hidden;
    border: 3px solid rgba(212, 165, 116, 0.35);
    box-shadow: 
        0 25px 70px rgba(0, 0, 0, 0.7),
        inset 0 0 120px rgba(212, 165, 116, 0.04);
    z-index: 1;
    pointer-events: auto;
}

#interactiveVillageMap::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(212, 165, 116, 0.02) 2px, rgba(212, 165, 116, 0.02) 4px),
        repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(212, 165, 116, 0.02) 2px, rgba(212, 165, 116, 0.02) 4px);
    pointer-events: none;
    z-index: 0;
}

#villageMapCanvas {
    width: 100%;
    height: 100%;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    pointer-events: auto;
    cursor: grab;
    touch-action: none;
}

/* Ultimate Controls */
.map-controls-ultimate {
    position: absolute;
    top: 25px;
    right: 25px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    pointer-events: auto;
}

.map-control-group-ultimate {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-radius: 16px;
    padding: 0.85rem;
    border: 1px solid rgba(212, 165, 116, 0.4);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6);
}

.map-btn-ultimate {
    width: 48px;
    height: 48px;
    background: rgba(212, 165, 116, 0.12);
    border: 1.5px solid rgba(212, 165, 116, 0.5);
    border-radius: 14px;
    color: var(--color-accent);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    pointer-events: auto;
    user-select: none;
}

.map-btn-ultimate::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(212, 165, 116, 0.25);
    transform: translate(-50%, -50%);
    transition: width 0.35s, height 0.35s;
}

.map-btn-ultimate:hover::before {
    width: 120%;
    height: 120%;
}

.map-btn-ultimate:hover {
    background: rgba(212, 165, 116, 0.25);
    border-color: var(--color-accent);
    transform: scale(1.08);
    box-shadow: 0 8px 25px rgba(212, 165, 116, 0.4);
}

.map-btn-ultimate:active {
    transform: scale(0.96);
}

.map-btn-ultimate svg {
    position: relative;
    z-index: 1;
    stroke: currentColor;
}

.map-btn-ultimate.toggle-btn-ultimate.active {
    background: rgba(212, 165, 116, 0.35);
    border-color: var(--color-accent);
    box-shadow: 0 0 18px rgba(212, 165, 116, 0.5);
}

.map-filter-ultimate {
    padding: 0.65rem 1.1rem;
    background: rgba(212, 165, 116, 0.1);
    border: 1.5px solid rgba(212, 165, 116, 0.4);
    border-radius: 12px;
    color: var(--color-text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 170px;
    font-weight: 500;
    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='%23d4a574' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 12px;
    padding-right: 2.5rem;
    pointer-events: auto;
    user-select: none;
}

.map-filter-ultimate:hover {
    background: rgba(212, 165, 116, 0.18);
    border-color: var(--color-accent);
}

.map-filter-ultimate:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.25);
}

/* Ultimate Search */
.map-search-ultimate {
    position: absolute;
    top: 25px;
    left: 25px;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-radius: 35px;
    padding: 0.85rem 1.35rem;
    border: 1.5px solid rgba(212, 165, 116, 0.4);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6);
    min-width: 360px;
    max-width: 520px;
    transition: all 0.3s ease;
    pointer-events: auto;
}

.map-search-ultimate:focus-within {
    border-color: var(--color-accent);
    box-shadow: 0 12px 35px rgba(212, 165, 116, 0.3);
}

.search-icon-ultimate {
    font-size: 1.25rem;
    color: var(--color-accent);
    flex-shrink: 0;
}

.map-search-input-ultimate {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--color-text);
    font-size: 1rem;
    padding: 0.5rem 0;
    outline: none;
    font-weight: 500;
    min-width: 0;
}

.map-search-input-ultimate::placeholder {
    color: var(--color-text-secondary);
    opacity: 0.7;
}

.map-btn-clear-ultimate {
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    line-height: 1;
    flex-shrink: 0;
}

.map-btn-clear-ultimate:hover {
    background: rgba(212, 165, 116, 0.2);
    color: var(--color-accent);
    transform: rotate(90deg) scale(1.1);
}

/* Ultimate Info Panel */
.village-info-panel-ultimate {
    position: absolute;
    bottom: 25px;
    right: 25px;
    width: 420px;
    max-width: calc(100% - 50px);
    background: rgba(0, 0, 0, 0.96);
    backdrop-filter: blur(35px);
    -webkit-backdrop-filter: blur(35px);
    border-radius: 28px;
    padding: 2.25rem;
    border: 2px solid rgba(212, 165, 116, 0.4);
    box-shadow: 
        0 25px 70px rgba(0, 0, 0, 0.8),
        0 0 50px rgba(212, 165, 116, 0.2);
    z-index: 300;
    color: var(--color-text);
    max-height: 85vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 165, 116, 0.5) transparent;
    pointer-events: auto;
}

.village-info-panel-ultimate::-webkit-scrollbar {
    width: 6px;
}

.village-info-panel-ultimate::-webkit-scrollbar-track {
    background: transparent;
}

.village-info-panel-ultimate::-webkit-scrollbar-thumb {
    background: rgba(212, 165, 116, 0.5);
    border-radius: 3px;
}

.village-info-panel-ultimate h3 {
    color: var(--color-accent);
    font-size: 1.85rem;
    margin: 0 0 1.1rem 0;
    padding-right: 3rem;
    font-weight: 800;
    line-height: 1.2;
}

.info-close-ultimate {
    position: absolute;
    top: 1.75rem;
    right: 1.75rem;
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    font-size: 2rem;
    cursor: pointer;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    line-height: 1;
}

.info-close-ultimate:hover {
    background: rgba(212, 165, 116, 0.2);
    color: var(--color-accent);
    transform: rotate(90deg) scale(1.1);
}

.info-photo-ultimate {
    width: 100%;
    height: 240px;
    object-fit: cover;
    border-radius: 22px;
    margin-bottom: 1.75rem;
    border: 2px solid rgba(212, 165, 116, 0.3);
}

.info-desc-ultimate {
    color: var(--color-text-secondary);
    line-height: 1.75;
    margin-bottom: 1.75rem;
    font-size: 1.05rem;
}

.info-stats-ultimate {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
}

.info-stat-ultimate {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--color-text-secondary);
    font-size: 0.98rem;
    padding: 0.6rem 1.15rem;
    background: rgba(212, 165, 116, 0.12);
    border-radius: 14px;
    border: 1px solid rgba(212, 165, 116, 0.25);
}

.stat-icon-ultimate {
    font-size: 1.35rem;
}

.info-meta-ultimate {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
    font-size: 0.92rem;
    color: var(--color-text-secondary);
}

.status-badge-ultimate {
    padding: 0.4rem 1rem;
    border-radius: 22px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.status-badge-ultimate.status-active {
    background: rgba(16, 185, 129, 0.28);
    color: #10b981;
    border: 1.5px solid rgba(16, 185, 129, 0.6);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.35);
}

.status-badge-ultimate.status-forming {
    background: rgba(245, 158, 11, 0.28);
    color: #f59e0b;
    border: 1.5px solid rgba(245, 158, 11, 0.6);
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.35);
}

.info-link-ultimate {
    display: inline-block;
    padding: 1.1rem 2.25rem;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
    color: var(--color-text);
    text-decoration: none;
    border-radius: 32px;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    width: 100%;
    font-size: 1.08rem;
    box-shadow: 0 6px 25px rgba(45, 80, 22, 0.45);
}

.info-link-ultimate:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(45, 80, 22, 0.65);
}

.info-link-ultimate-secondary {
    display: inline-block;
    padding: 0.85rem 1.75rem;
    background: rgba(212, 165, 116, 0.15);
    border: 2px solid rgba(212, 165, 116, 0.4);
    color: var(--color-accent);
    text-decoration: none;
    border-radius: 28px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
    width: 100%;
    margin-bottom: 0.85rem;
    font-size: 0.98rem;
}

.info-link-ultimate-secondary:hover {
    background: rgba(212, 165, 116, 0.25);
    border-color: var(--color-accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 165, 116, 0.45);
}

/* Ultimate Legend */
.map-legend-ultimate {
    position: absolute;
    bottom: 25px;
    left: 25px;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-radius: 16px;
    padding: 1.75rem;
    border: 1.5px solid rgba(212, 165, 116, 0.4);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6);
    z-index: 200;
    font-size: 0.92rem;
    color: var(--color-text);
    min-width: 220px;
    pointer-events: auto;
}

.map-legend-ultimate h4 {
    margin: 0 0 1.25rem 0;
    color: var(--color-accent);
    font-size: 1.15rem;
    font-weight: 700;
}

.legend-item-ultimate {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin: 0.6rem 0;
}

.legend-dot-ultimate {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 8px currentColor;
}

.legend-dot-ultimate.city-dot-ultimate {
    background: rgba(139, 195, 74, 0.85);
    box-shadow: 0 0 12px rgba(139, 195, 74, 0.6);
}

.legend-dot-ultimate.village-dot-ultimate {
    background: rgba(212, 165, 116, 0.95);
    box-shadow: 0 0 12px rgba(212, 165, 116, 0.6);
}

.legend-dot-ultimate.active-dot-ultimate {
    background: rgba(16, 185, 129, 0.95);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.6);
}

.legend-dot-ultimate.forming-dot-ultimate {
    background: rgba(245, 158, 11, 0.95);
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.6);
}

.legend-link-ultimate {
    display: block;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1.5px solid rgba(212, 165, 116, 0.3);
    color: var(--color-accent);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.legend-link-ultimate:hover {
    color: var(--color-accent-light);
    transform: translateX(6px);
}

/* Animations */
@keyframes slideInRightUltimate {
    from {
        transform: translateX(130%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading Indicator */
.map-loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 500;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    padding: 2rem 3rem;
    border-radius: 20px;
    border: 2px solid rgba(212, 165, 116, 0.4);
    color: var(--color-text);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(212, 165, 116, 0.2);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error Indicator */
.map-error-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 500;
    background: rgba(239, 68, 68, 0.95);
    backdrop-filter: blur(20px);
    padding: 1.5rem 2.5rem;
    border-radius: 16px;
    border: 2px solid rgba(239, 68, 68, 0.6);
    color: white;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.5);
    max-width: 400px;
}

/* Responsive */
@media (max-width: 768px) {
    .map-controls-ultimate {
        top: 15px;
        right: 15px;
    }

    .map-search-ultimate {
        top: 15px;
        left: 15px;
        min-width: 260px;
        max-width: calc(100% - 200px);
    }

    .village-info-panel-ultimate {
        bottom: 15px;
        right: 15px;
        width: calc(100% - 30px);
        max-width: none;
        padding: 1.75rem;
    }

    .map-legend-ultimate {
        bottom: 15px;
        left: 15px;
        font-size: 0.85rem;
        padding: 1.25rem;
        min-width: 180px;
    }

    .map-control-group-ultimate {
        flex-direction: row;
        gap: 0.4rem;
    }
    
    .map-btn-ultimate {
        width: 42px;
        height: 42px;
    }
}

