/* sme-assistant/control_panel/static/css/style.css */
:root {
    --primary-color: #007bff;
    --primary-color-hover: #0056b3;
    --secondary-color: #6c757d;
    --secondary-color-hover: #545b62;
    --danger-color: #dc3545;
    --danger-color-hover: #c82333;
    --success-bg: #d4edda;
    --success-border: #c3e6cb;
    --success-text: #155724;
    --success-color: #28a745;
    --error-bg: #f8d7da;
    --error-border: #f5c6cb;
    --error-text: #721c24;
    --light-gray: #f8f9fa;
    --medium-gray: #e9ecef;
    --dark-gray: #343a40;
    --border-color: #ced4da;
    --text-color: #212529;
    --font-family-sans-serif: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    --border-radius: 0.3rem;
    --box-shadow: 0 .125rem .25rem rgba(0,0,0,.075);
    --input-padding-y: .5rem;
    --input-padding-x: .75rem;
}

/* FIX: Add a universal box-sizing rule for more predictable layouts. */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family-sans-serif);
    margin: 0;
    padding: 0;
    background-color: var(--light-gray);
    color: var(--text-color);
    line-height: 1.6;
    font-size: 16px;
}

main {
    max-width: 1200px; /* Increased max-width for the new layout */
    margin: 2rem auto;
    padding: 2rem;
    background-color: #fff;
    border-radius: var(--border-radius);
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,.15);
}

nav {
    background-color: var(--dark-gray);
    padding: 0.75rem 2rem;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--box-shadow);

    position: sticky; /* Makes the nav bar stick to the viewport */
    top: 0;           /* Sticks it to the very top of the screen */
    z-index: 1000;    /* Ensures it renders on top of all other content */
}
/*
The nav's `display: flex; justify-content: space-between;` already ensures
its first direct child div is on the left, and the second is on the right.
*/

.nav-user-info {
    /* This div is the right-hand group. No special positioning needed here
       as the parent 'nav' element handles its placement.
       Its internal content (spans, links) will flow naturally left-to-right. */
}


nav a, nav span {
    color: #f8f9fa; /* Lighter color for better contrast on dark nav */
    text-decoration: none;
    vertical-align: middle; /* Improves alignment of text and potential icons/buttons */
}
nav a:hover {
    color: #fff;
    text-decoration: underline;
}

/* Style for the new separator spans */
.nav-separator {
    margin-left: 0.5rem;  /* Provides space from the item on its left */
    margin-right: 0.5rem; /* Provides space to the item on its right */
    color: var(--medium-gray); /* Optional: makes separator less prominent than links */
    vertical-align: middle; /* Ensure separator aligns well with text */
}

.nav-login-button { /* Special styling for login button in nav */
    padding: 0.4rem 0.8rem !important;
    font-size: 0.9rem !important;
}


