/* ============================================================
   Student Profile / Admission Details — minimal CSS overrides
   Applies the same clean design to BOTH pages:
     • Admin view (1st page) -> root .printheader        (student_details.rs)
     • Print preview page    -> root .printStudent_details (studentprint.rs)
   HTML / JS / backend / IDs / classes / print logic untouched.
   ============================================================ */

/* Poppins + light preview background */
.printheader,
.printStudent_details,
.printheader *,
.printStudent_details * {
    font-family: "Poppins", system-ui, sans-serif;
    box-sizing: border-box;
    color: #1e293b;
}
main:has(.printheader),
.print-document-body:has(.printStudent_details) {
    background: #f5f7fb;
}

/* The paper / card: subtle shadow + 6px radius, less whitespace */
.printheader,
.printStudent_details .print_stud > .row {
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.1);
    padding: 26px;
    --bs-gutter-x: 0;
}
.printheader {
    margin: 24px auto;
    max-width: 900px;
}
.details_section:has(.printheader) .container-fluid {
    max-width: 900px;
    margin-inline: auto;
}
.printStudent_details .details_section {
    margin: 0;
    padding: 0;
}
.printStudent_details .print_stud {
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
}
.printStudent_details .print_stud > .row {
    margin: 0;
}

/* Academic year + divider (admin page only) */
.printheader > h6.text-center {
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.82rem;
    font-weight: 600;
    color: #64748b;
    margin: 0 0 10px;
}
.printheader > hr.m-0 {
    border: 0 !important;
    border-top: 1px solid #e2e8f0 !important;
    margin: 0 0 16px !important;
}

/* Header: logo on the left, school name + address centred in the column
   beside it. The <table>/<tbody>/<tr> are flattened with display:contents so
   the two <td>s become flex items of the table (logo cell pulled left). */
.printheader > table:first-of-type,
.printStudent_details .print_stud > .row > table:first-of-type {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    border: 0 !important;
    margin: 0 0 14px !important;
}
.printheader > table:first-of-type tbody,
.printStudent_details .print_stud > .row > table:first-of-type tbody,
.printheader > table:first-of-type tr,
.printStudent_details .print_stud > .row > table:first-of-type tr {
    display: contents !important;
}
.printheader > table:first-of-type td,
.printStudent_details .print_stud > .row > table:first-of-type td {
    border: 0 !important;
    padding: 0 !important;
}
/* Logo cell on the left (it is 2nd in the DOM, so pull it to the front) */
.printheader > table:first-of-type td.col-md-1,
.printStudent_details .print_stud > .row > table:first-of-type td.col-md-1 {
    order: -1;
    flex: 0 0 auto;
    width: 72px !important;
    text-align: left !important;
}
.printheader > table:first-of-type td.col-8,
.printStudent_details .print_stud > .row > table:first-of-type td.col-8 {
    flex: 1 1 auto !important;
    width: auto !important;
    text-align: center !important;
}
.printheader > table:first-of-type h3.mx-green,
.printStudent_details .print_stud > .row > table:first-of-type h3.mx-green {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    letter-spacing: 0.02em;
}
.printheader > table:first-of-type img,
.printStudent_details .print_stud > .row > table:first-of-type img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    margin: 0;
}
/* Thin divider below header (print page has no <hr>) */
.printStudent_details .print_stud > .row > table:first-of-type {
    border-bottom: 1px solid #e2e8f0 !important;
}

/* School address line below the name */
.printheader .sp-school-address,
.printStudent_details .sp-school-address {
    font-size: 0.85rem;
    font-weight: 500;
    color: #64748b;
    text-align: center;
    margin: 2px 0 0;
}

/* Student details: tighter spacing, bold labels, aligned values */
.printheader .row:has(.stu_img_det),
.printStudent_details .row:has(.stu_img_det) {
    align-items: center;
    margin: 0 0 14px;
}
.printheader .stu_img_det,
.printStudent_details .stu_img_det {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    margin: 0 auto;
    display: block;
}
.printheader .row:has(.stu_img_det) .table,
.printStudent_details .row:has(.stu_img_det) .table {
    margin: 0;
}
.printheader .row:has(.stu_img_det) .table td,
.printStudent_details .row:has(.stu_img_det) .table td {
    border: 0;
    padding: 6px 4px;
    vertical-align: middle;
}
.printheader .row:has(.stu_img_det) .table td strong,
.printStudent_details .row:has(.stu_img_det) .table td strong {
    display: block;
    font-weight: 600;
    color: #64748b;
    font-size: 0.85rem;
}
.printheader .row:has(.stu_img_det) .table td:not(:first-child),
.printStudent_details .row:has(.stu_img_det) .table td:not(:first-child) {
    font-weight: 500;
    color: #1e293b;
}

