/* --- Global Style Reset & Variables --- */
:root {
    --primary-dark: #11652f;      /* Deeper forest green header background */
    --primary-accent: #15803d;    /* Forest green for buttons/links (vegetation theme) */
    --primary-accent-hover: #166534; /* Darker forest green for hover states */
    --header-button-accent: #15803d;    /* Forest green for buttons/links (vegetation theme) */
    --header-button-accent-hover: #1baa4f; /* Darker forest green for hover states */
    --header-line: #159745;       /* Bright green accent line under the header */
    --focus-ring: rgba(21, 128, 61, 0.4); /* Accessible focus outline */
    --background-color: #FFFFFF;
    --container-bg: #FFFFFF;
    --subtle-bg: #f8f9fa;
    --text-color: #4a5568;        /* Softer grey for body text */
    --header-text-color: #1a202c; /* Stronger grey for headers */
    --subtle-text: #718096;
    --border-color: #EAEAEA;
    --border-radius: 8px;
    --font-family: 'Fira Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    font-family: var(--font-family);
    font-weight: 400;
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

h1, h2, h3, h4 {
    font-weight: 600;
    letter-spacing: -0.5px;
    color: var(--header-text-color);
}

/* --- Accessible focus ring (keyboard navigation) --- */
a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
.filter-button:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--primary-accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* --- Main Layout --- */
header {
    background-color: var(--primary-dark);
    /* Eggshell grain: fine, dense noise softened with a tiny blur for a matte finish */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='e'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeGaussianBlur stdDeviation='0.4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23e)' opacity='0.14'/%3E%3C/svg%3E");
    background-size: 140px 140px;
    /*background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)' opacity='0.13'/%3E%3C/svg%3E");
    background-size: 160px 160px;*/
    color: #ffffff;
    padding: 0.75rem 1rem; 
    text-align: center;
}
.header-accent-bar {
    width: 100%;
    height: 4px;             /* Height of the strip */
    background-color: var(--header-line);
    margin: 0;
    padding: 0;
    border-bottom: 1px solid #e2e8f0; /* Optional: tiny border for definition */
}
.header-content {
    width: min(90vw, 900px);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

header h1 {
    margin: 0;
    font-size: 2.5rem;
    color: #ffffff;
}
.site-title-link {
    color: inherit;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.site-title-link:hover {
    opacity: 0.7;
}

header p {
    margin: 0;
    font-size: 1.05rem;
    color: rgba(255, 255, 255, 0.75);
}

.header-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* --- Development Banner --- */
.dev-banner {
    /* Flexbox is the best way to center Icon + Text together */
    display: flex;
    justify-content: center; /* Centers items horizontally */
    align-items: center;     /* Centers items vertically */
    
    /* Dimensions */
    width: 100%;
    box-sizing: border-box;  /* Prevents padding from breaking the width */
    margin: 0;               /* Removes any default browser margins */
    padding: 0.4rem 1rem;
    gap: 10px;               /* Space between Icon and Text */

    /* Colors */
    background-color: #fff3cd; 
    color: #856404;            
    border-bottom: 0.5px solid #ffeeba;
    
    /* Text settings */
    font-size: 0.95rem;
    text-align: center;      /* Failsafe for text wrapping on small screens */
}

.dev-banner i {
    font-size: 1rem;
    opacity: 0.8;
}
/* --- Main Layout --- */

main {
    width: 95%;
    max-width: 2000px;
    padding: 0.5rem 1rem;
    margin: 0 auto;
}
/* --- Map Container --- */
#map {
    width: 100%;
    height: 675px;
    
    /* CHANGED: 0 bottom margin */
    margin: 0 auto 0 auto; 
    
    /* OPTIONAL: Remove bottom rounded corners so it connects to the bar */
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: none; /* Remove bottom border to merge with footer */
    
    border-top-left-radius: var(--border-radius);
    border-top-right-radius: var(--border-radius);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
    
    background-color: var(--subtle-bg);
    position: relative;
    z-index: 1;
}

/* 2. Update the Footer to sit flush on top */
.map-footer-bar {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    width: 100%;
    
    /* CHANGED: Zero top margin */
    margin-top: 0;
    margin-bottom: 5px;
    
    /* Match the map's border settings to look like a footer */
    border: 1px solid var(--border-color);
    border-top: 1px solid #eee; /* Subtle separator line */
    
    /* Rounded corners ONLY on the bottom */
    border-bottom-left-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
    
    /* Add background color to distinguish it */
    background-color: #f9f9f9;
    
    /* Padding */
    padding: 8px 15px; /* Add horizontal padding so text isn't on the edge */
    box-sizing: border-box; /* Ensures padding doesn't break width */
}

/* Ensure the group layout stays flexible */
.selection-filter-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Style the text label */
.selection-text {
    font-weight: 500;
    color: #444;
    font-size: 0.95rem;
}
/* On mobile, make it a bit smaller */
@media (max-width: 768px) {
    #map {
        height: 350px;
    }
}
.table-container {
    background: var(--container-bg);
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.table-container h2 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

.table-container p {
    margin-bottom: 0.75rem;
    margin-top: 0;
}
/* --- Filters (unboxed, cleaner look) --- */


/* --- Checkbox Filters --- */
.filters-container {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.25rem 0;
    margin-bottom: 0.75rem;
    border: none;
    border-bottom: 1px solid var(--border-color);
    background: none;
    align-items: center;
}

/* Add breathing room between consecutive filter groups so buttons do not merge visually */
.filters-container .filter-group + .filter-group {
    margin-left: 0.5rem;
}

/* Section headings that group the View vs Filter controls */
.filter-bar-heading {
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--subtle-text);
    margin-right: 0.15rem;
}

.filter-separator {
    width: 1px;
    background-color: var(--border-color);
    margin: 0 1rem; /* Add some space on either side */
    align-self: stretch; /* Make it the full height of the container */
}

/* Decorative pseudo-element keeps separator height consistent in all browsers */
.filter-separator::after {
    content: '';
}
.filter-group {
    position: relative;
    display: flex;         /* Use Flexbox for alignment */
    align-items: center;   /* Vertically align items in the middle */
    gap: 2px;             /* Add a small space between label and button */
}

/* Style for the select dropdowns that remain */
.filter-group label {
    margin-right: 5px;
    font-weight: 500;
    font-size: 0.85em;
    color: var(--subtle-text);
}
.filter-group select {
    padding: 4px 8px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    background-color: var(--container-bg);
    font-family: var(--font-family);
    font-size: 0.9em;
    font-weight: 500;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s;
}
.filter-group select:hover {
    border-color: var(--primary-accent);
}

.filter-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 4px 8px;
    font-family: var(--font-family);
    font-size: 0.9em;
    font-weight: 500;
    background-color: var(--container-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
}
.filter-button.active {
    background-color: var(--primary-accent);
    color: white;
    border-color: var(--primary-accent);
}
.filter-button i {
    transition: transform 0.2s;
}
.filter-button.open i {
    transform: rotate(180deg);
}

.filter-panel {
    display: none; /* Hidden by default until a filter is toggled open */
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    background-color: var(--container-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    padding: 1rem;
    margin-top: 5px;
    max-height: 250px;
    overflow-y: auto;
    min-width: 200px;
}
.filter-panel label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 400;
    cursor: pointer;
}
.filter-panel input {
    margin-right: 0.5rem;
}
/* --- Buttons --- */
.download-button {
    display: inline-block;
    padding: 10px 18px;
    background-color: var(--primary-accent);
    color: white;
    text-decoration: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    border: 1px solid var(--primary-accent);
    transition: all 0.2s;
}

.download-button:hover {
    background-color: var(--primary-accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px var(--focus-ring);
}

.download-button.secondary {
    background-color: transparent;
    color: var(--header-text-color);
    border: 1px solid var(--border-color);
}

.download-button.secondary:hover {
    background-color: var(--subtle-bg);
    border-color: #DCDCDC;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

/* --- Popups & Lightbox --- */
.leaflet-popup-content {
    font-family: var(--font-family);
    /* Limit height so it fits inside the map */
    max-height: 450px; 
    
    /* Add a scrollbar if content is too long */
    overflow-y: auto;  
    
    /* Ensure it's wide enough to read */
    min-width: 260px !important; 
    
    /* Add some padding for the scrollbar */
    padding-right: 5px;
}

/* Make the scrollbar look nicer */
.leaflet-popup-content::-webkit-scrollbar {
    width: 8px;
}
.leaflet-popup-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}
.leaflet-popup-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}
.leaflet-popup-content::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}
.leaflet-popup-content-wrapper { border-radius: var(--border-radius); box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1); }
.leaflet-popup-content h3 { color: var(--primary-dark); }
.popup-actions { margin-top: 15px; display: flex; flex-direction: column; gap: 8px; }
.popup-button { padding: 8px 12px; border: none; background-color: var(--primary-accent); color: white; text-align: center; text-decoration: none; border-radius: var(--border-radius); font-weight: 500; transition: background-color 0.2s; }
.popup-button:hover { background-color: var(--primary-accent-hover); }
.leaflet-popup-content .popup-button { color: white !important; }
.popup-section { margin-top: 1rem; }
.sources-section h4 { margin: 0 0 0.5rem; font-size: 1rem; }
.source-links { display: flex; flex-direction: column; gap: 0.5rem; max-width: 340px; word-break: break-word; }
.source-block { font-size: 0.9rem; color: var(--text-color); }
.source-block:not(:last-child) { margin-bottom: 0.5rem; }
.source-subtitle { display: inline-block; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--subtle-text); margin-bottom: 0.25rem; }
.source-links a, .sources-section a { color: var(--primary-accent); word-break: break-word; }
.source-links a:hover, .sources-section a:hover { text-decoration: underline; }
.source-link-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem 0.65rem; }
.source-link-list li { display: inline-flex; align-items: center; gap: 0.25rem; }
.source-link-list li::before { content: '•'; color: var(--subtle-text); font-size: 0.75rem; }
.source-block > .source-subtitle + .source-link-list { margin-top: 0.25rem; }
.source-summary { display: flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; }
.source-summary a, .source-summary .source-summary-text { max-width: 14rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-summary .source-summary-text { color: var(--subtle-text); }
.source-expand-button { border: none; background: none; color: var(--primary-accent); cursor: pointer; font-size: 0.8rem; padding: 0; }
.source-expand-button:hover, .source-expand-button:focus { text-decoration: underline; }
.source-details { margin-top: 0.35rem; }
.source-details[hidden] { display: none; }

/* --- Custom Map Controls --- */
.leaflet-control-reset {
    background-color: #fff;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #4a5568;
    font-size: 16px;
    text-decoration: none;
    border-bottom: 1px solid #ccc;
    transition: background-color 0.2s;
}

.leaflet-control-reset:hover {
    background-color: #f4f4f4;
    color: #000;
}

/* Ensure the icon is centered */
.leaflet-control-reset i {
    line-height: 30px;
}

/* --- Interactive Table Styles --- */
#sites-table_wrapper { padding-top: 1rem; }
#sites-table tbody tr { cursor: pointer; transition: background-color 0.2s ease; border-left: 4px solid transparent; }
#sites-table tbody tr:hover { background-color: var(--subtle-bg); }
#sites-table thead th { border-bottom: 2px solid var(--border-color); font-weight: 500; color: var(--subtle-text); text-transform: uppercase; letter-spacing: 0.5px; font-size: 0.8rem; }
#sites-table tbody td.site-id-column { white-space: nowrap; }
#sites-table tbody td.site-id-column strong { display: inline-block; }
#sites-table tbody td.site-id-column .site-id-link { color: var(--primary-accent); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
#sites-table tbody td.site-id-column .site-id-link:hover { text-decoration: none; }
.dataTables_wrapper .dataTables_paginate .paginate_button { border-radius: 50% !important; }
.site-icon { margin-right: 8px; color: var(--subtle-text); }
.site-note { font-style: italic; color: var(--subtle-text); }
.site-table-wrapper {
    overflow-x: auto;
    width: 100%;
}

#site-table {
    width: 100%;
    white-space: nowrap; /* Prevent ugly wrapped text */
}

