/* js/style.css */
/* Core Typography and Base Styling */

body {
    font-family: 'Inter', sans-serif;
    background-color: #f1f5f9; /* slate-100 - page background */
    line-height: 1.6; /* Improved readability */
    color: #334155; /* Default text color, slate-700 equivalent */
    -webkit-font-smoothing: antialiased; /* Smoother fonts */
    -moz-osx-font-smoothing: grayscale; /* Smoother fonts */
}

/* Scroll lock for modals and fullscreen */
body.fullscreen-active-body-scroll-lock,
body.modal-active-body-scroll-lock {
    overflow: hidden;
}

/* Disable user select during column dragging */
body.is-column-dragging * {
    user-select: none !important;
}

/* Custom Shadow Definitions (Implemented via standard CSS, not custom Tailwind config) */
/* These are designed to give a more layered, modern depth */
.shadow-custom-3xl {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
}
.shadow-custom-4xl {
    box-shadow: 0 35px 70px -15px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.1);
}
.shadow-inset-light {
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}


/* Styles for Modals and Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); /* Darker, more immersive backdrop */
    backdrop-filter: blur(8px); /* Modern frosted glass effect */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content-base {
    background-color: #fff;
    padding: 30px;
    border-radius: 1.5rem; /* rounded-3xl */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); /* Default shadow for modals */
    max-width: 700px; /* Changed from 500px */
    width: 90%;
    transform: translateY(-40px) scale(0.95); /* Initial state for animation */
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease-in-out; /* Bounce-out transition */
    position: relative;
    box-sizing: border-box; /* Ensures padding doesn't affect width */
}
.modal-overlay.active .modal-content-base {
    transform: translateY(0) scale(1); /* End state for animation */
}
/* Specific modal content sizes */
.modal-content-confirm {
    max-width: 450px;
    box-shadow: var(--tw-shadow-xl, 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)); /* Tailwind shadow-xl */
}
.modal-content-row-summary {
    max-width: 900px; /* Wider for summaries */
    width: 95%;
    box-shadow: var(--tw-shadow-2xl, 0 25px 50px -12px rgba(0, 0, 0, 0.25)); /* Tailwind shadow-2xl */
}

.modal-content-sentiment {
    max-width: 900px; /* Provides ample width for the three columns */
}

.modal-title {
    font-size: 2rem; /* Larger text for clarity */
    font-weight: 800; /* Extra bold */
    color: #1a202c; /* gray-900 equivalent */
    margin-bottom: 1.5rem;
    text-align: center;
    border-bottom: 1px solid #e2e8f0; /* Subtle separator */
    padding-bottom: 0.75rem;
}
#rowSummaryModalTitle.modal-title {
    font-size: 1.75rem; /* text-2xl */
    text-align: left;
    margin-bottom: 1rem;
    border-bottom: none; /* Removed border for cleaner look with close button */
    padding-bottom: 0;
}
.modal-message {
    font-size: 1.125rem; /* text-lg */
    color: #4a5568; /* gray-700 */
    margin-bottom: 1.5rem;
    text-align: center;
    line-height: 1.5;
}
.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 1.25rem; /* Increased gap for better spacing */
    margin-top: 2rem; /* More space from content above */
}
.modal-cancel-btn, .modal-confirm-btn, .modal-save-btn, .modal-search-btn {
    padding: 0.85rem 1.75rem; /* Larger padding for better touch targets */
    border-radius: 9999px; /* rounded-full */
    font-weight: 700; /* Bolder text */
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease-in-out; /* Consistent bounce transition */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--tw-shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)); /* shadow-md */
}
.modal-cancel-btn {
    background-color: #cbd5e1; /* slate-300 */
    color: #334155; /* slate-700 */
    border: 1px solid #94a3b8; /* slate-400 */
}
.modal-cancel-btn:hover {
    background-color: #94a3b8; /* slate-400 */
    color: #1e293b; /* slate-800 */
    transform: translateY(-2px); /* Subtle lift */
    box-shadow: var(--tw-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)); /* shadow-lg */
}
.modal-confirm-btn {
    background-color: #3b82f6; /* blue-500 */
    color: #fff;
}
.modal-confirm-btn:hover {
    background-color: #2563eb; /* blue-600 */
    transform: translateY(-2px);
    box-shadow: var(--tw-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05));
}
.modal-save-btn {
    background-color: #22c55e; /* green-500 */
    color: #fff;
}
.modal-save-btn:hover {
    background-color: #16a34a; /* green-600 */
    transform: translateY(-2px);
    box-shadow: var(--tw-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05));
}
.modal-search-btn {
    background-color: #3b82f6; /* blue-500 */
    color: #fff;
}
.modal-search-btn:hover {
    background-color: #2563eb; /* blue-600 */
    transform: translateY(-2px);
    box-shadow: var(--tw-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05));
}

/* Specific styles for Row Summary Modal */
#rowSummaryContent strong {
    display: block;
    margin-bottom: 4px;
    color: #1e293b; /* slate-800 */
    font-size: 1.05rem; /* Slightly larger */
}
#rowSummaryContent input, #rowSummaryContent textarea {
    border: 1px solid #cbd5e1; /* slate-300 */
    padding: 10px 14px; /* More padding */
    border-radius: 8px; /* Rounded corners */
    font-size: 1rem;
    background-color: #f8fafc; /* light background */
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05); /* subtle inset shadow */
    transition: all 0.2s ease-in-out;
}
#rowSummaryContent textarea {
    min-height: 100px; /* More height */
    resize: vertical;
}
#rowSummaryContent input:focus, #rowSummaryContent textarea:focus {
    outline: none;
    border-color: #3b82f6; /* blue-500 */
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); /* Stronger focus ring */
    background-color: #fff; /* White background on focus */
}

/* Close button for modals */
.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    cursor: pointer;
    color: #64748b; /* slate-500 */
    padding: 8px; /* Larger hit area */
    border-radius: 9999px; /* fully rounded */
    transition: background-color 0.2s ease, color 0.2s ease;
}
.modal-close-btn:hover {
    color: #1e293b; /* slate-800 */
    background-color: #f1f5f9; /* slate-100 */
}
.modal-close-btn svg {
    width: 28px; /* Larger icon */
    height: 28px;
}

/* Google Search Modal */
#googleSearchModal {
    position: absolute; /* Positioned relative to parent content for pop-up behavior */
    background-color: #fff;
    padding: 25px 30px; /* More padding */
    border-radius: 1rem; /* rounded-xl */
    box-shadow: var(--tw-shadow-xl, 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)); /* shadow-xl */
    z-index: 1001;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 280px; /* Min width */
    max-width: 400px; /* Max width */
    text-align: center;
    opacity: 0;
    transform: scale(0.9); /* Initial state for animation */
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
    pointer-events: none; /* Allows clicks through when not active */
}
#googleSearchModal.active {
    opacity: 1;
    transform: scale(1); /* End state for animation */
    pointer-events: all;
}
#googleSearchModal h2 {
    font-size: 1.5rem; /* Larger title */
    font-weight: 700;
    margin-bottom: 15px;
    color: #1e293b;
}
#googleSearchModal #googleSearchText {
    font-size: 1rem;
    color: #475569;
    margin-bottom: 20px; /* More space */
    word-break: break-word;
}
#googleSearchModal .modal-buttons {
    margin-top: 0; /* Override default modal button margin */
}

/* General button styles for .action-button (used frequently) */
.action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem; /* Restored a sensible default padding */
    font-size: 0.9rem; /* Restored a sensible default font size */
    cursor: pointer;
    border: none;
    box-sizing: border-box;
    text-decoration: none;
    /* Shadows, rounded-full, hover:scale-105 are handled by Tailwind classes in HTML */
    /* Transition handled by Tailwind in HTML */
}
.action-buttons-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem; /* Increased gap */
    justify-content: center;
    margin-top: 2.5rem; /* More space */
}

/* This rule applies the grid layout ONLY when the Regulatory Analysis page is active.
   It creates a stable container for the two-column view without breaking other pages. */
body.active-page-regulatoryAnalysisPage #mainAppContainer {
    display: grid;
    grid-template-rows: auto 1fr; /* Header row (auto size) and Content row (fills space) */
    height: 100vh;
    overflow: hidden;
}

