﻿/* =============================================
   PAGE SHELL (fluid gutters; undo global section margins)
   ============================================= */
.daily-data-page {
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
    padding-left: max(clamp(0.75rem, 4vw, 10.3125rem), env(safe-area-inset-left, 0px));
    padding-right: max(clamp(0.75rem, 4vw, 10.3125rem), env(safe-area-inset-right, 0px));
}

.daily-data-page > section {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.daily-data-page-title {
    font-size: var(--title-font-size);
    font-weight: var(--title-font-weight);
    line-height: 1.2;
    word-wrap: break-word;
}

@media (min-width: 1400px) {
    .daily-data-page {
        padding-left: max(10.3125rem, env(safe-area-inset-left, 0px));
        padding-right: max(10.3125rem, env(safe-area-inset-right, 0px));
    }
}

/* =============================================
   REPORT HEADER & ACTIONS
   ============================================= */
#dailyDate {
    border: none !important;
    box-shadow: none !important;
    flex: 1 1 auto;
    min-width: 0;
    width: auto !important;
    min-height: 0;
    height: auto;
    padding: 0.15rem 0 0.15rem 0.25rem;
    margin: 0;
    background: transparent;
    line-height: 1.4;
    align-self: center;
}

#dailyDate:focus {
    outline: 2px solid var(--primary-teal, #0dcaf0);
    outline-offset: 2px;
}

/* Let the datepicker position itself (fixed coords break small screens) */
.datepicker-dropdown {
    max-width: calc(100vw - 1.5rem);
}

.report-header {
    background: linear-gradient(135deg, #f0fdfa 0%, #ecfeff 100%);
    padding: clamp(1rem, 4vw, 1.5rem) 0;
    border-bottom: 1px solid var(--border-color);
}

.date-badge {
    background: var(--white);
    color: var(--primary-teal-dark);
    padding: 0.45rem clamp(0.75rem, 3vw, 1.5rem);
    border-radius: 2rem;
    font-weight: 600;
    font-size: clamp(0.85rem, 2.5vw, 0.95rem);
    box-shadow: var(--shadow);
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    max-width: 100%;
}

    .date-badge > i {
        flex-shrink: 0;
        line-height: 1;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

.btn-download {
    background: linear-gradient(135deg, var(--primary-teal-dark), var(--dark-green));
    color: var(--white);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 2rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    position: relative;
}

    .btn-download:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-lg);
    }

    .btn-download:disabled {
        opacity: 0.7;
        cursor: not-allowed;
        transform: none;
    }

    .btn-download.loading::after {
        content: "";
        display: inline-block;
        width: 16px;
        height: 16px;
        border: 2px solid rgba(255, 255, 255, 0.3);
        border-top-color: white;
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
        margin-left: 8px;
    }

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.btn-print {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    align-items: stretch;
    flex-wrap: wrap;
}

.daily-data-page .header-actions form {
    display: flex;
    justify-content: center;
    flex: 1 1 auto;
    min-width: min(100%, 12rem);
    max-width: 100%;
}

.print-hint {
    font-size: 0.8rem;
    color: var(--body-color);
    opacity: 0.9;
}


/* =============================================
   GRID LAYOUT & CARDS
   ============================================= */