h1, h2, h3, h4 {
    color: var(--dark-gray);
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 500;
}
h1 { font-size: 2rem; border-bottom: 1px solid var(--medium-gray); padding-bottom: 0.5rem;}
h2 { font-size: 1.6rem; }
h3 { font-size: 1.3rem; color: #495057; }
h4 { font-size: 1.1rem; color: #495057; }

/* Remove border from main h1 titles for a cleaner look */
main > h1 {
    border-bottom: none;
    padding-bottom: 0;
}


p {
    margin-bottom: 1rem;
}
.small-text {
    font-size: 0.875em;
    color: var(--secondary-color);
    margin-top: -0.75rem;
    margin-bottom: 0.75rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

input[type="text"],
input[type="url"] {
    display: block;
    width: 100%;
    padding: var(--input-padding-y) var(--input-padding-x);
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-color);
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}
input[type="text"]:focus,
input[type="url"]:focus {
    border-color: var(--primary-color);
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

.button, button {
    /* Reset browser default appearance */
    -webkit-appearance: none; /* For Safari, Chrome, Edge */
    -moz-appearance: none;    /* For Firefox */
    appearance: none;         /* Standard */

    display: inline-flex; /* Use flex for easy alignment of text and icons */
    align-items: center;
    justify-content: center;
    gap: 0.5em; /* Space between text and an icon, if present */
    font-weight: 400;
    color: #fff;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background-color: transparent;
    border: 1px solid transparent;
    padding: var(--input-padding-y) var(--input-padding-x);
    font-size: 1rem;
    line-height: 1.5;
    border-radius: var(--border-radius);
    transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
    text-decoration: none;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    position: relative; /* Needed for the loader overlay */
    overflow: hidden; /* Keeps overlay corners rounded */
    white-space: nowrap; /* Prevent button text from wrapping */
}
button:not(:disabled):not(.disabled) {
    cursor: pointer;
}

.button-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff; /* Ensure text is white */
}
.button-primary:hover {
    background-color: var(--primary-color-hover);
    border-color: var(--primary-color-hover);
    color: #fff;
}

.button-secondary {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    color: #fff; /* Ensure text is white */
}
.button-secondary:hover {
    background-color: var(--secondary-color-hover);
    border-color: var(--secondary-color-hover);
    color: #fff;
}

.button-danger {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
    color: #fff; /* Ensure text is white */
}
.button-danger:hover {
    background-color: var(--danger-color-hover);
    border-color: var(--danger-color-hover);
    color: #fff;
}

/* NEW STYLES for a less prominent, outline-style button */
.button-outline {
    background-color: transparent;
    border-color: var(--secondary-color);
    color: var(--secondary-color);
    font-weight: 500;
}
.button-outline:hover {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    color: #fff;
}
.button-outline:hover .icon-external-link {
     background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='white'%3e%3cpath fill-rule='evenodd' d='M8.636 3.5a.5.5 0 0 0-.5-.5H1.5A1.5 1.5 0 0 0 0 4.5v10A1.5 1.5 0 0 0 1.5 16h10a1.5 1.5 0 0 0 1.5-1.5V7.864a.5.5 0 0 0-1 0V14.5a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h6.636a.5.5 0 0 0 .5-.5z'/%3e%3cpath fill-rule='evenodd' d='M16 .5a.5.5 0 0 0-.5-.5h-5a.5.5 0 0 0 0 1h3.793L6.146 9.146a.5.5 0 1 0 .708.708L15 1.707V5.5a.5.5 0 0 0 1 0v-5z'/%3e%3c/svg%3e");
}

/* NEW STYLES for embedding an icon in a button */
.button .icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em; /* Fine-tune vertical alignment */
    background-repeat: no-repeat;
    background-size: contain;
}
.icon-external-link {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%236c757d'%3e%3cpath fill-rule='evenodd' d='M8.636 3.5a.5.5 0 0 0-.5-.5H1.5A1.5 1.5 0 0 0 0 4.5v10A1.5 1.5 0 0 0 1.5 16h10a1.5 1.5 0 0 0 1.5-1.5V7.864a.5.5 0 0 0-1 0V14.5a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h6.636a.5.5 0 0 0 .5-.5z'/%3e%3cpath fill-rule='evenodd' d='M16 .5a.5.5 0 0 0-.5-.5h-5a.5.5 0 0 0 0 1h3.793L6.146 9.146a.5.5 0 1 0 .708.708L15 1.707V5.5a.5.5 0 0 0 1 0v-5z'/%3e%3c/svg%3e");
}

/* Make icon white inside secondary buttons */
.button-secondary .icon-external-link {
     background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='white'%3e%3cpath fill-rule='evenodd' d='M8.636 3.5a.5.5 0 0 0-.5-.5H1.5A1.5 1.5 0 0 0 0 4.5v10A1.5 1.5 0 0 0 1.5 16h10a1.5 1.5 0 0 0 1.5-1.5V7.864a.5.5 0 0 0-1 0V14.5a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h6.636a.5.5 0 0 0 .5-.5z'/%3e%3cpath fill-rule='evenodd' d='M16 .5a.5.5 0 0 0-.5-.5h-5a.5.5 0 0 0 0 1h3.793L6.146 9.146a.5.5 0 1 0 .708.708L15 1.707V5.5a.5.5 0 0 0 1 0v-5z'/%3e%3c/svg%3e");
}


#configForm hr {
    margin-top: 2.5rem;
    margin-bottom: 2rem;
    border: 0;
    border-top: 1px solid var(--medium-gray);
}

