* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    font-size: 16px;
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

/* Main Content Layout */
.content {
    display: flex;
    gap: 20px;
    padding: 20px;
    height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
}

/* Section Box Styles */
.map-section,
.info-section {
    background: white;
    border: 3px solid #2c5282;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.map-section {
    flex: 1.2;
}

.info-section {
    flex: 1;
    min-width: 400px;
    max-width: 600px;
}

.section-header {
    background: linear-gradient(135deg, #2c5282 0%, #1a365d 100%);
    color: white;
    padding: 16px 20px;
    border-bottom: 3px solid #1a365d;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.section-header h2 {
    margin: 0;
    font-size: 1.3em;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Legend inline in header */
.legend-inline {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.legend-inline .legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85em;
    background: rgba(255,255,255,0.15);
    padding: 4px 8px;
    border-radius: 4px;
}

.legend-inline .legend-color {
    width: 16px;
    height: 16px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 3px;
}

/* Map Container */
#map-container {
    flex: 1;
    position: relative;
    background: #f8fafc;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#map-container svg {
    width: 95%;
    height: 95%;
    max-width: 100%;
    max-height: 100%;
}

.map-source-text {
    text-align: center;
    font-size: 1rem;
    color: #868686;
    margin-top: 10px;
    margin-bottom: 10px;
    font-style: italic;
}

/* SVG District Styles */
#map-container svg path,
#map-container svg polygon {
    stroke: #94a3b8;
    stroke-width: 1.5;
    fill: #e0e0e0;
    transition: all 0.3s ease;
    cursor: pointer;
}

#map-container svg path:hover,
#map-container svg polygon:hover {
    stroke: #2c5282;
    stroke-width: 2.5;
    filter: brightness(1.05);
}

/* Selected District */
.district-selected {
    stroke: #dc2626 !important;
    stroke-width: 3.5 !important;
    filter: drop-shadow(0 0 8px rgba(241, 8, 8, 0.4)) brightness(1.2) !important;
    animation: pulse 2s infinite;
}

/* Language Highlight - districts containing selected language */
.language-highlight {
    stroke: #06261c  !important;
    stroke-width: 3 !important;
    filter: drop-shadow(0 0 6px rgba(4, 79, 55, 0.4)) brightness(1.15) !important;
    animation: glow 1.5s ease-in-out infinite alternate;
}

@keyframes pulse {
    0%, 100% { stroke-opacity: 1; }
    50% { stroke-opacity: 0.7; }
}

@keyframes glow {
    from { filter: drop-shadow(0 0 4px rgba(5, 150, 105, 0.4)) brightness(1.15); }
    to { filter: drop-shadow(0 0 12px rgba(5, 150, 105, 0.6)) brightness(1.25); }
}

/* Info Container */
#info-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(to bottom, #fafafa 0%, #ffffff 100%);
}

#info-container.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.empty-state {
    padding: 40px 20px;
    color: #666;
}

.empty-icon {
    font-size: 4em;
    margin-bottom: 20px;
    opacity: 0.7;
}

.empty-state h3 {
    color: #2c5282;
    font-size: 1.6em;
    margin-bottom: 12px;
    font-weight: 700;
}

.empty-state p {
    font-size: 1.05em;
    line-height: 1.7;
    color: #555;
    max-width: 280px;
    margin: 0 auto;
}

/* Info Header */
.info-header {
    background: linear-gradient(135deg, #e8f0f8 0%, #d4e4f7 100%);
    padding: 20px;
    margin: -20px -20px 20px -20px;
    border-bottom: 3px solid #2c5282;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-title {
    font-size: 1.8em;
    font-weight: 800;
    color: #1a365d;
    margin: 0 0 12px 0;
    font-family: 'Georgia', serif;
}

.info-stats {
    display: flex;
    align-items: center;
    gap: 10px;
}

.info-count {
    background: #2c5282;
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 1.2em;
    font-weight: 700;
}

.info-label {
    color: #4a5568;
    font-weight: 600;
    font-size: 1em;
}

/* Language Family Section */
.info-family {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e2e8f0;
}

.info-family:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.info-family h3 {
    color: #1a365d;
    font-size: 1.15em;
    font-weight: 700;
    margin-bottom: 14px;
    padding-left: 10px;
    border-left: 4px solid #2c5282;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.family-count {
    font-size: 0.8em;
    font-weight: 500;
    color: #666;
    background: #f0f4f8;
    padding: 3px 10px;
    border-radius: 12px;
}

/* Language List */
.info-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.info-card {
    background: white;
    padding: 14px;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    cursor: pointer;
}

.info-card:hover {
    border-color: #059669;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.2);
    transform: translateY(-2px);
    background: #f0fdf4;
}

.info-card.active-language {
    border-color: #059669;
    background: #d1fae5;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.info-card .lang-name {
    font-size: 1.05em;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 4px;
    line-height: 1.3;
}

.info-card .lang-code {
    color: #2c5282;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    background: #f0f4f8;
    padding: 3px 6px;
    border-radius: 4px;
    display: inline-block;
}

.info-card .lang-code::before {
    content: 'ISO: ';
    font-weight: 400;
    font-family: 'Georgia', 'Times New Roman', serif;
    color: #666;
}

/* No data message */
.no-data {
    text-align: center;
    padding: 50px 20px;
    color: #666;
}

.no-data-icon {
    font-size: 3em;
    margin-bottom: 16px;
    opacity: 0.5;
}

.no-data h3 {
    color: #2c5282;
    font-size: 1.4em;
    margin-bottom: 10px;
}

/* Tooltip */
.tooltip {
    position: fixed;
    background: rgba(26, 54, 93, 0.95);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.95em;
    pointer-events: none;
    z-index: 3000;
    max-width: 300px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.1);
    display: none;
}