.row > .col-md-6 {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.report-grid-auto {
    display: block; /* no column layout now */
}

.report-column {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.report-card {
    width: 100%;
    margin-bottom: 20px;
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
    break-inside: avoid;
    page-break-inside: avoid;
    /* smoother rendering */
    will-change: transform;
    transform: translateZ(0);
}

.report-card:hover {
    box-shadow: var(--shadow-lg);
}

@media (hover: hover) and (pointer: fine) {
    .report-card:hover {
        transform: translateY(-4px); /* slightly better */
        box-shadow: var(--shadow-lg);
    }
}
.report-card-title {
    font-family: "DM Serif Display", serif;
    color: var(--heading-color);
    font-size: 1.15rem;
    margin-bottom: 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 2px solid var(--primary-teal);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.report-data-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.data-row {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

    .data-row:last-child {
        border-bottom: none;
    }

.data-label {
    font-weight: 500;
    color: var(--body-color);
}

.data-value {
    font-weight: 600;
    color: var(--heading-color);
    text-align: right;
    min-width: 100px;
}

.text-muted {
    color: #6b7280 !important;
    font-size: 0.85em;
    font-weight: normal;
}


/* =============================================
   RIM STATIONS & RELEASES
   ============================================= */

.rim-section {
    margin-top: 2rem;
}

.rim-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.75rem 1.5rem;
    box-shadow: var(--shadow);
    border: 2px solid transparent;
    text-align: center;
    break-inside: avoid;
}

.rim-inflow {
    border-color: var(--primary-teal);
}

.rim-outflow {
    border-color: var(--primary-teal-dark);
}

.rim-card-title {
    font-family: var(--font-family);
    color: var(--heading-color);
    font-size: 1.25rem;
    margin-bottom: 1.25rem;
    text-transform: uppercase;
    font-weight: 600;
}

.rim-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--light-bg);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
}

.rim-value {
    font-family: var(--font-family);
    font-size: 1.5rem;
    color: var(--heading-color);
    font-weight: 700;
}


/* Releases Section */

.releases-section {
    margin-top: 2rem;
}

.releases-card {
    max-width: 100%;
}

.releases-grid {
    background: var(--light-bg);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.releases-header,
.releases-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.releases-header {
    background: linear-gradient(135deg, var(--dark-green), var(--primary-teal-dark));
    color: var(--white);
    font-weight: 600;
    border-bottom: 2px solid var(--dark-green);
}

.releases-row:last-child {
    border-bottom: none;
}

.rl-label {
    font-weight: 600;
    color: var(--heading-color);
}

.rl-value {
    text-align: justify;
    font-weight: 600;
    color: var(--body-color);
}

    .rl-value.highlight {
        color: var(--primary-teal-dark);
        font-weight: 700;
    }


/* Summary & Footnotes */

.summary-box {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow);
    border-left: 5px solid var(--primary-teal);
    margin-top: 2rem;
    break-inside: avoid;
}

.summary-text {
    font-size: 1rem;
    color: var(--heading-color);
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

    .summary-text strong {
        color: var(--primary-teal-dark);
        font-weight: 700;
    }

.footnotes {
    padding: 1.5rem 0 0.5rem;
    margin-top: 1.5rem;
    border-top: 1px dashed var(--border-color);
}

.footnote {
    font-size: 0.85rem;
    color: var(--body-color);
    line-height: 1.6;
    margin-bottom: 0.4rem;
}

/* disable animations in PDF mode */
.pdf-mode * {
    animation: none !important;
    transition: none !important;
    box-shadow: none !important;
}

/* =============================================
   PRINT CONTENT BASE
   ============================================= */

.print-content {
    display: none;
    position: absolute;
    left: -9999px;
    top: 0;
    background: #fff;
    width: 210mm;
    padding: 15mm;
    padding: 15mm 18mm;
    font-family: var(--font-family);
    font-size: 10.5pt;
}

/* Print Header */

.print-header {
    text-align: center;
    margin-bottom: 2mm;
    border-bottom: 3px solid #022c22;
    padding-bottom: 1mm;
    page-break-after: avoid;
}

.print-logo {
    width: 90px;
    height: auto;
    align-items: left;
    justify-content: left;
}

.print-logo-section {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.print-title {
    padding-left: 5rem;
}

    .print-title h1 {
        font-size: 16pt !important;
        color: #022c22 !important;
        margin: 0;
        font-weight: 400;
        font-family: var(--font-family);
        line-height: 1.2;
    }

    .print-title h2 {
        font-size: 9.5pt !important;
        color: #6b7280 !important;
        margin: 2px 0;
        font-weight: normal;
    }

    .print-title h3 {
        font-size: 11.5pt !important;
        color: #022c22 !important;
        margin: 4px 0 0;
        font-weight: 600;
        font-family: var(--font-family);
    }

.print-date {
    font-weight: 600;
    color: #047857 !important;
    margin-top: 4px;
    font-size: 9.5pt;
    font-family: var(--font-family);
}


/* Two-column print layout */

.print-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10mm;
    width: 100%;
}


/* Print Sections */

.print-section {
    margin-bottom: 10px;
    page-break-inside: avoid;
}

.print-section-title {
    font-family: var(--font-family);
    font-size: 10pt !important;
    color: #022c22 !important;
    margin: 0 0 5px 0;
    border-bottom: 1px solid #064e3b;
    padding-bottom: 3px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.print-data-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    font-size: 9pt !important;
    color: #333 !important;
}

    .print-data-row span:first-child {
        font-weight: 500;
        color: #4b5563;
    }

    .print-data-row span:last-child {
        font-weight: 600;
        color: #022c22 !important;
        text-align: right;
        min-width: 90px;
    }

.print-total {
    background: #f8fafc !important;
    padding: 5px 8px;
    margin-top: 4px;
    font-weight: 700 !important;
    border-left: 3px solid #047857;
    font-size: 9.5pt !important;
}


/* Releases Table for Print */

.print-releases-table {
    font-size: 8.5pt !important;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.print-releases-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    background: #064e3b !important;
    color: white !important;
    padding: 5px 8px;
    font-weight: 600;
    text-align: center;
    page-break-after: avoid;
}

.print-releases-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    padding: 4px 8px;
    border-bottom: 1px solid #e2e8f0;
    text-align: center;
}

    .print-releases-row:last-child {
        border-bottom: none;
    }

    .print-releases-row span:first-child {
        font-weight: 600;
        text-align: left;
        color: #022c22 !important;
    }

    .print-releases-row span:not(:first-child) {
        font-weight: 600;
        color: #047857 !important;
    }


/* Summary Box for Print */

.print-summary {
    background: #f8fafc !important;
    padding: 10px 12px;
    margin: 7mm 0;
    border-left: 4px solid #047857;
    page-break-inside: avoid;
    font-size: 9pt !important;
    border-radius: 0 4px 4px 0;
}

    .print-summary p {
        margin: 3px 0;
        color: #022c22 !important;
        line-height: 1.4;
    }

    .print-summary strong {
        color: #047857 !important;
        font-weight: 700;
    }


/* Footnotes for Print */

.print-footnotes {
    margin-top: 5mm;
    font-size: 7.5pt !important;
    color: #6b7280 !important;
    line-height: 1.5;
    page-break-inside: avoid;
    border-top: 1px dashed #cbd5e1;
    padding-top: 8px;
}

    .print-footnotes p {
        margin: 2px 0;
    }

#irsaPrintWrapper {
    font-size: 8pt !important;
    line-height: 1.2 !important;
}

