/**
 * REGION SOURCE TABS
 * 
 * Tab-based UI for switching between "Counties" and "My Maps" selection modes
 * Used in USCB dataset handler
 */

.region-source-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-gray);
    margin-bottom: 20px;
    gap: 0;
}

.region-source-tab {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
}

.region-source-tab:hover {
    color: var(--primary-dark, #2C3E50);
    background: rgba(44, 62, 80, 0.05);
}

.region-source-tab.active {
    color: var(--primary-dark, #2C3E50);
    border-bottom-color: var(--primary-dark, #2C3E50);
    background: rgba(44, 62, 80, 0.08);
}

.region-source-tab:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    color: #999;
}

.region-source-tab:disabled:hover {
    background: transparent;
    color: #999;
}

.region-source-tab svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
}

/* Tab content containers */
.region-source-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.region-source-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Tooltip for disabled My Maps tab */
.region-source-tab[data-tooltip] {
    position: relative;
}

.region-source-tab[data-tooltip]:disabled::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    font-size: 12px;
    font-weight: normal;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
    /* Prevent tooltip from going off screen */
    max-width: calc(100vw - 20px);
    white-space: normal;
    text-align: center;
    /* Ensure tooltip stays within viewport bounds */
    left: max(10px, min(50%, calc(100vw - 10px - 50%)));
}

.region-source-tab[data-tooltip]:disabled::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-2px);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.85);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
}

.region-source-tab[data-tooltip]:disabled:hover::after,
.region-source-tab[data-tooltip]:disabled:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* Tooltip for county badges (show county names) */
.county-count-badge[data-tooltip] {
    position: relative;
}

.county-count-badge[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    padding: 10px 14px;
    background: var(--primary-dark, #006056);
    color: var(--background, #FFF6E9);
    font-size: 12px;
    font-weight: normal;
    border-radius: 6px;
    white-space: normal;
    max-width: 280px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 2000;
    text-align: center;
    line-height: 1.5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.county-count-badge[data-tooltip]::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(2px);
    border: 6px solid transparent;
    border-bottom-color: var(--primary-dark, #006056);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 2000;
}

.county-count-badge[data-tooltip]:hover::after,
.county-count-badge[data-tooltip]:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(4px);
}

.county-count-badge[data-tooltip]:hover::before {
    transform: translateX(-50%) translateY(2px);
}

/* Disabled county styling for My Maps mode */
path.county.region-disabled {
    fill: #cccccc !important;
    pointer-events: none !important;
    cursor: default !important;
    opacity: 0.6;
}

/* Selected region styling (stays highlighted) */
path.county.region-selected {
    fill: var(--accent, #FF6B6B) !important;
    stroke: var(--background, #FFF6E9) !important; /* Visible separator lines between counties */
    stroke-width: 1.5px !important;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .region-source-tab {
        font-size: 13px;
        padding: 10px 12px;
    }
    
    .region-source-tab svg {
        width: 14px;
        height: 14px;
    }
    
    /* Ensure tooltip stays within mobile viewport */
    .region-source-tab[data-tooltip]:disabled::after {
        max-width: calc(100vw - 40px);
        left: 50%;
        right: auto;
        font-size: 11px;
        padding: 6px 10px;
    }
}