/* Fix DataTables Header Misalignment */
.dataTables_scrollHeadInner,
.dataTables_scrollHeadInner table {
    width: 100% !important;
}
/* --- Legend Styles --- */
.legend { 
padding: 10px 15px; 
font-size: 13px; 
background: rgba(255, 255, 255, 0.9); 
backdrop-filter: blur(5px); 
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1); 
border: 1px solid rgba(0, 0, 0, 0.05); 
border-radius: var(--border-radius); 
line-height: 20px; max-height: 30vh; 
overflow-y: auto; 
}

.legend h4 { 
    margin: 0 0 8px; 
    color: var(--primary-dark); 
}

.legend i { 
    width: 16px; 
    height: 16px; 
    float: left; 
    margin-right: 8px; 
    border-radius: 4px; 
}

/* --- Footer --- */
footer {
    text-align: center;
    padding: 1.5rem 1rem;
    margin-top: 1.5rem;
    background-color: var(--subtle-bg);
    color: var(--subtle-text);
    border-top: 1px solid var(--border-color);
}
.footer-logos {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    margin-bottom: 2rem;
    flex-wrap: wrap; /* Good to keep for responsiveness */
}
.footer-logos a {
    opacity: 0.7;
    transition: opacity 0.2s;
}
.footer-logos a:hover {
    opacity: 1;
}

