html {
    overflow: hidden;
}

body {
    overflow: hidden;
    display: flex;
    margin: 0;
    height: 100dvh; /* Full screen height */
}

nav {
    width: 70px;
    background-color: #343a40;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
}

nav a {
    color: #ffffff;
    text-decoration: none;
    padding: 20px 0;
    text-align: center;
    width: 100%;
}

nav a:hover {
    background-color: #34383d;
}

nav .active {
    background-color: #495057 !important;
}

.hidden {
    display: none !important;
}

main {
    margin-left: 70px;
    display: flex;
    flex-direction: column;
    width: calc(100% - 70px);
}

.modal-dialog {
    z-index: 1250 !important;
}

#headerBar {
    background-color: white;
    border-bottom: 1px solid #dee2e6;
    top: 0;
    z-index: 1050;
}

#condensedHeaderBar {
    background-color: white;
    border-bottom: 1px solid #dee2e6;
    z-index: 1050;
}

#headerBar h1, #condensedHeaderBar h1 {
    margin: 0;
    padding: 10px 15px;
}

#searchBar {
    padding: 10px 15px;
    background-color: #f8f9fa;
}

#dashboard {
    overflow: auto;
}

.list-table {
    overflow-y: auto;
}

.list-table.condensed {
    width: 370px;
    flex-grow: 0;
    flex-shrink: 0;
    /* overflow-y: auto; Scrollable content */
    position: relative; /* Ensure proper stacking context */
}

#partTable.condensed th:nth-child(1), /* Image column */
#partTable.condensed td:nth-child(1), /* Image cells */
#partTable.condensed th:nth-child(4), /* Quantity column */
#partTable.condensed td:nth-child(4), /* Quantity cells */
#partTable.condensed th:nth-child(5), /* Price column */
#partTable.condensed td:nth-child(5)  /* Price cells */ {
    display: none !important;
}

#vendorTable.condensed th:nth-child(2), 
#vendorTable.condensed td:nth-child(2),
#vendorTable.condensed th:nth-child(3),  
#vendorTable.condensed td:nth-child(3),
#vendorTable.condensed th:nth-child(4), 
#vendorTable.condensed td:nth-child(4)  {
    display: none !important;
}

#purchaseTable.condensed th:nth-child(4), 
#purchaseTable.condensed td:nth-child(4)  {
    display: none !important;
}

.list-table.condensed tr{
    height: 44px;
}

tr.highlight td{
    background-color: #88c092;
}

#partsList tr td img{
    width: 46px;
    padding: 2px;
    aspect-ratio: 4 / 4;
    object-fit: cover;
}

/* Condensed headerBar styling */
#headerBar.condensed {
    width: 25%; /* Adjust width to match the partTable's condensed size */
    transition: width 0.3s ease; /* Smooth transition */
    position: fixed; /* Keep it fixed while condensed */
    left: 0;
    top: 0;
    height: 100%; /* Full height */
    overflow: hidden; /* Prevent content overflow */
}

#headerBar.condensed{
    display: none; /* Hide title and search bar in condensed mode */
}

#condensedHeaderBar{
    display: none;
}

#condensedHeaderBar.condensed{
    display: block;
}

#tableAndPanelWrapper {
    display: flex;
    flex-grow: 1;
    height: 100%; /* Ensure it occupies full height */
    overflow-y: auto;
}

.flexible-section {
    transition: flex 0.3s ease; /* Smooth resizing for both table and details */
}

.item-details {
    flex-grow: 1;
    display: none; /* Hidden by default */
    overflow-y: auto;
    /* background-color: #f9f9f9; */
    /* padding: 20px; */
    background-color: #fff; /* White background */
    padding: 20px;
    border-left: 1px solid #dee2e6; /* Border to separate from partTable */
    box-shadow: -1px 0 5px rgba(0, 0, 0, 0.1); /* Subtle shadow for depth */
}

.item-details.show {
    display: block;
}

.item-details .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.item-details .header h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

