/* ==========================================================================
   BOL (Bill of Lading) Style sheet
   
   Table of Contents:
   1. Imports & Variables
   2. Base Layout & Container Styles
   3. Form Components
   4. Logo & Selection Components
   5. Preview Components
   6. Form Table Styles
   7. Preview Table Styles
   8. Responsive Design
   9. Print Styles
   10. Utility Classes
   ========================================================================== */

/* ==========================================================================
   1. Imports & Variables
   ========================================================================== */
   @import url('https://fonts.googleapis.com/css?family=Poppins;100,200,300,400,500,600,700,800,900');
   @import 'variables.css';
   
/* ==========================================================================
    2. Base Layout & Container Styles
    ========================================================================== */
   /* Base styles for the main container */
   .main-container {
       width: 100%;
       padding: 20px;
       background: linear-gradient(90deg, black, #2A003D);
       background-image: linear-gradient(90deg, black, #2A003D), 
                        repeating-linear-gradient(to bottom, transparent, transparent 8px, rgba(255,255,255,0.03) 8px, rgba(255,255,255,0.03) 10px);
       background-blend-mode: overlay;
       background-size: cover; 
   }
   
   /* Content layout */
   .content {
       width: 100%;
       margin-top: 80px;
       margin-bottom: 20px;
       padding: 20px; /* Space for fixed header */      
   }
/* ==========================================================================
   3. Form Components
   ========================================================================== */
    .form-container {
        flex: 1;
        background-color: var(--background-glass);
        padding: 20px;
        border-radius: 12px;      
        border: 2px solid var(--primary-color);
        width: 100%;
        max-width: 50%;
        overflow-x: hidden; /* Prevent horizontal scroll on container */
    }

    .form-container:hover {
        box-shadow: 0 0 30px var(--primary-color);
        border: 2px solid var(--primary-color);
    }

    .form-header {
        text-align: center;
        margin-bottom: 20px;
        font-size: var(--h1-size);
        font-weight: bold;
    }
    
    .form-page-number {
        text-align: right;
        margin-top: -30px;
        margin-bottom: 10px;
    }

    .form-row {
        display: flex;
        margin-bottom: 10px;
    }

    .form-cell {
        flex: 1;
        border: 1px solid var(--primary-color);
        padding: 5px;
        background-color: transparent;
    }

    .form-label {
        font-size: var(--h2-size);
        font-weight: bold;
        margin-bottom: 5px;
    }

    .form-input {
        width: 100%;
        background-color: var(--container-color);
        border: 1px solid var(--primary-color);
        color: var(--text-color);
        padding: 5px;
    }

    textarea.form-input {
        height: 60px;
        resize: none;
    }

    .special-instructions {
        margin-bottom: 10px;
        border: 1px solid var(--primary-color);
        padding: 5px;
        background-color: transparent;
    }

    .emergency-contact {
        font-size: var(--h3-size);
        text-align: center;
        margin-top: 5px;
        font-weight: bold;
    }

    
    .form-signature {
        display: flex;
        margin-bottom: 10px;
    }

    .signature-cell {
        flex: 1;
        border: 1px solid var(--primary-color);
        padding: 5px;
    }

    .form-shipper-signature,
    .form-carrier-signature {
        width: 100%;
        height: 40px;
        background-color: var(--container-color);
        border: 1px solid var(--primary-color);
        margin-bottom: 5px;
        color: var(--text-color);
        padding: 5px;
        font-family: "Poppins";
    }    

    .signature-text {
        font-size: var(--h3-size);
        margin-top: 5px;
        color: var(--text-color);
    }

    .bol-number {
        font-family: "Poppins";
        font-size: var(--h2-size);
        padding: 20px;
        background-color: var(--container-color);
        border-radius: 4px;
        min-height: 20px;
    }
    
/* ==========================================================================
   4. Logo & Selection Components
   ========================================================================== */
    /* Logo selection container */
    .logo-selection-container {
        display: flex;
        gap: 10px;
        align-items: center;
        margin-bottom: 20px;
        flex-wrap: wrap;
    }

    .logo-preview {
        width: 200px;
        height: 50px;
        border: 1px solid var(--primary-color);
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: white;
        margin-right: 10px;
        padding: 5px;
    }

    #logoSelect {
        flex: 1;
        min-width: 200px;
    }
    
    #logoSelect {
        flex: 0 0 200px;
        padding: 8px;
        border: 1px solid var(--primary-color);
        border-radius: 4px;
        background-color: var(--container-color);
        color: white;
        margin-right: 10px;  /* Reduced margin to accommodate print button */
    }    

    .logo-preview img {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
        display: block; /* Always display the image */
    }

    .bol-logo {
        display: block;
        width: 150px;
        height: auto;
        position: absolute;
        top: 4px;
        left: 48px;
        margin: 0;
    }
