/* ================================================
   Mining Stakeholder Database - Main Styles
   Inspired by nanoblue.org design
   ================================================ */

/* === Variables === */
:root {
    /* Colors */
    --primary-blue: #ffc03c;
    --primary-red: #dc2626;
    --primary-green: #16a34a;
    --primary-purple: #9333ea;
    --primary-orange: #ea580c;
    --primary-cyan: #0891b2;
    --primary-indigo: #d97706;
    --primary-yellow: #ffc03c;
    
    /* Grays */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Spacing */
    --container-width: 1400px;
    --sidebar-width: 300px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

/* === Reset & Base === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--gray-900);
    background: var(--gray-50);
}

/* === Hero Section === */
.hero {
    background-color: #000000;
    color: #ffffff;
}

.mining-db-hero {
    min-height: 480px;
    padding: 32px 20px;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.mining-db-hero__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}

.mining-db-hero__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to right,
        rgba(0, 0, 0, 0.72) 0%,
        rgba(241, 180, 52, 0.56) 70%
    );
    z-index: 1;
}

.mining-db-hero__inner {
    position: relative;
    z-index: 2;
    width: 100%;
}

.mining-db-hero__content {
    text-align: center;
}

.mining-db-hero h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 16px;
    letter-spacing: -0.5px;
    color: #ffffff;
}

.mining-db-hero p {
    font-size: 1.15rem;
    color: rgba(255, 255, 255, 0.92);
    margin-bottom: 32px;
    font-weight: 400;
}

/* Alert */
.alert {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 20px;
    margin: 20px auto;
    max-width: 600px;
}

.alert-warning {
    background: rgba(251, 191, 36, 0.2);
    border-color: rgba(251, 191, 36, 0.5);
}

.alert strong {
    display: block;
    font-size: 18px;
    margin-bottom: 8px;
}

.alert p {
    font-size: 14px;
    margin: 0;
}

.mining-db-alert-link {
    color: white;
    text-decoration: underline;
}

.mining-db-alert-link:hover {
    color: white;
}

/* === Category Pills === */
.category-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-width: 1000px;
    margin: 0 auto;
}

.pill {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.75);
    color: #111827 !important;
    padding: 10px 18px;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    line-height: 1.2;
    box-shadow: 0 6px 18px rgba(17, 24, 39, 0.08);
}

.pill:hover {
    background: #ffffff;
    border-color: rgba(255, 255, 255, 0.95);
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(17, 24, 39, 0.12);
}

.pill:focus-visible {
    outline: 3px solid rgba(255, 244, 207, 0.95);
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(151, 27, 47, 0.32);
}

.pill.active {
    --pill-active-bg: #971b2f;
    --pill-active-text: #ffffff;
    --pill-active-border: #c76479;
    --pill-active-chip-bg: rgba(255, 255, 255, 0.18);
    background: var(--pill-active-bg);
    color: var(--pill-active-text) !important;
    border-color: var(--pill-active-border);
    box-shadow: 0 10px 28px rgba(17, 24, 39, 0.16);
}

/* Individual pill colors when active */
.pill.active[data-category="all"] {
    --pill-active-bg: #971b2f;
    --pill-active-text: #ffffff;
    --pill-active-border: #d38a9b;
    --pill-active-chip-bg: rgba(255, 255, 255, 0.18);
}

.pill.active[data-category="federal-government"] {
    --pill-active-bg: #f3cf7a;
    --pill-active-text: #4b2d05;
    --pill-active-border: #e1b95d;
    --pill-active-chip-bg: rgba(17, 24, 39, 0.1);
}

.pill.active[data-category="state-agencies"] {
    --pill-active-bg: #8f4f15;
    --pill-active-text: #ffffff;
    --pill-active-border: #b06a26;
    --pill-active-chip-bg: rgba(255, 255, 255, 0.18);
}

.pill.active[data-category="mmsd-offices"] {
    --pill-active-bg: #e4ac3d;
    --pill-active-text: #3f2800;
    --pill-active-border: #cf9728;
    --pill-active-chip-bg: rgba(17, 24, 39, 0.1);
}