.tooltip-district {
    font-weight: 700;
    font-size: 1.1em;
    margin-bottom: 8px;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-bottom: 6px;
}

.tooltip-languages {
    color: #e2e8f0;
    line-height: 1.5;
}

/* Scrollbar */
#info-container::-webkit-scrollbar {
    width: 8px;
}

#info-container::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 10px;
    margin: 8px 0;
}

#info-container::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #2c5282 0%, #1a365d 100%);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

/* Mobile Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: #ffffff;
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 92%;
    max-width: 600px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.modal-header {
    padding: 20px;
    background: linear-gradient(135deg, #2c5282 0%, #1a365d 100%);
    position: relative;
}

.close {
    position: absolute;
    right: 16px;
    top: 16px;
    color: white;
    font-size: 28px;
    font-weight: 300;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close:hover {
    background: rgba(255,255,255,0.2);
    transform: rotate(90deg);
}

#modalTitle {
    color: white;
    margin: 0;
    padding-right: 50px;
    font-size: 1.6em;
    font-weight: 700;
}

#modalBody {
    max-height: 65vh;
    overflow-y: auto;
    padding: 20px;
}

/* Mobile Responsive */
@media (max-width: 900px) {
    .content {
        flex-direction: column;
        padding: 10px;
        gap: 10px;
        position: relative;
        height: 100vh;
        overflow: hidden;
    }
    
    .map-section {
        flex: 1;
        min-height: 60vh;
        display: flex;
        flex-direction: column;
    }
    
    #map-container {
        flex: 1;
        min-height: 0; /* Important for flex child scrolling */
    }
    
    /* Info panel as slide-in overlay on mobile */
    .info-section {
        position: fixed;
        top: 0;
        right: -100%;
        width: 85%;
        max-width: 380px;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile */
        z-index: 2500;
        transition: right 0.3s ease;
        border-radius: 0;
        border-left: 3px solid #2c5282;
        border-top: none;
        border-bottom: none;
        border-right: none;
        display: flex !important;
        flex-direction: column;
        min-width: auto;
        background: white;
    }
    
    .info-section.active {
        right: 0;
    }
    
    /* Make info container scrollable on mobile */
    #info-container {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        padding: 16px;
    }
    
    /* Backdrop when info is open */
    .info-backdrop {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        background: rgba(0,0,0,0.5);
        z-index: 2400;
        touch-action: none; /* Prevent touch events passing through */
    }
    
    .info-backdrop.active {
        display: block;
    }

    .info-header {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .section-header {
        padding: 14px 16px;
        flex-shrink: 0; /* Prevent header from shrinking */
    }
    
    .section-header h2 {
        font-size: 1.1em;
        padding-right: 40px; /* Space for close button */
    }
    
    .legend-inline {
        display: none;
    }
    
    /* Mobile legend below map */
    .mobile-legend {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px;
        background: white;
        border-top: 2px solid #2c5282;
        flex-shrink: 0;
    }
    
    .mobile-legend .legend-item {
        display: flex;
        align-items: center;
        gap: 4px;
        font-size: 0.75em;
    }
    
    .mobile-legend .legend-color {
        width: 14px;
        height: 14px;
        border: 1px solid #999;
        border-radius: 2px;
    }
    
    /* Close button for mobile panel */
    .info-close-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 10px;
        right: 10px;
        background: rgba(255,255,255,0.2);
        border: none;
        color: white;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        font-size: 24px;
        line-height: 1;
        cursor: pointer;
        z-index: 10;
        transition: background 0.2s;
    }
    
    .info-close-btn:hover {
        background: rgba(255,255,255,0.3);
    }
    
    /* Hide tooltip on mobile */
    .tooltip {
        display: none !important;
    }
    
    /* Ensure proper touch handling */
    .info-section * {
        touch-action: auto;
    }
}

@media (min-width: 901px) {
    .mobile-only,
    .info-backdrop,
    .info-close-btn,
    .mobile-legend {
        display: none !important;
    }
}

.bengali-card {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-color: #f59e0b;
}

.bengali-card:hover {
    border-color: #d97706;
    background: linear-gradient(135deg, #fde68a 0%, #fcd34d 100%);
}