/* Wide Container Mode for Rankings - Updated to match global header width */
.container.wide-mode {
    max-width: 1080px; /* Match standard container to align with header logo/nav */
}

/* Mobile Region Dropdown Styling */
#mobile-regional-power-select {
    background-color: var(--white);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}
[data-theme="dark"] #mobile-regional-power-select {
    background-color: #1f2937; /* Darker background */
    color: var(--text-main);
    border-color: #374151;
}
.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.section-header-row .section-title {
    margin-bottom: 0;
}
.region-stat-badge {
    background: #fff;
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    color: var(--text-muted);
    box-shadow: var(--shadow-soft);
    font-size: 0.95rem;
}
.region-stat-badge .value {
    color: var(--dark-blue);
    font-weight: 700;
    font-size: 1.1rem;
    margin-left: 6px;
}

/* Rankings Layout */
.rankings-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

#rankings-map-container {
    flex: 1;
    min-width: 0;
    /* Map takes remaining space, but we limit it to ensure it doesn't dominate on smaller large screens */
    max-width: 65%; 
    background: #fff;
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-soft);
    position: sticky;
    top: 90px; /* Sticky map on desktop */
    transition: box-shadow 0.3s;
    height: calc(100vh - 150px);
    overflow: hidden;
    display: flex; /* Ensure flex for centering/sizing */
    flex-direction: column; /* Legend top, map bottom */
}

#rankings-map-container:hover {
    box-shadow: var(--shadow-hover);
    border-color: rgba(11, 99, 199, 0.1);
}

#rankings-map {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    overflow: hidden;
    display: flex; /* Center SVG */
    align-items: center;
    justify-content: center;
    position: relative; /* Ensure controls are positioned relative to map */
}

#rankings-map svg {
    width: 100%;
    height: 100%;
}

#rankings-list {
    flex: 0 0 420px; /* Matched to previous task update */
    width: 420px;
    height: calc(100vh - 150px);
    overflow-y: auto;
    
    /* Best Upgrades scrollbar style */
    background: var(--white);
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}

/* Fix Map Height Sync */
/* Both map container and list have the same height calc, but padding in map might affect it if box-sizing isn't global. 
   Added global box-sizing in core.css to fix this. */

/* Mobile Region Header Spacing */
@media (max-width: 768px) {
    .section-header-row {
        margin-bottom: 32px; /* Increased from 20px for mobile */
    }
}

/* Allow text wrapping in country cell */
.country-cell {
    white-space: normal;
}
.country-cell .link-btn {
    white-space: normal;
    text-align: left;
    line-height: 1.3;
    height: auto;
    padding: 0;
    flex: 1; /* Allow button to take available space */
    min-width: 0; /* Allow shrinking below content size to force wrap */
    overflow-wrap: break-word;
    word-break: normal; /* Keep words whole */
    background: transparent;
    border: none;
    color: var(--primary-blue);
    box-shadow: none;
    border-radius: 0;
}

.country-cell .link-btn:hover {
    background: transparent;
    border: none;
    text-decoration: underline;
    color: var(--dark-blue);
    box-shadow: none;
}

#rankings-list::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
#rankings-list::-webkit-scrollbar-track {
    background: var(--light-blue-bg);
    border-radius: 10px;
}
#rankings-list::-webkit-scrollbar-thumb {
    background: var(--primary-blue);
    border-radius: 10px;
    border: 2px solid var(--light-blue-bg);
}
#rankings-list::-webkit-scrollbar-thumb:hover {
    background: var(--dark-blue);
}

/* Ensure sticky header works inside the scrollable container */
#rankings-list .data-table {
    border-collapse: separate; 
    border-spacing: 0;
}
#rankings-list .data-table thead th {
    position: sticky;
    top: 0;
    z-index: 10; /* Higher z-index */
    background: #f8fbff;
    border-top: none; /* Fix double border */
    box-shadow: 0 1px 0 #e0e0e0;
}

#rankings-list .data-table thead th:hover {
    z-index: 105;
}

/* PQI Column - Fixed narrow width */
#rankings-list .data-table th:nth-child(3),
#rankings-list .data-table td:nth-child(3) {
    width: 54px;
    padding-left: 4px;
    padding-right: 8px;
    text-align: right;
}