.item-details .header h2 {
    font-size: 18px;
    font-weight: 400;
    color: #6c757d;
    margin: 0;
}

.item-details .header p {
    font-size: 14px;
    color: #6c757d;
}

.item-details .header .actions button {
    border: none;
    background-color: transparent;
    color: #007bff;
    font-size: 14px;
    cursor: pointer;
}

.item-details .header .actions button:hover {
    color: #0056b3;
}

.item-details .content p {
    font-size: 16px;
    margin: 10px 0;
    line-height: 1.5;
}

.item-details .content p span {
    font-weight: 500;
    display: inline-block;
    margin-right: 10px;
}

/* Make the search box wider */
#addPartsSearch{
    flex: 2; /* Give it more space relative to the other elements */
    min-width: 300px; /* Minimum width */
}

/* Make the quantity box narrower */
#addPartsQuantity, #addProductsQuantity {
    flex: 1; /* Less space than the search box */
    max-width: 100px; /* Limit the maximum width */
}

#searchResults{
    max-height: 175px;
    overflow-y: scroll;
}
#searchResults{
    max-height: 250px;
    overflow-y: scroll;
}

/* Save Button Changes */
#saveButton {
    color: #6c757d;
    font-size: 14px;
    font-weight: 500;
    border: none;
    background-color: transparent;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 4px;
    transition: color 0.2s, background-color 0.2s;
}

#saveButton.edited {
    color: #fff;
    background-color: #28a745; /* Green to indicate changes */
}

#saveButton:hover {
    color: #fff;
    background-color: #218838; /* Darker green on hover */
}

.item-details .notes {
    font-size: 14px;
    color: #6c757d;
    margin-top: 20px;
    line-height: 1.6;
}

/* Print and Save Buttons */
.item-details .d-flex {
    margin-top: 0px;
}

/* Header Section */
.image-container {
    flex-shrink: 0;
    width: 250px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    position: relative;
}

#partImage {
    width: 100%;
    object-fit: cover;
    aspect-ratio: 4/3;
}

#imageActions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
    z-index: 2;
}

#imageActions .imageButton {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.item-details .text-muted {
    font-size: 1rem;
}

.imageButton{
    width: 40px;
    height: 40px;
    padding: 0px !important;
    overflow: hidden; /* Ensures image stays inside */
    justify-content: center;
    align-items: center;
}

.preview-image{
    width: 100% !important;
    height: 100% !important;
    object-fit: cover; /* Ensures the image fills the button */
    object-position: center; /* Centers the image */
}

/* Nav Tabs */
.nav-tabs .nav-link {
    background-color: #e9ecef;
    border-color: #dee2e6;
}

.nav-tabs .nav-link.active {
    background-color: #28a745;
    color: white;
}

.clickable {
    cursor: pointer;
}

.edit-style {
    padding: 2px 10px;
    cursor: pointer;
    border: 1px dashed transparent;
    border-radius: 3px;
    width: 100%;
}

.disabled-style {
    padding: 2px 10px;
    cursor: default;
    border: 1px dashed transparent;
    border-radius: 3px;
    width: 100%;
    background: none !important;  
    color: rgb(33, 37, 41) !important; /* Default text color */
}

.edit-style:hover {
    border-color: #ccc; /* Highlight on hover */
    background-color: #f9f9f9; /* Optional: Light background */
}

.disabled-style:hover {
    background: none; /* Optional: Light background */
}

/* Mobile-only adjustments */
@media (max-width: 576px) {
    /* Move the login modal dialog down so it isn't cut off at the top */
    #loginModal .modal-dialog {
        margin: 100px auto 1.75rem !important;
    }

    /* Controls in the item-details header: stack print buttons below other controls */
    .item-details .controls-row {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }

    .item-details .controls-right {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    /* Ensure the print buttons are on their own line below the other action buttons */
    .item-details .print-buttons {
        order: 2; /* Move after primary action buttons */
        width: 100%;
        display: flex;
        justify-content: flex-end;
        gap: 0.5rem;
        margin-top: 0.25rem;
    }

    .item-details .action-buttons {
        order: 1;
        display: flex;
        gap: 0.5rem;
        align-items: center;
    }
}

