/* ============================================
   MIRACLE Tank Cleaning Plan
   Print & Screen Styles

   Structure:
   1. CSS Variables
   2. Screen-Only Styles
   3. Print Styles (@media print)
   ============================================ */

/* ============================================
   1. CSS VARIABLES
   ============================================ */
:root {
    /* MIRACLE Brand Colors */
    --miracle-primary: #39585E;
    --miracle-light: #D3E0E1;

    /* Neutral Colors */
    --color-text: #333;
    --color-text-muted: #666;
    --color-text-light: #999;
    --color-border: #ddd;
    --color-border-light: #e0e0e0;
    --color-bg-light: #f8f9fa;
    --color-bg-lighter: #fafafa;

    /* Status Colors */
    --color-warning-bg: #fff3cd;
    --color-warning-border: #ffc107;
    --color-danger-bg: #f8d7da;
    --color-danger-border: #dc3545;
    --color-info-bg: #e3f2fd;
}


/* ============================================
   2. SCREEN-ONLY STYLES
   ============================================ */

/* --- Header (hidden on screen, shown in print) --- */
.print-header {
    display: none;
}

/* --- Footer (visible on screen and print) --- */
.print-footer {
    display: block;
    margin: 30px 0 15px 0;
    padding: 15px 0 0 0;
    text-align: center;
    border-top: 1px solid var(--color-border);
}

.print-footer-line {
    display: none;
}

.print-footer-content {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 5px;
}

.print-footer-copyright {
    font-weight: 600;
    color: var(--color-text);
}

.print-footer-separator {
    color: var(--miracle-primary);
    margin: 0 6px;
}

.print-footer-product {
    font-style: italic;
}

.print-footer-website {
    font-size: 11px;
    color: var(--miracle-primary);
    margin-bottom: 5px;
}

.print-footer-disclaimer {
    font-size: 10px;
    color: var(--color-text-light);
    margin-top: 3px;
}

/* --- Physical Properties Tables (Screen) --- */
.second-physical-properties-table {
    display: inline-table;
    float: left;
    width: 46%;
    margin-right: 4%;
    margin-bottom: 10px;
    border-collapse: collapse;
}

.second-physical-properties-table:last-of-type {
    margin-right: 0;
}

.second-physical-properties-table td {
    padding: 6px 8px;
    font-size: 14px;
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: middle;
}

.second-physical-properties-table tr:hover {
    background-color: var(--color-bg-light);
}

.second-physical-properties-table td:first-child {
    width: 50%;
    color: var(--color-text-muted);
    padding-right: 15px;
}

.second-physical-properties-table td:nth-child(2) {
    width: 30%;
    font-weight: 600;
    padding-right: 5px;
}

.second-physical-properties-table td:nth-child(3) {
    color: var(--color-text-muted);
    font-size: 13px;
    padding-left: 0;
    white-space: nowrap;
}

.second-physical-properties-table-right td:nth-child(4) {
    width: 30%;
    border-bottom: none;
}

/* --- Page Break (hidden on screen) --- */
.page-break {
    display: none;
}


/* ============================================
   3. PRINT STYLES
   ============================================ */

/* @page margins - minimal for maximum content width */
@page {
    size: A4;
    margin: 10mm 8mm 12mm 8mm;
}