.pill.active[data-category="mining-companies"] {
    --pill-active-bg: #b91c1c;
    --pill-active-text: #ffffff;
    --pill-active-border: #db4a4a;
    --pill-active-chip-bg: rgba(255, 255, 255, 0.18);
}

.pill.active[data-category="mining-consultancies"] {
    --pill-active-bg: #c24134;
    --pill-active-text: #ffffff;
    --pill-active-border: #df6a5e;
    --pill-active-chip-bg: rgba(255, 255, 255, 0.18);
}

.pill.active[data-category="artisanal-miners"] {
    --pill-active-bg: #a94f10;
    --pill-active-text: #ffffff;
    --pill-active-border: #ca732e;
    --pill-active-chip-bg: rgba(255, 255, 255, 0.18);
}

.pill.active[data-category="associations"] {
    --pill-active-bg: #0f6f8f;
    --pill-active-text: #ffffff;
    --pill-active-border: #2d92b4;
    --pill-active-chip-bg: rgba(255, 255, 255, 0.18);
}

.pill.active[data-category="state-companies"] {
    --pill-active-bg: #6d41c9;
    --pill-active-text: #ffffff;
    --pill-active-border: #916bf3;
    --pill-active-chip-bg: rgba(255, 255, 255, 0.18);
}

.pill.active[data-category="infrastructure"] {
    --pill-active-bg: #64748b;
    --pill-active-text: #ffffff;
    --pill-active-border: #8391a5;
    --pill-active-chip-bg: rgba(255, 255, 255, 0.18);
}

.pill.active[data-category="ngos"] {
    --pill-active-bg: #1f7a43;
    --pill-active-text: #ffffff;
    --pill-active-border: #3f9d64;
    --pill-active-chip-bg: rgba(255, 255, 255, 0.18);
}

.pill.active[data-category="civil-society"] {
    --pill-active-bg: #14805f;
    --pill-active-text: #ffffff;
    --pill-active-border: #31a382;
    --pill-active-chip-bg: rgba(255, 255, 255, 0.18);
}

.pill.active[data-category="donors"] {
    --pill-active-bg: #7d35c7;
    --pill-active-text: #ffffff;
    --pill-active-border: #9d63ea;
    --pill-active-chip-bg: rgba(255, 255, 255, 0.18);
}

.pill.active[data-category="training-institutes"] {
    --pill-active-bg: #e0b23f;
    --pill-active-text: #3f2900;
    --pill-active-border: #c89920;
    --pill-active-chip-bg: rgba(17, 24, 39, 0.1);
}

.pill.active[data-category="universities"] {
    --pill-active-bg: #c85710;
    --pill-active-text: #ffffff;
    --pill-active-border: #e27b3c;
    --pill-active-chip-bg: rgba(255, 255, 255, 0.18);
}

.pill .count {
    background: rgba(17, 24, 39, 0.08);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
}

.pill.active .count {
    background: var(--pill-active-chip-bg);
    color: var(--pill-active-text);
}

.pill.active[data-category="all"] .count {
    background: var(--pill-active-chip-bg);
    color: var(--pill-active-text);
}

/* === Container === */
.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 20px;
}

.mining-db-back-link {
    display: inline-flex;
    align-items: center;
    margin-bottom: 15px;
    text-decoration: none;
    position: relative;
    min-height: 30px;
}

.mining-db-back-link:focus-visible {
    outline: 2px solid var(--primary-indigo);
    outline-offset: 3px;
}

.mining-db-back-link__icon {
    transition: fill 0.2s ease;
}

.mining-db-back-link__tooltip {
    display: none;
    position: absolute;
    left: 35px;
    top: 5px;
    background: #333333;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    white-space: nowrap;
    font-size: 14px;
    pointer-events: none;
    z-index: 10;
}

.mining-db-back-link:hover .mining-db-back-link__icon,
.mining-db-back-link:focus-visible .mining-db-back-link__icon {
    fill: #666666;
}

.mining-db-back-link:hover .mining-db-back-link__tooltip,
.mining-db-back-link:focus-visible .mining-db-back-link__tooltip {
    display: inline-block;
}