/* This makes the main content area scrollable if needed, but only on this specific page. */
body.active-page-regulatoryAnalysisPage #mainAppContent {
    overflow-y: auto;
}

/* The existing fullscreen mode rule below will continue to work correctly.
   It will override the grid layout whenever the .fullscreen-mode class is applied,
   which is the desired behavior. */
#mainAppContainer.fullscreen-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    padding: 2rem;
    overflow-y: auto;
    z-index: 999;
    max-width: 100vw;
    margin: 0;
}
/* Revert general container styling when not in fullscreen (explicitly to override fixed) */
#mainAppContainer:not(.fullscreen-mode) {

}


/* Table specific styles */
.table-container { 
    overflow-x: auto;
    overflow-y: auto; 
    position: relative;
    max-height: 70vh; /* Controlled by max-height */
    width: auto;
    min-width: 100%;
    border-radius: 1rem; /* rounded-2xl from HTML */
    box-shadow: var(--tw-shadow-2xl, 0 25px 50px -12px rgba(0, 0, 0, 0.25)); /* shadow-2xl from HTML */
}
#mainDataTable {
    width: 100%;
    border-collapse: separate; 
    border-spacing: 0; /* Remove default table spacing */
    min-width: 100%;
    table-layout: fixed; /* Ensures columns respect defined widths */
}

#mainDataTable th,
#mainDataTable td {
    border-bottom: 1px solid #e2e8f0; /* gray-200 - subtle border as requested */
    border-right: 1px solid #e2e8f0; /* gray-200 - subtle border as requested */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0; /* Padding will be on the inner div or contenteditable td */
    font-size: 0.85rem; /* Reduced font size for compactness */
    vertical-align: middle; 
}

#mainDataTable td:last-child,
#mainDataTable thead#tableHeader tr th:last-child { 
    border-right: none; /* No border on last column */
}

#mainDataTable thead#tableHeader {
    position: sticky;
    top: 0;
    z-index: 21; /* Above table body */
    background-color: #f8fafc; /* Ensure background on sticky header */
}

#mainDataTable th {
    background-color: #f8fafc; /* slate-50 */
    padding: 0.25rem 0.5rem; /* Further reduced vertical padding */
    text-align: left;
    color: #334155; /* slate-700 */
    font-weight: 600; /* Semibold */
}

#mainDataTable td > div {
    padding: 0.2rem 0.5rem;
    white-space: normal;
    word-break: break-word;
    min-height: 1em;
    line-height: 1.2;
}
#mainDataTable td[contenteditable="true"] {
    padding: 0.2rem 0.5rem; /* Further reduced vertical padding */
    white-space: normal;
    word-break: break-word;
    min-width: 50px;
    outline: none; /* Remove default outline */
    box-shadow: none;
    transition: background-color 0.15s ease-in-out; /* Add transition for subtle feedback */
}
/* Optional: A very subtle visual feedback for editable cells on focus, not blue */
#mainDataTable td[contenteditable="true"]:focus {
    background-color: #e2f2fe; /* Very light blue background on focus, subtle */
}


#mainDataTable td.readonly-cell {
    cursor: default;
}
#mainDataTable td.cursor-cell {
    cursor: text;
}

.resize-handle {
    position: absolute;
    right: -5px;
    top: 0;
    bottom: 0;
    width: 20px; /* Wider handle for easier grabbing */
    cursor: col-resize;
    z-index: 22; /* Above sticky header content */
    background-color: transparent;
    transition: background-color 0.2s ease;
}
.resize-handle:hover, body.is-column-dragging .resize-handle.active-resize {
    background-color: rgba(59, 130, 246, 0.2); /* Subtle blue highlight */
}