/* Parent / address table: clean spacing, bold labels */
.printheader > table:nth-of-type(2),
.printStudent_details .print_stud > .row > table.table-bordered:nth-of-type(2) {
    border: 1px solid #e2e8f0 !important;
}
.printheader > table:nth-of-type(2) td,
.printStudent_details
    .print_stud
    > .row
    > table.table-bordered:nth-of-type(2)
    td {
    padding: 9px 12px;
    vertical-align: middle;
}
.printheader > table:nth-of-type(2) td strong,
.printStudent_details
    .print_stud
    > .row
    > table.table-bordered:nth-of-type(2)
    td
    strong {
    font-weight: 600;
    color: #64748b;
}

/* Section title */
.printheader h5,
.printStudent_details h5 {
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 10px;
}

/* Fee + discount tables: full width, branded header, zebra, balance highlight */
.printheader .mt-3,
.printStudent_details .mt-3 {
    margin-top: 14px !important;
}
.printheader .mt-3 .table,
.printStudent_details .mt-3 .table,
.printheader .table-responsive .table {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
    border-collapse: separate;
    border-spacing: 0;
}
.printheader .mt-3 .table thead th,
.printStudent_details .mt-3 .table thead th,
.printheader .table-responsive .table thead th {
    background: #4f46e5;
    color: #fff;
    border: 0;
    padding: 10px 12px;
    font-weight: 600;
    text-align: left;
}
.printheader .mt-3 .table tbody td,
.printStudent_details .mt-3 .table tbody td,
.printheader .table-responsive .table tbody td {
    border: 0;
    border-top: 1px solid #eef2f7;
    padding: 10px 12px;
}
.printheader .mt-3 .table tbody tr:nth-child(even),
.printStudent_details .mt-3 .table tbody tr:nth-child(even),
.printheader .table-responsive .table tbody tr:nth-child(even) {
    background: #f8fafc;
}
.printheader .mt-3 .table tbody tr.table-secondary,
.printStudent_details .mt-3 .table tbody tr.table-secondary {
    background: #eef2ff !important;
    font-weight: 700;
}
.printheader .mt-3 .table tbody tr.table-secondary td,
.printStudent_details .mt-3 .table tbody tr.table-secondary td {
    color: #4338ca;
}

/* Print: A4 portrait, large readable text, aligned */
@page studentProfile {
    size: A4 portrait;
    margin: 10mm;
}
/* Apply the named page to <body> (scoped) so the whole document uses it
   from page 1 — avoids a forced break that leaves the first page blank. */
body:has(.printheader),
body:has(.printStudent_details) {
    page: studentProfile;
}