/* Compact header for PQI to fit in narrow column */
#rankings-list .th-with-tip {
    gap: 2px;
    justify-content: flex-end;
}
#rankings-list .th-with-tip .tip {
    margin-left: 2px;
}

/* Fix Filter Input Spacing */
.country-filter-header {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    width: 100%;
}
.country-filter-input {
    flex: 1;
    min-width: 0; /* Allow shrinking */
    margin: 0; /* Remove potential margins */
    width: 100%;
    padding: 6px 8px;
    font-size: 0.9rem;
}

.rankings-header-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0;
    padding: 8px;
    background-color: #f8fbff;
    border-bottom: 1px solid #e0e0e0;
}

[data-theme="dark"] .rankings-header-bar {
    background-color: #1f2937;
    border-bottom-color: #374151;
}


/* Map Legend */
.map-legend-container {
    margin-bottom: 16px;
    background: #f8fbff;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #eef2f6;
}
[data-theme="dark"] .map-legend-container {
    background: #1f2937;
    border-color: #374151;
}

.map-legend-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--dark-blue);
    margin-bottom: 8px;
}
[data-theme="dark"] .map-legend-label {
    color: var(--text-main);
}

.map-legend-scale {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Dark Mode Overrides for Tables */
[data-theme="dark"] #rankings-list .data-table thead th {
    background: #1f2937; /* Match card bg */
    box-shadow: 0 1px 0 #374151;
    color: var(--text-main);
}
[data-theme="dark"] #vfe-list .data-table thead th {
    background: #1f2937;
    box-shadow: 0 1px 0 #374151;
    color: var(--text-main);
}
[data-theme="dark"] .vfe-header-bar {
    background: #1f2937;
    border-color: #374151;
}
[data-theme="dark"] #rankings-map-container,
[data-theme="dark"] #rankings-list,
[data-theme="dark"] .region-stat-badge {
    background: #1f2937;
    border-color: #374151;
}
[data-theme="dark"] #rankings-list::-webkit-scrollbar-track {
    background: var(--light-blue-bg);
}
[data-theme="dark"] #rankings-list::-webkit-scrollbar-thumb {
    border-color: var(--light-blue-bg);
}
[data-theme="dark"] .country-cell .link-btn:hover {
    color: var(--primary-blue);
}
[data-theme="dark"] .data-table tr:hover td {
    background-color: #374151 !important; /* Grey hover for dark mode */
}
[data-theme="dark"] .region-stat-badge .value {
    color: var(--text-main);
}
.legend-gradient {
    flex: 1;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(to right, #86efac 20%, #4ade80 20% 40%, #22c55e 40% 60%, #16a34a 60% 80%, #14532d 80%);
}

[data-theme="dark"] .legend-gradient {
    background: linear-gradient(to right, var(--map-fill-0) 20%, var(--map-fill-20) 20% 40%, var(--map-fill-40) 40% 60%, var(--map-fill-60) 60% 80%, var(--map-fill-80) 80%);
}

[data-theme="dark"] #regional-power-list .tip-content {
    background-color: #1f2937; /* Ensure opaque background */
    color: #f1f5f9;
    border-color: #374151;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    z-index: 10001; /* High z-index */
}

/* Fix Rankings Map Tooltip in Dark Mode */
[data-theme="dark"] #map-tooltip {
    background-color: #1f2937 !important;
    color: #f1f5f9 !important;
    border-color: #374151 !important;
    box-shadow: 0 4px 6px rgba(0,0,0,0.5) !important;
}

/* Fix Isolated Regional PQI Table Font Color */
[data-theme="dark"] #regional-power-list .data-table td {
    color: var(--text-main);
}
[data-theme="dark"] #regional-power-list .data-table th {
    color: var(--text-main);
}
[data-theme="dark"] #regional-power-list .data-table td.country-cell .link-btn {
    color: var(--accent-color);
}
[data-theme="dark"] #regional-power-list .data-table td.country-cell .link-btn:hover {
    color: var(--primary-blue);
}

[data-theme="dark"] #regional-power-list .tip-content::after {
    border-color: #1f2937 transparent transparent transparent;
}

[data-theme="dark"] .country-filter-input {
    background-color: #1f2937;
    color: var(--text-main);
    border-color: #374151;
}

[data-theme="dark"] .country-cell .link-btn {
    color: var(--accent-color);
}