#irsaPrintWrapper .p-section {
    margin-bottom: 3px !important;
}

#irsaPrintWrapper .p-section-title {
    margin-bottom: 2px !important;
    padding-bottom: 1px !important;
}

#irsaPrintWrapper .p-data-row {
    padding: 1px 2px !important;
    font-size: 7.8pt !important;
}

#irsaPrintWrapper .p-rim-row {
    margin: 5px 0 !important;
}

#irsaPrintWrapper .p-summary {
    padding: 6px 8px !important;
    margin: 5px 0 !important;
}

#irsaPrintWrapper .p-summary p {
    margin: 1px 0 !important;
}

#irsaPrintWrapper .p-footnotes {
    margin-top: 4px !important;
    padding-top: 4px !important;
}

#irsaPrintWrapper .p-footnotes p {
    font-size: 7pt !important;
    margin: 1px 0 !important;
}
#irsaPrintWrapper .p-logo {
    width: 55px !important;
}

#irsaPrintWrapper .p-org {
    font-size: 12pt !important;
}

#irsaPrintWrapper .p-report-title {
    font-size: 10pt !important;
}

#irsaPrintWrapper .p-divider {
    margin: 4px 0 6px 0 !important;
}
/* =============================================
   PRINT MEDIA QUERIES
   ============================================= */

@media print {
    @page {
        size: A4;
        margin: 12mm;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
        box-shadow: none !important;
    }

    body {
        height: auto !important;
        overflow: hidden !important;
        background: white !important;
        color: #000 !important;
        font-size: 10pt !important;
        line-height: 1.5 !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 210mm !important;
        font-family: var(--font-family);
    }
    #irsaPrintWrapper {
        page-break-after: avoid !important;
        page-break-before: avoid !important;
    }
    /* Hide web-only elements */
    .report-header,
    .btn-download,
    .print-hint,
    .section-py > .container > .report-grid,
    .section-py > .container > .report-grid-auto,
    .section-py > .container > .rim-section,
    .section-py > .container > .releases-section,
    .section-py > .container > .summary-box:not(.print-summary),
    .section-py > .container > .footnotes:not(.print-footnotes),
    footer,
    nav,
    header:not(.print-header) {
        display: none !important;
    }

    .section-py {
        padding: 0 !important;
        background: white !important;
    }

    .container {
        width: 100% !important;
        max-width: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Show print content */
    .print-content {
        display: block !important;
        position: static !important;
        left: auto !important;
        width: 100%;
    }
    /* Page break helpers */
    .page-break {
        page-break-before: always;
    }

    .no-break {
        page-break-inside: avoid;
    }
}



