:root {
    --primary-color: #007bff; /* Professional Blue */
    --secondary-color: #6c757d; /* Neutral Gray */
    --accent-color: #17a2b8; /* Informative Teal */
    --success-color: #28a745; /* Green for success */
    --error-color: #dc3545;   /* Red for errors/refunds */
    --warning-color: #ffc107; /* Yellow for processing/warnings */
    --info-color: #17a2b8;    /* Teal for info */

    --bg-light: #f8f9fa; /* Light page background */
    --bg-white: #ffffff; /* Content background */
    --text-dark: #212529; /* Dark text */
    --text-light: #ffffff; /* Light text */
    --border-color: #dee2e6; /* Standard border color */

    --font-family-main: 'Be Vietnam Pro', sans-serif;
    --box-shadow-light: 0 2px 8px rgba(0, 0, 0, 0.1);
    --box-shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.15);
    --border-radius: 8px;
    --transition-speed: 0.3s;
}

/* --- Basic Reset & Global Styles --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family-main);
    line-height: 1.6;
    background-color: var(--bg-light);
    color: var(--text-dark);
    overflow-x: hidden; /* Prevent horizontal scroll */
    display: flex; /* For footer later if needed */
    flex-direction: column; /* For footer */
    min-height: 100vh; /* For footer */
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    margin-bottom: 0.75rem;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-speed) ease;
}

a:hover {
    color: darken(var(--primary-color), 10%);
    text-decoration: underline;
}

button {
font-family: var(--font-family-main);
cursor: pointer;
border: none;
padding: 0.6rem 1.2rem;
border-radius: var(--border-radius);
/* MODIFIED: Added filter to the transition property */
    transition: background-color var(--transition-speed) ease, transform var(--transition-speed) ease, filter var(--transition-speed) ease;
font-size: 0.9rem;
font-weight: 500;
    /* ADDED: Default filter value */
    filter: brightness(100%);
}

button:hover {
    transform: translateY(-2px);
    filter: brightness(90%);
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
textarea,
select {
    font-family: var(--font-family-main);
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    width: 100%;
    margin-bottom: 0.5rem;
    transition: border-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

textarea {
    min-height: 100px;
    resize: vertical;
}

/* --- Loader --- */
#loader {
    display: none; /* Hidden by default, shown by JS */
    position: fixed;
    left: 50%;
    top: 50%;
    width: 50px;
    height: 50px;
    border: 5px solid var(--bg-light);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: spin 1s linear infinite;
    z-index: 2000;
}

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

/* --- Banner --- */
.banner {
    background-color: var(--primary-color);
    color: var(--text-light);
    padding: 0.8rem 1.5rem;
    text-align: center;
    font-size: 0.9rem;
    box-shadow: var(--box-shadow-light);
}
.banner h1 {
    font-size: 1.1rem;
    margin: 0;
    font-weight: 500;
}

/* --- Layout & Navigation --- */
.focus {
    display: flex;
    flex-grow: 1; /* Makes the focus area take remaining height */
}

.navMenu {
    background-color: #2c3e50;
    color: var(--text-light);
    width: 260px;
    flex-shrink: 0; /* Prevent sidebar from shrinking if content in .right is too wide */
    padding: 1.5rem 0;
    z-index: 900;
    display: flex;
    flex-direction: column;

    /* Desktop and default styles: visible, sticky sidebar */
   
    transform: translateX(0); /* Ensure it's visible and not transformed off-screen by default */
    transition: transform var(--transition-speed) ease-in-out;
}


.navMenu.open {
    transform: translateX(0);
}

.pic {
    display: flex; /* This should make the user avatar and name visible */
    flex-direction: column;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 0 1rem;
}
/* If you ever need to hide it programmatically via JS, use this class */
.pic.hidden {
 display: none;
}

.upic {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin-bottom: 0.75rem;
    border: 3px solid var(--accent-color);
    object-fit: cover;
}


.clientName {
    font-weight: 600;
    font-size: 1.1rem;
    text-align: center;
}

.navMenu ul {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
}

.navMenu ul li a {
    display: block;
    padding: 0.9rem 1.5rem;
    color: #ecf0f1;
    text-decoration: none;
    font-weight: 500;
    transition: background-color var(--transition-speed) ease, padding-left var(--transition-speed) ease;
    border-left: 4px solid transparent;
}

.navMenu ul li a:hover {
    background-color: #34495e;
    color: var(--text-light);
    padding-left: 1.8rem;
    border-left-color: var(--accent-color);
}

.navMenu ul li a.active {
    background-color: var(--primary-color);
    color: var(--text-light);
    font-weight: 700;
    border-left-color: var(--accent-color);
}

#hamburger {
    display: none; /* Hidden by default, shown for mobile/tablet */
    position: fixed;
    top: 10px; /* Adjusted to align with banner text if banner padding is ~0.8rem */
    left: 15px;
    font-size: 2rem;
    color: var(--text-dark); /* Ensure visibility on light backgrounds if any */
    background: var(--bg-white); /* Give it a background */
    padding: 5px 10px;
    border-radius: var(--border-radius);
    z-index: 1100;
    cursor: pointer;
    box-shadow: var(--box-shadow-light);
}

