/* Maps Section Styles */
.maps-section {
    padding: 4rem 0;
    background: #f8f9fa;
}

.maps-section h2 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 3rem;
    font-size: 2.5rem;
}

/* Tabs */
.maps-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 12px 24px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-dark);
    font-family: 'Vazirmatn';
}

.tab-btn:hover {
    background: var(--bg-light);
    border-color: var(--primary-color);
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Map Containers */
.map-container {
    display: none;
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.map-container.active {
    display: block;
}

/* Map Legend */


.map-legend h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.color-box {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

/* Role Stats */
.role-stats {
    position: absolute;
    top: 30px;
    right: 30px;
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    max-width: 300px;
}

/* Realtime Feed */
.realtime-feed {
    position: absolute;
    top: 30px;
    left: 30px;
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    max-width: 300px;
    max-height: 400px;
    overflow-y: auto;
}

.realtime-feed h4 {
    margin: 0 0 1rem 0;
    color: var(--primary-color);
}

.realtime-item {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    animation: slideIn 0.5s ease-out;
}

.realtime-item:last-child {
    border-bottom: none;
}

.realtime-name {
    font-weight: 600;
    color: var(--primary-color);
}

.realtime-info {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.realtime-time {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Pulse Animation for New Supporters */
.pulse-marker {
    width: 20px;
    height: 20px;
    background: var(--accent-color);
    border-radius: 50%;
    position: absolute;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.5);
        opacity: 0.7;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .map-legend,
    .role-stats,
    .realtime-feed {
        position: relative;
        top: auto;
        right: auto;
        left: auto;
        margin-top: 1rem;
        max-width: 100%;
    }
    
    #world-map-country,
    #world-map-role,
    #world-map-realtime {
        height: 300px !important;
    }
}

/* RTL Support */
[dir="rtl"] .map-legend {
    right: auto;
    left: 30px;
}

[dir="rtl"] .realtime-feed {
    left: auto;
    right: 30px;
}

[dir="rtl"] .role-stats {
    right: auto;
    left: 30px;
}

/* Tooltip Styles */
.country-tooltip {
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    pointer-events: none;
}

.country-tooltip .country-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.country-tooltip .supporter-count {
    font-size: 12px;
}

/* اصلاح موقعیت باکس راهنما */
.map-legend {
 position: absolute;
 bottom: 30px;
 left: 30px; /* تغییر از right به left */
 background: white;
 padding: 1rem;
 border-radius: 8px;
 box-shadow: 0 2px 10px rgba(0,0,0,0.1);
 z-index: 400; /* کاهش z-index */
}

/* برای زبان‌های RTL */
[dir="rtl"] .map-legend {
 left: auto;
 right: 30px;
}

/* اصلاح container نقشه */
.map-container {
 position: relative; /* اضافه کردن position relative */
 display: none;
 background: white;
 border-radius: 12px;
 padding: 2rem;
 box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

/* اطمینان از نمایش صحیح نقشه */
#world-map-country,
#world-map-role,
#world-map-realtime {
 position: relative;
 z-index: 1;
}

/* Pulse Animation */
.pulse-marker {
 position: relative;
}

.pulse-circle {
 width: 20px;
 height: 20px;
 background: #ff6b6b;
 border-radius: 50%;
 position: absolute;
 top: 50%;
 left: 50%;
 transform: translate(-50%, -50%);
}

.pulse-circle::before {
 content: '';
 position: absolute;
 width: 100%;
 height: 100%;
 background: #ff6b6b;
 border-radius: 50%;
 animation: pulse-animation 2s ease-out infinite;
}

@keyframes pulse-animation {
 0% {
 transform: scale(1);
 opacity: 1;
 }
 100% {
 transform: scale(3);
 opacity: 0;
 }
}

/* Fix for map container */
.map-container {
 position: relative;
 overflow: hidden;
}

/* Ensure proper z-index */
.leaflet-container {
 z-index: 1;
}

.map-legend,
.role-stats,
.realtime-feed {
 z-index: 1000;
}

/* استایل برای راهنمای نقشه */
.info.legend {
    line-height: 20px;
    color: #555;
}

.info.legend i {
    vertical-align: middle;
}

/* استایل برای لیبل‌های روی نقشه */
.role-label {
    background: none !important;
    border: none !important;
}

/* بهبود ظاهر popup ها */
.leaflet-popup-content {
    font-family: 'Vazir', sans-serif;
    direction: rtl;
}

.leaflet-popup-content h4 {
    font-size: 16px;
    font-weight: bold;
}

/* Role Map Specific Styles */
.role-map-wrapper {
    position: relative;
    flex: 1;
}

.role-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
}

.role-legend h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 600;
}

.role-legend .legend-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.role-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.role-legend .color-box {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.1);
}

#map-role {
    display: flex;
    gap: 20px;
}

.role-stats {
    width: 350px;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.role-stats h4 {
    margin: 0 0 20px 0;
    text-align: center;
}

#role-percentages {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.role-percentage-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
}

.role-percentage-item:last-child {
    border-bottom: none;
}

.role-percentage-bar {
    flex: 1;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    margin: 0 10px;
    overflow: hidden;
}

.role-percentage-fill {
    height: 100%;
    transition: width 0.3s ease;
}

/* Pie slices for country markers */
.country-role-marker {
    position: relative;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

/* تب‌های نقشه */
.map-container {
 display: none; /* همه تب‌ها مخفی باشند */
}

.map-container.active {
 display: block; /* فقط تب فعال نمایش داده شود */
}

/* اطمینان از اینکه تب اول در ابتدا نمایش داده شود */
#map-country {
 display: block;
}

/* استایل برای container تب دوم */
#map-role {
    display: none; /* پیش‌فرض مخفی */
    flex-direction: row;
    gap: 20px;
    align-items: flex-start;
}

#map-role.active {
    display: flex !important;
}

/* نقشه و باکس آمار */
.role-map-wrapper {
    flex: 1;
    position: relative;
    min-height: 500px;
}

.role-stats {
    width: 350px;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    max-height: 600px;
    overflow-y: auto;
}

/* برای موبایل */
@media screen and (max-width: 768px) {
    #map-role {
        flex-direction: column;
    }
    
    .role-stats {
        width: 100%;
        max-height: none;
        margin-top: 20px;
    }
}

/* اطمینان از نمایش صحیح canvas */
#roleChart {
    max-width: 100%;
    height: auto !important;
}

.role-stats h4 {
    margin: 0 0 20px 0;
    text-align: center;
    font-size: 18px;
    color: #333;
}

#role-percentages {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

/* اسکرول برای محتوای زیاد */
.role-stats::-webkit-scrollbar {
    width: 6px;
}

.role-stats::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.role-stats::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.role-stats::-webkit-scrollbar-thumb:hover {
    background: #555;
}