th.dragging { opacity: 0.7; background-color: #e0f2fe; border: 1px dashed #3b82f6; }
th.drag-over-target { box-shadow: inset 0 0 0 3px #3b82f6; } /* Thicker highlight */
body.is-column-dragging { cursor: col-resize !important; }

th.actions-column {
    text-align: center !important;
    min-width: 100px; /* Slightly wider for actions */
    width: 100px;
}
th.actions-column .header-content-wrapper { justify-content: center; }

.header-content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    height: 100%;
    width: 100%;
    position: relative;
}
.header-title-area {
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Align to start for text and icon, allow filter button to push to end */
    width: 100%;
    min-height: 36px; /* Taller for better click area */
    box-sizing: border-box;
    cursor: pointer;
    user-select: none;
}
.header-title-text-container { display: flex; align-items: center; gap: 6px; }
.header-title-text { 
    font-weight: 700; 
    color: #1e293b; 
    line-height: 1.25; /* Ensures text is not clipped */
} 
.sort-indicator { 
    width: 18px; 
    height: 18px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    color: #64748b; 
    margin-left: 6px; 
    flex-shrink: 0; /* Prevent icon from shrinking */
}


.column-filter-controls {
    position: absolute; 
    background-color: white;
    border: 1px solid #cbd5e1; /* gray-300 */
    padding: 15px; /* More padding */
    border-radius: 0.75rem; /* rounded-xl */
    box-shadow: var(--tw-shadow-xl, 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)); /* shadow-xl */
    z-index: 25;  
    display: none; 
    flex-direction: column;
    gap: 12px; /* More space between items */
    width: 320px; /* FIX 4: Explicit fixed width for the entire control */
    box-sizing: border-box;
}
.column-filter-controls.visible { display: flex; }
.filter-toggle-btn { background: none; border: none; cursor: pointer; padding: 6px; display: flex; align-items: center; justify-content: center; color: #64748b; transition: color 0.15s ease; }
.filter-toggle-btn:hover { color: #1e293b; background-color: #f1f5f9; border-radius: 4px; }
.filter-toggle-btn.active-filter { color: #3b82f6; font-weight: bold; }
.filter-toggle-btn.active-filter:hover { color: #2563eb; }
.filter-toggle-btn svg { width: 20px; height: 20px; } /* Larger icon */
.filter-condition-item { display: flex; gap: 8px; align-items: center; } /* More gap */
.filter-condition-select { 
    padding: 8px; 
    border: 1px solid #cbd5e1; 
    border-radius: 6px; 
    font-size: 0.9rem; 
    width: 120px; /* FIX 4: Explicit width for select */
    flex-shrink: 0; 
    min-width: 120px; /* Ensure a minimum width */
}
.column-filter-input {
    flex-grow: 1;
    padding: 8px 12px; /* More padding */
    border: 1px solid #cbd5e1; /* gray-300 */
    border-radius: 6px;
    font-size: 0.9rem;
    min-width: 80px; /* FIX 4: Adjusted min-width for input */
    width: auto; /* Allow auto width to fill space */
}
.column-filter-input:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); }
.remove-filter-btn { background-color: #f87171; color: white; border: none; border-radius: 6px; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-weight: bold; flex-shrink: 0; transition: background-color 0.1s ease; }
.remove-filter-btn:hover { background-color: #ef4444; }
.add-filter-condition-btn { background-color: #4ade80; color: white; padding: 8px 15px; border-radius: 8px; font-size: 0.9rem; border: none; cursor: pointer; transition: background-color 0.1s ease; margin-top: 10px; } /* More padding and radius */
.add-filter-condition-btn:hover { background-color: #22c55e; }

#filterGroupsBuilder .filter-group-condition-item {
    display: grid;
    grid-template-columns: minmax(100px, 1fr) minmax(100px, 1fr) minmax(180px, 3fr) auto; /* Adjusted grid columns slightly for input */
    gap: 0.75rem; /* More gap */
    align-items: center;
    margin-bottom: 0.75rem;
}
#filterGroupsBuilder .filter-group-condition-item select,
#filterGroupsBuilder .filter-group-condition-item input {
    padding: 0.5rem 0.75rem; /* More padding */
    border: 1px solid #cbd5e1; /* gray-300 */
    border-radius: 0.5rem; /* rounded-lg */
    font-size: 0.9rem;
    box-sizing: border-box;
}
#filterGroupsBuilder .filter-group-condition-item input[disabled] {
    background-color: #f1f5f9; /* slate-100 */
    cursor: not-allowed;
}

#columnToggleDropdown { padding: 15px; top: 100%; margin-top: 10px; z-index: 100; transform-origin: top; }
#columnToggleDropdown label { display: flex; align-items: center; gap: 10px; padding: 8px 10px; cursor: pointer; font-size: 0.95rem; color: #334155; border-radius: 6px; /* Rounded items */ }
#columnToggleDropdown label:hover { background-color: #f8fafc; }
#columnToggleDropdown input[type="checkbox"] { transform: scale(1.2); cursor: pointer; }
.columnToggle-actions { display: flex; justify-content: space-around; padding-bottom: 12px; border-bottom: 1px solid #e2e8f0; margin-bottom: 12px; } /* More padding, margin */
.columnToggle-actions button { background-color: #64748b; color: white; padding: 8px 15px; border-radius: 8px; font-size: 0.85rem; cursor: pointer; transition: background-color 0.1s ease; }
.columnToggle-actions button:hover { background-color: #475569; }
.columnToggle-actions button:disabled { opacity: 0.5; cursor: not-allowed; }

.pagination-controls { display: flex; justify-content: space-between; align-items: center; margin-top: 2rem; padding: 1rem 1.25rem; background-color: #fff; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.08); } /* More padding, radius, shadow */
.pagination-controls button { background-color: #e2e8f0; color: #334155; padding: 0.65rem 1.25rem; border-radius: 9999px; border: 1px solid #cbd5e1; cursor: pointer; transition: all 0.2s ease; } /* Rounded-full, transitions */
.pagination-controls button:not(:disabled) { background-color: #3b82f6; color: white; border-color: #3b82f6; }
.pagination-controls button:not(:disabled):hover { background-color: #2563eb; border-color: #2563eb; transform: translateY(-2px); box-shadow: var(--tw-shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)); }
.pagination-controls button:disabled { opacity: 0.6; cursor: not-allowed; background-color: #e2e8f0;  color: #334155; border: 1px solid #cbd5e1; }
.pagination-controls #rowsPerPageContainer label { margin-right: 0.6rem; color: #475569; font-size: 1rem; }
.pagination-controls #rowsPerPageSelect { padding: 0.5rem 0.75rem; border-radius: 8px; border: 1px solid #cbd5e1; background-color: #fff; color: #334155; font-size: 1rem; cursor: pointer; }
.pagination-controls #rowsPerPageSelect:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); }
#pageInfo { font-size: 1rem; font-weight: 600; color: #334155; }

.page-view { display: none; animation: fadeIn 0.4s ease-out; } /* Slightly longer animation */
.page-view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } } /* Stronger translateY */
.page-content-wrapper { padding: 5px; background-color: #fff; border-radius: 16px; box-shadow: 0 8px 20px rgba(0,0,0,0.08); } /* More padding, radius, shadow */

.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 2rem; margin-top: 2rem; } /* Wider minmax, more gap */
.grid-span-full {
    grid-column: 1 / -1;
}
.chart-container {
    background-color: #f8fafc;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
    
    /* These new flex properties force all direct children to be centered */
    display: flex;
    flex-direction: column;
    align-items: center;
}
.chart-container h3 { font-size: 1.25rem; font-weight: 700; color: #1e293b; margin-bottom: 1.25rem; } /* Larger, bolder text */

/* UPDATED STYLES FOR CHART CONTAINERS AND SVGs */
#jurisdictionChartContainer,
#statusChartContainer,
#defendantsChartContainer,
#vendorCompanyTypeChartContainer,
#vendorServiceAvailabilityChartContainer,
#vendorLocationChartContainer {
    min-height: 400px;
    width: 100%;
    display: block;
}

.chart-container svg {
    max-width: 100%;
    display: block;
    margin: 0 auto;
}


.admin-section { background-color: #f8fafc; padding: 12px; border-radius: 12px; box-shadow: 0 5px 15px rgba(0,0,0,0.08); margin-bottom: 2rem; } /* More padding, radius, shadow, margin */
.admin-section h3 { font-size: 1.25rem; font-weight: 700; color: #1e293b; margin-bottom: 1.25rem; display: flex; align-items: center; gap: 12px; } /* Larger, bolder text, more gap */
.role-option { display: flex; align-items: center; margin-bottom: 1rem; } /* More margin */
.role-option input[type="radio"] { margin-right: 0.85rem; transform: scale(1.3); } /* Larger radio buttons */
.role-option label { font-size: 1.05rem; color: #334155; cursor: pointer; } /* Slightly larger label text */
.form-label { display: block; font-size: 1rem; font-weight: 600; color: #334155; margin-bottom: 0.6rem; } /* Bolder, more margin */
.form-input, .form-select { display: block; width: 100%; padding: 0.85rem 1.25rem; border: 1px solid #cbd5e1; border-radius: 0.75rem; font-size: 1rem; color: #334155; background-color: #fff; box-shadow: inset 0 1px 2px rgba(0,0,0,0.05); transition: all 0.2s ease-in-out; } /* More padding, radius, shadow, transition */
.form-input:focus, .form-select:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); background-color: #fff; } /* Stronger focus ring, white background on focus */
.form-input::placeholder { color: #94a3b8; /* slate-400 */ } /* Placeholder color */


#usersTable {
    border-radius: 0.75rem; /* rounded-xl */
    overflow: hidden; /* Ensures rounded corners */
}
#usersTable th, #usersTable td {
    padding: 14px 18px; /* More padding */
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    font-size: 0.95rem; /* Slightly larger font */
}
#usersTable th {
    background-color: #f8fafc;
    font-size: 0.8rem;
    font-weight: 700; /* Bolder */
    color: #475569; /* slate-600 */
    text-transform: uppercase;
    letter-spacing: 0.08em; /* More tracking */
}
#usersTable tbody tr:last-child td {
    border-bottom: none;
}
#usersTable td button {
    border: none;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out, opacity 0.15s ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    padding: 8px; /* Larger hit area */
    border-radius: 9999px; /* rounded-full */
    color: #64748b; /* slate-500 */
}
#usersTable td button:hover {
    background-color: #e2e8f0; /* slate-200 */
    color: #1e293b; /* slate-800 */
}
#usersTable td button svg {
    width: 20px; /* Larger icon */
    height: 20px;
}


#loading-indicator, #saving-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem; /* More padding */
    border-radius: 1rem; /* rounded-xl */
    margin-bottom: 2rem; /* More margin */
    box-shadow: 0 4px 15px rgba(0,0,0,0.08); /* More prominent shadow */
}
#loading-indicator span, #saving-indicator span {
    font-size: 1.25rem; /* Larger text */
    font-weight: 600;
}
#loading-indicator svg, #saving-indicator svg {
    animation: spin 1s linear infinite;
    width: 32px; /* Larger SVG */
    height: 32px;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Fallback for logged out state (already exists) */
#mainAppContent.logged-out #tableViewPage,
#mainAppContent.logged-out #chartsPage,
#mainAppContent.logged-out #adminPage,
#mainAppContent.logged-out #userManagementPage {
    display: none; 
}
#mainAppContent.logged-out::before { 
    content: "Please log in to view the application content.";
    display: block;
    text-align: center;
    font-size: 1.5rem; /* Larger text */
    color: #475569; /* slate-600 */
    padding: 4rem; /* More padding */
    font-weight: 500;
}

/* Bulk Import Status Messages */
#importStatusMessage {
    padding: 1.25rem; /* More padding */
    border-radius: 12px; /* Rounded corners */
    font-size: 1rem;
    border: 1px solid transparent;
    line-height: 1.5;
}
#importStatusMessage.success {
    background-color: #dcfce7; /* green-100 */
    color: #166534; /* green-800 */
    border-color: #86efac; /* green-300 */
}
#importStatusMessage.warning {
    background-color: #fefce8; /* yellow-100 */
    color: #854d0e; /* yellow-800 */
    border-color: #fde047; /* yellow-300 */
}
#importStatusMessage.error {
    background-color: #fee2e2; /* red-100 */
    color: #991b1b; /* red-800 */
    border-color: #fca5a5; /* red-300 */
}
#importStatusMessage strong {
    font-weight: 700; /* Bolder */
    display: block;
    margin-bottom: 0.6rem;
    font-size: 1.1rem; /* Slightly larger heading */
}
#importStatusMessage pre {
    white-space: pre-wrap;
    font-family: monospace;
    font-size: 0.9rem; /* Slightly larger code text */
    margin-top: 1rem; /* More margin */
    padding: 0.75rem; /* More padding */
    background-color: rgba(0,0,0,0.07); /* Darker background for code */
    border-radius: 6px;
    max-height: 180px; /* Taller pre */
    overflow-y: auto;
    border: 1px solid rgba(0,0,0,0.1);
}