/* --- MODIFIED FOR UNIFORM HEIGHT --- */
.footer-logos img {
    height: 50px;  /* <-- This is the main change */
    width: auto;   /* <-- This lets the width scale proportionally */
}

.footer-affiliation {
    max-width: 700px;
    margin: 0 auto 2rem auto;
    font-size: 0.8rem;
    line-height: 1.6;
}
.footer-text a {
    color: var(--primary-accent);
    font-weight: 500;
    text-decoration: none;
}
.footer-text a:hover {
    text-decoration: underline;
}
.footer-muted {
    color: var(--text-muted, #888);
    font-weight: 500;
    font-style: italic;
}

/* --- Policy Page Specific --- */
.back-link { display: inline-block; padding: 8px 15px; background-color: var(--header-button-accent); color: white; text-decoration: none; border-radius: var(--border-radius); font-weight: 500; transition: all 0.2s; }
.back-link:hover {transform: translateY(-2px); }
.basicLightbox__placeholder img { max-width: 90vw; max-height: 90vh; }

/* --- PFT Scheme Toggle Switch --- */
input:checked + .slider {
    background-color: var(--primary-accent);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

/* --- Action Bar (New Container) --- */
.action-bar {
    display: flex;
    justify-content: center;
    margin-bottom: 0.5rem; /* Space between button and filters */
    width: 100%;
    gap: 15px;
}

/* --- Documentation Button Styling --- */
.help-button {
    background-color: #ffffff; /* White background for contrast against page */
    color: var(--primary-accent); /* Blue text */
    border: 2px solid var(--primary-accent); /* Solid blue border */
    border-radius: 15px; /* Fully rounded pill shape */
    padding: 0.4rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    
    /* Make it look "lifted" and clickable */
    box-shadow: 0 4px 6px rgba(21, 128, 61, 0.15);
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    
    /* Flex alignment for the icon */
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.help-button i {
    font-size: 1.1em;
}

/* Hover State - Lifts up and shadow grows */
.help-button:hover {
    background-color: var(--primary-accent);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 7px rgba(21, 128, 61, 0.3);
}

/* Active/Click State - Presses down */
.help-button:active {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(21, 128, 61, 0.2);
}
/* The KG table lives inside this scroll container */
.kg-scroll {
    overflow-x: auto;
    max-width: 100%;
}

/* KG table: big matrix, allow it to be wider but scroll horizontally */
.kg-table {
    border-collapse: collapse;
    width: max-content;   /* only as wide as needed for all columns */
    white-space: nowrap;  /* keep headings on one line */
    font-size: 0.8rem;
    margin-top: 0.75rem;
}

.kg-table th,
.kg-table td {
    border: 1px solid #ddd;
    padding: 4px 6px;
    text-align: center;
}

.kg-table th:first-child,
.kg-table td:first-child {
    text-align: left;
    background: #f8f9fa;
}
#help-modal .modal-content {
    width: min(90vw, 900px);  /* never larger than 900px */
    margin: 5% auto;
}
/* Modal styling */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1001; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0, 0, 0, 0.6); /* Black w/ opacity */
}

