/* Inward / Despatch Module Styles */

:root {
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --primary: #3b82f6;
    --accent: #facc15;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    background: var(--bg-dark);
    color: #fff;
    margin: 0;
    font-family: 'Inter', sans-serif;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

.app-shell {
    display: flex;
    height: 100vh;
    width: 100vw;
    max-width: 100vw;
    overflow: hidden;
}

/* 1. Sidebar Nav (Icon Column) */
.sidebar-nav {
    width: 60px;
    flex-shrink: 0;
    background: #020617;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    border-right: 1px solid var(--border);
    gap: 20px;
}

.nav-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-muted);
    transition: all 0.2s;
}

.nav-icon:hover {
    background: rgba(255, 255, 255, 0.05);
}

.nav-icon.active {
    background: var(--primary);
    color: #fff;
}

/* 2. Module Body */
.module-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.header-strip {
    height: 60px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.title-area {
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 600;
}

.search-box {
    flex: 1;
    max-width: 600px;
    position: relative;
    margin: 0 40px;
}

.search-box input {
    width: 100%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    padding: 10px 15px 10px 40px;
    border-radius: 8px;
    color: #fff;
    outline: none;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.7;
}

.header-actions {
    display: flex;
    gap: 12px;
}

.add-btn {
    background: #fff;
    color: var(--primary);
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
}

.status-top-bar {
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 15px 20px;
}

.status-chips-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-print {
    background: white;
    color: #333;
    border: 1px solid #ddd;
    padding: 6px 14px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: all 0.2s;
}

.btn-print:hover {
    background: #f1f5f9;
    border-color: var(--primary);
}

.status-top-bar::-webkit-scrollbar {
    display: none;
}

.status-top-bar .btn-print {
    flex-shrink: 0;
}

.status-chip {
    padding: 8px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.status-chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.status-chip:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.status-chip .count-badge {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    margin-left: 6px;
}

/* 3. Content Area */
.module-content-wrapper {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Filter Sidebar */
.filter-sidebar {
    width: 200px;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.2);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    overflow-y: auto;
}

.filter-sidebar::-webkit-scrollbar {
    width: 6px;
}

.filter-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.filter-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.filter-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.filter-header {
    padding: 0 20px 10px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-muted);
}

.filter-item {
    padding: 10px 20px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.filter-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.filter-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    border-right: 3px solid var(--primary);
}

/* Range Slider Styling */
.filter-sidebar input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
}

.filter-sidebar input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 5px rgba(59, 130, 246, 0.5);
}

.filter-sidebar input[type=range]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.badge {
    background: var(--text-muted);
    color: #fff;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
}

/* History Date Picker & Calendar Indicator */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.85);
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.history-date-picker-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.07);
    padding: 5px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: border-color 0.2s, background 0.2s;
}

.history-date-picker-wrap:hover,
.history-date-picker-wrap:focus-within {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.12);
}

.history-date-picker-input {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 0.75rem;
    width: 100%;
    cursor: pointer;
    outline: none;
    font-family: inherit;
    font-weight: 500;
}


#main-content-area {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

/* Despatch List (Full Width) */
.despatch-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.despatch-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    border: 1px solid transparent;
}

.despatch-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    border-color: var(--primary);
    background: rgba(30, 41, 59, 0.8);
}

.barcode-area {
    width: 80px;
    height: 80px;
    min-width: 80px;
    background: #fff;
    border-radius: 6px;
    padding: 4px;
}

.card-info-col {
    flex: 1;
    overflow: hidden;
}

.card-title {
    font-weight: 500;
    font-size: 0.85rem;
    margin-bottom: 2px;
    color: var(--text-muted);
    white-space: pre-wrap;
}