/* === Main Content Grid === */
.main-content {
    padding: 40px 0;
}

.grid {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    gap: 24px;
    max-width: var(--container-width);
    margin: 0 auto;
    align-items: start;
}

/* === Filter Sidebar === */
.filter-sidebar {
    background: linear-gradient(180deg, #fffaf0 0%, #fff3d6 100%);
    border: 1px solid #ead7a3;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 16px 36px rgba(151, 27, 47, 0.08);
    width: 100%;
    min-width: 0;
    height: fit-content;
    position: sticky;
    top: 20px;
    overflow: visible;
    color: #22161b;
}

.filter-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.filter-group {
    border-bottom: 1px solid rgba(151, 27, 47, 0.12);
    padding-bottom: 20px;
    min-width: 0;
}

.filter-group:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

.filter-group label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: #971b2f;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group > label[for="search-input"] {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    width: fit-content;
}

.filter-group > label[for="search-input"] .mining-db-inline-icon,
.btn-export .mining-db-inline-icon {
    margin-right: 0;
    flex-shrink: 0;
}

.mining-db-inline-icon {
    display: inline-block;
    vertical-align: middle;
    margin-right: 5px;
}

.help-text {
    display: block;
    font-size: 11px;
    color: #6f5a47;
    margin-top: 4px;
}

.search-box,
.filter-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e6d5aa;
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 14px;
    transition: all 0.2s;
    font-family: inherit;
    background: rgba(255, 255, 255, 0.82);
    color: #2b1d23;
}

.search-box:focus,
.filter-select:focus {
    outline: none;
    border-color: #971b2f;
    box-shadow: 0 0 0 3px rgba(255, 192, 60, 0.28);
}

/* Checkbox Group */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    padding: 8px 0;
    cursor: pointer;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    margin: 0;
    transition: background 0.2s;
    border-radius: 6px;
    padding: 8px 8px;
}

.checkbox-group label:hover {
    background: rgba(255, 244, 207, 0.82);
}

.checkbox-group input[type="checkbox"] {
    margin-right: 10px;
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: #971b2f;
}

.checkbox-label {
    flex: 1;
    font-size: 14px;
    color: #3d2c30;
}

.checkbox-group .count {
    background: rgba(255, 244, 207, 0.95);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    color: #971b2f;
    font-weight: 600;
    border: 1px solid rgba(151, 27, 47, 0.1);
}

/* Custom State Dropdown */
.custom-state-dropdown {
    position: relative;
    min-width: 0;
}

.custom-state-trigger {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e6d5aa;
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.82);
    color: #2b1d23;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.custom-state-trigger:hover {
    border-color: #d6b75f;
}

.custom-state-dropdown.open .custom-state-trigger {
    border-color: #971b2f;
    box-shadow: 0 0 0 3px rgba(255, 192, 60, 0.28);
}

.custom-state-trigger svg {
    transition: transform 0.2s;
}

.custom-state-dropdown.open .custom-state-trigger svg {
    transform: rotate(180deg);
}

.custom-state-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: #fffdf8;
    border: 1px solid #e6d5aa;
    border-radius: 8px;
    box-sizing: border-box;
    box-shadow: 0 18px 32px rgba(151, 27, 47, 0.1);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.custom-state-dropdown.open .custom-state-menu {
    display: block;
}