[data-theme="dark"] .csv-export-btn {
    background-color: #1f2937;
    color: var(--text-main);
    border-color: #374151;
}

[data-theme="dark"] .csv-export-btn:hover {
    background-color: #374151;
    color: var(--text-main);
}

[data-theme="dark"] .switch .slider {
    background-color: #4b5563;
}

[data-theme="dark"] .switch input:checked + .slider {
    background-color: var(--primary-blue);
}

[data-theme="dark"] .share-btn {
    color: var(--text-muted);
    border-color: var(--border-color);
}

[data-theme="dark"] .share-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--primary-blue);
}

/* VFE Header Bar (Export Button Area) */
.vfe-header-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0;
    padding: 8px 8px 10px 8px;
    background: #f8fbff;
    border-radius: 8px 8px 0 0;
}

/* VFE Table Header Styles */
#vfe-list .data-table thead th {
    background: #f8fbff;
    border-top: none;
}

.vfe-country-header {
    display: flex;
    align-items: center;
    gap: 10px;
}
.vfe-filter-wrapper {
    position: relative;
    flex: 1;
    min-width: 140px;
}
.vfe-filter-wrapper .country-filter-input {
    width: 100%;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 0.85rem;
    font-weight: normal;
    box-sizing: border-box;
}

/* Utility classes for responsive text */
.mobile-only { display: none; }
.desktop-only { display: inline; }

/* Mobile adjustments */
@media (max-width: 1000px) {
    html {
        font-size: 16px; /* Main content 16px for readability on mobile */
    }
    body {
        font-size: 1rem;
    }
    .mobile-only { display: inline; }
    .desktop-only { display: none; }

    .rankings-layout {
        flex-direction: column;
    }
    #rankings-map-container {
        display: none; /* Hide map on mobile/tablet as requested */
    }
    #rankings-list {
        width: 100%;
        flex: auto;
        height: auto !important; /* Force reset fixed height */
        max-height: none !important;
        overflow: visible !important; /* Ensure content flows and pushes footer down */
    }

    /* Restore sticky header offset on mobile to match site header */
    #rankings-list .data-table thead th {
        top: 60px;
    }

    /* Fix word breaking in home page tables */
    .home-card .data-table {
        table-layout: auto;
    }
    .home-card .data-table th, 
    .home-card .data-table td {
        padding: 12px 8px;
        word-break: keep-all;
        word-wrap: normal;
        overflow-wrap: normal;
        white-space: normal; /* Allow wrapping only between words */
    }
    .home-card .data-table th:nth-child(3),
    .home-card .data-table td:nth-child(3) {
        width: 65px; /* Slightly narrower PQI column on mobile */
    }

    /* Fix for VFE table overflow on mobile */
    #vfe-list {
        width: 100%;
        height: auto;
        overflow: visible; /* Use body scroll */
        display: block;
    }
    
    #vfe-list .data-table {
        width: 100%;
        min-width: 0;
        table-layout: auto; /* Allow flexible columns on mobile */
    }

    #vfe-list .data-table th, 
    #vfe-list .data-table td {
        padding: 6px 4px;
        font-size: 14px; /* Minimum 12px, preferred 14px for accessibility on mobile */
        word-break: keep-all;
        word-wrap: normal;
        overflow-wrap: normal;
        white-space: normal;
    }

    /* Column Widths */
    #vfe-list .data-table th:nth-child(1),
    #vfe-list .data-table td:nth-child(1) {
        width: 30px; /* Rank */
        text-align: center;
        padding-left: 0;
        padding-right: 0;
    }
    
    #vfe-list .data-table th:nth-child(2),
    #vfe-list .data-table td:nth-child(2) {
        width: auto; /* Country */
    }
    
    #vfe-list .data-table th:nth-child(3),
    #vfe-list .data-table td:nth-child(3) {
        width: 45px; /* VFE */
        text-align: center;
        padding-left: 0;
        padding-right: 0;
    }
    
    #vfe-list .data-table th:nth-child(4),
    #vfe-list .data-table td:nth-child(4) {
        width: 60px; /* Count */
        text-align: center;
        font-size: 0.75rem;
        line-height: 1.1;
        padding-left: 0;
        padding-right: 0;
    }
    
    /* Header for Country Column - Row Layout on Mobile */
    .vfe-country-header {
        flex-direction: row;
        align-items: center;
        gap: 6px;
    }
    .vfe-filter-wrapper {
        width: auto;
        flex: 1;
        min-width: 60px; /* Allow shrinking */
    }
    
    /* Fix VFE Tooltip spacing */
    .th-with-tip {
        gap: 2px !important;
        justify-content: center;
    }
    
    /* Sticky Header - Relative to Page */
    #vfe-list .data-table thead th {
        position: sticky;
        top: 60px;
        z-index: 5;
        background: #fff;
        vertical-align: middle;
        box-shadow: 0 1px 0 #e0e0e0;
    }

    #vfe-list .data-table thead th:focus-within {
        z-index: 50;
    }
    
    /* Ensure input font size 16px to prevent zoom */
    .country-filter-input {
        font-size: 16px !important;
    }
}
#synergy-top-list .data-table { border-collapse: separate; border-spacing: 0; }
#synergy-top-list .data-table thead th { position: sticky; top: 0; z-index: 2; background: #f8fbff; }

