@page {
    size: Letter portrait;
    margin: 0.5in;
}

/* Print styles: clean, black-and-white output */
@media print {
    /* Hide modal and user bar when printing */
    .modal,
    .user-bar {
        display: none !important;
    }

    /* Colors -> B/W */
    * {
        color: #000 !important;
        background: transparent !important;
        box-shadow: none !important;
        text-shadow: none !important;
        border-color: #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        animation: none !important;
        transition: none !important;
    }

    /* Ensure animated rows are visible when animations are disabled */
    .row-in { opacity: 1 !important; transform: none !important; animation: none !important; }

    /* Layout: fit to one page where possible */
    html, body { width: auto; margin: 0; }
    body { margin: 0; }
    main { max-width: none; }

    /* Hide interactive UI */
    .theme-toggle,
    .tabs,
    .quick-actions,
    .controls button,
    .controls input,
    .controls label,
    .spacer,
    footer,
    .status { display: none !important; }

    /* Hide header extras for minimal print */
    .date-selector,
    .subtitle { display: none !important; }
    /* Remove mobile view-only banner in print */
    #daily-goal::before { content: none !important; display: none !important; }

    /* By default, print Plan only; Team/Admin hidden */
    #team-view { display: none !important; }
    #admin-view { display: none !important; }
    /* When explicitly printing team, swap */
    html.print-team #team-view { display: block !important; }
    html.print-team #daily-goal { display: none !important; }

        /* Reset mobile responsive styles for print - force normal table layout */
        #hour-table,
        #hour-table thead,
        #hour-table tbody,
        #hour-table tr,
        #hour-table th,
        #hour-table td {
            display: table !important;
        }
        #hour-table thead { display: table-header-group !important; }
        #hour-table tbody { display: table-row-group !important; }
        #hour-table tr { display: table-row !important; }
        #hour-table th,
        #hour-table td { display: table-cell !important; }
    
        /* Remove grid layout from mobile cards */
        #hour-table td {
            grid-template-columns: unset !important;
        }
    
        /* Hide mobile labels (data-label) */
        #hour-table td::before { display: none !important; content: none !important; }
    
        /* Reset wrap containers to normal inline */
        #hour-table td.hour-goal .goal-wrap,
        #hour-table td.cum-goal .cum-wrap {
            display: inline !important;
            grid-column: unset !important;
        }

        /* Disable sticky first column in print */
        table td.hour-label,
        table th:first-child {
            position: static !important;
            left: auto !important;
            box-shadow: none !important;
            z-index: auto !important;
        }

        /* Reset team table as well (avoid mobile card layout in print) */
        #team-table,
        #team-table thead,
        #team-table tbody,
        #team-table tr,
        #team-table th,
        #team-table td {
            display: table !important;
        }
        #team-table thead { display: table-header-group !important; }
        #team-table tbody { display: table-row-group !important; }
        #team-table tr { display: table-row !important; }
        #team-table th,
        #team-table td { display: table-cell !important; }
        /* Remove grid layout from team table cards */
        #team-table td { grid-template-columns: unset !important; }
        /* Hide mobile labels for team table */
        #team-table td::before { display: none !important; content: none !important; }

        /* Remove card-like spacing/styling on rows for print */
        #hour-table tr,
        #team-table tr {
            margin: 0 !important;
            padding: 0 !important;
            background: transparent !important;
            border: none !important;
            border-radius: 0 !important;
            box-shadow: none !important;
        }
        /* Ensure data-label-driven cells are visible in print */
        #hour-table td[data-label],
        #team-table td[data-label] {
            display: table-cell !important;
        }
        /* Ensure container doesn't clip during print */
        #table-wrap { overflow: visible !important; margin: 0 !important; }

    .tab[disabled] { opacity: 0.5; cursor: not-allowed; filter: grayscale(0.2); }
    /* Keep title visible */
    header { margin-bottom: 8px; }
    /* Ensure gradient title prints solid black */
    .brand-gradient { 
        background: none !important;
        -webkit-text-fill-color: #000 !important;
        color: #000 !important;
    }
    /* Hide decorative line under header for minimal print */
    header::after { display: none !important; }

    /* Table: compact, clear borders and readable lines */
    table { 
        border: 1px solid #000 !important; 
        table-layout: fixed !important;
        border-collapse: collapse !important;
        border-spacing: 0 !important;
        width: 100% !important;
        font-size: 12px !important; /* compact text */
        overflow: visible !important; /* allow multi-page flow; override screen overflow:hidden */
    }
    th, td { box-sizing: border-box !important; }
    thead th { border-bottom: 2px solid #000 !important; position: static !important; top: auto !important; }
    th, td { 
        border-bottom: 1px solid #000 !important; 
        padding: 6px 8px !important; /* tighter padding */
        line-height: 1.2 !important;
        white-space: normal !important;
        word-break: break-word !important;
    }
    /* Keep colgroup active so column widths remain consistent */
    #hour-table colgroup { display: table-column-group !important; }

    /* Tidy cumulative goal cell: remove original target parentheses in print */
    .original-cum { display: none !important; }
    /* Center all cells except the Hour column for print */
    thead th:not(:first-child), tbody td:not(:first-child) { text-align: center !important; }
    /* Hour text left-aligned for readability */
    #hour-table thead th:first-child,
    #hour-table tbody td:first-child { text-align: left !important; }
    .hour-goal, .cum-goal, .hour-label { text-align: center !important; }
    input.hour-units, textarea.notes { text-align: center !important; }
    /* Column widths via colgroup for reliable alignment */
    /* Daily plan table column widths (with Notes visible by default) */
    #hour-table col.col-hour { width: 20% !important; }
    #hour-table col.col-goal { width: 20% !important; }
    #hour-table col.col-cum  { width: 20% !important; }
    #hour-table col.col-units{ width: 15% !important; }
    #hour-table col.col-notes{ width: 25% !important; }

    /* Hide Notes column entirely in print for a cleaner sheet */
    #hour-table col.col-notes { display: none !important; }
    #hour-table thead th:nth-child(5),
    #hour-table tbody td:nth-child(5) { display: none !important; }
    /* Reallocate widths when Notes is hidden */
    #hour-table col.col-hour { width: 28% !important; }
    #hour-table col.col-goal { width: 24% !important; }
    #hour-table col.col-cum  { width: 24% !important; }
    #hour-table col.col-units{ width: 24% !important; }

    /* Team table column widths */
    #team-table col.col-hour { width: 40% !important; }
    #team-table col.col-goal { width: 30% !important; }
    #team-table col.col-each { width: 30% !important; }
    tbody tr:nth-child(even) { background: transparent !important; }

    /* Compact print mode: smaller text/padding and hide Notes column */
    html.compact-print table { font-size: 11px !important; }
    html.compact-print th, html.compact-print td { padding: 4px 6px !important; }
    html.compact-print col.col-notes { display: none !important; }
    html.compact-print thead th:nth-child(5),
    html.compact-print tbody td:nth-child(5) { display: none !important; }
    html.compact-print col.col-hour { width: 25% !important; }
    html.compact-print col.col-goal { width: 25% !important; }
    html.compact-print col.col-cum  { width: 25% !important; }
    html.compact-print col.col-units{ width: 25% !important; }

    /* Repeat header on each printed page */
    thead { display: table-header-group; }
    tfoot { display: table-footer-group; }
    tr { page-break-inside: avoid; }

    /* Hide badges/deltas/excess in print for a cleaner table */
    html .delta-positive,
    html .delta-negative,
    html .excess-large { display: none !important; }

    /* Inputs/Textareas: show values as plain text */
    input.hour-units,
    textarea.notes {
        border: none !important;
        padding: 0 !important;
        width: auto !important;
        min-width: 0 !important;
        height: auto !important;
        background: transparent !important;
        box-shadow: none !important;
        outline: none !important;
    }

    /* Hide placeholder hints (e.g., "Optional notes") in print */
    input::placeholder,
    textarea::placeholder { color: transparent !important; opacity: 0 !important; }
    /* Vendor-prefixed fallbacks */
    input::-webkit-input-placeholder,
    textarea::-webkit-input-placeholder { color: transparent !important; opacity: 0 !important; }
    input:-ms-input-placeholder,
    textarea:-ms-input-placeholder { color: transparent !important; }
    input::-ms-input-placeholder,
    textarea::-ms-input-placeholder { color: transparent !important; }
}

