/* --- TRUCK LOADER PRO: MASTER STYLESHEET --- */

:root {
    --primary: #007bff;
    --primary-hover: #0056b3;
    --success: #28a745;
    --info: #17a2b8;
    --danger: #dc3545;
    --dark: #212529;
    --light: #f8f9fa;
    --bg: #f0f2f5;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--dark);
    /* IMPORTANT: Ensure no overflow: hidden is set here */
}

/* --- NAVIGATION --- */
header {
    background: var(--dark);
    color: white;
    padding: 1rem 0;
    box-shadow: var(--shadow);
}

nav {
    width: 95%;
    max-width: 1600px;
    margin: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

nav h2 {
    margin: 0;
    font-size: 1.4rem;
}

.nav-links {
    display: flex;
    gap: 20px;
    align-items: center;
}

.nav-links a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-weight: 600;
}

/* --- BUTTON BAR --- */
.no-print {
    background: white;
    border-bottom: 1px solid #ddd;
    padding: 15px;
    position: sticky;
    top: 0;
    z-index: 1100;
    /* Stays above the sidebar */
}

.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    color: white;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: 0.2s;
    margin: 0 5px;
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--primary);
}

.btn-success {
    background: var(--success);
}

.btn-danger {
    background: var(--danger);
}

.btn-info {
    background: var(--info);
}

.btn-grey {
    background: #6c757d;
}

/* --- MAIN LAYOUT --- */
.main-container {
    display: flex;
    gap: 30px;
    max-width: 1600px;
    margin: 20px auto;
    padding: 0 20px;
    /* REQUIRED: Stops sidebar from stretching to full trailer height */
    align-items: flex-start !important;
}

/* --- STICKY INVENTORY PANEL --- */
.inventory-panel {
    width: 350px;
    background: #fff;
    border-radius: 10px;
    box-shadow: var(--shadow);

    /* THE STICKY FIX */
    position: -webkit-sticky;
    position: sticky;
    top: 80px;
    /* Adjust based on your header/button bar height */
    height: calc(100vh - 100px);
    /* Keeps it within view */

    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.inventory-header {
    padding: 15px;
    background: var(--primary);
    color: white;
    font-weight: bold;
    border-radius: 10px 10px 0 0;
    text-align: center;
}

#source {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    background: #fafafa;
}

/* --- TRASH ZONE --- */
#trash {
    margin: 10px;
    padding: 15px;
    background: #fff1f0;
    color: #d85c5c;
    border: 2px dashed #ffa39e;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    font-size: 12px;
}

/* --- PRODUCT ITEMS --- */
.product-item {
    padding: 10px;
    margin-bottom: 8px;
    background: white;
    border: 1px solid #d9d9d9;
    font-size: 13px;
    border-radius: 4px;
    cursor: grab;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* --- TRAILER MANIFEST AREA --- */
#printArea {
    flex-grow: 1;
    background: #fff;
    padding: 30px 80px;
    /* Space for Plt labels */
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.trailer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    background: #e9ecef;
    padding: 20px;
    border-radius: 8px;
}

.bay {
    min-height: 80px;
    background: #fff;
    border: 1px solid #adb5bd;
    padding: 10px;
    position: relative !important;
}

/* --- PALLET LABELS --- */
.bay::before {
    content: attr(data-bay);
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: 800;
    color: #444;
    width: 50px;
}

.bay:nth-child(odd)::before {
    left: -65px !important;
    text-align: right;
}

.bay:nth-child(even)::before {
    right: -65px !important;
    left: auto !important;
    text-align: left;
}

/* --- ORIENTATION & DOORS --- */
.orientation-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 15px;
}

.front-arrow {
    width: 0;
    height: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-bottom: 25px solid var(--dark);
    margin-bottom: 5px;
}

.trailer-label {
    text-align: center;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: #111;
    margin: 10px 0;
    font-size: 1.1rem;
}

.doors-visual-container {
    display: flex;
    width: 100%;
    margin-top: 15px;
}

.trailer-door {
    flex: 1;
    height: 80px;
    border: 6px solid var(--dark);
    background: #fdfdfd;
    position: relative;
    display: flex;
    align-items: center;
}

.door-left {
    border-right: 3px solid var(--dark);
    border-radius: 10px 0 0 10px;
    justify-content: flex-end;
}

.door-right {
    border-left: 3px solid var(--dark);
    border-radius: 0 10px 10px 0;
    justify-content: flex-start;
}

.door-handle {
    width: 8px;
    height: 30px;
    background: var(--dark);
    margin: 0 15px;
    border-radius: 4px;
}

.locking-bar {
    position: absolute;
    width: 4px;
    height: 100%;
    background: var(--dark);
    top: 0;
}

.door-left .locking-bar {
    left: 25%;
}

.door-right .locking-bar {
    right: 25%;
}

.hinge {
    position: absolute;
    width: 12px;
    height: 18px;
    background: #666;
    left: -9px;
    border-radius: 2px;
}

.door-right .hinge {
    left: auto;
    right: -9px;
}

/* --- PRINT RULES --- */
@media print {

    header,
    .no-print,
    .inventory-panel,
    button {
        display: none !important;
    }

    body {
        background: white;
    }

    #printArea {
        box-shadow: none;
        padding: 0 80px;
        width: 100%;
    }

    .main-container {
        display: block;
        margin: 0;
        padding: 0;
    }

    input {
        border: none !important;
        font-weight: bold;
    }
}