/*
========================================
AI Query Page Specific Styles
========================================
*/

/* --- Main Layout --- */
.ai-query-layout-grid {
    display: grid;
    grid-template-columns: 1fr; /* Single column on small screens */
    gap: 2rem;
}

@media (min-width: 1024px) { /* Two columns on larger screens */
    .ai-query-layout-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* --- Form Enhancements --- */
.ai-query-form-container {
    background-color: #fff;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}

.select-wrapper {
    position: relative;
}

.select-wrapper::after {
    content: '\25BC'; /* Downward-pointing triangle */
    font-size: 1rem;
    color: #9ca3af;
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

#aiQueryService {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: none;
}

.ai-query-submit-btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    background-image: linear-gradient(to right, #4f46e5, #7c3aed, #c026d3);
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 4px 15px 0 rgba(124, 58, 237, 0.35);
    transition: all 0.3s ease;
    cursor: pointer;
}
.ai-query-submit-btn:hover {
    background-position: right center;
    box-shadow: 0 4px 15px 0 rgba(192, 38, 211, 0.5);
    transform: translateY(-2px);
}

/* --- Results Area & Skeleton Loader --- */
#aiQueryResults {
    border-radius: 1rem;
    padding: 1rem;
    min-height: 300px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s ease;
    border: 2px dashed #e5e7eb;
}

.ai-results-placeholder {
    text-align: center;
}

/* Add this class with JS when loading */
#aiQueryResults.is-loading .ai-results-placeholder {
    display: none;
}

#aiQueryResults.is-loading::before {
    content: '';
    display: block;
    width: 100%;
    height: 100%;
    min-height: 300px;
    background:
        linear-gradient(100deg, rgba(255, 255, 255, 0) 40%, rgba(255, 255, 255, .5) 50%, rgba(255, 255, 255, 0) 60%) #f3f4f6;
    background-size: 200% 100%;
    background-position-x: 180%;
    animation: 1s loading-skeleton ease-in-out infinite;
    border-radius: 0.75rem;
}

@keyframes loading-skeleton {
    to {
      background-position-x: -20%;
    }
}

/* Style for actual text results */
#aiQueryResults p.generated-text {
    white-space: pre-wrap;
    text-align: left;
    font-size: 1rem;
    line-height: 1.6;
    width: 100%;
    align-self: flex-start;
}

/* Style for actual image results */
#aiQueryResults img.generated-image {
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
    border-radius: 0.5rem;
}

/* --- Divider & Tips Section --- */
.gradient-divider {
    height: 2px;
    background-image: linear-gradient(to right, rgba(229, 231, 235, 0), #a855f7, rgba(229, 231, 235, 0));
    margin: 3rem 0;
}

.tips-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    margin-bottom: 2rem;
    font-size: 0.95rem;
}
.tips-table th, .tips-table td {
    border: 1px solid #e5e7eb;
    padding: 0.75rem 1rem;
    text-align: left;
    vertical-align: top;
}
.tips-table th {
    background-color: #f9fafb;
    font-weight: 600;
}
.tips-table td:first-child {
    background-color: #fee2e2; /* Light red */
}
.tips-table td:nth-child(2) {
    background-color: #dcfce7; /* Light green */
}
/* Aligns content to the top-left once results are populated */
#aiQueryResults.has-results {
    justify-content: flex-start;
    align-items: flex-start;
}
/* Adds some spacing to the dynamically added result headers */
#aiQueryResults.has-results h4 {
    font-weight: 700;
    font-size: 1.1rem;
    color: #374151; /* gray-700 */
    margin-bottom: 0.5rem;
}

.ai-query-download-btn {
    padding: 0.8rem 1.5rem;
    border-radius: 9999px; /* rounded-full */
    font-weight: 700;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); /* shadow-md */
    background-color: #cbd5e1; /* slate-300 */
    color: #334155; /* slate-700 */
    border: 1px solid #94a3b8; /* slate-400 */
    cursor: pointer;
}

.ai-query-download-btn:hover:not(:disabled) {
    background-color: #94a3b8; /* slate-400 */
    color: #1e293b; /* slate-800 */
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); /* shadow-lg */
}

.ai-query-download-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #e2e8f0; /* slate-200 */
    transform: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}


/* Styling for the text labels on the network graph nodes */
.node-label-div {
    font-size: 11px;
    font-weight: 600; /* Bolder for better readability */
    color: #1e293b; /* Dark text for high contrast on a light background */
    background-color: rgba(248, 250, 252, 0.85); /* Very light, semi-transparent background */
    padding: 3px 7px;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); /* A soft, clean shadow */
    border: 1px solid rgba(0, 0, 0, 0.05); /* A subtle border to define the edge */
    max-width: 160px;
    line-height: 1.4;
    text-align: center;
    transition: all 0.2s ease;
    position: absolute;
    pointer-events: none !important;    /* mouse still reaches circles */
    word-wrap: break-word;     /* wrap long names */
    color: #333;
}


/* Base styles for the summary pop-up box */
.network-summary-popup {
    display: none; /* Hidden by default, controlled by JavaScript */
    position: absolute;
    top: 20px;
    left: 20px;
    max-width: 380px;
    background-color: rgba(255, 255, 255, 0.9); /* Slightly transparent white */
    backdrop-filter: blur(10px); /* Stronger frosted glass effect */
    border-radius: 1rem; /* 16px */
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15); /* Modern, soft shadow */
    z-index: 10;
    border: 1px solid rgba(255, 255, 255, 0.5);
    opacity: 0;
    transform: translateY(10px) scale(0.98);
    /* Transition for the fade-in effect */
    transition: opacity 0.25s cubic-bezier(0.25, 1, 0.5, 1), transform 0.25s cubic-bezier(0.25, 1, 0.5, 1);
    pointer-events: none; /* Disables interaction when hidden */
}

/* This rule detects when JS makes the box visible and triggers the animation */
.network-summary-popup[style*="block"] {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto; /* Enables interaction when visible */
}

/* Content area styling for better padding and text wrapping */
#network-summary-content {
    padding: 1.5rem;
    padding-top: 3rem; /* Extra padding to clear the close button */
    font-size: 0.95rem;
    line-height: 1.6;
    color: #334155; /* slate-700 */
    white-space: pre-wrap; /* Allows text to wrap */
    word-wrap: break-word; /* Breaks long words if necessary */
}

/* Modern, circular close button */
#network-summary-close-btn {
    position: absolute;
    top: 1rem; /* 16px */
    right: 1rem; /* 16px */
    width: 2rem; /* 32px */
    height: 2rem; /* 32px */
    background-color: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: 9999px; /* Fully rounded */
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b; /* slate-500 */
    cursor: pointer;
    transition: all 0.2s ease-out;
}

#network-summary-close-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
    color: #1e293b; /* slate-800 */
    transform: scale(1.1) rotate(90deg); /* Adds a nice micro-interaction */
}

/* style.css  (append anywhere) */
.network-labels-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;   /* clicks go through to the circles */
    z-index: 10;
}


/* keep graph contents inside the frame */
#network-visualization-container {
  overflow: hidden;
  position: relative;
  z-index: 1; /* Add this to ensure it's below the main menu */
  touch-action: none;
  -ms-touch-action: none;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

#network-visualization-container canvas {
  touch-action: none;
}

/* pin, style, and lift the legend */
#network-legend {
  font-size: 0.75rem;
  line-height: 1rem;
  backdrop-filter: blur(2px);
  position: absolute;
  top: 0.5rem;       /* ~8 px */
  right: 0.5rem;
  z-index: 20;       /* above SVG */
  font-size: 0.75rem;
  line-height: 1rem;
  background: rgba(255,255,255,0.85);
  border-radius: 0.25rem;
  padding: 0.25rem 0.5rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

