/* Common styles for all pages */

/* Import Nunito Sans font */
@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@300;400;500;600;700;900&display=swap');

/* Disabled button styling for POST operations */
button.post-disabled,
button.post-disabled:hover,
button.post-disabled:active,
button.post-disabled:focus {
    background: #ccc !important;
    background-color: #ccc !important;
    color: #666 !important;
    cursor: not-allowed !important;
    opacity: 0.6 !important;
    pointer-events: none !important;
}

/* Design System Colors - Based on SCSS guidelines */
:root {
    --primary-colour: #1A4C41;        /* primaryColour - dark green */
    --deep-green: #153D33;            /* deepGreen - darker green for hover */
    --leaf-green: #3D7F4B;            /* leafGreen - medium green (secondary) */
    --light-green: #5A9F6F;           /* lightGreen - lighter green for nav */
    --green-brand-100: #3D7F4B;       /* greenBrand-100 - active state */
    --green-brand-200: #5A9F6F;       /* greenBrand-200 - inactive state */
    --green-brand-30: #8FC19F;        /* greenBrand-30 - lighter state */
    --accent-colour: #F57C00;         /* accentColour - orange */
    --drop-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --space-s: 16px;
}

.search-section {
    background: white;
    padding: var(--space-s);
    border-radius: 12px;             /* rounded-xl equivalent */
    box-shadow: var(--drop-shadow);
    margin-bottom: 24px;
}

.search-group {
    margin-bottom: 12px;
}

.search-bar {
    display: flex;
    gap: 8px;
    align-items: center;             /* Center align items vertically */
}

.search-bar input,
.search-bar button {
    height: 32px;                    /* Ensure all have same height */
    box-sizing: border-box;
    margin: 0;                       /* Remove any margins */
    vertical-align: middle;          /* Additional vertical alignment */
}

.search-bar input {
    flex: 1;
}

/* Remove any margins from buttons in search-bar */
.search-bar button {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

* {
    font-family: Nunito Sans, ui-sans-serif, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #333;
    font-size: 12px;
}

input[type="text"], input[type="number"], select, input[type="date"] {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    background: white;
    height: 32px;
    line-height: 1;
}

.filter-row {
    background: #fff;
    border: 1px solid #ddd;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 4px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.filter-row select {
    min-width: 150px;
}

.filter-row input {
    flex: 1;
}

.remove-filter {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;               /* Match input field height (32px total) */
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    height: 32px;                    /* Match input field height exactly */
    box-sizing: border-box;
    transition: all 0.3s;
}

.remove-filter:hover {
    background: #c82333;
}

.add-filter-btn, .save-search-btn {
    background: var(--leaf-green);   /* Using leafGreen for secondary actions */
    color: white;
    border: none;
    padding: 8px 16px;               /* Match input field height (32px total) */
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: all 0.3s;
    height: 32px;                    /* Match input field height exactly */
    box-sizing: border-box;
}

/* Remove margin-top when save-search-btn is in search-bar */
.search-bar .save-search-btn {
    margin-top: 0;
}

.add-filter-btn:hover, .save-search-btn:hover {
    background: var(--deep-green);
}

.filters-container, .indicators {
    background: white;
    border: 1px solid #ddd;
    padding: 15px;
    border-radius: 12px;             /* rounded-xl */
    box-shadow: var(--drop-shadow);
    margin-bottom: 20px;
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.filters-header h3 {
    margin: 0;
    color: var(--primary-colour);
    font-size: 13px;
}

h1 {
    color: var(--primary-colour);
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-colour);
}

h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-colour);
}

p {
    font-size: 16px;
}

a {
    font-size: 16px;
}

/* Button styles - matching SCSS design system */
button, .button {
    background: var(--primary-colour);
    color: white;
    border: none;
    padding: 8px 16px;               /* Match input field height (32px total) */
    border-radius: 4px;              /* rounded-[4px] */
    font-size: 12px;                 /* text-xs */
    font-weight: 600;                /* font-semibold */
    text-transform: uppercase;       /* uppercase */
    letter-spacing: 0.1em;           /* tracking-widest */
    cursor: pointer;
    transition: all 0.3s;
    line-height: 1;                  /* leading-none */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    appearance: none;
    outline: none;
    height: 32px;                    /* Match input field height exactly */
    box-sizing: border-box;
}

button:hover:not(:disabled):not(.hide-btn), .button:hover:not(:disabled):not(.hide-btn) {
    background: var(--deep-green);
}

button:disabled, .button:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.3;
}

button:focus, .button:focus {
    outline: none;
    border: 1px solid #333;
}

/* Secondary button */
button.button--secondary, .button--secondary {
    background: var(--leaf-green);
}

button.button--secondary:hover:not(:disabled):not(.hide-btn), .button--secondary:hover:not(:disabled):not(.hide-btn) {
    background: var(--deep-green);
}