/* Shared modal layout container */
.modal-content {
    background-color: #fefefe;
    margin: 5% auto; /* 5% from the top and centered */
    padding: 20px 30px;
    border: 1px solid #888;
    width: 80%;
    max-width: 800px;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
}

.modal-content.view-modal {
    max-width: 960px;
    padding: 2.5rem 2.75rem;
}

.view-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.view-modal-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.view-site-subtitle {
    margin: 0.35rem 0 0;
    color: var(--subtle-text);
}

.view-modal-body {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
/* Container for the arrows */
.view-nav-controls {
    display: flex;
    gap: 10px;
    margin-right: 15px; /* Space between arrows and title */
}

/* The Arrow Buttons */
.nav-arrow {
    background: #f0f2f5;
    border: 1px solid #dcdcdc;
    border-radius: 50%; /* Circle shape */
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: #555;
    transition: all 0.2s ease;
}

.nav-arrow:hover {
    background-color: var(--primary-accent);
    color: white;
    border-color: var(--primary-accent);
}

.nav-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background-color: #f9f9f9;
    color: #ccc;
}

/* Adjust header to align items properly */
.view-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.view-field {
    background: var(--subtle-bg);
    padding: 0.85rem 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.view-label {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--subtle-text);
}

.view-value {
    font-size: 0.95rem;
    color: var(--text-color);
    word-break: break-word;
}