.right {
    flex-grow: 1; /* This is crucial for taking up remaining space */
    padding: 1.5rem;
    overflow-y: auto; /* Allow content scrolling within the right panel */
    /* min-width: 0; /* Can sometimes help in complex flex scenarios if content overflows */
}


/* --- Seller Info Box --- */
#sellerInfoWrapper {
    margin-bottom: 2rem;
}
#sellerInfoBox {
    background-color: var(--bg-white);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-light);
}
#sellerInfoBox h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}
#sellerInfoBox p {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}
#sellerInfoBox p strong {
    color: var(--text-dark);
    min-width: 100px;
    display: inline-block;
}
#sellerInfoBox span {
    color: var(--secondary-color);
}


/* --- Analytics Section --- */
.analytics-section {
    background-color: var(--bg-white);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-light);
    margin-bottom: 2rem;
}
.analytics-section h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    text-align: center;
}
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
.analytics-card {
    background-color: var(--bg-light);
    padding: 1rem;
    border-radius: var(--border-radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.analytics-card h3 {
    font-size: 1.1rem;
    color: var(--accent-color);
    margin-bottom: 1rem;
}
.chart-container {
    min-height: 150px; /* Placeholder height */
    font-size: 0.85rem;
}
.chart-container p {
    color: var(--secondary-color);
    text-align: center;
    padding-top: 20px;
}

.analytics-filters {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: center;
    margin-top: 1rem;
}
.analytics-filters select {
    width: auto;
    min-width: 150px;
}
.analytics-filters button {
    background-color: var(--accent-color);
    color: var(--text-light);
}
.analytics-filters button:hover {
    filter: brightness(90%);
}


/* --- Order Status Guide --- */
.order-status-info {
    background-color: var(--bg-white);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-light);
    margin-bottom: 2rem;
}
.order-status-info h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}
.order-status-info ul {
    list-style: none;
    padding-left: 0;
}
.order-status-info li {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}
.order-status-info li strong {
    color: var(--text-dark);
}

/* --- Main Orders Container --- */
.container {
    background-color: var(--bg-white);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-light);
}
.container h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    text-align: center;
}

.search-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: flex-end;
}
.date-search, .keyword-search {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}
.date-search label, .keyword-search label { /* If you add labels to keyword search */
    margin-right: 0.5rem;
    font-weight: 500;
}
.search-filters input[type="date"],
.search-filters input[type="text"] {
    width: auto; /* Override default full width */
    min-width: 150px;
    margin-bottom: 0; /* Remove bottom margin for inline alignment */
}
.search-filters button {
    background-color: var(--primary-color);
    color: var(--text-light);
}
.search-filters button:hover {
    filter: brightness(90%);
}
.search-filters button[onclick="refreshOrders()"] {
    background-color: var(--secondary-color);
}
.search-filters button[onclick="refreshOrders()"]:hover {
    filter: brightness(90%);
}


/* Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    box-shadow: var(--box-shadow-light);
}

thead {
    background-color: #e9ecef; /* Light gray for table header */
}

th, td {
    padding: 0.8rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

th {
    font-weight: 600;
    color: var(--text-dark);
}

tbody tr:hover {
    background-color: var(--bg-light);
}

.order-item {
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background-color: #fdfdfd;
    border-left: 3px solid var(--accent-color);
    font-size: 0.85rem;
}
.order-item p {
    margin: 0.2rem 0;
}

.action-buttons button {
    margin: 0.25rem;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}
.status-btn.processing { background-color: var(--warning-color); color: var(--text-dark); filter: brightness(90%);}
.status-btn.processing:hover { filter: brightness(90%); }
.status-btn.shipped { background-color: var(--primary-color); color: var(--text-light); }
.status-btn.shipped:hover { background-color: darken(var(--primary-color), 10%); }
.status-btn.delivered { background-color: var(--success-color); color: var(--text-light); }
.status-btn.delivered:hover { background-color: darken(var(--success-color), 10%); }
.status-btn.refund { background-color: var(--error-color); color: var(--text-light); }
.status-btn.refund:hover { background-color: darken(var(--error-color), 10%); }

#message {
    text-align: center;
    padding: 1rem;
    margin-top: 1rem;
    border-radius: var(--border-radius);
    font-weight: 500;
}

/* --- Modal Styles (enhancing HTML inline styles) --- */
#refundModal, #shippedModal {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6); /* Darker overlay */
    z-index: 1000;
    align-items: center; /* Vertically center */
    justify-content: center; /* Horizontally center */
    animation: fadeIn 0.3s ease-out;
    overflow-y: auto; /* Allow modal scroll if content is too long */
    padding: 20px; /* Padding for smaller screens */
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-white);
    padding: 2rem;
    width: 90%;
    max-width: 600px; /* Max width for shipped modal */
    margin: auto; /* Fallback if flex alignment fails */
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-medium);
    position: relative; /* For close button positioning */
    animation: slideInUp 0.4s ease-out;
}

@keyframes slideInUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Specific width for refund modal if needed */
#refundModal .modal-content {
    max-width: 500px;
}


.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    cursor: pointer;
    font-size: 1.8rem; /* Larger close icon */
    color: var(--secondary-color);
    transition: color var(--transition-speed) ease;
}

.close-modal:hover {
    color: var(--error-color);
}

.modal-content h3 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.modal-content textarea,
.modal-content input[type="text"],
.modal-content input[type="number"],
.modal-content select {
    margin-bottom: 1rem; /* Spacing for modal inputs */
}

.modal-content button {
    background-color: var(--primary-color);
    color: var(--text-light);
    margin-top: 0.5rem; /* Space above button */
    width: 100%;
}
.modal-content button:hover {
    background-color: darken(var(--primary-color), 10%);
}
.modal-content button[onclick="closeShippedModal()"],
.modal-content button[onclick="closeRefundModal()"] /* If you add a dedicated close button */
{
    background-color: var(--secondary-color);
}
.modal-content button[onclick="closeShippedModal()"]:hover,
.modal-content button[onclick="closeRefundModal()"]:hover {
    background-color: darken(var(--secondary-color), 10%);
}


/* Shipped Modal Specifics */
.delivery-options {
    margin-bottom: 1.5rem;
}
.delivery-options label {
    display: block;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: border-color var(--transition-speed) ease, background-color var(--transition-speed) ease;
}
.delivery-options label:hover {
    border-color: var(--primary-color);
    background-color: #f8f9fa80;
}
.delivery-options input[type="radio"] {
    margin-right: 0.5rem;
}

