/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background: linear-gradient(135deg, #2c3e50, #3498db);
    color: white;
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 30px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 300;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Controls */
.controls {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-success {
    background-color: #27ae60;
    color: white;
}

.btn-success:hover {
    background-color: #229954;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

/* Table */
.table-container {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.delivery-notes-table {
    width: 100%;
    border-collapse: collapse;
}

.delivery-notes-table th {
    background-color: #34495e;
    color: white;
    padding: 15px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.delivery-notes-table th.text-center {
    text-align: center;
}

.delivery-notes-table td {
    padding: 15px 12px;
    border-bottom: 1px solid #ecf0f1;
    vertical-align: top;
}

.delivery-notes-table tbody tr:hover {
    background-color: #f8f9fa;
}

.delivery-notes-table tbody tr.selected {
    background-color: #e3f2fd;
}

/* Column widths */
.checkbox-col {
    width: 50px;
    text-align: center;
}

.file-id-col {
    width: 250px;
    font-weight: 600;
    color: #2c3e50;
    word-break: break-all;
    font-size: 13px;
    line-height: 1.4;
}

.distribution-center-col {
    width: 220px;
    color: #7f8c8d;
}

.request-date-col {
    width: 160px;
    text-align: left !important;
    color: #7f8c8d;
}

.print-col {
    width: 80px;
    text-align: center;
}

.preview-col {
    width: 80px;
    text-align: center;
}

.view-col {
    width: 80px;
    text-align: center;
}

.download-col {
    width: 80px;
    text-align: center;
}

.csv-download-col {
    width: 80px;
    text-align: center;
}

/* Printer icon button */
.printer-btn {
    background: none;
    border: none;
    color: #3498db;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.printer-btn:hover {
    background-color: #3498db;
    color: white;
    transform: scale(1.1);
}

.printer-btn:active {
    transform: scale(0.95);
}

/* Print button */
.print-btn {
    background: none;
    border: none;
    color: #e74c3c;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.print-btn:hover {
    background-color: #e74c3c;
    color: white;
    transform: scale(1.1);
}

.print-btn:active {
    transform: scale(0.95);
}

/* View button */
.view-btn {
    background: none;
    border: none;
    color: #9b59b6;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.view-btn:hover {
    background-color: #9b59b6;
    color: white;
    transform: scale(1.1);
}

.view-btn:active {
    transform: scale(0.95);
}

/* Download button */
.download-btn {
    background: none;
    border: none;
    color: #27ae60;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.download-btn:hover {
    background-color: #27ae60;
    color: white;
    transform: scale(1.1);
}

.download-btn:active {
    transform: scale(0.95);
}

/* CSV Download button */
.csv-download-btn {
    background: none;
    border: none;
    color: #27ae60;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.csv-download-btn:hover {
    background-color: #27ae60;
    color: white;
    transform: scale(1.1);
}

.csv-download-btn:active {
    transform: scale(0.95);
}

/* File ID styling */
.file-id {
    background-color: #3498db;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    display: inline-block;
    word-break: break-all;
}

/* Distribution center styling */
.distribution-center {
    background-color: #95a5a6;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    display: inline-block;
}

/* Request date styling */
.request-date {
    background-color: #e67e22;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    display: inline-block;
}

/* Checkbox styling */
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #3498db;
}

/* Loading indicator */
.loading {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error message */
.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #f5c6cb;
    text-align: center;
    margin: 20px 0;
}

/* Modal - Full Screen */
.modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: white !important;
    display: flex !important;
    flex-direction: column !important;
    z-index: 1000 !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.modal.hidden {
    display: none !important;
    visibility: hidden !important;
}

.modal-content {
    background: white;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    background-color: #34495e;
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-weight: 300;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.modal-body {
    padding: 0;
    flex: 1;
    overflow-y: auto;
    background-color: #f8f9fa;
    overflow-x: hidden;
}

/* Hide broken images and prevent browser placeholders */
img {
    background: transparent !important;
    background-color: transparent !important;
}

/* Ensure modal body doesn't clip content during print */
@media print {
    .modal-body {
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
    }
    
    /* Prevent browser from showing broken image placeholders */
    img {
        background: transparent !important;
        background-color: transparent !important;
        border: none !important;
    }
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #ecf0f1;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    background-color: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

/* Print content styling in modal */
#printContent {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin: 0;
    padding: 0;
}

/* Print styles */
@media print {
    /* Hide everything by default */
    body > * {
        display: none !important;
    }
    
    /* Only show the modal and its content */
    body > #printModal {
        display: flex !important;
    }
    
    /* Reset body styling for print */
    body {
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Hide modal controls */
    .modal-header,
    .modal-footer,
    .close-btn {
        display: none !important;
    }
    
    /* Make modal fill the entire page */
    .modal {
        position: relative !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
        display: block !important;
    }
    
    .modal-content {
        box-shadow: none !important;
        overflow: visible !important;
        height: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        display: block !important;
        position: relative !important;
    }
    
    .modal-body {
        padding: 0 !important;
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
        min-height: 0 !important;
        display: block !important;
        position: relative !important;
    }
    
    /* Ensure print-note divs expand fully */
    .print-note {
        height: auto !important;
        max-height: none !important;
        min-height: 0 !important;
        overflow: visible !important;
        page-break-inside: avoid !important;
    }
    
    /* Prevent extra blank pages - remove all trailing margins */
    html, body {
        height: auto !important;
        min-height: 0 !important;
    }
    
    /* Remove trailing page breaks and margins */
    .print-note:last-child {
        page-break-after: avoid !important;
        margin-bottom: 0 !important;
    }
    
    /* Trim empty content at the end */
    #printContent::after {
        content: none !important;
    }
    
    /* Ensure all content is visible */
    #printContent {
        overflow: visible !important;
        max-height: none !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
        display: block !important;
    }
    
    /* Ensure nested container divs don't constrain height */
    #printContent > div,
    #printContent .print-note,
    #printContent .print-note > div {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }
    
    /* Remove all trailing margins and padding to prevent blank pages */
    #printContent > .print-note > div > div:last-child {
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
    }
    
    #printContent > .print-note > div > div:last-child:empty {
    display: none;
}

    /* Remove any remaining spacing */
    body:after {
        content: none !important;
    }
}

/* Utility classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: #6c757d;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .table-container {
        overflow-x: auto;
    }
    
    .delivery-notes-table {
        min-width: 700px;
    }
    
    .preview-col, .print-col, .download-col, .csv-download-col {
        min-width: 80px;
    }
    
    .request-date-col {
        min-width: 100px;
    }
    
    .modal-content {
        width: 100%;
        height: 100%;
    }
}