/* Hover state for green outline secondary buttons (white bg, green border) */
button[style*="border: 1px solid #3D7F4B"][style*="background: white"]:hover {
    background: #f5f5f5 !important;
    color: #3D7F4B !important;
}

/* Hollow button */
button.hollow, .button.hollow {
    background: transparent;
    color: #666;
    border: 1px solid #666;
}

button.hollow:hover:not(.hide-btn), .button.hollow:hover:not(.hide-btn) {
    color: var(--primary-colour);
    border-color: var(--primary-colour);
}

/* Large screen button padding - keep same height for consistency */
@media (min-width: 1024px) {
    button, .button {
        height: 32px;                /* Keep same height on large screens */
        padding: 8px 16px;
    }
    
    .add-filter-btn, .save-search-btn, .download-csv-btn, .hide-btn, .remove-filter, .date-range-btn {
        height: 32px;                /* Keep same height on large screens */
    }
}

.chart-section, .tile {
    margin-bottom: 30px;
    padding: var(--space-s);
    background: white;
    border-radius: 12px;             /* rounded-xl */
    box-shadow: var(--drop-shadow);
}

.tile__no-padding {
    padding: 0;
}

.chart-container {
    position: relative;
    height: 320px;
    margin-top: 16px;
}

.module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.module-header h2, .module-header h3 {
    margin: 0;
}

