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

body {
    font-family: 'Arial', sans-serif;
    background: #e0f2fe;

    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.6);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #3c5ab5 0%, #7dd3fc 100%);
    color: white;
    text-align: center;
    padding: 20px;
    border-bottom: 2px solid #f9fafb;
    box-shadow: 0 4px 20px rgba(30, 58, 138, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.header h2 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-family: 'Merriweather', serif;
    font-weight: 900;
}

.header-text {
    display: inline;
}

.header-line1,
.header-line2 {
    display: inline;
}

.header-logo {
    height: 48px;
    width: auto;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.2));
    transition: transform 0.3s ease;
}

.header-logo:hover {
    transform: scale(1.05);
}

.map-container {
    position: relative;
    padding: 10px;
    background: #f8f9fa;
}

.map-wrapper {
    position: relative;
    width: 100%;
    margin: 0 auto;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.map-image {
    width: 100%;
    height: auto;
    display: block;
}

.commune-area {
    position: absolute;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 3px;
}

.commune-area:hover {
    background-color: rgba(255, 215, 0, 0.4);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
    transform: scale(1.02);
    z-index: 10;
}

.commune-area.active {
    background-color: rgba(255, 215, 0, 0.6);
    box-shadow: 0 0 20px rgba(255, 215, 0, 1);
    transform: scale(1.05);
    z-index: 15;
}

/* Tooltip Styles */
.tooltip {
    position: fixed;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: none;
    z-index: 9999;
    width: 400px;
    max-width: 90vw;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    font-family: 'Roboto', sans-serif;
    opacity: 0;
    transition: opacity 0.3s ease;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 1px solid #d1d5db;
}

.tooltip.show {
    display: block;
    opacity: 1;
}

/* --- HEADER --- */
.card-header {
    background-color: #4f7dc9;
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #f59e0b;
}

.card-header h2 {
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.location-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.location-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* --- BODY CONTENT --- */
.card-body {
    padding: 10px;
}

/* Stats Grid (Diện tích / Dân số) */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 10px;
}

.stat-box {
    background-color: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.stat-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.stat-label i {
    color: #2563eb;
    font-size: 14px;
}

.stat-box>div:last-child {
    font-size: 15px;
    font-weight: 700;
    color: #1f2937;
}

.stat-unit {
    font-size: 12px;
    font-weight: 400;
    color: #6b7280;
}

/* Address Section */
.address-section {
    background-color: #eff6ff;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.home-icon {
    background-color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2563eb;
    border: 1px solid #bfdbfe;
    flex-shrink: 0;
}

.address-content h3 {
    font-size: 11px;
    color: #2563eb;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 4px;
    margin: 0 0 4px 0;
}

.address-content p {
    font-size: 13px;
    color: #42454b;
    font-weight: 500;
    line-height: 1.4;
    margin: 0;
}

/* Metrics List (Ngân sách, Đảng viên...) */
.metrics-list {
    list-style: none;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 10px;
    padding: 0;
}

.metric-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 13px;
}

.metric-item:last-child {
    border-bottom: none;
}

.metric-label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #1f2937;
    font-weight: 500;
}

.metric-value {
    font-weight: 700;
    color: #1f2937;
}

/* Icon Colors specific to row */
.icon-green {
    color: #10b981;
}

.icon-red {
    color: #ef4444;
}

.icon-blue {
    color: #3b82f6;
}

.icon-purple {
    color: #8b5cf6;
}

.icon-orange {
    color: #f97316;
}

/* Info Box (Sáp nhập) */
.info-box {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    gap: 10px;
}

.info-icon {
    color: #6b7280;
    margin-top: 2px;
}

.info-text h4 {
    font-size: 12px;
    color: #1f2937;
    font-weight: 600;
    margin-bottom: 2px;
    margin: 0 0 2px 0;
}

.info-text p {
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
    margin: 0;
}

/* --- FOOTER --- */
.card-footer {
    background-color: #f8fafc;
    border-top: 1px solid #e5e7eb;
    padding: 16px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.official-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    border: 1px solid #e5e7eb;
    background-color: white;
}

.avatar-red {
    color: #ef4444;
    border-color: #fca5a5;
}

.avatar-blue {
    color: #3b82f6;
    border-color: #93c5fd;
}

.avatar-green {
    color: #10b981;
    border-color: #6ee7b7;
}

.avatar-orange {
    color: #f97316;
    border-color: #fdba74;
}

.profile-info {
    display: flex;
    flex-direction: column;
}

.role-title {
    font-size: 10px;
    text-transform: uppercase;
    color: #9ca3af;
    font-weight: 700;
}

.official-name {
    font-size: 13px;
    font-weight: 700;
    color: #1f2937;
    margin: 1px 0;
}

.phone-number {
    font-size: 11px;
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
}