#mainMenu,          /* your menu <div id="mainMenu"> … */
.main-menu-dropdown /* or whatever class you use for the fly-out */
{ z-index: 90; }    /* higher than legend, lower than modals (1000) */


#mainDataTable td.actions-cell button {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.g6-tooltip {
    position: absolute; /* Ensures z-index is respected */
    visibility: visible;
    z-index: 20; /* High z-index to be on top of labels */
    pointer-events: none; /* Tooltip should not intercept mouse clicks */
}


/* ========================================
   Case Summary Modal Enhancements
   ======================================== */

/* Styles for the new circular close button.
   Positioning is handled by utility classes in the HTML. */
.case-modal-close-btn {
    width: 2.25rem;  /* 36px */
    height: 2.25rem; /* 36px */
    
    /* Center the 'X' icon inside the button */
    display: flex;
    align-items: center;
    justify-content: center;

    background-color: #f1f5f9; /* slate-100 */
    color: #64748b; /* slate-500 */
    border: none;
    border-radius: 50%; /* This makes it a perfect circle */
    cursor: pointer;
    
    /* Smooth transition for hover effects */
    transition: all 0.2s ease-in-out;
}

/* A nicer hover effect */
.case-modal-close-btn:hover {
    background-color: #e2e8f0; /* slate-200 */
    color: #1e293b; /* slate-800 */
    transform: rotate(90deg) scale(1.05); /* Adds a nice micro-interaction */
}

/* Ensure the SVG icon inside is sized correctly */
.case-modal-close-btn svg {
    width: 1.25rem; /* 20px */
    height: 1.25rem; /* 20px */
}

/* js/style.css */

/* Add this to ensure the comparison table dropdowns are styled */
.form-multiselect {
    border: 1px solid #d1d5db; /* gray-300 */
    border-radius: 0.5rem; /* rounded-md */
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    background-color: #fff;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease-in-out;
    height: 15rem; /* Set a taller height (240px) */
}

.form-multiselect:focus {
    outline: none;
    border-color: #60a5fa; /* blue-400 */
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.5); /* blue-400 with 0.5 opacity */
}

/* Specific styling for the comparison table */
#comparisonTable th,
#comparisonTable td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb; /* gray-200 */
    text-align: left;
    white-space: normal; /* Allow content to wrap */
    word-break: break-word; /* Break long words */
}

#comparisonTable thead th {
    background-color: #f9fafb; /* gray-50 */
    font-weight: 600;
    color: #4b5563; /* gray-700 */
    position: sticky;
    top: 0;
    z-index: 20; /* Ensure header is above body cells */
}

/* Sticky first column in comparison table */
#comparisonTable th.sticky,
#comparisonTable td.sticky {
    position: -webkit-sticky; /* For Safari */
    position: sticky;
    left: 0;
    background-color: #ffffff; /* Ensure it covers content behind it */
    z-index: 10; /* Ensure it's above other cells but below sticky header */
    box-shadow: 2px 0 3px rgba(0,0,0,0.05); /* Subtle shadow on the right edge */
    width: 200px;       /* Set a default width */
    min-width: 200px;   /* Prevent it from being squished */
}

/* Ensure the sticky header's first cell is also sticky */
#comparisonTable thead th.sticky {
    z-index: 21; /* Above both sticky body cells and other header cells */
}

/* Map specific styles */
#worldMapContainer {
    overflow: hidden; /* Important for map container */
    position: relative;
    background-color: #000000; /* Sets a black background to match the theme */
}


/* The main panel container */
#mapSummaryPanel {
    position: absolute; /* The key change for in-element centering */
    z-index: 1000;
    width: 700px;
    max-width: 90vw;
    height: 75vh;
    max-height: 750px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-radius: 1rem;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
    pointer-events: none;
}

#mapSummaryPanel:not(.hidden) {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1); /* Animates to full size in the center */
    pointer-events: auto;
}

/* The panel's header area */
#mapSummaryHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

/* The title inside the header */
#mapSummaryCountry {
    font-size: 1.25rem; /* text-xl */
    font-weight: 700;
    color: #1e293b;
}

/* The main scrollable content area */
#mapSummaryContentContainer {
    overflow-y: auto;
    flex-grow: 1; 
}

/* This is the missing base style for the close button */
.map-panel-close-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f1f5f9;
    color: #64748b;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.map-panel-close-btn:hover {
    background-color: #e2e8f0;
    color: #1e293b;
    transform: rotate(90deg) scale(1.05);
}

.map-panel-close-btn svg {
    width: 1.25rem;
    height: 1.25rem;
}

#mapSummaryPanel.hidden {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none; /* Can't interact with it when hidden */
}



/* General page-view adjustments if needed */
#regulatoryAnalysisPage {
    min-height: calc(100vh - 80px); /* Adjust based on your header/footer height */
    display: none; /* Hidden by default, managed by viewManager.js */
}
#regulatoryAnalysisPage.active {
    display: block;
}


/* Comparison Matrix Modal Styles */
#comparisonModalOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.6); /* slate-900 with 60% opacity */
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    transition: opacity 0.3s ease-in-out;
}

#comparisonModalOverlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#comparisonModalContent {
    background-color: #ffffff;
    border-radius: 1rem;
    padding: 1.5rem 2rem;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 90vw;
    height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.98);
    transition: transform 0.3s ease-in-out;
}

#comparisonModalOverlay:not(.hidden) #comparisonModalContent {
    transform: scale(1);
}

#modalComparisonTableContainer {
    overflow: auto; /* This makes the table content scrollable within the modal */
    flex-grow: 1;
}

/* Specific styles for the modal table */
#modalComparisonTable th,
#modalComparisonTable td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb; /* gray-200 */
    text-align: left;
    white-space: normal;
    word-break: break-word;
}

#modalComparisonTable thead th {
    background-color: #f9fafb; /* gray-50 */
    font-weight: 600;
    color: #4b5563; /* gray-700 */
    position: sticky;
    top: 0;
    z-index: 10;
}

#modalComparisonTable th.sticky,
#modalComparisonTable td.sticky {
    position: -webkit-sticky;
    position: sticky;
    left: 0;
    background-color: #ffffff;
    z-index: 5;
    box-shadow: 2px 0 3px rgba(0,0,0,0.05);
    min-width: 250px; /* This gives the column a fixed minimum width */
}

#modalComparisonTable thead th.sticky {
    z-index: 11;
}

#userManagementPage .page-content-wrapper {
    max-width: 1480px; /* or whatever you prefer */
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Custom Toggle Switch Styles */
.toggle-checkbox {
    -webkit-appearance: none;
    appearance: none;
    transition: all 0.2s ease-in-out;
    left: -0.1rem; /* Adjust for border */
    border-color: #cbd5e1; /* slate-300 */
}
.toggle-checkbox:checked {
    left: 1.1rem; /* Moves the toggle switch to the right */
    border-color: #afd353;
    right: auto; /* Use auto for left-based positioning */
}
.toggle-checkbox:checked + .toggle-label {
    background-color: #afd353;
}

#darkModeToggleContainer {
    margin-left: auto; /* This pushes the toggle to the far right */
}


/*
  On smaller screens (mobile and most tablets), hide the toggle completely
  because the hover functionality is not used. We use !important to ensure
  this rule always applies on small screens.
*/
@media (max-width: 1023px) {
    #googleSearchToggleContainer {
        display: none !important;
    }
}

/*
  On larger screens (1024px and wider), where a mouse is likely used,
  we define the position for the toggle. The JavaScript showPage() function
  will handle toggling its display between 'none' and 'flex'.
*/
@media (min-width: 1024px) {
    #googleSearchToggleContainer {
        position: absolute;
        top: 2.75rem;
        right: 1.75rem;
        z-index: 30;
    }
}

/* --- START: CSS-driven visibility for the Search on Hover Toggle --- */

/* 1. By default, the toggle is hidden. */
#googleSearchToggleContainer {
    display: none;
}

/* 2. ONLY show the toggle when the body has the 'active-page-tableViewPage' class.
      This rule will only apply on screens wider than 1023px due to the rule below. */
body.active-page-tableViewPage #googleSearchToggleContainer {
    display: flex;
}

/* 3. The existing rule to hide it on small screens MUST remain to override the rule above. */
@media (max-width: 1023px) {
    #googleSearchToggleContainer {
        display: none !important;
    }
}