.state-option {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.state-option:hover {
    background: rgba(255, 244, 207, 0.82);
}

.state-option input[type="checkbox"] {
    cursor: pointer;
}

.state-option label {
    cursor: pointer;
    flex: 1;
    min-width: 0;
    margin: 0;
}

.state-group {
    border-top: 1px solid rgba(151, 27, 47, 0.08);
    padding: 4px 0;
}

.state-group-label {
    padding: 8px 12px 4px;
    font-size: 11px;
    font-weight: 600;
    color: #971b2f;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 4px;
    margin: 0 4px;
}

.state-group-label:hover {
    background: rgba(255, 244, 207, 0.9);
    color: #971b2f;
}

/* Category Filter Controls */
.category-filter-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.btn-select-all,
.btn-clear-all {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid #e6d5aa;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-select-all {
    background: #971b2f;
    border-color: #971b2f;
    color: #ffffff;
}

.btn-select-all:hover {
    background: #7f1628;
    border-color: #7f1628;
    color: white;
}

.btn-clear-all {
    background: #fff4cf;
    color: #971b2f;
}

.btn-clear-all:hover {
    background: #ffe5b1;
    border-color: #d6b75f;
}

.btn-select-all:focus-visible,
.btn-clear-all:focus-visible,
.btn-secondary:focus-visible,
.btn-export:focus-visible {
    outline: 3px solid rgba(255, 192, 60, 0.45);
    outline-offset: 2px;
}

/* === Stats Box === */
.stats-box {
    background: linear-gradient(135deg, #971b2f 0%, #7f1628 100%);
    padding: 20px;
    border-radius: 14px;
    margin-top: 20px;
    color: #ffffff;
    border: 1px solid rgba(255, 229, 177, 0.4);
    box-shadow: 0 16px 30px rgba(151, 27, 47, 0.2);
}

.stats-box h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #ffe5b1;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 229, 177, 0.22);
}

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

.stat-label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.88);
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #fff7dc;
}

/* === Filter Actions === */
.filter-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.btn-secondary,
.btn-export {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    box-sizing: border-box;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1.2;
    white-space: nowrap;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.88);
    color: #971b2f;
    border-color: #e6d5aa;
}

.btn-secondary:hover {
    background: #fff4cf;
    border-color: #d6b75f;
}

.btn-export {
    background: #ffc03c;
    color: #3b2500;
    border-color: #d89f18;
    box-shadow: 0 8px 20px rgba(255, 192, 60, 0.28);
}

.btn-export:hover {
    background: #e3aa23;
    border-color: #c88e12;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* === Main Content Column === */
.main-column {
    display: flex;
    flex-direction: column;
    gap: 30px;
    min-width: 0;
    width: 100%;
}

/* === Map Wrapper === */
.map-wrapper {
    position: relative;
    z-index: 1;
    isolation: isolate;
    background: white;
    border-radius: 12px;
    padding: 0;  /* Remove padding so map fills container */
    box-shadow: var(--shadow-sm);
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 700px;  /* Fixed height for the wrapper */
    overflow: hidden;  /* Ensure rounded corners are respected */
}

#map-container {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 100%;  /* Fill the wrapper height */
    border-radius: 12px;  /* Match wrapper border radius */
    overflow: hidden;
    background: var(--gray-50);
    position: relative;
}

#map-container .leaflet-container {
    width: 100%;
    max-width: 100%;
    height: 100%;
}

/* Map Controls */
.map-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}

.map-controls button {
    width: 44px;
    height: 44px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    box-shadow: var(--shadow-md);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-controls button:hover {
    background: var(--gray-50);
    transform: scale(1.05);
    border-color: var(--primary-blue);
}

.map-controls button:active {
    transform: scale(0.98);
}

.map-legend-toggle {
    display: none;
}

/* Map Legend */
.map-legend {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 250px;
    z-index: 1000;
}

.map-legend h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-700);
}

#legend-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

/* Map Loading */
.map-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.map-loading p {
    margin-top: 16px;
    color: var(--gray-600);
    font-size: 14px;
}

/* === D3 Map Styles === */
path.state {
    cursor: pointer;
    transition: fill 0.2s, stroke 0.2s;
}

path.state:hover {
    fill: #fef3c7 !important;
    stroke: var(--primary-blue) !important;
    stroke-width: 2px !important;
}

circle.stakeholder {
    cursor: pointer;
    transition: all 0.3s;
}

circle.stakeholder:hover {
    stroke-width: 3px !important;
    filter: drop-shadow(0 0 8px rgba(0, 0, 0, 0.4));
}

/* === Tooltip === */
#tooltip {
    position: absolute;
    display: none;
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
    z-index: 1000;
    max-width: 320px;
    border: 1px solid var(--gray-200);
}

#tooltip h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: var(--gray-900);
    font-weight: 600;
}

#tooltip p {
    margin: 4px 0;
    font-size: 13px;
    color: var(--gray-600);
    line-height: 1.5;
}