/* ==========================================================================
   5. Preview Components
   ========================================================================== */
    /* Add these styles to your existing CSS */ 
    .preview-section {
        flex: 1;
        padding: 20px;       
        min-width: 0;
    }

    .preview-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center; 
        margin-left: 20px;
        border: 2px solid var(--primary-color);
        background: var(--background-glass);
        padding: 10px;
        width: 50%;
        border-radius: 12px;        
    }
    
    .preview-container:hover {
        box-shadow: 0 0 30px var(--primary-color);
        border: 2px solid var(--primary-color);
    }

    .bol-preview {
        width: 8.5in;
        height: 11in;
        background-color: white;
        box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
        position: relative;
        margin: 0 auto;
    }

    .preview-content {
        padding-top: 0.5in;
        padding-left: 0.125in;
        padding-right: 0.125in;
        height: 100%;
        box-sizing: border-box;
        color: black;
        position: relative;
    }

    .preview-header {
        text-align: center;
        font-weight: bold;
        font-size: var(--h1-size);
        margin-top: 10px; 
        margin-bottom: 10px;
        padding-bottom: 10px;
    }

    .preview-scroll-container {
        width: 100%;
        display: flex;
        justify-content: center; 
        align-items: center;
        overflow-x: auto;
        padding: 20px;
    }  
    
    .preview-row {
        display: flex;
        margin-bottom: 5px;
    }

    .preview-cell {
        flex: 1;
        border: 1px solid black;
        padding: 3px;
        font-size: var(--h3-size);
    }    

    .preview-signature {
        display: flex;
        margin-bottom: 10px;
    }

    .preview-signature-cell {
        flex: 1;
        border: 1px solid black;
        padding: 3px;
        font-size: var(--h3-size);
    }

    .preview-shipper-signature,
    .preview-carrier-signature {
        font-family: 'Mrs Saint Delafield', cursive;
        font-size: 28px;
        color: blue;
        display: block;
        margin: 5px 0;
    }

    .preview-signature-cell strong {
        font-size: var(--h3-size);  /* Slightly larger size for the labels */
    }

    .preview-signature-cell .certification-text {
        font-size: var(--h2-size);  /* Keep certification text small */
        margin-top: 1px;
        display: block;
    }

/* ==========================================================================
   6. Form Table Styles
   ========================================================================== */
   /* Table styles */
    .table-wrapper {
        width: 100%;
        overflow-x: auto;
        margin-bottom: 10px;
    }

    #itemsTable {
        width: 100%;
        table-layout: fixed;
   }
    
    /* Center align the line number column */
    #form-table td:first-child {
        text-align: center;
    }    

    #form-table td input {
        width: 100%;
        box-sizing: border-box;
        padding: 1px;
        height: 22px;
        line-height: 22px;
        font-size: var(--h3-size);
        border: none;
        background: var(--container-color);
        color: var(--text-color);
    }
        
    .form-table {
        width: auto;
        border-collapse: collapse;
        table-layout: fixed;
    }
  
    table input {
        width: 100%;
        box-sizing: border-box;
        padding: 2px 4px;
        border: none;
        background: var(--container-color); 
        color: var(--text-color);
        font-family: "Poppins";
        margin: 0;
        line-height: 1.2;
        display: block;
    }

    .line-number {
        line-height: 22px; 
        height: 22px;
    }

    .form-table th, .form-table td {
        border: 1px solid var(--primary-color);
        padding: 5px;
        text-align: center;
        background-color: var(--container-color);
    }
  
/* ==========================================================================
   7. Preview Table Styles
   ========================================================================== */      
.preview-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: var(--h4-size);  /* Choose the size you want */
}

.preview-table th,
.preview-table td {
    border: 1px solid black;
    padding: 3px;
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: var(--h4-size);  /* Make it consistent */
}



/* Match the form table column widths exactly */
.preview-table th:nth-child(1),
.preview-table td:nth-child(1) { /* Line Number */
    width: 2%;
    text-align: center;
    padding: 0px;
}

.preview-table th:nth-child(2),
.preview-table td:nth-child(2) { /* Qty*/
    width: 3%;
}

.preview-table th:nth-child(3),
.preview-table td:nth-child(3) { /* Type/PN */
    width: 8%;
}

.preview-table th:nth-child(4),
.preview-table td:nth-child(4) { /* Weight */
    width: 8%;
}

.preview-table th:nth-child(5),
.preview-table td:nth-child(5) { /* HM */
    width: 3%;
}

.preview-table th:nth-child(6),
.preview-table td:nth-child(6) { /* Description */
    width: 40%;
}

.preview-table th:nth-child(7),
.preview-table td:nth-child(7) { /* NMFC# */
    width: 5%;
}

