﻿/*
* Contains all global CSS overrides for RadzenDataGrid, moved from site.css.
*/

:root {
    /* DataGrid */
    --rz-grid-background-color: rgba(55, 65, 81, 0.45);
    --rz-grid-header-background-color: rgba(31, 41, 55, 0.70);
    --rz-grid-header-color: var(--color-text-secondary);
    --rz-grid-header-border-color: rgba(255,255,255,0.08);
    --rz-grid-row-background-color: rgba(55, 65, 81, 0.45);
    --rz-grid-row-stripe-background-color: rgba(31, 41, 55, 0.45);
    --rz-grid-row-hover-background-color: var(--color-border);
    --rz-grid-row-color: var(--color-text-primary);
    --rz-grid-row-border-color: rgba(255,255,255,0.06);

    /* Pager */
    --rz-paginator-background-color: rgba(31, 41, 55, 0.60);
    --rz-paginator-color: var(--color-text-secondary);
    --rz-paginator-button-hover-background-color: var(--color-border);
    --rz-paginator-button-active-background-color: var(--color-accent);
    --rz-paginator-button-active-color: var(--color-text-primary);
}

.pretty-radzen-grid .rz-grid-table tfoot td.numeric-cell-padding {
    padding-right: 24px !important;
}

/* Apply text-align: right ONLY on screens wider than the mobile breakpoint */
@media (min-width: 769px) {
    .pretty-radzen-grid .rz-grid-table tfoot td.numeric-cell-padding {
        text-align: right;
    }
}

/* Dark theme for Radzen Grid Footer */
.rz-grid-table tfoot {
    background-color: var(--color-background); /* Darker footer bg */
}

.rz-grid-table tfoot td {
    color: var(--color-text-primary);
    font-weight: bold;
    border-top: 2px solid var(--color-accent) !important; /* Separator line */
    border-bottom: none !important;
}

/* --- START: Mobile Responsive Override for .pretty-radzen-grid --- */
/*
 * This override replaces the default Radzen stacking with a 
 * "card" style view on mobile, inspired by the HistoricalStations footer.
*/
@media (max-width: 768px) {

    /* 1. Hide the table header, as labels will be in each cell */
    .pretty-radzen-grid .rz-grid-table thead {
        display: none;
    }

    .live-sessions-grid .rz-grid-table tbody td .rz-cell-data > div {
        /* 1. Swap visual order: Text first, Icon second */
        flex-direction: row-reverse !important;

        /* 2. Align to the Right (Start of the reversed row) */
        justify-content: flex-start !important;

        /* 3. Ensure container fills the width */
        width: 100% !important;
    }

    .influx-stats-grid .station-cell {
        /* 1. Swap visual order: Text first, Image/Dot second */
        flex-direction: row-reverse !important;

        /* 2. Align to the Right (Start of the reversed row) */
        justify-content: flex-start !important;

        /* 3. Ensure container fills the width to allow alignment */
        width: 100% !important;
    }

    /* 2. Turn each row into a distinct "card" */
    .pretty-radzen-grid .rz-grid-table tbody tr {
        display: block;
        background-color: transparent;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md); /* Changed from 12px to 8px */
        margin-bottom: var(--space-sm);
        padding: var(--space-sm);
        box-shadow: var(--shadow-sm);
    }

    /* 3. Make each cell a flex row (Label vs Value) */
    .pretty-radzen-grid .rz-grid-table tbody td {
        display: flex !important;
        justify-content: flex-start;
        align-items: baseline;
        padding: 0.6rem 0.25rem !important;
        border-bottom: 1px dashed var(--color-border);
        text-align: left !important;
        white-space: normal;
        font-size: var(--text-sm); /* Changed from 0.85em */
        color: var(--color-text-secondary); /* Standardized gray */
        border-radius: var(--radius-sm); /* Changed from 5px */
    }

    /* 4. Last cell in card gets no border */
    .pretty-radzen-grid .rz-grid-table tbody td:last-child {
        border-bottom: none;
    }

    /* 5. Style the Label (Radzen's ::before pseudo-element) */
    .pretty-radzen-grid .rz-grid-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--color-text-secondary);
        padding-right: 1rem;
        text-align: left;
        flex-shrink: 0;
        font-size: var(--text-sm); /* Ensure mobile labels match data */
    }

    /* 6. Style the Value (Radzen's .rz-cell-data span) */
    .pretty-radzen-grid .rz-grid-table tbody td .rz-cell-data {
        padding-right: 6px;
        flex-grow: 1; /* MODIFICATION: Allow value to fill space */
        word-break: break-word;
        font-weight: 600;
        color: var(--color-text-primary); /* Value color */
        padding-left: 8px;
        text-align: right; /* MODIFICATION: Align value to the right */
    }

    /* 7. --- START: Updated Icon Cell Styling --- */

    /* 7a. Center the image container (rz-cell-data) */
    .pretty-radzen-grid .rz-grid-table tbody td:first-child {
        background: transparent !important;
        justify-content: center; /* Center the flex item */
        border-bottom: none; /* No separator line under the image */
        margin-bottom: 0.5rem; /* Add space below the image */
        padding-bottom: 0.25rem !important;
    }

    /* 7b. The cell data wrapper itself doesn't need 100% width */
    .pretty-radzen-grid .rz-grid-table tbody td:first-child .rz-cell-data {
        text-align: center;
        width: auto; /* Let it be the size of the image */
        flex-grow: 0; /* Don't let it grow */
    }

    /* 7c. Hide the label for the icon cell */
    .pretty-radzen-grid .rz-grid-table tbody td:first-child::before {
        display: none;
    }

    /* 7d. [NEW] Hide the entire cell if it's empty (no image) */
    .pretty-radzen-grid .rz-grid-table tbody td:first-child:empty {
        display: none !important;
    }

    /* --- END: Updated Icon Cell Styling --- */

    /* 8. Make the data container a simple block */
    .pretty-radzen-grid .rz-data-grid-data {
        overflow-x: hidden; /* No horizontal scroll */
    }

    /* 9. Give the pager some space */
    .pretty-radzen-grid .rz-paginator-bottom {
        margin-top: 8px;
    }
}
/* --- END: Mobile Responsive Override --- */