#tooltip strong {
    color: var(--gray-700);
    font-weight: 600;
}

/* === Data Section === */
/* === Table Wrapper === */
.table-wrapper {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow-sm);
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
}

.table-wrapper h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--gray-900);
}

.table-controls {
    margin-bottom: 20px;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
}

.table-info {
    font-size: 14px;
    color: var(--gray-500);
}

.table-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: white;
    border: 1px solid var(--gray-200);
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--gray-50);
}

.btn-icon.active {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
}

.btn-icon.active svg {
    fill: white;
}

.table-container {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.data-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
}

.data-table th {
    padding: 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.data-table th.sortable:hover {
    background: var(--gray-100);
}

.sort-icon {
    margin-left: 4px;
    opacity: 0.4;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.2s;
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.data-table td {
    padding: 16px;
    font-size: 14px;
    color: var(--gray-700);
}

.category-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    background: #e0e7ff;
    color: #3730a3;
}

.state-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    background: var(--gray-100);
    color: var(--gray-600);
}

.contact-info {
    font-size: 13px;
    line-height: 1.5;
}

.contact-info div {
    margin-bottom: 2px;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.mining-db-table-btn {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid transparent;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.mining-db-table-btn:focus-visible {
    outline: 3px solid rgba(151, 27, 47, 0.24);
    outline-offset: 2px;
}

.mining-db-table-btn--primary {
    background: #ffc03c;
    color: #3b2500;
    border-color: #971b2f;
    box-shadow: 0 4px 12px rgba(255, 192, 60, 0.22);
}

.mining-db-table-btn--primary:hover {
    background: #e3aa23;
    color: #4a1620;
    border-color: #971b2f;
}

.mining-db-table-btn--secondary {
    background: #fffaf0;
    color: #971b2f;
    border-color: #e6d5aa;
}

.mining-db-table-btn--secondary:hover {
    background: #fff1c7;
    color: #7f1628;
    border-color: #d9b05a;
}

.no-data {
    text-align: center;
    padding: 60px 20px !important;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.empty-state p {
    font-size: 16px;
    color: var(--gray-500);
    margin: 0 0 8px 0;
}

.empty-state small {
    font-size: 13px;
    color: var(--gray-400);
}

.mining-db-empty-icon {
    margin-bottom: 16px;
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
}

.page-btn {
    padding: 8px 16px;
    border: 1px solid var(--gray-200);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    background: var(--gray-100);
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-info {
    font-size: 14px;
    color: var(--gray-500);
}

.grid-container {
    display: none;
}

.stakeholder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

.stakeholder-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s;
    cursor: pointer;
}

.stakeholder-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.stakeholder-card h3 {
    font-size: 16px;
    margin: 0 0 8px 0;
    color: var(--gray-900);
}

.stakeholder-card .category {
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 12px;
}

.stakeholder-card .location {
    font-size: 13px;
    color: var(--gray-400);
    margin-bottom: 12px;
}

/* Legacy data-section (now unused) */
.data-section {
    padding: 40px 20px;
    background: white;
    margin-top: 40px;
}

.data-section h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--gray-900);
}

/* === Modal === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

#detail-modal {
    display: none;
}

.modal-content {
    background: #fffdf8;
    border-radius: 16px;
    padding: 32px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    border: 1px solid #ead7a3;
    box-shadow: 0 24px 48px rgba(34, 22, 27, 0.16);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 32px;
    font-weight: 300;
    color: var(--gray-400);
    cursor: pointer;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #fff1c7;
    color: #971b2f;
}

/* Modal Content Styles */
#modal-body h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #4a1620;
    margin-bottom: 8px;
}

.modal-category-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    background: #fff1c7 !important;
    color: #971b2f !important;
    border: 1px solid #f0c35c;
    margin-bottom: 24px;
}

.detail-grid {
    display: grid;
    gap: 24px;
}

.detail-section {
    background: #fffaf0;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #ead7a3;
}

.detail-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #5f1321;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #ffc03c;
}

.detail-section p {
    margin: 8px 0;
    line-height: 1.6;
    color: var(--gray-700);
}

