/* Print Stylesheet - Optimized for clean multi-page printing */
@media print {
    /* Page setup */
    @page {
        size: letter;
        margin: 0.5in 0.5in 0.6in 0.5in;
    }

    /* Reset for print */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    /* Hide non-printable elements */
    .return-to-top,
    .header-download-btn {
        display: none !important;
    }

    /* Body and HTML reset */
    html, body {
        margin: 0;
        padding: 0;
        font-size: 9.5pt;
        line-height: 1.3;
        background: white !important;
    }

    /* Main container */
    .container {
        max-width: 100%;
        margin: 0;
        padding: 0;
        box-shadow: none;
    }

    /* Header section */
    .header {
        padding: 10px 15px;
        margin-bottom: 10px;
        page-break-inside: avoid;
        page-break-after: avoid;
    }

    .profile-photo {
        width: 60px;
        height: 60px;
    }

    .name {
        font-size: 18pt;
        margin-bottom: 2px;
    }

    .title {
        font-size: 10pt;
    }

    .contact-bar {
        font-size: 9pt;
        gap: 15px;
    }

    /* Two-column layout for print */
    .content-grid {
        display: grid;
        grid-template-columns: 1fr 2.2in;
        gap: 20px;
    }

    /* Main column (jobs) */
    .main-column {
        padding-right: 10px;
    }

    /* Side column (skills/education) */
    .side-column {
        padding-left: 10px;
        border-left: 1px solid #ddd;
    }

    /* Section titles - keep with content */
    .section-title {
        font-size: 11pt;
        margin-top: 10px;
        margin-bottom: 6px;
        padding-bottom: 3px;
        page-break-after: avoid;
        border-bottom: 1.5px solid #3498db;
    }

    .employment-header {
        font-size: 12pt;
        margin-top: 12px;
        margin-bottom: 8px;
        page-break-after: avoid;
    }

    /* Profile section */
    .section.profile {
        margin-bottom: 10px;
    }

    .profile-text {
        font-size: 9pt;
        line-height: 1.35;
        text-align: justify;
    }

    /* Job entries - ALLOW breaks inside long entries */
    .section.position-card {
        margin-bottom: 12px;
        padding-bottom: 8px;
        border-bottom: 0.5px solid #e1e4e8;
        /* Allow page breaks inside long job entries */
        page-break-inside: auto;
    }

    .section.position-card:last-of-type {
        border-bottom: none;
    }

    /* Job header - keep together and with some content */
    .position-header {
        page-break-inside: avoid;
        page-break-after: avoid;
    }

    .position-title {
        font-size: 10pt;
        font-weight: 600;
        margin-bottom: 2px;
        line-height: 1.3;
    }

    .dates {
        font-size: 8pt;
        color: #5a6c7d !important;
    }

    .position-description {
        font-size: 9pt;
        line-height: 1.3;
        margin-bottom: 6px;
        text-align: justify;
    }

    /* Achievement bullets - avoid breaking individual items */
    .achievements {
        padding-left: 15px;
        margin-top: 5px;
        margin-bottom: 5px;
    }

    .achievements li {
        font-size: 9pt;
        line-height: 1.25;
        margin-bottom: 3px;
        page-break-inside: avoid;
    }

    /* Subheadings within jobs (AI Technical Skills, etc.) */
    .section.position-card h4 {
        font-size: 9.5pt;
        page-break-after: avoid;
        margin-top: 8px !important;
        margin-bottom: 5px !important;
    }

    /* Keep skill category headers with their lists */
    .section.position-card p[style*="font-weight: 600"] {
        page-break-after: avoid;
    }

    /* Skills section */
    .section.skills {
        page-break-inside: avoid;
    }

    .skills-list {
        font-size: 8.5pt;
        padding-left: 12px;
    }

    .skills-list li {
        margin-bottom: 2px;
    }

    /* Education section */
    .section.education {
        page-break-inside: avoid;
    }

    .degree {
        font-size: 9pt;
        margin-bottom: 1px;
    }

    .degree-field {
        font-size: 8.5pt;
    }

    .university {
        font-size: 8.5pt;
    }

    /* Awards section */
    .section.awards {
        page-break-inside: avoid;
    }

    .award-item {
        margin-bottom: 5px;
    }

    .award-title {
        font-size: 9pt;
        margin-bottom: 1px;
    }

    .award-date {
        font-size: 8pt;
    }

    .award-detail {
        font-size: 8pt;
    }

    /* Currently Building section */
    .section.currently-building {
        page-break-inside: avoid;
    }

    .building-list li {
        font-size: 8.5pt;
        padding: 3px 0 !important;
    }

    /* Additional experience */
    .section.additional {
        margin-top: 10px;
    }

    .additional-grid {
        gap: 4px;
    }

    .additional-item {
        padding-bottom: 3px;
        page-break-inside: avoid;
    }

    .additional-role {
        font-size: 8.5pt;
    }

    .additional-company {
        font-size: 8pt;
    }

    /* Orphan/widow control */
    p {
        orphans: 2;
        widows: 2;
    }

    /* Ensure headers stay with following content */
    h2, h3, h4 {
        page-break-after: avoid;
    }

    /* Links - print without underline */
    a {
        color: #2c3e50 !important;
        text-decoration: none;
    }
}
