/* =====================================================
   Depanneur Product Management – Custom Styles
   ===================================================== */

html, body {
    height: 100%;
    overflow-x: auto;   /* allow page-level horizontal scroll when content overflows */
    overflow-y: auto;
}

body {
    background-color: #f8f9fa;
    font-size: 0.9rem;
}

/* Table containers: fixed height so the div itself scrolls (not the page body).
   This enables sticky headers and keeps the horizontal scrollbar always visible. */
.table-responsive {
    overflow-x: scroll !important;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
    -webkit-overflow-scrolling: touch;
}

/* Sticky column headers: pin to the top of the scroll container */
.table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

/* No wrapping in any table cell — horizontal scrollbar handles overflow */
.table td {
    white-space: nowrap;
}

/* Editable table: tighten up input padding */
.editable-table input.form-control,
.editable-table select.form-select {
    padding: 2px 4px;
    font-size: 0.82rem;
}

.editable-table th {
    white-space: nowrap;
    font-size: 0.82rem;
}

/* Expandable parent tile (Purchase Order, Order Receive) */
.tile-parent {
    cursor: pointer;
    position: relative;
    min-height: 128px;
    user-select: none;
}
.tile-parent .tile-icon-lg {
    font-size: 2.6rem;
    color: #4a7fa0;
    margin: .5rem 0 .3rem;
}
.tile-chevron {
    position: absolute;
    top: 7px;
    right: 9px;
    font-size: .75rem;
    color: #b0c4d8;
    transition: transform .2s;
}
.tile-parent.expanded .tile-chevron {
    transform: rotate(180deg);
}
.tile-sub-actions {
    display: none;
    flex-direction: column;
    gap: 5px;
    width: 100%;
    margin-top: .5rem;
}
.tile-parent.expanded .tile-sub-actions {
    display: flex;
}

/* Sub-group label within a section (smaller than group-label) */
.sub-group-label {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #8da4b8;
    margin: 1rem 0 .45rem;
    padding-left: .1rem;
    border-left: 3px solid #c5d9e8;
    padding-left: .5rem;
}

/* Sticky save/action bar — sits just below the navbar when scrolling */
.sticky-action-bar {
    position: sticky;
    top: 56px;        /* Bootstrap navbar height */
    z-index: 90;
    background: #fff;
    border-bottom: 1px solid #dee2e6;
    padding: 6px 12px;
    margin-bottom: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,.08);
}

/* Navbar active link underline */
.navbar-nav .nav-link.active {
    border-bottom: 2px solid #fff;
}

/* Card header style */
.card-header {
    background-color: #e9ecef;
}

/* Report tables: cap description column width and truncate with ellipsis */
.col-desc {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Recommended products: force red text on every cell so Bootstrap table-striped
   CSS variable overrides on <td> do not swallow the row-level text-danger class */
.table > tbody > tr.text-danger > td,
.table > tbody > tr.text-danger > th {
    color: #dc3545 !important;
}

/* Click-to-edit display spans */
.field-display {
    cursor: pointer;
    display: inline-block;
    min-width: 20px;
    min-height: 1em;
    border-bottom: 1px dashed #adb5bd;
    font-size: 0.82rem;
    color: #495057;
}
.field-display:empty::after {
    content: '—';
    color: #ced4da;
}
.field-display:hover {
    border-bottom-color: #0d6efd;
    color: #0d6efd;
}

/* Sortable table headers */
.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.sortable:hover {
    filter: brightness(0.94);
}
.sort-icon {
    font-size: 0.72rem;
    opacity: 0.4;
    margin-left: 2px;
}
.active-sort {
    opacity: 1;
    color: #0d6efd;
}

/* Mobile: stack the filter card selectors vertically */
@media (max-width: 767px) {
    /* Selector dropdowns take full width */
    .card .row.g-2 > [class*="col-"] {
        width: 100%;
    }

    /* Report/action buttons wrap instead of overflow */
    .card .col-auto {
        width: 100%;
    }
    .card .col-auto .btn {
        width: 100%;
        margin-left: 0 !important;
        margin-top: 4px;
    }

    /* Editable table inputs: let them shrink on mobile */
    .editable-table input.form-control,
    .editable-table select.form-select {
        min-width: 60px;
        width: 100%;
    }

    /* Description column: allow wrapping on mobile */
    .col-desc {
        max-width: 140px;
        white-space: normal;
    }
}

/* Print: clean output */
@media print {
    .no-print,
    nav,
    .card,
    .alert {
        display: none !important;
    }

    body {
        background: white;
        font-size: 10pt;
    }

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

    th, td {
        border: 1px solid #000 !important;
        padding: 3px 5px;
    }
}