.detail-section p strong {
    color: var(--gray-900);
    font-weight: 600;
    margin-right: 8px;
}

.detail-section a {
    color: #971b2f;
    text-decoration: none;
    transition: color 0.2s;
}

.detail-section a:hover {
    color: #6d1323;
    text-decoration: underline;
}

.detail-row {
    display: flex;
    align-items: start;
    margin: 8px 0;
}

.detail-label {
    min-width: 120px;
    font-weight: 600;
    color: #5f1321;
}

.detail-value {
    flex: 1;
    color: var(--gray-700);
}

.detail-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid rgba(151, 27, 47, 0.14);
}

.btn-detail {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-detail-primary {
    background: #ffc03c;
    color: #3b2500;
    border: 1px solid #d89f18;
}

.btn-detail-primary:hover {
    background: #e3aa23;
    color: #2d1c00;
    transform: translateY(-1px);
}

.btn-detail-secondary {
    background: #fffaf0;
    color: #971b2f;
    border: 1px solid #e6d5aa;
}

.btn-detail-secondary:hover {
    background: #fff1c7;
    border-color: #d9b05a;
}

/* === Responsive === */
@media (max-width: 1200px) {
    .mining-db-hero h1 {
        font-size: 2.5rem;
    }
    
    .grid {
        grid-template-columns: 280px 1fr;
    }
}

@media (max-width: 1024px) {
    .main-content {
        padding: 32px 0;
    }

    .main-content > .container {
        padding: 0 20px;
    }

    .grid {
        grid-template-columns: 1fr;
    }
    
    .filter-sidebar {
        position: static;
        width: 100%;
        max-width: none;
        top: auto;
    }

    .filter-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .filter-actions .btn-secondary,
    .filter-actions .btn-export {
        flex: 1 1 220px;
    }

    .map-wrapper,
    .table-wrapper {
        width: 100%;
    }

    .map-wrapper {
        height: 500px;
    }

    #map-container {
        height: 100%;
    }
}