/* PDF export styles (apply to screen while generating PDF) */
html.export-pdf * {
    color: #000 !important;
    background: transparent !important;
    box-shadow: none !important;
    text-shadow: none !important;
    border-color: #000 !important;
    animation: none !important;
    transition: none !important;
}
/* Print whichever view is currently visible */
html.export-pdf #team-view[hidden] { display: none !important; }
html.export-pdf #daily-goal[hidden] { display: none !important; }
/* PDF export: ensure gradient title and underline render in solid black */
html.export-pdf .brand-gradient {
    background: none !important;
    -webkit-text-fill-color: #000 !important;
    color: #000 !important;
}
html.export-pdf header::after { background: #000 !important; }
/* Ensure animated rows are visible in export mode */
html.export-pdf .row-in { opacity: 1 !important; transform: none !important; animation: none !important; }
html.export-pdf .theme-toggle,
html.export-pdf .tabs,
html.export-pdf .quick-actions,
html.export-pdf .controls button,
html.export-pdf .controls input,
html.export-pdf .controls label,
html.export-pdf .spacer,
html.export-pdf footer { display: none !important; }
html.export-pdf header { margin-bottom: 8px; }
html.export-pdf table {
    border: 1px solid #000 !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    border-spacing: 0 !important;
    width: 100% !important;
    font-size: 12px !important;
    overflow: visible !important; /* prevent clipping in generated PDF */
}
html.export-pdf th, html.export-pdf td { box-sizing: border-box !important; }
html.export-pdf thead th { border-bottom: 2px solid #000 !important; }
html.export-pdf th, html.export-pdf td {
    border-bottom: 1px solid #000 !important;
    padding: 6px 8px !important;
    line-height: 1.2 !important;
    white-space: normal !important;
    word-break: break-word !important;
}
html.export-pdf thead th, html.export-pdf tbody td { text-align: center !important; }
html.export-pdf .hour-goal, html.export-pdf .cum-goal, html.export-pdf .hour-label { text-align: center !important; }
html.export-pdf input.hour-units, html.export-pdf textarea.notes { text-align: center !important; }
html.export-pdf col.col-hour { width: 20% !important; }
html.export-pdf col.col-goal { width: 20% !important; }
html.export-pdf col.col-cum  { width: 20% !important; }
html.export-pdf col.col-units{ width: 15% !important; }
html.export-pdf col.col-notes{ width: 25% !important; }
html.export-pdf tbody tr:nth-child(even) { background: transparent !important; }
html.export-pdf .delta-positive,
html.export-pdf .delta-negative,
html.export-pdf .excess-large { display: none !important; }
html.export-pdf input.hour-units,
html.export-pdf textarea.notes {
    border: none !important;
    padding: 0 !important;
    width: auto !important;
    min-width: 0 !important;
    height: auto !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
}
html.export-pdf input::placeholder,
html.export-pdf textarea::placeholder { color: transparent !important; opacity: 0 !important; }