/* Mobile Redesign for Synergy Tool */
@media (max-width: 810px) {
    .synergy-grid {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 20px;
    }

    /* Use display: contents to flatten the structure and reorder items */
    .synergy-left, .synergy-right {
        display: contents;
    }

    /* 1. Header */
    .synergy-header-group {
        order: 1;
        width: 100%;
        margin-bottom: 10px;
    }

    /* 2. Controls (Inputs + Result) */
    .synergy-controls {
        order: 2;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }
    .synergy-controls .combo, 
    .synergy-controls .primary-btn, 
    .synergy-controls .synergy-result {
        width: 100%;
    }
    .synergy-controls .synergy-result {
        min-width: 0; /* Allow shrinking */
    }

    /* Hide mobile disclaimer here, we'll show the desktop one at bottom */
    .synergy-disclaimer.mobile-only {
        display: none !important;
    }

    /* 3. Table Title (from Right column) */
    .synergy-right > .section-subtitle:nth-child(1) {
        order: 3;
        margin-top: 10px;
    }

    /* 4. Best Upgrades Table (from Right column) */
    #synergy-top-list {
        order: 4;
        width: 100%;
        max-height: 300px; /* Limit height on mobile */
    }

    /* 5. Map Title (from Left column) */
    .synergy-left > .section-subtitle:nth-child(3) {
        order: 5;
        margin-top: 20px;
    }

    /* 6. Map (from Left column) */
    #synergy-map {
        order: 6;
        width: 100%;
        height: 300px;
    }

    /* 7. Disclaimer (from Right column - reuse desktop one) */
    .synergy-disclaimer.desktop-only {
        order: 7;
        display: block !important; /* Force show */
        margin-top: 15px;
    }
}
#synergy-top-list { overflow-x: auto; }

#synergy-top-list .data-table th, 
#synergy-top-list .data-table td {
    padding: 3px 8px;
    font-size: 0.85rem;
    line-height: 1.2;
}
#synergy-top-list .link-btn {
    font-size: 0.85rem;
    padding: 2px 6px;
}