@media (max-width: 768px) {
    .mining-db-hero {
        min-height: 340px;
        padding: 28px 20px;
    }

    .mining-db-hero h1 {
        font-size: 2rem;
    }
    
    .mining-db-hero p {
        font-size: 1rem;
    }
    
    .category-pills {
        justify-content: center;
    }
    
    .pill {
        font-size: 12px;
        padding: 8px 14px;
    }

    .main-content {
        padding: 28px 0;
    }

    .main-content > .container {
        padding: 0 18px;
    }

    .grid {
        gap: 18px;
    }

    .filter-sidebar {
        padding: 20px;
        border-radius: 14px;
    }

    .main-column {
        gap: 22px;
    }

    .filter-panel {
        gap: 16px;
    }

    .filter-group {
        padding-bottom: 16px;
    }

    .category-filter-controls,
    .filter-actions {
        flex-direction: column;
    }

    .filter-actions .btn-secondary,
    .filter-actions .btn-export {
        width: 100%;
        flex: 1 1 auto;
    }

    .custom-state-menu {
        position: static;
        left: auto;
        right: auto;
        width: 100%;
        margin-top: 8px;
        max-height: 48vh;
        box-shadow: 0 12px 24px rgba(151, 27, 47, 0.1);
    }

    .map-wrapper {
        height: 400px;
        border-radius: 14px;
    }
    
    #map-container {
        height: 100%;
    }
    
    .map-controls {
        top: 12px;
        right: 12px;
        gap: 6px;
    }
    
    .map-controls button {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .map-legend-toggle {
        display: inline-flex;
        position: absolute;
        left: 12px;
        bottom: 12px;
        z-index: 1001;
        align-items: center;
        justify-content: center;
        min-height: 36px;
        padding: 8px 12px;
        border: 1px solid #d6b75f;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.96);
        color: #3f2900;
        font-size: 12px;
        font-weight: 700;
        letter-spacing: 0.2px;
        box-shadow: 0 8px 22px rgba(17, 24, 39, 0.18);
        cursor: pointer;
    }

    .map-legend-toggle:focus-visible {
        outline: 2px solid #971b2f;
        outline-offset: 2px;
    }
    
    .map-legend {
        left: 12px;
        right: 12px;
        bottom: 56px;
        max-width: none;
        width: auto;
        padding: 12px;
        font-size: 12px;
        max-height: 48%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transform: translateY(calc(100% + 16px));
        opacity: 0;
        pointer-events: none;
        transition: transform 0.2s ease, opacity 0.2s ease;
    }

    .map-legend.is-open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .table-wrapper {
        padding: 22px 18px;
        border-radius: 14px;
    }

    .table-wrapper h2 {
        font-size: 1.35rem;
        margin-bottom: 18px;
    }

    .table-header,
    .pagination {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .table-actions,
    .action-buttons {
        width: 100%;
    }

    .action-buttons {
        flex-wrap: wrap;
    }

    .data-table th,
    .data-table td {
        padding: 12px;
    }

    .table-container {
        overflow: visible;
        background: transparent;
        box-shadow: none;
    }

    .data-table {
        min-width: 100%;
        border-collapse: separate;
        border-spacing: 0;
    }

    .data-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .data-table tbody {
        display: block;
    }

    .data-table tbody tr {
        display: block;
        background: #ffffff;
        border: 1px solid #ead7a3;
        border-radius: 12px;
        margin-bottom: 12px;
        box-shadow: 0 6px 16px rgba(17, 24, 39, 0.06);
        overflow: hidden;
    }

    .data-table tbody tr:hover {
        background: #ffffff;
    }

    .data-table td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        width: 100%;
        border-bottom: 1px solid #f3e6bf;
        padding: 10px 12px;
        font-size: 13px;
    }

    .data-table td:last-child {
        border-bottom: 0;
    }

    .data-table td::before {
        content: attr(data-label);
        display: inline-block;
        min-width: 92px;
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.4px;
        color: #6b7280;
        flex-shrink: 0;
    }

    .data-table td.no-data {
        display: table-cell;
    }

    .data-table td.no-data::before {
        content: none;
    }

    .contact-info,
    .action-buttons {
        width: 100%;
    }

    .action-buttons {
        justify-content: flex-end;
    }

    .action-buttons .mining-db-table-btn {
        flex: 1 1 0;
    }
}

@media (max-width: 480px) {
    .mining-db-hero {
        min-height: 300px;
        padding: 24px 16px;
    }
    
    .mining-db-hero h1 {
        font-size: 1.5rem;
    }
    
    .main-content,
    .data-section {
        padding: 24px 0;
    }

    .main-content > .container {
        padding: 0 16px;
    }

    .grid {
        gap: 16px;
    }
    
    .filter-sidebar {
        padding: 16px;
        border-radius: 12px;
    }

    .search-box,
    .filter-select,
    .custom-state-trigger {
        font-size: 16px;
    }

    .custom-state-menu {
        max-height: 42vh;
    }

    .map-wrapper {
        height: 360px;
    }

    #map-container {
        height: 100%;
    }

    .checkbox-group label,
    .state-option {
        align-items: flex-start;
    }

    .checkbox-label,
    .state-option label {
        line-height: 1.35;
    }

    .checkbox-group .count {
        margin-left: 8px;
        flex-shrink: 0;
    }

    .map-controls {
        top: 10px;
        right: 10px;
    }

    .map-controls button {
        width: 34px;
        height: 34px;
        font-size: 16px;
    }

    .map-legend-toggle {
        left: 10px;
        bottom: 10px;
        min-height: 34px;
        padding: 7px 11px;
        font-size: 11px;
    }

    .map-legend {
        left: 10px;
        right: 10px;
        bottom: 52px;
        padding: 10px 12px;
        max-height: 52%;
    }

    .legend-item {
        font-size: 11px;
        gap: 8px;
    }

    .table-wrapper {
        padding: 18px 14px;
    }

    .table-wrapper h2 {
        font-size: 1.2rem;
        margin-bottom: 16px;
    }

    .table-container {
        border-radius: 10px;
    }

    .data-table {
        min-width: 100%;
    }

    .pagination {
        padding: 14px;
    }

    .page-btn {
        width: 100%;
    }

    .mining-db-back-link__tooltip {
        left: 0;
        top: calc(100% + 8px);
    }
}