.hide-btn {
    background: transparent !important;
    border: none !important;
    outline: none !important;
    padding: 8px;
    cursor: pointer;
    transition: none;
    height: 32px;
    width: 32px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hide-btn:focus,
.hide-btn:active,
.hide-btn:focus-visible,
.hide-btn:hover {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    background-color: transparent !important;
}

.hide-btn img {
    width: 18px;
    height: 18px;
    transition: filter 0.2s ease;
}

/* Default state: inactive/hidden (eye icon shown) - lighter grey */
.hide-btn img {
    opacity: 0.5;
    filter: brightness(0) saturate(100%) invert(75%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(1) contrast(1);
}

/* Active state: visible (eye-off icon shown) - slightly darker grey */
.hide-btn.content-visible img {
    opacity: 0.7;
    filter: brightness(0) saturate(100%) invert(60%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(1) contrast(1);
}

/* Hover state: change icon to dark green (#3D7F4B) */
.hide-btn:hover img {
    opacity: 1;
    filter: brightness(0) saturate(100%) invert(38%) sepia(25%) saturate(2000%) hue-rotate(100deg) brightness(0.85) contrast(1);
}

.module-content {
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
    overflow: hidden;
}

.module-content.collapsed {
    max-height: 0 !important;
    opacity: 0;
    margin: 0;
    padding: 0;
}

.table-container {
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

thead {
    position: sticky;
    top: 0;
    background: var(--primary-colour);
    color: white;
    z-index: 10;
}

th, td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    font-weight: 600;
    white-space: nowrap;
}

tbody tr:hover {
    background: #f5f5f5;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 25px;
}

th.sortable:hover {
    background: var(--deep-green);
}

th.sortable::after {
    content: '⇅';
    position: absolute;
    right: 8px;
    opacity: 0.3;
}

th.sortable.sort-asc::after {
    content: '↑';
    opacity: 1;
}

th.sortable.sort-desc::after {
    content: '↓';
    opacity: 1;
}

.loading {
    text-align: center;
    padding: 32px;
    color: #666;
    font-size: 13px;
}

.error {
    background: #ffebee;
    color: #c62828;
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 12px;
}

.download-csv-btn {
    background: var(--leaf-green);   /* Using leafGreen for success actions */
    color: white;
    border: none;
    padding: 8px 16px;               /* Match input field height (32px total) */
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.3s;
    height: 32px;                    /* Match input field height exactly */
    box-sizing: border-box;
}

.download-csv-btn:hover {
    background: var(--deep-green);
}

.saved-searches-section {
    background: white;
    padding: var(--space-s);
    border-radius: 12px;             /* rounded-xl */
    box-shadow: var(--drop-shadow);
    margin-bottom: 20px;
}

.saved-search-item {
    display: inline-block;
    background: white;
    border: 1px solid var(--leaf-green);
    border-radius: 4px;
    padding: 6px 10px;
    margin: 4px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 12px;
}

.saved-search-item:hover {
    background: var(--leaf-green);
    color: white;
}

.saved-search-item .delete-btn {
    margin-left: 10px;
    color: #dc3545;
    font-weight: bold;
    cursor: pointer;
}

.saved-search-item:hover .delete-btn {
    color: white;
}

/* .save-search-btn is now styled with .add-filter-btn above */

/* Date filter buttons - segmented control style with shared background */
.date-range-buttons, .date-filter {
    display: inline-flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 0;                          /* No gap between buttons */
    margin-bottom: 15px;
    flex-wrap: wrap;
    background: #eeedef;             /* Custom background color */
    padding: 4px;                    /* Padding around buttons */
    border-radius: 8px;              /* Rounded container */
}

.date-range-btn {
    font-weight: 400;                /* Normal weight instead of bold */
    color: #8a9199 !important;       /* Darker text color for unselected - improved contrast */
    background: transparent !important;
    background-color: transparent !important;
    border: none;
    padding: 8px 16px;               /* Match input field height (32px total) */
    border-radius: 6px;              /* Slightly rounded individual buttons */
    font-size: 12px;                 /* text-sm */
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    height: 32px;                    /* Match input field height exactly */
    box-sizing: border-box;
    white-space: nowrap;
}

.date-range-btn:hover:not(.active) {
    color: #8a9199 !important;       /* Keep same text color as unselected */
    background: #f5f5f5 !important;  /* Custom hover background color - more visible */
    background-color: #f5f5f5 !important;  /* Ensure background color is set */
}

/* Ensure hover works even with inline container styles */
.date-range-buttons .date-range-btn:hover:not(.active) {
    background: #f5f5f5 !important;
    background-color: #f5f5f5 !important;
}

.date-range-btn.active {
    color: #23282d !important;       /* Custom text color for selected */
    background: #ffffff !important;  /* White background for selected */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); /* Slight shadow for depth */
    border: 1px solid #3D7F4B !important; /* Green border for active state */
}

/* Large screen date filter padding - keep same style */
@media (min-width: 640px) {
    .date-range-buttons, .date-filter {
        gap: 0;                      /* Still no gap between buttons */
        padding: 4px;                /* Same padding */
    }
    
    .date-range-btn {
        padding: 8px 16px;           /* Same padding */
        font-size: 12px;             /* Keep consistent font size */
    }
}

.date-range-custom {
    display: none;
    gap: 10px;
    align-items: center;
    margin-left: auto;
}

.date-range-custom input {
    width: 120px;
    height: 32px;
    font-size: 12px;
}

.date-range-custom.show {
    display: flex;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .search-bar {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
        align-items: center;
        width: 100%;
    }
    
    .search-bar input {
        flex: 1;
        min-width: 150px;
        margin: 0 !important;
        box-sizing: border-box;
    }
    
    .search-bar button {
        flex-shrink: 0;
        width: fit-content;
        margin: 0 !important;
        box-sizing: border-box;
    }
    
    .save-search-btn {
        width: 100%;
        margin: 0 !important;
        box-sizing: border-box;
    }
    
    .filter-row {
        flex-direction: column;
        gap: 6px;
        padding: 8px;
        align-items: stretch;
    }
    
    .filter-row select,
    .filter-row input,
    .filter-row button {
        width: 100%;
        min-width: auto;
        margin: 0;
        box-sizing: border-box;
    }
    
    .filters-header {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .add-filter-btn {
        width: 100%;
        margin-top: 8px;
    }
    
    .date-range-buttons {
        flex-wrap: wrap;
        gap: 6px;
        justify-content: center;
    }
    
    .date-range-btn {
        padding: 6px 10px;
        font-size: 11px;
        height: 28px;
        box-sizing: border-box;
        margin: 0;
    }
    
    .date-range-buttons > span {
        width: 100%;
        text-align: center;
        margin-bottom: 4px;
    }
    
    .date-range-custom {
        flex-direction: column;
        width: 100%;
        margin-left: 0;
        margin-top: 8px;
        align-items: stretch;
    }
    
    .date-range-custom input,
    .date-range-custom button,
    .date-range-custom label {
        width: 100%;
        box-sizing: border-box;
    }
    
    .chart-container {
        height: 600px !important;
    }
    
    /* Taller charts for time series and regression on mobile - 25% of screen height */
    .chart-wrapper {
        height: 25vh !important;
        min-height: 300px !important;
        max-height: 25vh !important;  /* Prevent growing beyond viewport */
        position: relative !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;  /* Allow flexbox items to shrink */
        overflow: hidden !important;  /* Prevent content overflow */
    }
    
    /* Constrain canvas to container dimensions */
    .chart-wrapper canvas {
        max-width: 100% !important;
        max-height: 100% !important;
        width: 100% !important;
        height: 100% !important;
        display: block !important;
    }
    
    /* Also target chart-wrapper with chart-container inside (for distribution charts) */
    .chart-wrapper .chart-container {
        height: 25vh !important;
        min-height: 300px !important;
    }
    
    .module-header {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .module-header h2 {
        text-align: center;
        margin-bottom: 0;
    }
    
    .module-header button {
        width: 100%;
    }
    
    .module-header .hide-btn {
        width: auto !important;
        align-self: flex-end;
    }
    
    /* Ensure the button container in module-header doesn't force full width */
    .module-header > div {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        width: auto;
    }
    
    table {
        font-size: 10px;
    }
    
    th, td {
        padding: 6px;
        white-space: nowrap;
    }
}