.ticket-type-section {
    border: 1px solid var(--medium-gray);
    padding: 1.5rem;
    margin-bottom: 2rem;
    background-color: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}
.ticket-type-section h3 { margin-top: 0; }

/* FIX: New styles for URL input layout using Flexbox */
.url-field-wrapper {
    margin-bottom: 0.75rem; /* Provides space between each URL input row */
}

.url-input-group {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.url-input-group > input {
    flex-grow: 1; /* Input field takes up all available space */
    min-width: 0; /* Prevents input from overflowing its container */
    margin-bottom: 0;
}

.url-input-group > button {
    flex-shrink: 0; /* Prevents the button from shrinking */
    padding: 0.3rem 0.6rem;
    font-size: 0.875rem;
    margin: 0; /* Override default button margins */
}

/* Error message styling - appears below input */
.url-error-message {
    color: #d73a49;
    font-size: 12px;
    margin-top: 4px;
    margin-bottom: 4px;
    display: block;
    width: 100%;
}

#messages { margin-bottom: 1.5rem; }
.message {
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
}
.message.success {
    color: var(--success-text);
    background-color: var(--success-bg);
    border-color: var(--success-border);
}
.message.error {
    color: var(--error-text);
    background-color: var(--error-bg);
    border-color: var(--error-border);
}

/* Ticket Tester / Test Assistant Page */
.form-group {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.form-group label {
    margin-bottom: 0; /* Align with input */
    flex-shrink: 0;
}
.form-group input[type="text"] {
    flex-grow: 1;
    min-width: 250px;
    max-width: 600px;
}

/* Reset margins on buttons inside a form-group to rely on flexbox gap and alignment */
.form-group > .button,
.form-group > button {
    margin: 0;
}

.status-message {
    font-weight: 500;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
    border-radius: var(--border-radius);
    padding-left: 0.5rem; /* Add some padding if using background */
}
.status-message.error { color: var(--error-text); /* background-color: var(--error-bg); border: 1px solid var(--error-border); */ }
.status-message.success { color: var(--success-text); /* background-color: var(--success-bg); border: 1px solid var(--success-border); */}
.status-message.neutral { color: var(--secondary-color); }


.data-section {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background-color: var(--light-gray);
    border: 1px solid var(--medium-gray);
    border-radius: var(--border-radius);
}
.data-section h2 { margin-top: 0; }

pre {
    background-color: var(--medium-gray);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    overflow-x: auto;
    font-size: 0.9em;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
}

footer {
    text-align: center;
    margin-top: 3rem;
    padding: 1.5rem 0;
    font-size: 0.875em;
    color: var(--secondary-color);
    border-top: 1px solid var(--medium-gray);
}

.button-group {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* NEW: Two-Column Setup Layout */
.setup-layout {
    display: flex;
    gap: 2rem; /* Space between the two columns */
    align-items: flex-start; /* Align columns to the top */
}

.config-column {
    flex-grow: 1; /* Let it take up the remaining space */
    min-width: 0;
}

.tools-sidebar {
    flex-basis: 320px; /* Give it a fixed base width */
    flex-shrink: 0; /* Prevent it from shrinking */
    position: sticky;
    top: 2rem; /* Sticks 2rem from the top of the viewport on scroll */
    max-height: calc(100vh - 4rem); /* Prevents sidebar from being taller than the viewport */
    overflow-y: auto; /* Allows scrolling within the sidebar if its content is too long */
    padding: 1.5rem;
    background-color: var(--light-gray);
    border: 1px solid var(--medium-gray);
    border-radius: var(--border-radius);
}

.tools-sidebar h2 {
    margin-top: 0; /* The sidebar is its own container now */
}

/* Modified Tool Drag and Drop UI */
.tools-palette {
    display: flex;
    flex-direction: column; /* Stack tool cards vertically in the sidebar */
    gap: 1rem;
    padding: 0;
    background-color: transparent;
    border: none;
    margin-bottom: 0;
}

/* NEW & IMPROVED Ticket Type Header */
.ticket-type-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline; /* FIX: Align by text baseline for perfect visual alignment. */
    gap: 1rem;
}

.ticket-type-name-group {
    display: flex;
    align-items: baseline; /* FIX: Also align this inner group by baseline. */
    flex-grow: 1;
    gap: 0.75rem;
}

.ticket-type-name-group label {
    font-size: 1rem;
    font-weight: 500;
    color: var(--dark-gray);
    margin-bottom: 0;
    white-space: nowrap;
}

.ticket-type-name-group .ticket-type-name {
    font-size: 1rem;
    flex-grow: 1;
}

.ticket-type-header .removeTicketTypeBtn {
    margin-left: 0;
    flex-shrink: 0;
}

/* Divider within the ticket card */
.ticket-section-divider {
    margin-top: 1.25rem;
    margin-bottom: 1.25rem;
    border: 0;
    border-top: 1px solid var(--medium-gray);
}


.assigned-tools-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    min-height: 80px;
    transition: background-color 0.2s, border-color 0.2s;
    margin-top: 0.5rem; /* Space from the 'Tool Names' h4 */
}

.assigned-tools-container.drag-over {
    background-color: #e9f5ff; /* A light blue to indicate a valid drop target */
    border-color: var(--primary-color);
}

.tool-card {
    position: relative;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    width: 100%; /* Tool cards now take the full width of their container */
    box-shadow: var(--box-shadow);
    cursor: grab;
    transition: box-shadow 0.2s, transform 0.2s;
}

.tool-card:hover {
    box-shadow: 0 .25rem .5rem rgba(0,0,0,.1);
    transform: translateY(-2px);
}

.tool-card.dragging {
    opacity: 0.5;
    cursor: grabbing;
    box-shadow: 0 .5rem 1rem rgba(0,0,0,.15);
    transform: scale(1.05);
}

.tool-card .remove-tool-btn {
    position: absolute;
    top: 2px;
    right: 5px;
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--secondary-color);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    text-align: center;
}