/* --- Hide built-in Radzen pager when using CustomPager --- */
.hide-radzen-pager .rz-pager {
    display: none !important;
}

/* --- Custom Pager (mirrors Radzen rz-pager look) --- */
.custom-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0;
    padding: var(--rz-pager-padding, 0.25rem 0.5rem);
    background-color: var(--rz-paginator-background-color, rgba(31, 41, 55, 0.60));
    font-size: var(--rz-body-font-size, 0.875rem);
    font-family: var(--rz-body-font-family, inherit);
    color: var(--rz-paginator-color, #9ca3af);
}

.custom-pager .cp-btn,
.custom-pager .cp-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--rz-pager-element-width, 2rem);
    height: var(--rz-pager-element-height, 2rem);
    padding: 0 var(--rz-pager-element-padding, 0.5rem);
    margin: 0 1px;
    border: none;
    border-radius: var(--rz-border-radius, 4px);
    background: transparent;
    color: inherit;
    font-size: inherit;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
    user-select: none;
}

.custom-pager .cp-btn:hover,
.custom-pager .cp-nav:hover:not(:disabled) {
    background-color: var(--rz-paginator-button-hover-background-color, rgba(255,255,255,0.08));
    color: var(--color-text-primary, #fff);
}

.custom-pager .cp-btn.cp-active {
    background-color: var(--rz-paginator-button-active-background-color, var(--color-accent, #3b82f6));
    color: var(--rz-paginator-button-active-color, #fff);
    font-weight: 600;
    cursor: default;
}

.custom-pager .cp-nav:disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

/* Invisible placeholder — same size as a page button, takes up layout space */
.custom-pager .cp-ghost {
    visibility: hidden;
    pointer-events: none;
}

.custom-pager .cp-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: var(--rz-pager-element-height, 2rem);
    padding: 0 2px;
    color: inherit;
    pointer-events: none;
}
/* --- End Custom Pager --- */