/* ==========================================================================
   Job Card PDF Styles
   Styles specific to PDF export and preview
   ========================================================================== */

/* ==========================================================================
   1. Base Styles
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    text-indent: 0;
}

body {
    font-family: "Helvetica Neue", sans-serif;
}

/* ==========================================================================
   2. Container Styles
   ========================================================================== */
.job-details-view {
    width: 100% !important;
    height: 100vh;
    overflow: auto;
    background: var(--color-background);
    padding: var(--space-24) 0px;
    display: flex;
    justify-content: center;
}

/* PDF Preview Container */
.pdf-preview-container {
    width: 210mm; /* A4 width */
    margin: 21px auto;
    transform-origin: top center;
    background: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    position: relative;
    transition: none;
}

/* Print container for proper scaling */
.print-container {
    width: 100%;
    height: 100%;
    position: relative;
    transition: none;
}

.job-card-pdf_container {
    width: 210mm;
    min-height: 297mm;
    padding: 0mm;
    margin: 0 auto 27px auto;
    page-break-after: always;
    background: #fff;
    transform-origin: top center;
    position: relative;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #ddd;
}

/* Scale container based on viewport width */
@media screen and (max-width: 1200px) {
    .pdf-preview-container {
        transform: scale(var(--pdf-scale, 1));
        margin-bottom: calc((var(--pdf-scale, 1) - 1) * -297mm); /* Adjust for scale */
    }
}

/* ==========================================================================
   3. Grid Layout
   ========================================================================== */
.split_120-75 {
    display: grid;
    grid-template-columns: 120mm 75mm;
    gap: 5mm;
    padding: 5mm 5mm 0mm 5mm;
}

.split_120 {
    max-width: 120mm;
}

.split_75 {
    max-width: 75mm;
}

.split_50-50 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5mm;
    padding: 5mm 5mm 0mm 5mm;
    width: 100%;
    box-sizing: border-box;
}

.split_50 {
    width: 100%;
    box-sizing: border-box;
}

/* ==========================================================================
   4. Typography
   ========================================================================== */

p {
    font-style: normal;
    font-weight: bold;
    text-decoration: none;
    font-size: 10pt;
    margin: 0;
    line-height: normal;
}

.s1 {
    color: #EE220C;
    font-style: normal;
    font-weight: bold;
    text-decoration: none;
    font-size: 42pt;
    padding: 0pt;
    margin: 7pt 4pt;
    line-height: 33pt;
}

.s2 {
    color: #000000;
    font-style: normal;
    font-weight: bold;
    text-transform: uppercase;
    text-decoration: none;
    font-size: 7.2pt;
    padding: 2pt 4pt;
    text-indent: 0pt;
    letter-spacing: 0.02rem;
}

.s3 {
    color: #000000;
    font-style: normal;
    font-weight: normal;
    text-decoration: none;
    font-size: 9pt;
    padding: 2pt 4pt;
    text-indent: 0pt;
}

/* ==========================================================================
   5. Table Styles
   ========================================================================== */
table {
    border-collapse: collapse;
}

table, tbody {
    vertical-align: top;
    overflow: visible;
}

td {
    padding: 0;
    vertical-align: top;
    border: 1px solid #999999;
}

.td-label-cell {
    background-color: #ffffff;
}

.td-33 {
    width: 33mm !important;
}

.td-44 {
    width: 44mm !important;
    text-align: right;
}

.td-cutlist-ref {
    padding: 0;
    vertical-align: top;
    width: 20pt;
    text-align: center;
}

.td-cutlist-dims-qty {
    padding: 0;
    vertical-align: top;
    width: 42pt;
    text-align: right;
}

.PDF-panel-name {
    padding: 0;
    vertical-align: top;
    width: 114pt;
    text-align: left;
}

.job-info-cells {
    width: 237pt;
}

tr {
    height: 5mm;
}