.card-recipient {
    color: #fff;
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-address {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Right Side Column for Status/Tags */
.card-status-col {
    width: 250px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    padding-right: 15px;
}

.status-pill {
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-pill.booked {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.status-pill.delivered {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}


.status-pill.returned {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.status-pill.return-recieved {
    /* Matches 'Return Recieved' class list conversion */
    background: rgba(251, 146, 60, 0.2);
    color: #fb923c;
}

.category-tag {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 10px;
}

/* Inward Table */
.inward-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    /* Force stretch and distribution */
}

.inward-table th,
.inward-table td {
    padding: 15px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: pre-wrap;
}

.inward-table th {
    text-align: left;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
}

/* Specific Column Widths */
.inward-table .col-date {
    width: 120px;
}

.inward-table .col-from {
    width: 25%;
}

.inward-table .col-desc {
    width: auto;
}

.inward-table .col-status {
    width: 150px;
    text-align: right;
}

.inward-table tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* 4. Detail Pane */
.detail-pane {
    width: 400px;
    flex-shrink: 0;
    background: #020617;
    border-left: 1px solid var(--border);
    display: none;
    flex-direction: column;
}

.detail-pane.active {
    display: flex;
}

.pane-header {
    height: 60px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    justify-content: space-between;
}

.pane-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.detail-header h2 {
    margin: 0;
    font-size: 1.4rem;
    color: var(--accent);
}

.large-barcode {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 20px;
}

.large-barcode img {
    width: 100%;
    max-width: 200px;
}

.detail-row {
    margin-bottom: 20px;
}

.detail-row label {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.detail-row p {
    margin: 0;
    font-size: 1rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.status-select {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 10px;
    color: #fff;
    border-radius: 6px;
    outline: none;
}

.history-log {
    background: rgba(255, 255, 255, 0.03);
    padding: 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.icon-btn {
    background: none;
    border: 1px solid var(--border);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
}

.icon-btn.primary {
    background: var(--primary);
    border: none;
}

/* 5. Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    width: 600px;
    max-width: 95%;
    background: #1e293b;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 0;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: var(--accent);
}

.close-x {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
}

#record-form {
    padding: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    padding: 10px;
    border-radius: 8px;
    color: #fff;
    outline: none;
    font-size: 0.9rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    border: 1px solid var(--border);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
}

/* Record Selection Styles */
.despatch-card.selected {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.card-selection {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-right: 5px;
}

.card-selection input[type="checkbox"],
.inward-table input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

.inward-table tr.selected {
    background: rgba(59, 130, 246, 0.1) !important;
}

.select-all-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 20px;
}

.select-all-chip input[type="checkbox"] {
    margin: 0;
    accent-color: var(--primary);
}

@media screen and (max-width: 768px) {
    .card-status-col {
        width: 100px;
    }

    .barcode-area {
        width: 60px;
        height: 60px;
        min-width: 60px;
    }
}

/* --- MOBILE RESPONSIVENESS --- */
@media screen and (max-width: 768px) {
    .app-shell {
        flex-direction: column;
    }

    /* 1. Navigation Bar (Bottom on Mobile) */
    .sidebar-nav {
        width: 100%;
        height: 35px;
        /* Reduced to match user request */
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border);
        order: 3;
        padding: 0;
        justify-content: space-around;
        background: #020617;
        position: fixed;
        bottom: 0;
        left: 0;
        z-index: 1000;
    }

    .nav-icon {
        height: 100%;
        width: 45px;
        font-size: 0.9rem;
    }

    .nav-icon {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    /* 2. Main Content Wrapper */
    .module-body {
        height: calc(100vh - 35px);
        /* Space for bottom nav */
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .module-content-wrapper {
        flex: 1;
        display: flex;
        flex-direction: column;
        /* Stack timeline and list */
        overflow: hidden;
        position: relative;
    }

    #main-content-area {
        flex: 1;
        overflow-y: auto;
        padding: 5px;
        /* Reduced from 10px */
        padding-bottom: 45px;
        /* Clearance for fixed bottom nav 35px + buffer */
    }

    /* 3. Header Improvements */
    .header-strip {
        height: 32px;
        /* Reduced to match user request */
        padding: 0 4px;
        gap: 5px;
    }

    .title-area span {
        font-size: 0.75rem;
        white-space: nowrap;
    }

    .search-box {
        margin: 0;
        flex: 1;
        /* Allow it to grow */
        max-width: 120px;
    }

    .search-box input {
        padding: 4px 6px 4px 24px;
        font-size: 0.7rem;
        height: 24px;
    }

    .search-box i {
        left: 8px;
        font-size: 0.7rem;
    }

    .add-btn {
        padding: 2px 6px;
        font-size: 0.65rem;
        border-radius: 3px;
    }

    /* 4. Filter Sidebar (Restored for Mobile as horizontal timeline) */
    .filter-sidebar {
        width: 100%;
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        padding: 5px 8px;
        background: rgba(0, 0, 0, 0.3);
        border-right: none;
        border-bottom: 1px solid var(--border);
        white-space: nowrap;
        gap: 10px;
        align-items: center;
        -webkit-overflow-scrolling: touch;
    }

    .filter-sidebar::-webkit-scrollbar {
        display: none;
    }

    .filter-header {
        padding: 0;
        margin: 0 !important;
        font-size: 0.65rem;
        background: var(--accent);
        color: #000;
        padding: 1px 4px;
        border-radius: 3px;
        font-weight: 800;
    }

    .filter-item {
        padding: 2px 0;
        font-size: 0.75rem;
        border-right: none !important;
    }

    .filter-item.active {
        color: var(--primary);
        font-weight: 700;
    }

    /* 5. Inward Table Mobile View */
    .status-top-bar {
        padding: 10px 8px;
        background: #020617;
    }

    .status-chips-wrapper {
        gap: 6px;
        overflow-x: auto;
    }

    .btn-print .btn-text {
        display: none;
        /* Icon only on small screens */
    }

    .btn-print {
        padding: 4px 6px;
    }

    .status-chip {
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    .inward-table thead {
        display: none;
        /* Hide headers */
    }

    .inward-table tr {
        display: flex;
        flex-direction: column;
        padding: 8px 10px;
        background: rgba(255, 255, 255, 0.02);
        margin-bottom: 6px;
        border-radius: 6px;
        border: 1px solid var(--border);
    }

    .inward-table td {
        padding: 3px 0;
        border: none;
        width: 100% !important;
        white-space: normal;
        /* Allow text wrap for description */
    }

    .inward-table .col-date {
        font-size: 0.75rem;
        color: var(--text-muted);
    }

    .inward-table .col-from {
        font-size: 1rem;
        font-weight: 600;
        color: #fff;
    }

    .inward-table .col-status {
        text-align: left;
    }

    /* 6. Despatch Card Adjustments */
    .despatch-card {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px;
        border-radius: 8px;
        gap: 8px;
    }

    .barcode-area {
        width: 50px;
        height: 50px;
        min-width: 50px;
    }

    .card-recipient {
        font-size: 0.95rem;
        margin-bottom: 2px;
    }

    .card-address {
        font-size: 0.75rem;
    }

    .card-status-col {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding-right: 0;
        margin-top: 5px;
        border-top: 1px dashed rgba(255, 255, 255, 0.1);
        padding-top: 8px;
    }

    /* 7. Detail Pane (Full Screen Overlay) */
    .detail-pane {
        width: 100vw;
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 5000;
        border-left: none;
        transform: translateX(100%);
        transition: transform 0.3s ease-in-out;
        display: none;
        /* Managed by JS/Active */
        background: #020617;
    }

    .detail-pane.active {
        transform: translateX(0);
        display: flex;
    }

    .modal-content {
        width: 98%;
        max-width: 98%;
        max-height: 95vh;
    }

    #record-form {
        padding: 15px;
    }
}