/* Desktop/default layout for the controls so markup changes don't break non-mobile views */
.item-details .controls-row {
    display: flex; /* keep the top-level row as a flex container */
    flex-direction: row;
    gap: 0.5rem;
    align-items: center;
}

.item-details .controls-right {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-end;
}

.item-details .print-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    order: 0;
}

.item-details .action-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    order: 0;
}

.edit-style.editing {
    border-color: #007bff; /* Blue border for editing mode */
    background-color: #eaf4ff; /* Light blue background */
    outline: none; /* Remove default outline */
}

textarea.edit-style {
    width: 100%;
    resize: vertical; /* Allow vertical resizing */
}

.no-edit {
    padding: 2px 10px;
    border: none;
    border-radius: 3px;
    cursor: default;
    background: none !important;
    color: black !important;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table thead {
    top: 90px; /* Adjust to match the height of the headerBar + searchBar */
    background-color: white;
    z-index: 5;
}



#partsList tr {
    height: 52px;
    scroll-margin-top: 45px;
}

.sortable {
    cursor: pointer;
}

.sortable:hover {
    text-decoration: underline;
}

#assemblyPartsSku{
    width: 15%;
}

#assemblyPartsName{
    width: 50%;
}

#assemblyPartsQuantity{
    width: 29%;
}

.purchaseDataHeader{
    font-size: 1.5rem;
}

#purchaseContentProduct{
    width: 24%;
}

#purchaseContentVendorSku{
    width: 18%;
}

#purchaseContentQuantity{
    width: 18%;
}

#purchaseContentPrice{
    width: 16%;
}

#purchaseContentTotal{
    width: 14%;
}

#purchaseContentAction{
    width: 5%;
}

.actions-cell{
    cursor: pointer;
}

.edit-quantity{
    cursor: pointer;
}

#unsavedChangesModal .hidden {
    display: none !important;
}

#unsavedChangesModal{
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1060;
}

.modalShow{
    display: flex !important;
}

#unsavedChangesModal .modal-content {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
}

#unsavedChangesModal .modal-actions {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
}

#vendorSelect {
    max-height: 150px; /* Adjust height to show up to 4 rows */
    overflow-y: auto; /* Enable scrolling */
}

#vendorOverviewContainer{
    width: 100%;
}

#vendorOverview{
    max-width: 400px;
}

.save-input {
    position: relative;
    display: inline-block;
}

.save-input input {
    padding-right: 2rem; /* space for icon */
}

.input-save-icon {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    color: #28a745;
    cursor: pointer;
    display: none; /* shown only when needed */
    z-index: 2;
}

.text-muted{
    color: #c1c1c1 !important;
}

.detailsContainer{
    max-width: 1000px;
}

.clickable:hover{
    cursor: pointer;
}

@media (min-width: 1200px) {
}

@media (max-width: 1199.98px) {
    .image-container {
        width: 250px;
    }
}

@media (max-width: 991.98px) {
    .image-container {
        width: 100%;
    }

    .imageButton{
        width: 70px;
        height: 70px;
        padding: 0px !important;
        overflow: hidden; /* Ensures image stays inside */
        justify-content: center;
        align-items: center;
    }
}

@media (max-width: 767px) {
    nav {
        height: auto;
    }
    nav.vh-100 {
        display: none !important;
    }

    main {
        margin-left: 0;
        margin-top: 48px;
    }

    nav.navbar {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 1200;
    }

    .mobile-nav-link {
        padding: 10px 15px;
        margin: 5px 10px;
        background-color: #343a40;
        border-radius: 5px;
        text-align: center;
        transition: background-color 0.3s;
    }

    .mobile-nav-link:hover {
        background-color: #495057;
    }

    .mobile-nav-link:active {
        background-color: #212529;
    }

    .mobile-nav-link {
        font-size: 16px;
        font-weight: bold;
    }

    .list-table.condensed {
        display: none;
    }
}