/* Close Button */
.close-btn {
    display: none;
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Mobile adjustment */
@media (max-width: 400px) {
    .card-footer {
        /* Giữ nguyên 2 cột nhưng giảm khoảng cách để không bị vỡ giao diện */
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        /* Giảm gap */
        padding: 12px;
        /* Giảm padding một chút */
    }

    .official-profile {
        gap: 6px;
        /* Giảm khoảng cách giữa avatar và text */
    }

    .official-name {
        font-size: 12px;
        /* Giảm font tên một chút nếu cần */
    }
}


.search-container {
    background: linear-gradient(135deg, #bae6fd 0%, #7dd3fc 100%);
    padding: 5px;
    display: flex;
    justify-content: center;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05), 0 2px 8px rgba(59, 130, 246, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

.search-box {
    position: relative;
    max-width: 380px;
    width: 100%;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: white;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.8);
    height: 42px;
}

.search-input-wrapper:focus-within {
    transform: translateY(-1px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.4);
}

#searchInput {
    flex: 1;
    border: none;
    outline: none;
    padding: 10px 16px;
    font-size: 16px;
    background: transparent;
    color: #333;
    font-weight: 500;
    transition: all 0.3s ease;
}

#searchInput::placeholder {
    color: #9ca3af;
    transition: color 0.3s ease;
    font-weight: 400;
}

#searchInput:focus::placeholder {
    color: #d1d5db;
}

.clear-btn,
.search-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 8px 10px;
    color: #6b7280;
    font-size: 16px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin: 3px;
}

.clear-btn:hover,
.search-btn:hover {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.08);
    transform: scale(1.08);
}

.search-btn {
    background: #7dd3fc;
    color: white;
    font-size: 14px;
}

.search-btn:hover {
    background: #60a5fa;
    color: white;
    transform: scale(1.03);
}

.suggestions {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: white;
    border-radius: 16px;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.12);
    max-height: 280px;
    overflow: hidden;
    z-index: 1000;
    display: none;
    border: 1px solid rgba(59, 130, 246, 0.08);
    backdrop-filter: blur(8px);
}

.suggestions::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid white;
    filter: drop-shadow(0 -1px 2px rgba(0, 0, 0, 0.08));
}

.suggestion-item {
    padding: 12px 18px;
    cursor: pointer;
    color: #374151;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: 1px solid #f3f4f6;
    position: relative;
    overflow: hidden;
}

.suggestion-item:hover {
    background: linear-gradient(90deg, #f9fafb 0%, #f3f4f6 100%);
    color: #3b82f6;
    transform: translateX(3px);
}

.suggestion-item:last-child {
    border-bottom: none;
    border-radius: 0 0 16px 16px;
}

.suggestion-item:first-child {
    border-radius: 16px 16px 0 0;
}

.suggestion-item.selected {
    background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    transform: translateX(6px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.suggestion-item .highlight {
    background: rgba(59, 130, 246, 0.15);
    color: #1e40af;
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.suggestion-item.selected .highlight {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.no-results {
    padding: 16px 18px;
    color: #6b7280;
    font-style: italic;
    text-align: center;
    font-size: 13px;
}

@media (max-width: 768px) {
    .search-container {
        padding: 8px 15px;
    }

    .search-box {
        max-width: 100%;
    }

    .search-input-wrapper {
        height: 38px;
        border-radius: 18px;
    }

    #searchInput {
        padding: 8px 14px;
        font-size: 16px;
    }

    .clear-btn,
    .search-btn {
        padding: 6px 8px;
        font-size: 14px;
        width: 32px;
        height: 32px;
        margin: 3px;
    }

    .suggestions {
        border-radius: 14px;
        top: calc(100% + 5px);
        max-height: 240px;
    }

    .suggestion-item {
        padding: 10px 16px;
        font-size: 12px;
    }

    .suggestion-item:first-child {
        border-radius: 14px 14px 0 0;
    }

    .suggestion-item:last-child {
        border-radius: 0 0 14px 14px;
    }

    .no-results {
        padding: 14px 16px;
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .header h2 {
        flex-direction: row;
        gap: 10px;
        font-size: 1.2rem;
        align-items: center;
    }

    .header-logo {
        height: 40px;
        flex-shrink: 0;
    }

    .header-text {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .header-line1 {
        display: block;
        font-size: 1em;
        line-height: 1.2;
    }

    .header-line2 {
        display: block;
        font-size: 0.75em;
        line-height: 1.2;
    }

    .header h1 {
        font-size: 2rem;
    }

    .map-container {
        padding: 0px;
    }

    .tooltip {
        width: calc(100% - 30px);
        max-width: 380px;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        max-height: 85vh;
        border-radius: 12px;
    }

    .card-header {
        padding: 12px 15px;
    }

    .card-body {
        padding: 10px;
    }

    .stats-grid {
        gap: 10px;
    }

    .stat-box {
        padding: 10px;
    }

    .card-footer {
        padding: 12px;
        gap: 12px;
    }

    .close-btn {
        display: flex;
        top: 12px;
        right: 12px;
        background: rgba(255, 255, 255, 0.2);
    }
}

@media (max-width: 480px) {
    .card-header h2 {
        font-size: 14px;
    }
}

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.tooltip-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tooltip-backdrop.show {
    display: block;
    opacity: 1;
}