.view-section {
    background: var(--subtle-bg);
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.view-section h3 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-size: 1.05rem;
}

/* Revision-history section: date line + the (code-like) PFT change note. */
.revision-date {
    margin: 0 0 0.4rem;
    font-size: 0.9rem;
}

.revision-note {
    margin: 0;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-color);
    white-space: pre-wrap;
    word-break: break-word;
}

.media-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.media-card {
    background: white;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.media-card img {
    width: 100%;
    height: 160px;
    object-fit: cover;
}

.media-card figcaption {
    padding: 0.75rem;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.media-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.media-action {
    font-size: 0.85rem;
    color: var(--primary-accent);
    text-decoration: none;
}

.media-action:hover {
    text-decoration: underline;
}

.close-button {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
}

.modal-content .close-button:not(button) {
    float: right;
}

button.close-button {
    background: none;
    border: none;
    position: absolute;
    top: 12px;
    right: 18px;
    padding: 0;
    line-height: 1;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.modal h2 {
    margin-top: 0;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

.modal h3 {
    margin-top: 20px;
    color: #333;
}

.modal section {
    margin-bottom: 15px;
}

.modal ul {
    padding-left: 20px;
}
.modal li {
    margin-bottom: 8px;
}

/* Style for PFT tables in modal */
/* PFT tables: only take the space they need */
.pft-table {
    border-collapse: collapse;
    width: auto;
    max-width: 100%;  /* don’t overflow small screens */
}

.pft-table th,
.pft-table td {
    border: 1px solid #ddd;
    padding: 4px 6px;
    text-align: left;
}


.pft-table th {
    background-color: #f2f2f2;
}

/* --- Edit modal form --- */
.edit-modal {
    max-width: 900px;
}

.download-modal {
    max-width: 620px;
}

.download-modal-description {
    margin-top: 0.5rem;
    color: var(--subtle-text);
}

.download-column-options {
    margin-top: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem 1rem;
}

.download-column-option {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.95rem;
    color: var(--text-color);
}

.download-column-option.required {
    font-weight: 600;
}

.download-column-option input {
    margin-top: 0.2rem;
}

.download-modal-actions {
    margin-top: 1.75rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.edit-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.edit-form-grid label {
    display: flex;
    flex-direction: column;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--subtle-text);
}

.edit-form-grid input,
.edit-form-grid select,
.edit-form-grid textarea {
    margin-top: 0.4rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    background-color: var(--container-bg);
    font-family: var(--font-family);
    font-size: 0.95rem;
    color: var(--text-color);
}

.edit-form-grid textarea {
    resize: vertical;
}

.edit-form-grid .full-width {
    grid-column: 1 / -1;
}

.edit-modal-actions {
    margin-top: 1.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.button {
    padding: 0.65rem 1.4rem;
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.button.primary {
    background-color: var(--primary-accent);
    color: #fff;
    border-color: var(--primary-accent);
}

.button.primary:hover {
    background-color: var(--primary-accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px var(--focus-ring);
}

.button.warning {
    background-color: transparent;
    color: #b45309;
    border-color: #f59e0b;
}

.button.warning:hover {
    background-color: #fffbeb;
    transform: translateY(-1px);
}

.button.secondary {
    background-color: transparent;
    color: var(--header-text-color);
    border-color: var(--border-color);
}

.button.secondary:hover {
    background-color: var(--subtle-bg);
    transform: translateY(-1px);
}

.button[disabled],
.button[aria-disabled="true"] {
    background-color: var(--border-color);
    color: var(--subtle-text);
    border-color: var(--border-color);
    cursor: not-allowed;
    transform: none;
}

.button[disabled]:hover,
.button[aria-disabled="true"]:hover {
    transform: none;
}

.edit-modal-notice {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    margin: 0 0 1.25rem;
    padding: 0.75rem 0.9rem;
    background-color: #fff8e6;
    border: 1px solid #f4d576;
    border-left: 4px solid #e0a800;
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    line-height: 1.45;
    color: #6b5300;
}

.edit-modal-notice i {
    margin-top: 2px;
    color: #d99400;
    flex-shrink: 0;
}

.edit-modal-hint {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--subtle-text);
    text-align: right;
}

.view-site-button {
    padding: 4px 10px;
    font-size: 0.8rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--primary-accent);
    background-color: transparent;
    color: var(--primary-accent);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.view-site-button:hover {
    background-color: var(--primary-accent);
    color: #fff;
}

.flag-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 2rem;
    text-transform: uppercase;
    color: #fff;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.95), 
    /* 2. A larger, softer glow for the ambient effect */
    0 0 12px rgba(255, 255, 255, 0.7);
}

.flag-a { background-color: #009E73; }
.flag-b { background-color: #F0E442; color: #2d2d2d; }
.flag-c { background-color: #D55E00; }
.flag-d { background-color: #8C8C8C; }
.flag-n-a { background-color: #bdc3c7; }

.coverage-flag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.coverage-flag-letter {
    font-weight: 600;
    color: var(--header-text-color);
}

.coverage-flag .coverage-range {
    color: var(--subtle-text);
    white-space: nowrap;
}

#sites-table tbody td .coverage-range {
    font-size: 0.85em;
}

.coverage-flag--with-pill {
    gap: 0.25rem;
}

.coverage-flag .flag-pill {
    text-transform: none;
}

.coverage-flag--with-pill .flag-pill {
    margin-right: 0;
}

.coverage-detail {
    margin-left: 0.35rem;
    font-size: 0.85rem;
    color: var(--subtle-text);
}
/* Styles pour les tablettes et les téléphones (écrans de moins de 768px de large) */
@media (max-width: 768px) {

    /* --- En-tête --- */
    header {
        padding: 2rem 1rem;
    }
    header h1 {
        font-size: 2rem; /* Titre plus petit */
    }
    header p {
        font-size: 1rem; /* Texte plus petit */
    }

    /* --- Contenu principal --- */
    main {
        width: 100%;
        padding: 1.5rem 0.5rem;
    }

    /* --- Filtres --- */
    .filters-container {
        flex-direction: column; /* Empile les groupes de filtres verticalement */
        align-items: stretch;   /* Étire les filtres sur toute la largeur */
        gap: 0.75rem;
        border-bottom: 2px solid var(--border-color);
    }
    .filter-separator {
        display: none; /* Cache le séparateur vertical qui n'est plus utile */
    }
    .filter-panel {
        left: 0;
        right: 0; /* Assure que le panneau prend toute la largeur */
        width: auto;
    }

    /* --- Modales --- */
    .modal-content {
        width: 90%;
        margin: 10% auto;
        padding: 15px 20px;
    }
    .view-modal-header, .view-modal-actions {
        flex-direction: column;
        align-items: flex-start;
    }
    .edit-form-grid, .download-column-options {
        grid-template-columns: 1fr; /* Une seule colonne pour les formulaires */
    }
}
/* --- Toggle Switch Styling --- */
.selection-filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 20px;
}

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

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

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

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

input:checked + .slider:before {
    transform: translateX(14px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

.text-link-btn {
    background: none;
    border: none;
    color: #c0392b;
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0;
    margin-left: 5px;
}

/* --- Table Checkbox Styling --- */
td.select-checkbox {
    text-align: center;
    cursor: pointer;
}
.site-select-cb {
    transform: scale(1.2);
    cursor: pointer;
}