/* Mobile Fixes for Synergy Tool (Moved to end to override desktop styles) */
@media (max-width: 810px) {
    .synergy-grid {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start;
        width: 100%;
        gap: 20px;
    }
    
    .synergy-left, .synergy-right {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    /* Hide map on mobile */
    #synergy-map { display: none !important; }
    .synergy-left > .section-subtitle { display: none; }

    /* Controls Styling */
    .synergy-controls {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    .synergy-controls .combo {
        width: 100%;
        flex: 0 0 auto;
    }
    .synergy-controls .primary-btn {
        width: 100%;
        flex: 0 0 auto;
    }
    .synergy-controls .combo input {
        width: 100%;
        box-sizing: border-box;
    }
    .synergy-controls .synergy-result {
        width: 100%;
        flex: 0 0 auto;
        box-sizing: border-box;
        min-width: 0;
        padding: 6px;
        margin-top: 6px;
        font-size: 0.85em;
    }

    /* Table Visibility and Overflow */
    #synergy-top-list {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-top: 10px;
        max-height: calc(var(--header-h) + var(--row-h) * 12);
    }
    
    #synergy-top-list .data-table {
        min-width: 100%;
        width: auto;
    }
    
    #synergy-top-list .data-table th, 
    #synergy-top-list .data-table td { 
        font-size: 0.9rem; 
        padding: 8px 10px; 
    }
    
    #synergy-top-list .link-btn { 
        font-size: 0.85rem; 
        padding: 4px 8px; 
        white-space: normal; 
        flex-shrink: 1; 
        min-width: 0; 
    }
    
    /* Hide Rank column on mobile */
    #synergy-top-list .data-table thead th:nth-child(1), 
    #synergy-top-list .data-table tbody td:nth-child(1) { 
        display: none; 
    }
    
    #synergy-top-list .country-cell { 
        min-width: 0; 
        display: flex; 
        align-items: center; 
        gap: 10px; 
        width: 100%; 
    }

    /* Reorder Layout: Inputs -> Table -> Disclaimer */
    /* Hide the mobile disclaimer in the left column */
    .synergy-left .synergy-disclaimer.mobile-only {
        display: none !important;
    }
    
    /* Show the desktop disclaimer in the right column (which is now at bottom) */
    .synergy-right .synergy-disclaimer.desktop-only {
        display: block !important;
        margin-top: 15px;
    }
    
    .synergy-right .section-subtitle {
        margin-top: 0;
        margin-bottom: 10px;
        display: block;
    }
}

/* Isolated Regional PQI Mobile Fix */
@media (max-width: 810px) {
    #regional-power-list .table-container {
        overflow-x: visible;
        width: 100%;
        display: block;
    }
    #regional-power-list .data-table {
        width: 100%;
        table-layout: auto;
    }
    #regional-power-list .data-table th,
    #regional-power-list .data-table td {
        white-space: normal;
        padding: 8px 6px;
        word-break: normal;
        overflow-wrap: break-word;
    }
    #regional-power-list .data-table th:nth-child(1),
    #regional-power-list .data-table td:nth-child(1) {
        width: 45px;
        text-align: center;
        padding-left: 2px;
        padding-right: 2px;
        word-break: normal;
    }
    #regional-power-list .data-table th:nth-child(3),
    #regional-power-list .data-table td:nth-child(3) {
        width: 75px;
        text-align: right;
    }
    #regional-power-list .country-filter-header {
        width: 100%;
        display: grid;
        grid-template-columns: auto 1fr auto;
        grid-template-areas:
            "label spacer house"
            "filter filter filter";
        align-items: start;
        column-gap: 6px;
        row-gap: 6px;
    }
    #regional-power-list .country-filter-header span {
        white-space: nowrap;
        word-break: normal;
    }
    #regional-power-list .country-filter-header > span {
        grid-area: label;
        align-self: start;
    }
    #regional-power-list .country-filter-input-wrapper {
        grid-area: filter;
        width: 66%;
        align-self: start;
        justify-self: start;
        position: relative;
    }
    #regional-power-list .country-filter-input-wrapper .clear-filter-btn {
        position: absolute;
        right: 6px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 5;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: #9ca3af;
    }
    #regional-power-list .country-filter-input {
        width: 100%;
    }
    #regional-power-list .home-filter-wrapper {
        grid-area: house;
        justify-self: end;
    }
    #regional-power-list .home-filter-wrapper span {
        margin-left: -4px;
    }
    #regional-power-list .th-with-tip {
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    /* Scoped Mobile Tooltip for Regional PQI */
    #regional-power-list .tip-content {
        position: fixed;
        top: 50%;
        left: 50%;
        width: 85vw;
        max-width: 320px;
        transform: translate(-50%, -50%);
        white-space: normal;
        text-align: left;
        margin: 0;
        box-shadow: 0 10px 25px rgba(0,0,0,0.2);
        border: 1px solid rgba(0,0,0,0.15);
        z-index: 9999;
    }
    #regional-power-list .tip:hover .tip-content,
    #regional-power-list .tip:focus .tip-content {
        transform: translate(-50%, -50%);
    }
    #regional-power-list .tip-content::before {
        display: none;
    }
}