/* ============================================
   POLICY PROFILE CARDS (Related Policies Section)
============================================ */
.related-policies-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #ead7a3;
}

.policy-profiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.policy-profile-card {
    background: white;
    border: 1px solid #4a1620;
    border-radius: 8px;
    padding: 15px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.policy-profile-card:hover {
    border-color: #ffc03c;
    box-shadow: 0 8px 18px rgba(151, 27, 47, 0.14);
    transform: translateY(-2px);
}

.policy-profile-card a.policy-profile-name {
    color: #22161b;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    display: block;
    margin-bottom: 8px;
    line-height: 1.4;
}

.policy-profile-name:visited {
    color: #ffc03c;
}

.policy-profile-name:hover {
    color: #ffc03c;
    text-decoration: underline;
}

.policy-profile-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.policy-meta-badge {
    display: inline-block;
    background: #fff1c7;
    color: #971b2f;
    border: 1px solid rgba(151, 27, 47, 0.14);
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
}

.view-all-link {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #ead7a3;
    text-align: center;
}

.view-all-link a {
    color: #971b2f;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
}

.view-all-link a:hover {
    color: #6d1323;
    text-decoration: underline;
}

/* === Custom Map Pin Markers === */
.custom-marker-icon {
    background: none;
    border: none;
}

.marker-pin {
    width: 16px;
    height: 22px;
    position: relative;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

.marker-pin:hover {
    transform: rotate(-45deg) scale(1.25);
}

.marker-pin-dot {
    width: 5px;
    height: 5px;
    background-color: white;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Leaflet popup adjustment for pin markers */
.leaflet-popup-content-wrapper {
    background: #fffdf8;
    border: 1px solid #ead7a3;
    border-radius: 14px;
    box-shadow: 0 18px 34px rgba(34, 22, 27, 0.16);
}

.leaflet-popup-content {
    margin: 14px 16px;
    min-width: 0;
}

.leaflet-popup-tip {
    background: #fffdf8;
}

.leaflet-popup-tip-container {
    margin-top: -1px;
}

.stakeholder-popup-content {
    color: #2b1d23;
}

.stakeholder-popup-title {
    margin: 0 0 8px;
    font-size: 1rem;
    line-height: 1.35;
    font-weight: 700;
    color: #4a1620;
}

.stakeholder-popup-meta {
    margin: 4px 0;
    font-size: 0.88rem;
    line-height: 1.45;
    color: #4b5563;
}

.stakeholder-popup-meta strong {
    color: #971b2f;
    font-weight: 600;
}

.stakeholder-popup-button {
    margin-top: 10px;
    padding: 6px 12px;
    border: 1px solid #971b2f;
    border-radius: 999px;
    background: #ffc03c;
    color: #3b2500;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.stakeholder-popup-button:hover {
    background: #e3aa23;
    color: #4a1620;
    border-color: #7f1628;
    transform: translateY(-1px);
}

.stakeholder-popup-button:focus-visible {
    outline: 3px solid rgba(151, 27, 47, 0.24);
    outline-offset: 2px;
}

/* === Marker Cluster Styling === */
.marker-cluster {
    background-clip: padding-box;
    border-radius: 50%;
}

.marker-cluster div {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.marker-cluster-small {
    background-color: rgba(255, 192, 60, 0.35);
}

.marker-cluster-small div {
    background-color: rgba(255, 192, 60, 0.75);
}

.marker-cluster-medium {
    background-color: rgba(255, 152, 0, 0.35);
}

.marker-cluster-medium div {
    background-color: rgba(255, 152, 0, 0.75);
}

.marker-cluster-large {
    background-color: rgba(244, 67, 54, 0.35);
}

.marker-cluster-large div {
    background-color: rgba(244, 67, 54, 0.75);
}

.marker-cluster:hover {
    cursor: pointer;
}

.marker-cluster:hover div {
    transform: scale(1.1);
    transition: transform 0.2s ease;
}