/* --- END: CSS-driven visibility for the Search on Hover Toggle --- */

/* ===========================================
   DEFINITIVE NEWS FEED STYLES
   =========================================== */

/* --- Layout & Controls --- */

.news-feed-header {
  margin-bottom: 2rem;
  text-align: center;
}

.news-feed-header h2 {
    font-size: 2.25rem;
    font-weight: 800;
    color: #1e293b;
}

.news-feed-header p {
    font-size: 1.125rem;
    color: #64748b;
    margin-top: 0.5rem;
}

.news-controls-container {
  margin-bottom: 1.5rem;
}

.news-controls {
  /* Widen container to fit all controls on one line */
  max-width: 1400px; /* Changed from 1280px */
  margin-left: auto;
  margin-right: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background-color: #ffffff;
  padding: 1rem 1.5rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease-in-out;
}

.controls-left,
.controls-right {
  display: flex;
  align-items: center;
  /* Allow wrapping for smaller screens within this group */
  flex-wrap: wrap; 
  gap: 1.5rem;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.control-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #4b5563;
  white-space: nowrap; /* Prevent labels from wrapping */
}

.news-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-color: #fff;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  padding-top: 0.625rem;
  padding-bottom: 0.625rem;
  padding-left: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: #111827;
  transition: all 0.2s ease-in-out;
}

.news-select:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
}

.news-stats {
  font-size: 0.8rem;
  color: #6b7280;
}


.refresh-button {
  display: inline-flex;
  align-items: center;
  justify-content: center; /* Add this */
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.625rem 1.25rem;
  background-color: #afd353; /* Your new color */
  color: #1e293b; /* A dark text color for contrast */
  border: 1px solid transparent;
  border-radius: 0.375rem;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  transition: all 0.2s;
  cursor: pointer;
  min-width: 140px; /* Add this */
}

