/* ==========================
   Global reset
   ========================== */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

/* ==========================
   Container & Sections
   ========================== */
.order-container {
    display: flex;
    flex-direction: column;
    height: 90vh; /* full viewport */
    margin: 0; /* remove external margin to avoid overflow */
    gap: 4px;
}

.section {
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 8px;
    background-color: #fafafa;
}

.top-section {
    flex: 0 0 auto; /* do not shrink or grow */
}

.middle-section {
    flex: 1 1 auto; /* take remaining space */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* restrict overflowing content */
}

/* ==========================
   Table Styling
   ========================== */
/* Make MudTable container fill the middle section */
.order-lines-table thead th {
    position: sticky;
    top: 0;
    background-color: white;
    z-index: 10;
}

.sticky-table-container {
    max-height: 600px; /* Adjust height as needed */
    overflow-y: auto;
}

.sticky-table-header th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: white; /* Prevent transparency while scrolling */
}

.middle-section .order-lines-table {
    flex: 1;
    min-height: 0; /* important for flex to allow shrinking */
}

.middle-section .order-lines-table .mud-table-container {
    height: 100%; /* fill middle section */
    overflow-y: auto; /* scroll inside table */
}

.order-lines-table .mud-table-child-row {
    padding-left: 4px;
}

.expand-icon {
    margin-right: 2px;
    vertical-align: middle;
}

.full-width-table {
    width: 100%;
}

/* Optional: visually separate the child area */
.order-lines-table .mud-table-child-row .mud-paper {
    background: transparent;
}

/* Grid for child component table aligned with main table columns */
.component-table-container {
    background: #fafafa;
    padding: 8px 0;
}

.components-grid-header,
.components-grid-row {
    display: grid;
    grid-template-columns:
        60px     /* # */
        450px    /* Item Code */
        auto     /* Description */
        100px    /* Qty */
        100px    /* Min Qty */
        100px    /* Max Qty */
        120px    /* Price Net */
        60px     /* VAT */
        120px    /* Price Gross */
        100px    /* Weight */
        120px    /* Volume */
        60px; /* Delete */
    gap: 4px;
    padding: 2px 0;
    align-items: center;
}

.components-grid-header {
    font-weight: 600;
    border-bottom: 1px solid #ccc;
    padding-bottom: 4px;
    margin-bottom: 4px;
}

.components-grid-row {
    border-bottom: 1px solid #f0f0f0;
}

.components-grid-row > div {
    padding: 4px;
}

.components-grid-row div:nth-child(4),
.components-grid-row div:nth-child(5),
.components-grid-row div:nth-child(6),
.components-grid-header div:nth-child(4),
.components-grid-header div:nth-child(5),
.components-grid-header div:nth-child(6) {
    text-align: right;
}

/* ==========================
   Bottom Section
   ========================== */
.bottom-section {
    flex: 0 0 auto; /* fixed at bottom */
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.bottom-left,
.bottom-right {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.calc-box {
    padding: 4px;
    background-color: white;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.calc-label {
    font-weight: 600;
    font-size: 0.7rem;
    color: #8d8d8d;
    margin-bottom: 4px;
}

.calc-value {
    font-size: 0.8rem;
    font-weight: 700;
    color: #606060;
}

.calc-value-gross {
    font-size: 1rem;
    color: #000000;
}

.button-group {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
    margin-top: 12px;
}

/* ==========================
   Top Section / Info Grid
   ========================== */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 4px;
}

.info-item {
    display: flex;
    flex-direction: column;
}

.info-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: #666;
}

.info-value {
    font-size: 1rem;
    color: #333;
    margin-top: 4px;
}

/* ==========================
   Misc Styling
   ========================== */
.mud-table-cell-quantity-error-text {
    color: rgb(255, 0, 0) !important;
    font-weight: bold;
}

.mud-table-cell-quantity-error {
    background-color: rgba(255, 0, 0, 0.3) !important;
}

.mud-table-cell-quantity-error input {
    color: black !important;
}

/* small cosmetic rotation (optional) */
.rotated {
    transform: rotate(180deg);
    transition: transform 0.15s ease-in-out;
}

.sales-order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.button-group > * {
    margin-left: 8px; /* tiny gap between bottom buttons */
}

/* fade-in animation */
.fade-in {
    animation: fadeIn 200ms ease-in-out;
}

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

.centered {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 0;
}

.mt-2 {
    margin-top: .5rem;
}

/* Disable lines */
/* greyed-out effect */
.out-of-stock-row {
    opacity: 0.5;
}

.out-of-stock-row input,
.out-of-stock-row .mud-numeric-input {
    pointer-events: none;
    background-color: #f5f5f5 !important;
}

.out-of-stock-row .delete-button {
    pointer-events: auto;
    opacity: 1;
}