/* ==========================================================================
   6. Section Styles
   ========================================================================== */

   .textbox {
    border: 1px solid #999999;
    display: block;
    width: 120mm;
    height: calc(100% - 2px);
    padding: 0pt;
    margin: 0pt;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.job-id-main {
    font-style: normal;
    font-weight: bold;
    text-decoration: none;
    font-size: 42pt;
    color: #EE220C;
    padding: 7pt 4pt;
    line-height: 33pt;
}

.page-number {
    font-weight: normal;
    font-size: 10pt;
    color: #666;
    padding: 9pt;
    align-self: flex-start;
}

.section-title {
    color: black;
    font-style: normal;
    font-weight: bold;
    text-decoration: none;
    font-size: 12pt;
    margin: 0;
    text-transform: uppercase;
    padding-bottom: 6pt;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-title-main {
    font-weight: bold;
    font-size: 12pt;
    text-transform: uppercase;
}

.section-title-sheet {
    font-weight: normal;
    font-size: 10pt;
    text-transform: none;
    color: #666;
}

.layout-cell {
    width: 102mm;
    height: 200mm;
}

/* ==========================================================================
   6.1. PDF Layout Visualization Styles
   ========================================================================== */

.layout-visualization-container {
    width: 102mm;
    height: 222mm;
    padding: 2px;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
}

.layout-visualization-container-50 {
    width: 97.5mm;
    height: 222mm;
    padding: 2px;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
}

.pdf-layout-container {
    position: relative;
    box-sizing: border-box;
    /* Use outline instead of border to avoid affecting internal dimensions */
    outline: 1pt dashed #666666;
    outline-offset: 0pt;
}

.pdf-base-material {
    position: absolute;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 100%;
}

/* Material Pattern Styles for PDF */
.pdf-base-material.material-pattern--horizontal {
    background-image: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2mm,
        rgba(0,0,0,0.1) 2mm,
        rgba(0,0,0,0.1) 2.2mm
    );
}

.pdf-base-material.material-pattern--vertical {
    background-image: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 2mm,
        rgba(0,0,0,0.1) 2mm,
        rgba(0,0,0,0.1) 2.2mm
    );
}

.pdf-base-material.material-pattern--diagonal {
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 3mm,
        rgba(0,0,0,0.1) 3mm,
        rgba(0,0,0,0.1) 3.2mm
    );
}

.pdf-panel {
    position: absolute;
    top: 0px;
    left: 0px;
    background: rgba(255, 255, 255, 0);
    /* Use inset box-shadow for border effect that overlaps nicely */
    box-shadow: inset 0 0 0 0.25pt #000000, 0 0 0 0.25pt #000000;
    box-sizing: border-box;
}


.pdf-panel-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #333;
    width: 90%;
}

.pdf-panel-name {
    font-size: 8pt;
    font-weight: 600;
    margin-bottom: 0pt;
    white-space: nowrap;
}

.pdf-panel-letter {
    font-size: 7pt;
    font-weight: 600;
}

.pdf-panel-instance {
    font-weight: 400;
    font-size: 6pt !important;
}


.pdf-layout-info {
    position: absolute;
    bottom: 1mm;
    right: 1mm;
    font-size: 6pt;
    color: #666;
    background: rgba(255,255,255,0.8);
    padding: 0.5mm 1mm;
    border-radius: 1mm;
}

/* Empty/Error states */
.layout-empty,
.layout-error {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #c44;
    font-size: 12pt;
    text-align: center;
    font-style: italic;
}

.layout-error {
    color: #c44;
}

/* ==========================================================================
   7. Print Styles
   ========================================================================== */
@media print {
    @page {
        size: A4;
        margin: 0;
    }

    body {
        margin: 0;
        padding: 0;
        background: white;
    }

    .job-details-view {
        padding: 0;
        background: white;
    }

    .pdf-preview-container {
        width: 210mm;
        transform: none;
        margin: 0;
        box-shadow: none;
    }

    .job-card-pdf_container {
        width: 210mm;
        min-height: 297mm;
        padding: 0mm;
        margin: 0;
        page-break-after: always;
        box-shadow: none;
        border: none;
    }

    /* Ensure proper page breaks */
    table, tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    /* Hide UI elements */
    .button--small,
    .edit-button,
    .export-buttons {
        display: none !important;
    }
}

/* ==========================================================================
   8. Error State
   ========================================================================== */
.job-details-view.error {
    position: relative;
}

.error-message {
    padding: var(--space-18);
    margin: var(--space-12);
    border: 1px solid var(--color-accent-02);
    border-radius: 4px;
    background: rgba(var(--color-accent-02-rgb), 0.1);
    color: var(--color-accent-02);
    text-align: center;
}

.error-message button {
    background: none;
    border: 1px solid var(--color-accent-02);
    color: var(--color-accent-02);
    padding: var(--space-6) var(--space-12);
    margin-top: var(--space-12);
    cursor: pointer;
    transition: all 0.2s ease;
}

.error-message button:hover {
    background: var(--color-accent-02);
    color: var(--color-background);
}