.parcel-fields h4, #customDelivery h4 {
    font-size: 1.1rem;
    color: var(--accent-color);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}
.parcel-fields label, #customDelivery label { /* If custom delivery uses labels */
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}
.parcel-fields input, .parcel-fields select {
    margin-bottom: 1rem;
}

#shippingConfirmation {
    margin-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}
#shippingConfirmation h3 {
    color: var(--success-color);
    margin-bottom: 1rem;
}
#downloadWaybillLink {
    display: inline-block;
    margin-top: 0.5rem;
    background-color: var(--accent-color);
    color: var(--text-light);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
}
#downloadWaybillLink:hover {
    background-color: darken(var(--accent-color), 10%);
    text-decoration: none;
}

/* --- Success Popup --- */
.popup-success {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--success-color);
    color: var(--text-light);
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-medium);
    z-index: 1500;
    display: flex;
    align-items: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity var(--transition-speed) ease, transform var(--transition-speed) ease;
}
.popup-success.show {
    opacity: 1;
    transform: translateY(0);
}
.popup-success.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none; /* Prevent interaction when hidden */
}
.popup-icon {
    font-size: 1.5rem;
    margin-right: 0.75rem;
}

/* --- Responsiveness --- */

/* For tablets and smaller desktops */
@media (max-width: 992px) {
    .navMenu {
        position: fixed; /* Fixed position for mobile overlay */
        left: 0;
        top: 0; /* Start from top */
        height: 100vh; /* Full height */
        transform: translateX(-100%); /* Initially hidden */
        box-shadow: var(--box-shadow-medium);
    }
    .navMenu.open {
        transform: translateX(0);
    }
    #hamburger {
        display: block; /* Show hamburger on smaller screens */
    }
    .banner { /* Push banner content slightly if hamburger is there */
        padding-left: 60px;
    }

    .right {
        padding: 1rem; /* Reduce padding */
    }

    .search-filters {
        flex-direction: column;
        align-items: stretch;
    }
    .date-search, .keyword-search {
        flex-direction: column;
        align-items: stretch;
    }
    .search-filters input[type="date"],
    .search-filters input[type="text"],
    .search-filters button {
        width: 100%;
    }

    .analytics-grid {
        grid-template-columns: 1fr; /* Stack cards */
    }
}


/* For mobile phones */
@media (max-width: 768px) {
    /* Responsive Table: Stack rows */
    table thead {
        display: none; /* Hide table header */
    }
    table, table tbody, table tr, table td {
        display: block;
        width: 100%;
    }
    table tr {
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius);
        overflow: hidden; /* Clip content */
        box-shadow: var(--box-shadow-light);
    }
    table td {
        text-align: right; /* Align content to the right */
        padding-left: 50%; /* Create space for the label */
        position: relative;
        border-bottom: 1px solid #f0f0f0; /* Lighter border between td */
    }
    table td:last-child {
        border-bottom: none;
    }
    table td span { /* Ensure span takes full width for alignment if needed */
        display: block;
        text-align: right;
    }
    table td::before {
        content: attr(data-label); /* Use data-label for pseudo-header */
        position: absolute;
        left: 10px; /* Position label to the left */
        width: calc(50% - 20px); /* Adjust width */
        padding-right: 10px;
        font-weight: 600;
        text-align: left;
        color: var(--primary-color);
    }
    .action-buttons {
        text-align: center !important; /* Center buttons in mobile view */
        padding-left: 10px !important; /* Override padding for action buttons */
    }
    .action-buttons::before {
        display: none; /* No label needed for action buttons cell */
    }
    .action-buttons button {
        display: block; /* Stack buttons */
        width: calc(100% - 20px); /* Full width buttons with margin */
        margin: 0.5rem auto;
    }

    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }
    .modal-content h3 {
        font-size: 1.3rem;
    }

    .analytics-filters {
        flex-direction: column;
        align-items: stretch;
    }
    .analytics-filters select, .analytics-filters button {
        width: 100%;
    }

    .popup-success {
        width: calc(100% - 40px); /* Full width with padding */
        left: 20px;
        right: 20px;
        bottom: 10px;
    }
}