@media (min-width: 1024px) {
    #regional-power-list .table-container {
        max-width: 66%;
        margin: 0 auto;
    }
}
@media (min-width: 1024px) {
    #regional-power-list .table-container {
        background: transparent;
        border: none;
        box-shadow: none;
        border-radius: 0;
    }
    #regional-power-list .table-container::after {
        display: none;
    }
}
#regional-power-list .data-table {
    background: #ffffff;
}
[data-theme="dark"] #regional-power-list .data-table {
    background: #1f2937;
}
@media (min-width: 1024px) {
    #regional-power-list {
        background: transparent;
        border: none;
        box-shadow: none;
        border-radius: 0;
    }
    #regional-power-list::after {
        display: none;
    }
}
@media (min-width: 1024px) {
    #regional-power-section .regions-select-row {
        justify-content: center;
    }
}
@media (min-width: 1024px) {
    #regional-power-list .country-filter-header {
        gap: 8px;
    }
    #regional-power-list .country-filter-input {
        flex: 0 0 220px;
        max-width: 220px;
    }
    #regional-power-list .country-filter-input-wrapper {
        position: relative;
        flex: 0 0 220px;
        max-width: 220px;
    }
    #regional-power-list .country-filter-input-wrapper .clear-filter-btn {
        position: absolute;
        right: 6px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 5;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: #9ca3af;
    }
}
#regional-power-list .home-filter-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 0;
    padding-right: 0;
    border-right: none;
}
#regional-power-list .home-filter-wrapper span {
    display: flex;
    align-items: flex-start;
    line-height: 1;
    margin-left: -8px;
}
#regional-power-list .home-filter-wrapper .switch {
    margin: 0;
}
#regional-power-list .data-table thead th {
    vertical-align: top;
    padding-top: 4px;
    padding-bottom: 4px;
}
#regional-power-list .country-filter-header {
    align-items: flex-start;
}
#regional-power-list .th-with-tip {
    align-items: flex-start;
}
#regional-power-list .home-icon-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}
#regional-power-list .home-icon-spacer {
    width: 40px;
    height: 1px;
}

[data-theme="dark"] #regional-power-list .tip-content {
    background: #1f2937;
    color: #f1f5f9;
    border-color: #374151;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

@media (min-width: 1024px) {
    #regional-power-list .home-filter-wrapper {
        margin-left: auto;
        gap: 10px;
    }
    #regional-power-list .home-filter-wrapper span {
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    #region-avg-pqi {
        display: none;
    }
}

.csv-export-btn {
    background-color: #f3f4f6;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    margin-bottom: 8px;
    margin-left: auto;
}
.csv-export-btn svg {
    width: 14px;
    height: 14px;
}
.csv-export-btn:hover {
    background-color: #e5e7eb;
    border-color: #d1d5db;
    color: var(--dark-blue);
}

.share-btn {
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 6px;
    padding: 4px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    text-decoration: none;
    line-height: 1.2;
}
.share-btn:hover {
    background-color: var(--primary-color);
    color: #fff;
}
.share-btn svg {
    width: 14px;
    height: 14px;
}

/* Home Filter & Toggle Switch */
.home-filter-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 8px;
    padding-right: 12px;
    border-right: 1px solid var(--border-color);
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-blue);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--primary-blue);
}

input:checked + .slider:before {
    -webkit-transform: translateX(18px);
    -ms-transform: translateX(18px);
    transform: translateX(18px);
}

/* Ensure country names in table wrap correctly on mobile */
.country-cell .link-btn {
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
    text-align: left;
    display: inline-block; /* Allow wrapping behavior */
}

/* Mobile adjustments for filters */
@media (max-width: 600px) {
    .country-filter-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .country-filter-input {
        width: 100%;
        max-width: 320px;
        font-size: 16px; /* Prevent iOS zoom */
    }

    .home-filter-wrapper {
        margin-right: 4px;
        padding-right: 8px;
    }
}

/* Fix suggest box overflow on mobile */
.suggest-box {
    width: 100%;
    min-width: 240px;
    max-width: 100vw;
}

@media (min-width: 601px) {
    .country-filter-header .suggest-box {
        min-width: 300px;
        max-width: 480px;
    }
}

/* Increase home icon size on desktop */
@media (min-width: 601px) {
    .home-filter-wrapper > span,
    .home-icon {
        font-size: 24px; /* Increased size for desktop */
        line-height: 1;
    }
    
    .home-icon {
        margin-left: 5px; /* Add some spacing from the country name */
    }
}