.preview-table th:nth-child(8),
.preview-table td:nth-child(8) { /* Class */
    width: 4%;
}

/* Ensure consistent styling */
.preview-table th,
.preview-table td {
    border: 1px solid black;
    padding: 3px;
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.preview-table th {
    background-color: #f5f5f5;
    font-weight: bold;
}   
  

    /* Custom scrollbar for better visibility */
    .table-wrapper::-webkit-scrollbar {
        height: 8px;
    }

    .table-wrapper::-webkit-scrollbar-track {
        background: var(--container-color);
        border-radius: 4px;
    }

    .table-wrapper::-webkit-scrollbar-thumb {
        background: var(--primary-color);
        border-radius: 4px;
    }

    .table-wrapper::-webkit-scrollbar-thumb:hover {
        background: var(--primary-color-hover);
    }  

    .print-btn {
        background-color: var(--primary-color);
        color: white;
        border: none;
        padding: 8px 16px;
        border-radius: 4px;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 8px;
        transition: all 0.3s ease;
        height: 35px;  /* Match the height of the dropdown */
    }

    .print-btn:hover {
        background-color: var(--primary-color-dark);
        transform: translateY(-2px);
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    }   
    
/* ==========================================================================
   8. Responsive Design
   ========================================================================== */
/* Large Screens and Tablets */
@media (max-width: 1400px) {
    /* Large screens */
    .content > div {
        flex-direction: column;
    }

    .preview-container {
        margin-left: 0;
        margin-top: 20px;
    }

    .bol-preview {
        margin: 0 auto;
    }
}

@media (max-width: 1200px) {
    .preview-container {
        margin-top: 20px;
    }

    .form-container {
        max-width: 100%;
    }

    /* Stack form and preview vertically */
    div[style="display: flex;"] {
        flex-direction: column;
    }

    .preview-pane {
        margin-left: 0;
        margin-top: 20px;
        width: 100%;
        max-width: 100%;
    }
}

/* Tablets */
@media (max-width: 991px) {
    .main-container {
        padding: 10px;
    }

    .form-container,
    .preview-container {
        padding: 15px;
    }

    .logo-selection-container {
        flex-direction: column;
        align-items: stretch;
    }

    .logo-preview {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }

    #logoSelect,
    #printButton {
        width: 100%;
    }

    .form-signature {
        flex-direction: column;
    }

    .signature-cell {
        width: 100%;
        margin-bottom: 20px;
    }
}

/* Mobile Devices */
@media (max-width: 768px) {
    .content {
        margin-top: 60px;
    }

    .form-header {
        font-size: 20px;
    }

    .form-row {
        flex-direction: column;
    }

    .form-cell {
        width: 100%;
        margin-bottom: 15px;
    }
}

@media (max-width: 480px) {
    .main-container {
        padding: 5px;
    }

    .form-container,
    .preview-container {
        padding: 10px;
    }

    .form-input,
    .form-textarea {
        font-size: 14px;
    }
}

/* ==========================================================================
   9. Print Styles
   ========================================================================== */
@media print {
    @page {
        margin: 0;
        size: letter;
    }

    /* Hide everything except the BOL preview */
    body * {
        visibility: hidden;
    }
    
    /* Make the preview visible */
    .bol-preview, 
    .bol-preview * {
        visibility: visible;
    }
    
    /* Hide unnecessary elements */
    .header, .footer, .form-container, .logo-selection-container {
        display: none !important;
    }

    .container {
        padding: 0;
        margin: 0;
    }

    .preview-section {
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .preview-container {
        margin: 0;
        padding: 0;
    }

    /* Reset all containers */
    body, html, .content, .preview-container, .preview-scroll-container {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        background: none !important;
        border: none !important;
        box-shadow: none !important;
    }
    
    /* Position BOL preview to fill the page */
    .bol-preview {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        transform: none !important;
        page-break-after: always !important;
    }
    
    /* Ensure content is properly sized */
    .preview-content {
        padding-top: 0.5in !important;
        padding-left: 0.25in !important;
        padding-right: 0.25in !important;
        margin: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Fix table sizing */
    .preview-table {
        width: 100% !important;
        table-layout: fixed !important;
    }

    .preview-content .meta-logo,
    .preview-content .preview-header {
        margin-top: 0;
    }

    .preview-scroll-container {
        overflow: visible !important;
        padding: 0;
    }     
  
    .preview-table th,
    .preview-table td {
        padding: 2px !important;
        font-size: var(--h4-size) !important;
    }
}
    
/* ==========================================================================
   10. Utility Classes
   ========================================================================== */
    .overflow-auto {
        overflow: auto;
    }

    .w-100 {
        width: 100%;
    }

    .text-center {
        text-align: center;
    }