/* =============================================
   RESPONSIVE BREAKPOINTS
   ============================================= */

@media (max-width: 991.98px) {
    .report-grid {
        grid-template-columns: 1fr !important;
        gap: 1.25rem !important;
    }

    .report-grid-auto {
        column-count: 1;
        column-gap: 0;
    }

    .daily-data-page .container {
        padding-left: max(0.75rem, var(--bs-gutter-x, 0.75rem));
        padding-right: max(0.75rem, var(--bs-gutter-x, 0.75rem));
    }

    .rim-section .row {
        flex-direction: column;
    }

    .rim-card {
        margin-bottom: 1rem;
    }

    .releases-header,
    .releases-row {
        grid-template-columns: 1.5fr 1fr 1fr !important;
        font-size: 0.85rem;
        padding: 0.7rem 1rem;
    }
}

@media (max-width: 767.98px) {
    .report-card,
    .rim-card,
    .summary-box,
    .releases-card {
        padding: 1.25rem !important;
    }

    .report-card-title,
    .rim-card-title {
        font-size: 1.05rem !important;
        margin-bottom: 0.85rem !important;
        padding-bottom: 0.5rem !important;
    }

    .data-row {
        font-size: 0.85rem !important;
        flex-wrap: wrap;
        gap: 2px;
    }

    .data-value {
        min-width: 85px;
        font-size: 0.9rem;
    }

    .header-actions {
        flex-direction: column;
        gap: 0.6rem !important;
    }

    .daily-data-page .btn-download {
        width: 100%;
        max-width: 22rem;
        justify-content: center;
        box-sizing: border-box;
        margin-left: auto;
        margin-right: auto;
    }

    .daily-data-page .section-py {
        padding-top: clamp(0.75rem, 3vw, 1.5rem) !important;
        padding-bottom: clamp(0.75rem, 3vw, 1.5rem) !important;
    }

    .releases-row {
        display: flex;
        flex-direction: column;
        gap: 0;
        padding: 0;
        border-bottom: 1px solid var(--border-color);
    }

        .releases-row:last-child {
            border-bottom: none;
        }
    /* Province name — full-width coloured bar (reuses your gradient) */
    .rl-label {
        background: linear-gradient(135deg, var(--dark-green), var(--primary-teal-dark));
        color: var(--white);
        padding: 0.5rem 1rem;
        font-size: 0.82rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }
    /* Today + Last Year side by side below the label */
    .rl-values-wrap {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .rl-value {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 0.6rem 0.75rem;
        text-align: center;
        font-size: 0.88rem;
        border-right: 1px solid var(--border-color);
        gap: 2px;
    }

        .rl-value:last-child {
            border-right: none;
        }
        /* Auto captions so header row is not missed */
        .rl-value::before {
            font-size: 0.68rem;
            font-weight: 500;
            color: var(--body-color);
            text-transform: uppercase;
            letter-spacing: 0.05em;
            opacity: 0.75;
        }

        .rl-value.highlight::before {
            content: "Today";
        }

        .rl-value:not(.highlight)::before {
            content: "Last Year";
        }

        .rl-value.highlight {
            color: var(--primary-teal-dark);
            background: #f0fdf4;
        }

        .rl-value:not(.highlight) {
            color: var(--body-color);
            background: var(--white);
        }
}

@media (max-width: 480px) {
    .report-header {
        padding: 1rem 0;
    }

    .report-title-section h1,
    .report-title-section h2 {
        font-size: 1.3rem !important;
        margin-bottom: 0.75rem !important;
    }

    .date-badge {
        padding: 0.4rem 1rem;
        font-size: 0.88rem;
        width: 100%;
        max-width: 22rem;
    }

    .rim-value {
        font-size: 1.3rem;
    }

    .rim-total {
        padding: 0.85rem 1.25rem;
        font-size: 0.95rem;
        flex-wrap: wrap;
        gap: 0.35rem;
    }

    .summary-text {
        font-size: 0.95rem;
    }

    .footnote {
        font-size: 0.8rem;
    }

    .daily-data-page .btn-download {
        font-size: 0.82rem;
        padding: 0.65rem 1rem;
        line-height: 1.35;
    }

    .releases-header {
        grid-template-columns: 1fr !important;
        text-align: center;
        gap: 0.35rem;
        padding: 0.65rem 0.75rem;
    }
}


/* Utility & Accessibility */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (prefers-reduced-motion: reduce) {
    .daily-data-page,
    .daily-data-page * {
        transition: none !important;
        animation: none !important;
    }
}