.refresh-button:hover:not(:disabled) {
  background-color: #99bb44; /* Darker shade for hover */
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.refresh-button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* --- News Card Grid & Items --- */

.news-grid {
  display: grid;
  gap: 1rem;
  grid-auto-rows: 1fr;
  grid-template-columns: repeat(5, 1fr);
}

.news-item {
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: all 0.2s ease-out;
  border: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
}

.news-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.news-item[data-category="Core AI & Tech News"] { border-left: 5px solid #0ea5e9; }
.news-item[data-category="AI Research & Models"] { border-left: 5px solid #2563eb; }
.news-item[data-category="AI Governance & Policy"] { border-left: 5px solid #10b981; }
.news-item[data-category="AI Regulation & Litigation"] { border-left: 5px solid #ef4444; }
.news-item[data-category="AI & Intellectual Property"] { border-left: 5px solid #4f46e5; }
.news-item[data-category="Legal Tech & Innovation"] { border-left: 5px solid #8b5cf6; }
.news-item[data-category="AI Business & Enterprise"] { border-left: 5px solid #f59e0b; }
.news-item[data-category="AI Security & Privacy"] { border-left: 5px solid #f43f5e; }
.news-item[data-category="Custom Scraped Feeds"] { border-left: 5px solid #84cc16; }
.news-item[data-category="General"] { border-left: 5px solid #64748b; }

/* --- News Item Content --- */

.news-item-image-wrapper {
  width: 100%;
  height: 200px;
  background-color: #f3f4f6;
  overflow: hidden;
}

.news-item-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease-out;
}

.news-item:hover .news-item-image {
  transform: scale(1.05);
}

.news-item-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.news-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.category-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.news-item-title a {
  font-size: 1.125rem;
  font-weight: 700;
  color: #1f2937;
  text-decoration: none;
  line-height: 1.4;
  transition: color 0.15s ease;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-item-title a:hover {
  color: #2563eb;
}

.news-item-snippet {
  color: #4b5563;
  font-size: 0.875rem;
  line-height: 1.6;
  margin-top: 0.75rem;
  margin-bottom: 1.25rem;
  flex-grow: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-item-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid #f3f4f6;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* --- Responsive & Dark Mode --- */

.refresh-button svg.animate-spin {
  animation: spin 1s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
/* For Tablets: Stack controls into two clean rows */
@media (max-width: 1280px) {
  .news-controls {
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
  }
  .controls-left, .controls-right {
    justify-content: center;
    width: 100%;
  }
}

/* For Mobile: Stack all controls vertically for easy access */
@media (max-width: 768px) {
  .controls-left, .controls-right {
    flex-direction: column;
    align-items: stretch; /* Makes inputs full-width */
  }
  .control-group {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
  }
  .control-group label {
    margin-bottom: 0.25rem;
  }
  .news-select, .refresh-button {
    width: 100%;
  }
  .controls-right {
    align-items: center; /* Center stats and button */
  }
  .refresh-button {
    width: auto; /* Let button size to its content on mobile */
  }
  #mapSummaryPanel {
    /* Use max-height to prevent it from being too tall, and allow it to shrink */
    height: auto;
    max-height: 85vh;

    /* These flex properties ensure the content area can scroll correctly */
    display: flex;
    flex-direction: column;
  }
  #mapSummaryContentContainer {
    /* This makes only the content area scrollable, keeping the header in place */
    overflow-y: auto;
  }
  #worldMapContainer {
    /* Prevents the map from being taller than the screen on mobile */
    max-height: 100vh;
    max-height: 100dvh; /* More modern unit for mobile viewport height */
  }
}
@media (max-width: 1700px) { .news-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 1200px) { .news-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) { .news-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .news-stats { display: block; } }
@media (max-width: 600px) { .news-grid { grid-template-columns: 1fr; } .news-controls { flex-direction: column; } }

/* All dark mode styles are now controlled by this single class */
body.dark-mode-active {

  /* --- 1. Core & Layout --- */
  background-color: #111827 !important;
  color: #d1d5db !important;

  #mainAppContainer,
  #mainAppContent.logged-out::before,
  .bg-gradient-to-br.from-white.to-slate-50 {
    background: #1f2937 !important;
  }

  /* --- 2. General Containers & Panels --- */
  .page-content-wrapper, .admin-section, .chart-container,
  #network-visualization-container, .ai-query-form-container,
  #aiQueryResults, #filterGroupsBuilder, #viewActionsPanel {
    background-color: #1f2937;
    border-color: #374151;
  }

  /* --- 3. Typography --- */
  h1, h2, h3, h4, h5, h6, .modal-title, .form-label {
    color: #f9fafb !important;
  }
  p, span, div, label, .modal-message, .text-slate-600, .text-gray-600, .text-gray-800 {
    color: #d1d5db !important;
  }

  /* --- 4. Modals & Dropdowns --- */
  .modal-content-base, #mainMenuPanel, #userDropdownMenu, #columnToggleDropdown {
    background-color: #1f2937 !important;
    border: 1px solid #4b5563 !important;
  }

  /* --- 5. Buttons --- */
  .action-button, #mainMenuBtn, #userDropdownBtn, #viewActionsToggleBtn, #backToRegulatoryTableBtn {
    background-color: #374151 !important;
    color: #e5e7eb !important;
    border-color: #4b5563 !important;
  }
  .action-button:hover, #mainMenuBtn:hover, #userDropdownBtn:hover, #viewActionsToggleBtn:hover {
    background-color: #4b5563 !important;
  }
  .pagination-controls button:disabled {
    background-color: #2c3a4b !important;
    color: #64748b !important;
    border-color: #374151 !important;
    opacity: 0.7;
  }

  /* --- 6. Forms & Inputs --- */
  .form-input, .form-select, .form-multiselect, .news-select, #globalSearch, #rowsPerPageSelect, #aiSystemPrompt {
    background-color: #374151; border-color: #4b5563; color: #f9fafb;
  }
  .form-input::placeholder { color: #9ca3af; }

  /* --- 7. Tables & Data Grids --- */
  #tableActionsToolbar { background-color: #1f2937; border-bottom-color: #4b5563; }
  #mainDataTable th, #usersTable th {
    background-color: #374151 !important; color: #f9fafb; border-color: #4b5563;
  }
  #mainDataTable tbody.bg-white, #usersTable tbody, #mainDataTable tr {
    background-color: #1f2937 !important;
  }
  #mainDataTable td, #usersTable td { color: #d1d5db; border-color: #4b5563; }
  #mainDataTable tr:hover td { background-color: #374151 !important; }
  #mainDataTable td[contenteditable="true"]:focus { background-color: #4b5563 !important; }

  /* --- 8. News Feed --- */
  .news-controls, .news-item { background-color: #1f2937; border-color: #374151; }
  .news-item-title a { color: #f9fafb; }
  .news-item-footer, .news-item-snippet { color: #d1d5db !important; }

  /* --- 9. AI Query Page --- */
  #aiQueryPage .service-selector-container, #aiQueryPage .service-card, #aiQueryPage .result-card,
  #aiQueryPage #geminiOptionsContainer, #aiQueryPage #imagenOptionsContainer, #aiQueryPage #videoOptionsContainer,
  #aiQueryPage #veoOptionsContainer, #aiQueryPage #klingOptionsContainer, #aiQueryPage #seedanceOptionsContainer,
  #aiQueryPage #falVeo3OptionsContainer, #aiQueryPage #fluxLoraOptionsContainer,
  #aiQueryPage #klingI2VProOptionsContainer, #aiQueryPage #hailuoOptionsContainer,
  #aiQueryPage #wanLoraOptionsContainer, #aiQueryPage .tips-table th, #aiQueryPage .tips-table td {
    background-color: #374151; border-color: #4b5563;
  }
  #aiQueryPage .service-card.selected { background-color: #4f46e5; border-color: #818cf8; }
  #aiQueryPage .service-card p, #aiQueryPage .result-card p { color: #e5e7eb !important; }
  #aiQueryPage .tips-table td:first-child { background-color: #451a20; }
  #aiQueryPage .tips-table td:nth-child(2) { background-color: #164e32; }

  /* --- 10. Regulatory Analysis Page & Modals --- */
  #regulatoryAnalysisPage .lg\:w-1\/3.bg-white { background-color: #1f2937 !important; border-color: #374151 !important; }
  #chartsModalOverlay .bg-slate-50 { background-color: #1f2937; }
  #modalComparisonTable th.bg-slate-100 { background-color: #374151 !important; }
  #modalComparisonTable td.sticky.bg-white { background-color: #2c3a4b !important; }

    /* inputs inside the row editor modal */
  #rowSummaryContent input,
  #rowSummaryContent textarea {
    background-color: #374151 !important;
    border-color: #4b5563 !important;
    color: #f9fafb !important;
  }


  /* --- 11. Network View --- */

  /* Main container background */
  #network-visualization-container {
    background-color: #1f2937 !important; /* slate-800 */
  }

  /* Dynamically created buttons (Reset, Export) */
  #network-visualization-container .bg-white\/90 {
    background-color: rgba(55, 65, 81, 0.9) !important; /* slate-700 w/ opacity */
    color: #e5e7eb !important;
  }

  /* Search input box */
  #network-search-input {
    background-color: #374151;
    border-color: #4b5563;
    color: #f9fafb;
  }

  /* Legend panel on the right */
  #network-legend {
    background-color: rgba(30, 41, 59, 0.8) !important;
  }
  #network-legend .text-slate-600 {
    color: #d1d5db !important;
  }

  /* The individual text labels on the graph nodes */
  .node-label-div {
    background-color: rgba(55, 65, 81, 0.9);
    color: #f9fafb;
    border-color: rgba(100, 116, 139, 0.5);
  }

  /* The pop-up summary box for a case */
  #network-summary-box {
    background-color: #1f2937;
  }

  /* Loading overlays */
  #network-loading-indicator,
  #network-progress-indicator {
    background-color: rgba(30, 41, 59, 0.7) !important;
    color: #f9fafb !important;
  }

  /* Fix for the main menu item text color */
  #mainMenuPanel button {
    color: #d1d5db !important; /* gray-300 */
  }

  /* Fix for the hover state of menu items */
  #mainMenuPanel button:hover {
    background-color: #374151; /* slate-700 */
  }

  #userDropdownMenu button {
    color: #d1d5db !important; /* gray-300 */
  }

  /* Fix for the hover state of the user profile menu */
  #userDropdownMenu button:hover {
    background-color: #374151; /* slate-700 */
  }

  /* Fix for the news feed refresh button text */
  .refresh-button,
  .refresh-button span,
  .refresh-button svg {
    color: #1e293b !important; /* A very dark slate (almost black) */
  }

  #googleSearchModal {
    background-color: #1f2937 !important; /* slate-800 */
    border: 1px solid #4b5563;
  }

  /* Fix for the individual column filter pop-ups */
  .column-filter-controls {
    background-color: #1f2937 !important;
    border-color: #4b5563 !important;
  }
  
  #filterGroupsBuilder {
    background-color: #1f2937 !important; /* slate-800 */
  }

  /* FIX for the individual filter group cards created by JS */
  #filterGroupsBuilder .bg-slate-50 {
    background-color: #374151 !important; /* slate-700 */
    border-color: #4b5563 !important;
  }
  
  /* FIX for the light-colored "Remove Condition" button */
  #filterGroupsBuilder .bg-slate-200 {
      background-color: #4b5563 !important;
  }
  
  /* FIX for the dark text on the "Add Condition" link */
  #filterGroupsBuilder .text-blue-600 {
      color: #60a5fa !important;
  }

  .filter-toggle-btn:hover {
    background-color: #374151 !important; /* slate-700 */
  }

  /* Fix for the input boxes inside the column filter */
  .column-filter-controls .filter-condition-select,
  .column-filter-controls .column-filter-input {
      background-color: #374151;
      border-color: #4b5563;
      color: #f9fafb;
  }
  /* --- 14. Regulatory Analysis Modals & Charts --- */

  /* Fix for the main content areas of all three modals */
  #comparisonModalContent,
  #sentimentModalOverlay .modal-content-base,
  .modal-content-charts {
    background-color: #1f2937 !important; /* slate-800 */
  }

  /* Fix for alternating row colors in Sentiment & Comparison tables */
  #sentimentModalOverlay .even\:bg-slate-50,
  #modalComparisonTable .even\:bg-slate-50 {
    background-color: #2c3a4b !important; /* A slightly different dark color */
  }

  /* Fix for table headers in all modals on this page */
  #sentimentModalOverlay thead,
  #modalComparisonTable thead th,
  #modalComparisonTableHeader .bg-slate-100 {
    background-color: #374151 !important;
    border-color: #4b5563 !important;
  }
  
  /* Fix for the sticky column in the Comparison Matrix */
  #modalComparisonTable td.sticky.bg-white {
    background-color: #2c3a4b !important;
  }

  /* Fix for the Back to List button */
  #sentimentDetailBackBtn {
      background-color: #374151 !important;
      color: #e5e7eb !important;
  }

  /* Fix for the various tags (Key Themes, Activity Trend) */
  .theme-tag,
  .activity-trend-tag {
      background-color: #374151 !important;
      color: #d1d5db !important;
  }

  /* Fix for the individual chart containers inside the Charts modal */
  #chartsModalOverlay .bg-slate-50 {
    background-color: #1f2937 !important;
  }
  
  /* Force Plotly.js chart text (titles, axes, labels) to be light */
  body.dark-mode-active .js-plotly-plot .plotly text {
    fill: #d1d5db !important;
  }
  
    /* A more specific fix for Plotly.js chart legends */
  body.dark-mode-active .legendtext {
    fill: #d1d5db !important;
  }

  /* Fix for the sentiment tags */
  .sentiment-tag {
    background-color: #374151;
    color: #d1d5db;
  }

  #sentimentModalOverlay .text-slate-700 {
      color: #e5e7eb !important; /* A light gray */
  }

  /* Fix for the chart legend text */
  body.dark-mode-active .legend-item {
    color: #d1d5db !important; /* A light gray */
  }

  #modalComparisonTable td {
    color: #d1d5db !important;
  }

  /* Fix for the logout button in the profile menu */
  #logoutBtnNew {
      background-color: #7f1d1d !important; /* A dark, muted red */
      color: #fecaca !important;          /* A light red for the text */
  }

