@media print {
    /* Hide WordPress admin bar and other elements */
    #wpadminbar,
    .site-header,
    .et-l--header,
    .et-l--footer,
    .calendar-home-header,
    .calendar-headers,
    .site-footer,
    .navigation,
    .sidebar,
    .no-print,
    .print-controls {
        display: none !important;
    }

    /* Divi spacing fixes */
    .et_pb_section {
        margin: 0 !important;
        padding: 0 !important;
    }
    .et_pb_row {
        padding: 0 !important;
    }

    /* Calendar specific styles */
    .calendar-list-container {
        width: 100%;
        overflow: visible;
        /* Remove any height constraints that might affect printing */
        height: auto;
        max-height: none;
    }

    .calendar-list {
        width: 100%;
        border-collapse: collapse;
        font-size: 10pt;
        line-height: 1.2;
        /* Ensure consistent border rendering */
        border-spacing: 0;
        table-layout: fixed; /* Helps with consistent column widths */
        /* Ensure the table itself has borders */
        border: 1px solid #000;
        /* Force table to maintain structure across pages */
        page-break-inside: auto;
    }

    /* Ensure borders are explicitly defined for each edge */
    .calendar-list th,
    .calendar-list td {
        border-top: 1px solid #000;
        border-right: 1px solid #000;
        border-bottom: 1px solid #000;
        border-left: 1px solid #000;
        padding: 2px 4px;
        vertical-align: top;
        /* Ensure content doesn't overflow and affect borders */
        overflow: hidden;
        word-wrap: break-word;
    }

    /* Ensure table header prints at the top of each page and isn't sticky/transformed */
    .calendar-list thead {
        display: table-header-group !important;
        position: static !important;
        transform: none !important;
        top: auto !important;
        margin: 0 !important;
        z-index: auto !important;
    }

    .calendar-list thead th {
        background-color: white !important;
        color: black !important;
        position: static !important;
        transform: none !important;
        top: auto !important;
        margin: 0 !important;
        z-index: auto !important;
    }

    .calendar-list tbody {
        display: table-row-group !important;
    }

    /* Apply page break control to rows instead of cells */
    .calendar-list tr {
        display: table-row !important;
        page-break-inside: avoid;
        /* Ensure row integrity across pages */
        break-inside: avoid;
        /* Ensure borders are maintained across page breaks */
        border-collapse: collapse;
    }

    /* Prevent awkward page breaks */
    .calendar-list tbody tr {
        page-break-inside: avoid;
        /* Ensure row integrity across pages */
        break-inside: avoid;
    }

    .calendar-list th,
    .calendar-list td {
        display: table-cell !important;
    }

    .calendar-list .today-highlight {
        background-color: white;
        color: inherit !important;
        font-weight: normal !important;
    }

    .textarea-day {
        border: none;
        background: none;
        resize: none;
        font-family: inherit;
        font-size: inherit;
        width: 100%;
        min-height: auto;
        overflow: visible;
    }

    .list-date {
        width: 15%;
    }

    /* Hide browser headers/footers */
    @page {
        margin: 0.5in;
        size: landscape;
        /* Ensure consistent page rendering */
        orphans: 2;
        widows: 2;
    }

    body {
        margin: 0;
    }
}