@media print {

    /* -----------------------------------------
       3.1 Base & Reset
       ----------------------------------------- */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    html, body {
        width: 100%;
        height: auto;
        margin: 0;
        padding: 0;
        font-family: 'Segoe UI', Arial, Helvetica, sans-serif;
        font-size: 10pt;
        line-height: 1.4;
        color: var(--color-text);
        background: white !important;
    }

    /* -----------------------------------------
       3.2 Hidden Elements
       ----------------------------------------- */
    .no-print,
    .btn-add-note,
    .recipe-button,
    .triggerlink,
    .info-link,
    .edit-link,
    .note-actions,
    .privateCleaningButton,
    .cleaner-accordion button,
    .cleaner-arrow,
    .badge-custom,
    #tipsDisplayText,
    #tipsDisplayCheckbox,
    #cleaning-seminar-link,
    #section-header,
    #calculatorWithViewModel,
    table.cleanerPreviewTable[data-cleaner-id],
    .zsiq_floatmain,
    .zsiq_theme1,
    .siq_bR,
    nav, header, .navbar, .sidebar, .menu, .breadcrumb,
    footer:not(.print-footer),
    input[type="button"],
    input[type="submit"],
    button:not(.print-visible),
    .card-header,
    .download-separator,
    .module-separator,
    .knowledge-separator {
        display: none !important;
    }

    /* -----------------------------------------
       3.3 Layout
       ----------------------------------------- */
    .mainContent,
    #MainContentPanel {
        position: static !important;
        margin: 0 !important;
        width: 100% !important;
    }

    #TankCleaningPlanView {
        margin: 0;
    }

    /* -----------------------------------------
       3.4 Page Breaks
       ----------------------------------------- */
    .page-break {
        display: block;
        page-break-before: always;
    }

    /* Keep sections together when possible, but allow break if needed for large sections */
    .doNotDivideContent {
        page-break-inside: avoid;
    }

    .partialContainer,
    .cleaner-panel,
    .ppeCheckboxDiv,
    .ppeCheckboxContainer {
        page-break-inside: avoid;
    }

    /* Footer should always stay together and appear at end */
    .print-footer {
        page-break-inside: avoid;
        page-break-before: auto;
    }

    /* Signature block should stay on same page as Notes if possible */
    .MoreSpaceAtTheTop {
        page-break-inside: avoid;
    }

    h1, h2, h3, h3.category-header {
        page-break-after: avoid;
    }

    table { page-break-inside: auto; }
    tr { page-break-inside: avoid; page-break-after: auto; }
    thead { display: table-header-group; }
    tfoot { display: table-footer-group; }

    /* Recipe tables can break if very long */
    .recipe-table {
        page-break-inside: auto;
    }

    /* Category sections - try to keep header with content */
    .category-header + * {
        page-break-before: avoid;
    }

    /* -----------------------------------------
       3.5 Header
       ----------------------------------------- */
    .print-header {
        display: block;
        text-align: left;
        margin: 0 0 25px 0;
        padding: 10px 0;
    }

    .print-logo {
        max-width: 220px;
        height: auto;
        margin-bottom: 5px;
    }

    .print-header-subtitle {
        font-size: 9pt;
        color: var(--miracle-primary);
        font-style: italic;
        letter-spacing: 0.5px;
    }

    /* -----------------------------------------
       3.6 Typography
       ----------------------------------------- */
    h1 {
        font-size: 18pt;
        font-weight: 600;
        color: #1a237e;
        margin: 0 0 10px 0;
    }

    h2 {
        font-size: 14pt;
        font-weight: 600;
        color: var(--miracle-primary);
        margin: 15px 0 8px 0;
    }

    h3 {
        font-size: 12pt;
        font-weight: 600;
        color: var(--color-text);
        margin: 12px 0 6px 0;
    }

    h3.category-header {
        font-size: 13pt;
        color: var(--miracle-primary);
        background-color: transparent !important;
        border-bottom: 1px solid var(--miracle-primary);
        padding-bottom: 5px;
        margin: 20px 0 10px 0;
    }

    h3.category-header img.category-header-icon {
        width: 20px;
        height: 20px;
        margin-right: 8px;
        vertical-align: middle;
    }

    p {
        margin: 0 0 8px 0;
        orphans: 3;
        widows: 3;
    }

    a {
        color: var(--color-text) !important;
        text-decoration: none !important;
    }

    /* -----------------------------------------
       3.7 Tables (General)
       ----------------------------------------- */
    table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 15px;
        font-size: 9pt;
    }

    th, td {
        padding: 6px 8px;
        text-align: left;
        vertical-align: top;
        border: 1px solid var(--color-border);
    }

    th {
        background-color: #f5f5f5 !important;
        font-weight: 600;
        color: var(--color-text);
    }

    tbody tr:nth-child(even) {
        background-color: var(--color-bg-lighter) !important;
    }

    .table-responsive {
        overflow: visible !important;
    }

    /* -----------------------------------------
       3.8 Recipe Styles
       ----------------------------------------- */
    .recipe-container {
        margin-bottom: 25px;
        border: none;
        box-shadow: none;
        page-break-inside: avoid;
    }

    .recipe-header {
        background-color: transparent !important;
        padding: 0 0 8px 0;
        border-bottom: 2px solid var(--miracle-primary);
        margin-bottom: 12px;
    }

    .recipe-title {
        font-size: 12pt;
        font-weight: 600;
        color: var(--miracle-primary);
        margin: 0;
    }

    .recipe-title strong {
        margin-right: 10px;
    }

    .recipe-body {
        padding: 0;
    }

    /* Recipe Status Banner */
    .recipe-status-banner {
        padding: 10px;
        margin-bottom: 10px;
        background-color: var(--color-warning-bg) !important;
        border-left: 4px solid var(--color-warning-border);
    }

    .recipe-status-banner.danger {
        background-color: var(--color-danger-bg) !important;
        border-left-color: var(--color-danger-border);
    }

    .recipe-status-banner h3 {
        font-size: 10pt;
        margin: 0 0 5px 0;
        color: #856404;
    }

    .recipe-status-banner.danger h3 {
        color: #721c24;
    }

    /* Recipe Table */
    .recipe-table {
        width: 100%;
        border-collapse: collapse;
        margin-top: 8px;
    }

    .recipe-table th {
        background-color: transparent !important;
        color: var(--color-text) !important;
        font-size: 9pt;
        font-weight: 600;
        padding: 8px 6px;
        border: none;
        border-bottom: 2px solid var(--color-text);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .recipe-table td {
        font-size: 9pt;
        padding: 6px;
        border: none;
        border-bottom: 1px solid var(--color-border-light);
    }

    .recipe-table tbody tr:nth-child(even) {
        background-color: var(--color-bg-lighter) !important;
    }

    .recipe-table tbody tr:last-child td {
        border-bottom: none;
    }

    /* -----------------------------------------
       3.9 Cleaner Information
       ----------------------------------------- */
    .cleaner-accordion {
        margin-top: 15px;
    }

    .cleaner-accordion > div {
        display: block !important;
    }

    .cleaner-accordion > div[data-bind*="invisible"] {
        display: none !important;
    }

    .cleaner-accordion > div[data-bind*="visible:"] {
        display: block !important;
    }

    .cleaner-panel {
        display: block !important;
        border: none;
        border-top: 1px solid var(--color-border);
        margin-bottom: 10px;
        padding-top: 10px;
    }

    .cleaner-panel-heading {
        background-color: transparent !important;
        padding: 0 0 5px 0;
        font-weight: 600;
        font-size: 10pt;
        color: var(--miracle-primary);
    }

    .cleaner-panel-heading::before {
        content: "Cleaner Information";
    }

    .cleaner-panel-body {
        display: block !important;
        padding: 8px 0;
    }

    .cleanerDetailRowTemplate {
        display: flex;
        flex-wrap: wrap;
        margin: 0 -8px;
    }

    .cleaner-part {
        width: 33.33%;
        padding: 8px;
        box-sizing: border-box;
    }

    .cleaner-full-width {
        width: 100%;
        padding: 8px;
    }

    .cleaner-part label {
        font-weight: 600;
        font-size: 8pt;
        color: var(--color-text-muted);
        display: block;
        margin-bottom: 2px;
    }

    .cleaner-part span,
    .cleaner-part div {
        font-size: 9pt;
    }

    .cleanerPreviewTable {
        width: 100%;
        border-collapse: collapse;
        font-size: 9pt;
    }

    .cleanerPreviewTable th {
        background-color: #f5f5f5 !important;
        font-weight: 600;
        padding: 6px 8px;
        text-align: left;
        border: 1px solid var(--color-border);
    }

    .cleanerPreviewTable td {
        padding: 5px 8px;
        border: 1px solid var(--color-border);
    }

    /* -----------------------------------------
       3.10 Notes Table
       ----------------------------------------- */
    .card {
        border: none;
        box-shadow: none;
        margin-bottom: 15px;
        width: 100%;
    }

    .card-body {
        padding: 0;
    }

    .card .table,
    .card .table-striped,
    .card .table-bordered,
    .card .table-hover {
        width: 100%;
        border: 1px solid var(--color-border);
        margin-bottom: 15px;
        table-layout: fixed;
    }

    .card .table thead {
        background-color: transparent !important;
    }

    .card .table thead th,
    .card .table .table-dark th {
        background-color: transparent !important;
        color: var(--color-text) !important;
        font-weight: 600;
        font-size: 9pt;
        padding: 8px 10px;
        border: none;
        border-bottom: 2px solid var(--color-text);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    /* Column widths for Notes table */
    .card .table thead th:first-child { width: 25%; }
    .card .table thead th:nth-child(2) { width: 55%; }
    .card .table thead th:nth-child(3) { width: 20%; }

    /* Hide Edit column */
    .card .table thead th:last-child,
    .card .table tbody td:last-child {
        display: none;
    }

    .card .table tbody td {
        padding: 8px 10px;
        font-size: 9pt;
        border: none;
        border-bottom: 1px solid var(--color-border);
        vertical-align: top;
    }

    .card .table tbody tr:nth-child(odd) {
        background-color: white !important;
    }

    .card .table tbody tr:nth-child(even) {
        background-color: var(--color-bg-light) !important;
    }

    /* Warning notes - subtle left border instead of full yellow background */
    .card .table tbody tr.table-warning {
        background-color: white !important;
        border-left: 4px solid var(--color-warning-border);
    }

    .card .table tbody tr.table-warning td:first-child {
        padding-left: 8px;
    }

    .card .table tbody tr.global-note {
        background-color: #f9f9f9 !important;
        border-left: 3px solid var(--color-text-muted);
    }

    /* Note Title - clean styling without box */
    .note-title-cell {
        min-width: 100px;
        display: table-cell !important;
        cursor: default !important;
    }

    .note-title-row {
        display: inline !important;
        background: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        cursor: default !important;
    }

    .note-title-row strong {
        font-weight: 600;
    }

    /* Warning/Important icons inline */
    .note-title-row i.fa-exclamation-triangle,
    .note-title-row i.fa-exclamation-circle {
        font-size: 10pt;
        margin-left: 6px;
        vertical-align: middle;
    }

    /* Hide custom badge in print */
    .badge-custom {
        display: none !important;
    }

    .badge-info {
        background-color: #f5f5f5 !important;
        color: var(--color-text) !important;
        font-size: 8pt;
        padding: 2px 5px;
        border-radius: 2px;
        margin-left: 5px;
        border: 1px solid var(--color-border);
    }

    /* Note Content */
    .note-content {
        max-width: none;
    }

    .note-content p {
        margin: 0;
        display: inline;
    }

    .attachment-info {
        margin-top: 8px;
        padding: 5px 8px;
        background-color: #f5f5f5 !important;
        border: 1px solid var(--color-border);
        font-size: 8pt;
    }

    /* Note Sections (Download, Module, Knowledge Base) */
    .download-section,
    .module-section,
    .knowledge-base-section {
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px dashed #ccc;
    }

    .download-content,
    .module-content,
    .knowledge-content {
        font-size: 8pt;
    }

    .download-badge,
    .module-badge,
    .knowledge-badge {
        background-color: #f5f5f5 !important;
        color: var(--color-text) !important;
        padding: 2px 6px;
        border-radius: 2px;
        font-size: 8pt;
        font-weight: 600;
        margin-right: 5px;
        border: 1px solid var(--color-border);
    }

    .download-text,
    .module-text,
    .knowledge-text {
        color: var(--color-text);
    }

    .download-link,
    .module-link,
    .knowledge-link {
        color: var(--miracle-primary) !important;
        font-size: 8pt;
    }

    /* Category Badges - elegant & subtle */
    .badge-general,
    .badge-cleaning,
    .badge-cargo,
    .badge-handling,
    .badge-safety,
    .badge-coating {
        background-color: transparent !important;
        color: var(--color-text-muted) !important;
        padding: 3px 8px;
        border-radius: 2px;
        font-size: 8pt;
        font-weight: 500;
        display: inline-flex;
        align-items: center;
        border: 1px solid var(--color-border);
    }

    .badge-general i,
    .badge-cleaning i,
    .badge-cargo i,
    .badge-handling i,
    .badge-safety i,
    .badge-coating i {
        margin-right: 4px;
        font-size: 8pt;
    }

    /* -----------------------------------------
       3.11 Physical Properties (Print Overrides)
       ----------------------------------------- */
    .second-physical-properties-table {
        border: 1px solid var(--color-border);
    }

    .second-physical-properties-table td {
        padding: 4px 6px;
        font-size: 9pt;
        border-bottom: 1px solid var(--color-border-light);
    }

    /* Ensure last row also has border */
    .second-physical-properties-table tr:last-child td {
        border-bottom: 1px solid var(--color-border);
    }

    .second-physical-properties-table td:nth-child(3) {
        font-size: 9pt;
    }

    .second-physical-properties-table tr:hover {
        background-color: transparent;
    }

    /* Right table - hide empty 4th column */
    .second-physical-properties-table-right td:nth-child(4) {
        display: none;
    }

    /* -----------------------------------------
       3.12 Specific Sections
       ----------------------------------------- */
    .partialContainer {
        padding: 10px 0;
    }

    .prewashCalculationContainer {
        padding: 15px 0;
    }

    .pollution-data-container {
        margin-bottom: 15px;
    }

    /* -----------------------------------------
       3.13 Footer (Print Overrides)
       ----------------------------------------- */
    .print-footer {
        margin: 30px 0 0 0;
        padding-top: 15px;
        border-top: 2px solid var(--miracle-primary);
    }

    .print-footer-line {
        display: block;
        height: 1px;
        background: var(--color-border);
        margin-bottom: 10px;
    }

    .print-footer-content,
    .print-footer-website {
        font-size: 8pt;
    }

    .print-footer-disclaimer {
        font-size: 7pt;
    }

    /* -----------------------------------------
       3.14 Signature Block (existing layout from SignatureViewPartial)
       ----------------------------------------- */
    .MoreSpaceAtTheTop {
        margin-top: 35px;
        padding-top: 15px;
    }

    .floatLeft {
        float: left;
        text-align: center;
        min-width: 160px;
    }

    .floatRight {
        float: right;
        text-align: center;
        min-width: 100px;
        margin-left: 25px;
    }

    /* Signature lines - only bottom border, no box */
    .longLine,
    .mediumLine {
        border: none;
        border-bottom: 1px solid var(--color-text);
        height: 25px;
        margin-bottom: 3px;
    }

    .longLine {
        width: 160px;
    }

    .mediumLine {
        width: 90px;
    }

    .floatLeft label,
    .floatRight label {
        font-size: 9pt;
        color: var(--color-text-muted);
    }

    /* -----------------------------------------
       3.15 Utility Classes
       ----------------------------------------- */
    .hidden-print {
        display: none !important;
    }

    .visible-print {
        display: block !important;
    }

    .text-center {
        text-align: center;
    }

    .clearfix::after {
        content: "";
        display: table;
        clear: both;
    }
}