.tool-card .remove-tool-btn:hover {
    color: var(--danger-color);
}

.tool-card-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
    padding-right: 20px; /* Make space for the X button */
}

.tool-card-description {
    font-size: 0.8em;
    color: var(--secondary-color);
    line-height: 1.4;
}

/* === NEW STYLES FOR TEST PAGE COMMENTS === */
#commentsContainer {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.comment-block {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: #fff;
    box-shadow: var(--box-shadow);
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background-color: var(--light-gray);
    border-bottom: 1px solid var(--border-color);
}

.comment-author {
    font-weight: 500;
    color: var(--dark-gray);
}

.toggle-metadata-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.875rem;
    margin: 0; /* Override default button margin */
}

.comment-body {
    padding: 1rem;
    line-height: 1.5;
    overflow-wrap: break-word; /* Prevents long strings like URLs from overflowing */
    word-break: break-word; /* Fallback for older browsers and additional safety */
}

/* Make images inside comments responsive to prevent layout breaks */
.comment-body img {
    max-width: 100%;
    height: auto;
    display: block; /* Ensures it's on its own line and respects margins */
    border-radius: var(--border-radius);
}

/* Zendesk content often has its own styling, so this provides a basic reset */
.comment-body p {
    margin-top: 0;
    margin-bottom: 1em;
}
.comment-body table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 1em;
    font-size: 0.9em;
}
.comment-body th, .comment-body td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}
.comment-body th {
    background-color: #f2f2f2;
}

.comment-metadata {
    border-top: 1px dashed var(--border-color);
    background-color: #fafafa;
}

.comment-metadata pre {
    margin: 0;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    border: none;
    background-color: transparent;
}

/* === NEW STYLES FOR TEST ASSISTANT PAGE LAYOUT === */
.test-assistant-content-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    margin-top: 1.5rem; /* Space below the fetch form */
}

.ticket-data-column {
    flex: 1; 
    min-width: 0; 
    max-width: 800px; /* Prevent content from stretching too wide */
}

/* Override default margin for the data section in the left column to ensure top alignment */
.ticket-data-column .data-section {
    margin-top: 0;
}

.assistant-response-column {
    flex-basis: 450px;
    flex-shrink: 0;
    position: sticky;
    top: 2rem;
    /* max-height: calc(100vh - 4rem);  <-- REMOVED to eliminate inner scrollbar */
    /* overflow-y: auto; <-- REMOVED to eliminate inner scrollbar */
    padding: 1rem;
    background-color: var(--light-gray);
    border: 1px solid var(--medium-gray);
    border-radius: var(--border-radius);
}