@media print {
    /* Black body text; allow the branded header / zebra / balance to print */
    .printheader,
    .printStudent_details,
    .printheader *,
    .printStudent_details * {
        color: #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Sheet: fill the printable width, no chrome, no gutter offsets.
       Overrides print.css .print_stud { width:210mm } and the inline 842px. */
    .printheader,
    .printStudent_details .print_stud,
    .printStudent_details .print_stud > .row {
        box-shadow: none !important;
        border: 0 !important;
        border-radius: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        display: block !important;
    }
    .details_section:has(.printheader) .container-fluid,
    .printStudent_details .details_section {
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    /* Reset the theme .section_space_md (100px) padding on the admin section
       and print.css fixed mm widths on .print-container so nothing overflows. */
    .details_section:has(.printheader),
    .print-document-body:has(.printStudent_details),
    .print-container:has(.printStudent_details) {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* (Portrait = vertical stack. The 2-column grid for landscape lives in its
       own @media print and (orientation: landscape) block below.) */

    /* Header: logo on the left, school name + address centred beside it */
    .printheader > table:first-of-type,
    .printStudent_details .print_stud > .row > table:first-of-type {
        display: flex !important;
        align-items: center !important;
        width: 100% !important;
        margin: 0 0 8px !important;
        border: 0 !important;
    }
    .printheader > table:first-of-type td.col-md-1,
    .printStudent_details .print_stud > .row > table:first-of-type td.col-md-1 {
        order: -1;
        flex: 0 0 auto;
        width: 60px !important;
        text-align: left !important;
    }
    .printheader > table:first-of-type img,
    .printStudent_details .print_stud > .row > table:first-of-type img {
        width: 50px !important;
        height: 50px !important;
        margin: 0 !important;
    }
    .printheader > table:first-of-type h3.mx-green,
    .printStudent_details .print_stud > .row > table:first-of-type h3.mx-green {
        margin: 0 !important;
        font-size: 22pt !important;
        line-height: 1.25 !important;
    }
    /* School address line below the name (print) */
    .printheader .sp-school-address,
    .printStudent_details .sp-school-address {
        font-size: 12pt !important;
        text-align: center !important;
        margin: 2px 0 0 !important;
    }
    .printheader > hr.m-0 {
        border: 0 !important;
        border-top: 1px solid #000 !important;
        margin: 0 0 8px !important;
    }
    .printStudent_details .print_stud > .row > table:first-of-type {
        border-bottom: 1px solid #000 !important;
    }

    /* Student photo + details: photo fixed top-left, details beside it, large text */
    .printheader .row:has(.stu_img_det),
    .printStudent_details .row:has(.stu_img_det) {
        align-items: flex-start !important;
        margin: 0 !important;
    }
    .printheader .row:has(.stu_img_det) > *,
    .printStudent_details .row:has(.stu_img_det) > * {
        padding: 0 !important;
    }
    .printheader .row:has(.stu_img_det) > *:first-child,
    .printStudent_details .row:has(.stu_img_det) > *:first-child {
        flex: 0 0 auto;
        width: 160px !important;
    }
    .printheader .row:has(.stu_img_det) > *:last-child,
    .printStudent_details .row:has(.stu_img_det) > *:last-child {
        flex: 1 1 auto !important;
        width: auto !important;
    }
    .printheader .stu_img_det,
    .printStudent_details .stu_img_det {
        width: 150px !important;
        height: 150px !important;
        margin: 0 !important;
        border: 1px solid #000 !important;
        border-radius: 0 !important;
        object-fit: cover !important;
    }
    .printheader .row:has(.stu_img_det) .table,
    .printStudent_details .row:has(.stu_img_det) .table {
        width: 100% !important;
        margin: 0 !important;
    }
    .printheader .row:has(.stu_img_det) .table td,
    .printStudent_details .row:has(.stu_img_det) .table td {
        padding: 4px 8px !important;
        border: 0 !important;
        font-size: 15pt !important;
        line-height: 1.3 !important;
    }
    .printheader .row:has(.stu_img_det) .table td strong,
    .printStudent_details .row:has(.stu_img_det) .table td strong {
        font-size: 14pt !important;
    }

    /* Parent / address + fee + discount tables: full width, collapsed black borders */
    .printheader > table:nth-of-type(2),
    .printStudent_details
        .print_stud
        > .row
        > table.table-bordered:nth-of-type(2),
    .printheader .mt-3 .table,
    .printStudent_details .mt-3 .table,
    .printheader .table-responsive .table {
        width: 100% !important;
        border-collapse: collapse !important;
        border-spacing: 0 !important;
        border: 1px solid #000 !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }
    .printheader > table:nth-of-type(2) td,
    .printStudent_details
        .print_stud
        > .row
        > table.table-bordered:nth-of-type(2)
        td,
    .printheader .mt-3 .table tbody td,
    .printStudent_details .mt-3 .table tbody td,
    .printheader .table-responsive .table tbody td {
        border: 1px solid #000 !important;
        padding: 6px 10px !important;
        font-size: 15pt !important;
        line-height: 1.3 !important;
    }
    /* Fee header bar: brand indigo, sticky off (sticky breaks print) */
    .printheader .mt-3 .table thead th,
    .printStudent_details .mt-3 .table thead th,
    .printheader .table-responsive .table thead th {
        position: static !important;
        background: #4f46e5 !important;
        color: #fff !important;
        border: 1px solid #000 !important;
        padding: 6px 10px !important;
        font-size: 14pt !important;
        text-align: left !important;
    }
    /* Zebra + Balance Fee highlight */
    .printheader .mt-3 .table tbody tr:nth-child(even),
    .printStudent_details .mt-3 .table tbody tr:nth-child(even),
    .printheader .table-responsive .table tbody tr:nth-child(even) {
        background: #f8fafc !important;
    }
    /* Section titles + spacing */
    .printheader h5,
    .printStudent_details h5 {
        margin: 8px 0 4px !important;
        font-size: 16pt !important;
        line-height: 1.25 !important;
    }
    .printheader .mt-3,
    .printStudent_details .mt-3 {
        margin-top: 8px !important;
    }

    /* Hide buttons / interactive controls */
    .printheader .stuprint,
    .printheader .btn_primary,
    .printheader a.btn_primary,
    .printheader button.btn_primary,
    .printheader .d-flex.flex-wrap.justify-content-center,
    .printStudent_details .print-no-print,
    .printStudent_details .btn_primary,
    .printStudent_details a.btn_primary,
    .printStudent_details button.btn_primary {
        display: none !important;
    }

    /* Keep each block together to fit one page */
    .printheader .row:has(.stu_img_det),
    .printheader .mt-3,
    .printStudent_details .row:has(.stu_img_det),
    .printStudent_details .mt-3 {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }
}