body.dark-mode-active .chart-container svg g text {
  fill: #f9fafb !important; /* A bright white color */
  }

  /* --- 15. Globe Summary Panel --- */
  #mapSummaryPanel {
    background-color: rgba(30, 41, 59, 0.95) !important; /* slate-800 with backdrop-filter */
    border-color: #374151 !important;
  }
  #mapSummaryPanel #mapSummaryCountry {
    color: #f1f5f9 !important; /* slate-100 */
  }
  #mapSummaryPanel .map-panel-close-btn {
    background-color: #374151 !important;
    color: #9ca3af !important;
  }
  #mapSummaryPanel .map-panel-close-btn:hover {
    background-color: #4b5563 !important;
    color: #f9fafb !important;
  }
  #mapSummaryPanel .popup-main-summary,
  #mapSummaryPanel .popup-reg-summary {
    color: #cbd5e1 !important; /* slate-300 */
  }
  #mapSummaryPanel .popup-section-header,
  #mapSummaryPanel .popup-reg-title,
  #mapSummaryPanel .popup-detail-label {
    color: #e2e8f0 !important; /* slate-200 */
  }
  #mapSummaryPanel .theme-tag,
  #mapSummaryPanel .activity-trend-tag,
  #mapSummaryPanel .sentiment-tag {
    background-color: #374151 !important;
    color: #d1d5db !important;
  }
  #mapSummaryPanel .popup-reg-item {
    border-top-color: #374151 !important;
  }

    #rowSummaryContent strong {
        color: #e2e8f0 !important; /* slate-200 for bright text in dark mode */
    }

}

.news-feed-wrapper {
  /* Default (mobile) padding. Top padding is now 0. */
  padding: 0 1rem 2rem;
  transition: padding 0.2s ease-out;
}

/* For tablet sizes and larger, add more horizontal padding. */
@media (min-width: 768px) {
  .news-feed-wrapper {
    /* Kept the standard padding for medium screens. Top padding is 0. */
    padding: 0 1.5rem 2rem;
  }
}

@media (min-width: 1025px) {
  .news-feed-wrapper {
    padding: 0 2rem 2rem; /* Adjusted from 'em' to 'rem' for consistency. Top padding is 0. */
  }
}

/* For very wide screens (5-column layout), add the new, larger padding. */
@media (min-width: 1501px) {
  .news-feed-wrapper {
    padding: 0 3rem 2rem; /* Top padding is 0. */
  }
}

@media (min-width: 1801px) {
  .news-feed-wrapper {
    padding: 0 10rem 2rem; /* Top padding is 0. */
  }
}

/* for the regulatory analysis popup */

.popup-main-summary {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-top: 0.5rem;
    color: #475569;
}

.popup-details-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
    align-items: center;
    margin-top: 1rem;
    font-size: 0.85rem;
}

.popup-detail-label {
    font-weight: 600;
    color: #334155;
    font-size: 0.85rem; /* This makes it consistent with the other labels */
}

.popup-section-header {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.25rem;
}

.popup-reg-item {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e2e8f0;
}

.popup-reg-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: #334155;
}

.popup-reg-summary {
    font-size: 0.8rem;
    color: #64748b;
}

.sentiment-tag {
  display: inline-block;
  background-color: #e2e8f0; /* slate-200 */
  color: #475569; /* slate-600 */
  padding: 0.25rem 0.75rem;
  margin: 0.25rem;
  border-radius: 9999px; /* rounded-full for a pill shape */
  font-size: 0.75rem; /* text-xs */
  font-weight: 600; /* semibold */
  line-height: 1.2;
  justify-self: start; /* Add this line */
}

.activity-trend-tag {
  display: inline-block;
  background-color: #e2e8f0; /* slate-200 */
  color: #475569; /* slate-600 */
  padding: 0.25rem 0.75rem;
  margin: 0.25rem;
  border-radius: 9999px; /* rounded-full for a pill shape */
  font-size: 0.75rem; /* text-xs */
  font-weight: 600; /* semibold */
  line-height: 1.2;
  justify-self: start; /* Prevents the tag from stretching */
}

.theme-tag {
  display: inline-block;
  background-color: #e2e8f0; /* slate-200 */
  color: #475569; /* slate-600 */
  padding: 0.25rem 0.75rem;
  margin: 0.25rem;
  border-radius: 9999px; /* rounded-full for a pill shape */
  font-size: 0.75rem; /* text-xs */
  font-weight: 600; /* semibold */
  line-height: 1.2;
  font-family: 'Inter', sans-serif; /* Ensures consistent font */
}

#regulatoryAnalysisPage #mapSummaryPanel {
    width: 700px !important; /* Wider for better readability and !important to ensure it applies */
}

.popup-details-grid, .popup-reg-item, .popup-main-summary, .popup-section-header {
  font-family: 'Inter', sans-serif; /* Ensures consistent font family */
}

/* This is the missing style for the theme tags */
.theme-tag {
  font-family: 'Inter', sans-serif;
}


/* ===========================================
   INTERACTIVE CHART STYLES
   =========================================== */

/* --- Tooltip --- */
.chart-tooltip {
    position: absolute;
    background-color: rgba(30, 41, 59, 0.9); /* slate-800 */
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    pointer-events: none; /* The tooltip should not interfere with mouse events */
    transition: opacity 0.2s ease-in-out;
    z-index: 1100; /* Ensure it's above modal content */
}

/* --- Sentiment Chart Legend --- */
#sentimentDonutChartLegend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
}


.modal-content-charts {
    background-color: #ffffff;
    border-radius: 1rem;
    padding: 1.5rem 2rem;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
    width: 96vw;
    max-width: 1800px;
    height: 96vh;
    display: flex;
    flex-direction: column;
}



#solar-system-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}
#solar-system-modal iframe {
    width: 95%;
    height: 95%;
    border-radius: 8px;
    border: 2px solid #555;
}
#solar-system-modal .close-btn {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 30px;
    color: white;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
}


/* --- Custom Header Controls Layout --- */

/* Default Desktop Layout */
#header-controls-wrapper {
    display: flex;
    align-items: center;
}

#darkModeToggleContainer {
    margin-right: 0.5rem; /* Space between toggle and icons on desktop */
}

/* Mobile Layout Overrides */
@media (max-width: 767px) {
    #header-controls-wrapper {
        flex-direction: column; /* Stack items vertically */
        align-items: flex-end;  /* Align the whole group to the right */
    }

    #header-icon-group {
        order: 1; /* Visually positions the icons FIRST */
        margin-bottom: 0.5rem; /* Adds space below the icons */
    }

    #darkModeToggleContainer {
        order: 2; /* Visually positions the toggle SECOND (below icons) */
        margin-right: 0; /* Removes desktop margin */
        justify-content: flex-end; /* This pulls the text and switch together */
    }
}

@media (min-width: 1800px) {
    .charts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
body.active-page-chartsPage .page-content-wrapper {
    max-width: 1800px;
}

/* --- Chart Legend Styling --- */
.chart-legend {
    /* 1. Center the entire legend block */
    display: block;
    max-width: 95%;
    margin-left: auto;
    margin-right: auto;
    margin-top: 1.25rem;

    /* 2. Create a responsive multi-column grid */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.5rem 1.5rem;

    /* 3. Force all content within the grid to be left-aligned */
    justify-items: start;
    text-align: left;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem; /* Spacing between color box and text */
    font-size: 0.875rem; /* 14px */
    font-weight: 500;
    color: #475569; /* slate-600 */
}

.legend-color-box {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    flex-shrink: 0; /* Prevents color box from shrinking */
}
.chart-legend:empty {
    display: none;
}

#statusByJurisdictionHeatmapWrapper {
  display: block;
  width: 100%;
  overflow-x: auto;
  padding-bottom: 20px; /* space so scrollbar won't overlap chart */
}

/* Bulletproof reset for chart SVG sizing (avoid icon rules leaking in) */
#statusByJurisdictionHeatmapWrapper svg,
#statusByJurisdictionHeatmapLegend svg,
.chart-container svg {
  width: auto !important;
  height: auto !important;
  max-width: none; /* allow overflow for scroll */
}

/* Center + responsive gradient legend for the heatmap */
#statusByJurisdictionHeatmapLegend {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  margin-top: 1rem;
}

#statusByJurisdictionHeatmapLegend svg {
  max-width: 100%;
  height: auto;
}