/* REFINED STYLES for run controls */
.run-controls-group {
    margin-bottom: 1.5rem;
    text-align: center;
}

.run-controls-label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.button-group-horizontal {
    display: inline-flex; /* This allows the group to be centered by the parent's text-align */
    gap: 0.5rem;
}

.button-group-horizontal .button {
    margin: 0; /* Override default button margins */
}

.assistant-response-column .data-section {
    margin-top: 0;
    padding: 0;
    background: none;
    border: none;
}

/* === NEW STYLES FOR BUTTON LOADING & DISABLED STATE === */
.button:disabled, button:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.button .button-spinner {
    display: none; /* Hidden by default */
    border: 3px solid rgba(255, 255, 255, 0.3); /* A faint, light track for the spinner */
    border-top-color: #fff; /* The main spinning part, fully opaque white for high contrast */
    border-radius: 50%;
    width: 16px;
    height: 16px;
    animation: spin 1s linear infinite;
    flex-shrink: 0; /* Prevent spinner from shrinking */
}

.button.is-loading .button-spinner {
    display: block;
}

.button.auto-run-success {
    background-color: var(--success-color);
    border-color: var(--success-color);
    cursor: not-allowed;
    opacity: 1;
}

.button.auto-run-success:hover {
    background-color: var(--success-color); /* Keep color on hover */
    border-color: var(--success-color);
}

.button.save-error {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
    cursor: not-allowed;
    opacity: 1;
}

.button.save-error:hover {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
}

/* === NEW STYLES FOR RECENT TICKETS DROPDOWN === */
.recent-tickets-container {
    position: relative;
    margin-bottom: 1.5rem;
}

.recent-tickets-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,.15);
    padding: 1rem;
    margin-top: 0.25rem;
    width: 100%;
    max-width: 960px; /* Widen the dropdown to give cells more space */
    max-height: calc(100vh - 200px); /* Prevent dropdown from going off-screen */
    overflow-y: auto; /* Add a scrollbar ONLY if content exceeds max-height */
}

#recentTicketsGrid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.recent-ticket-item {
    padding: 0.75rem;
    border: 1px solid var(--medium-gray);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    font-size: 0.9em;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Prevent content from spilling out */
}

.recent-ticket-item:hover {
    background-color: var(--light-gray);
    border-color: var(--primary-color);
}

.recent-ticket-item .ticket-id {
    display: block;
    font-weight: 500;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-ticket-item .ticket-subject {
    color: var(--secondary-color);
    font-size: 0.9em;
    white-space: normal; /* Allow subject to wrap */
    line-height: 1.4;
    margin-bottom: auto; /* Push the time-ago to the bottom */
}

.recent-ticket-item .ticket-time-ago {
    font-size: 0.85em;
    color: #868e96;
    margin-top: 0.5rem; /* Add space from the subject */
}

/* === NEW STYLES FOR FEEDBACK PAGE === */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr; /* Default to single column on small screens */
    gap: 2rem;
    margin-top: 2rem;
}

/* Make data sections have a white background and border, matching the screenshot */
.charts-grid .data-section {
    background-color: #fff;
    border: 1px solid var(--border-color);
    box-shadow: var(--box-shadow);
    margin-top: 0; /* Override default margin */
}

/* Ensure canvas elements inside the grid sections are sized correctly */
.charts-grid .data-section canvas {
    max-height: 450px;
    width: 100% !important;
    height: auto !important;
}

@media (min-width: 992px) { /* On larger screens (laptops, etc.) */
    .charts-grid {
        /* Create a 2-column grid */
        grid-template-columns: 1fr 1.5fr;
        align-items: stretch; /* Make columns equal height */
    }
}

/* NEW Loading Overlay Styles */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: var(--border-radius);
    transition: opacity 0.3s ease-in-out;
}

.loading-overlay .spinner {
    border: 5px solid var(--light-gray);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

.loading-overlay p {
    margin-top: 1rem;
    font-size: 1.1rem;
    color: var(--dark-gray);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}