/* Utility class for hidden pic section in HTML */
.pic.hidden {
 display: none;
}
.contain {
    display: grid;
    /* Use your desired column ratio for desktop */
    grid-template-columns: 1fr 4fr; /* Or consider '260px 1fr' if sidebar has fixed width */

    /* Ensure it takes appropriate vertical space */
    height: calc(100vh - 50px); /* Adjust 50px if banner height is different */
    overflow: hidden; /* Hide potential overflow within the grid */
}

/* --- Responsiveness --- */

/* For tablets and smaller desktops */
@media (max-width: 992px) { /* Or your chosen breakpoint */
    .contain {
        /* Disable the grid layout on smaller screens */
        display: block;

        /* Allow height to adjust based on content in block layout */
        height: auto;
        /* Allow content overflow as the navMenu is fixed/overlay */
        overflow: visible;
    }

    /* Ensure the right content takes full width in the block layout */
    .right {
        width: 100%;
        /* Add necessary padding at the top to account for the banner/hamburger */
        padding-top: 60px; /* Adjust this value as needed */
        /* ... keep other mobile styles for .right ... */
    }

    /* Ensure navMenu becomes fixed/overlay */
    .navMenu {
        position: fixed;
        /* ... keep other fixed/mobile specific styles for navMenu ... */
         transform: translateX(-100%); /* Ensure it starts hidden */
         /* ... keep transition and z-index ... */
    }

    /* Ensure hamburger is displayed */
     #hamburger {
        display: block;
        /* ... keep other hamburger styles including fixed position and z-index ... */
    }

    /* Adjust banner padding for hamburger */
     .banner {
         padding-left: 60px; /* Adjust this value as needed */
     }

    /* ... keep other styles for this media query (search filters, analytics grid, etc.) ... */
}

/* Ensure styles for the 'open' class on navMenu are defined */
.navMenu.open {
    transform: translateX(0); /* Slide into view when open */
}

/* Keep the existing styles for the smaller mobile breakpoint (max-width: 768px) */
/* ... @media (max-width: 768px) styles ... */

/* --- Analytics Section - Text Truncation for Product Names --- */
.analytics-card #topProductsChart li,
.analytics-card #topProductsChart p { /* Target potential list items or paragraphs holding product names */
    white-space: nowrap;       /* Prevent the text from wrapping to the next line */
    overflow: hidden;          /* Hide any text that overflows the element's box */
    text-overflow: ellipsis;   /* Display an ellipsis (...) to indicate truncated text */

    /*
     * Set a maximum width for the element. This is crucial because
     * overflow/text-overflow only work when the content's natural width
     * exceeds the element's defined width or max-width.
     * Adjust the percentage (e.g., 85%) as needed. It should be wide
     * enough for most reasonable product names but small enough to
     * truncate very long ones and leave space for quantity information
     * if displayed on the same line.
     */
    max-width: 85%; /* Example: Adjust this percentage based on layout */

    /*
     * Use display: inline-block; so that max-width is respected and
     * the element can sit on the same line as other potential content
     * (like the quantity).
     */
    display: inline-block;
    vertical-align: top;   /* Helps with vertical alignment if needed */
}

/* If you have other elements next to the product name (like quantity in a span), */
/* you might need to ensure they also stay on the same line. */
/* Example if your structure is like <li><span>Product Name</span> (Qty)</li> */
.analytics-card #topProductsChart li span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%; /* Make the span take max width within its LI parent */
    display: inline-block;
    vertical-align: top;
}

/* Ensure margin is still applied for spacing between list items */
.analytics-card #topProductsChart li {
    margin-bottom: 0.5rem; /* Keep your existing spacing */
}