/* Penyesuaian tampilan bersama; aturan data, izin, dan transaksi tidak diubah. */
.app-main :is(.container-fluid, .row > *, .card, .card-header, .card-body, .card-footer),
.modal :is(.modal-content, .modal-body),
.dt-container,
.dataTables_wrapper,
.table-controls {
    min-width: 0;
}

.app-main :is(h1, h2, h3, dd, .card-footer, .alert),
.modal :is(.modal-title, .modal-body p) {
    overflow-wrap: anywhere;
}

.card-header.d-flex::before,
.card-header.d-flex::after,
.card-footer.d-flex::before,
.card-footer.d-flex::after {
    display: none;
}

.table-responsive {
    max-width: 100%;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
}

.inventory-table-scroll:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

/* Ringkasan HP dan pemicu aksi tidak menambah kolom pada desktop. */
.mobile-table-summary,
.mobile-actions-trigger,
.mobile-table-action-label { display: none; }
.mobile-table-actions { display: inline-flex; align-items: center; gap: .25rem; }
.mobile-table-actions.is-open {
    position: fixed;
    z-index: 1090;
    display: flex;
    flex-direction: column;
    gap: .25rem;
    width: 10.5rem;
    max-width: calc(100vw - 1rem);
    padding: .375rem;
    border: 1px solid var(--bs-border-color);
    border-radius: .75rem;
    background: var(--bs-body-bg);
    box-shadow: 0 .5rem 1.5rem rgb(15 23 42 / 18%);
}
.mobile-table-actions.is-open .btn {
    display: flex;
    align-items: center;
    gap: .625rem;
    width: 100%;
    min-height: 2.75rem;
    border: 0;
    border-radius: .375rem;
    padding: .625rem .75rem;
    text-align: start;
    font-size: .875rem;
    box-shadow: none;
}
.mobile-table-actions.is-open .mobile-table-action-label { display: inline; }



.receipt-item-names {
    display: block;
    min-width: 0;
    overflow-wrap: anywhere;
}

@media (max-width: 991.98px) {
    /* Tombol Pilih tetap terlihat saat tabel modal digeser. */
    .modal .picker-action {
        position: sticky;
        right: 0;
        z-index: 2;
        min-width: 4.5rem;
        background-color: var(--bs-body-bg);
        border-inline-start: 1px solid var(--bs-border-color);
    }

    .modal thead .picker-action {
        z-index: 3;
        background-color: var(--bs-tertiary-bg);
    }

    .app-main .card-header.d-flex,
    .app-main .card-footer.d-flex {
        flex-wrap: wrap;
        gap: .5rem;
    }

    .app-main .card-header .card-title {
        float: none;
        max-width: 100%;
        line-height: 1.4;
    }

    .app-main .card-header > .btn,
    .app-main .card-header > .d-flex:not(.flex-column):last-child {
        margin-inline-start: auto;
    }

    .app-main .card-header > .d-flex:not(.flex-column):last-child {
        flex-wrap: wrap;
        justify-content: flex-end;
        max-width: 100%;
    }

    .dt-container,
    .dataTables_wrapper {
        width: 100%;
        max-width: 100%;
    }

    .dt-container table.dataTable,
    .dataTables_wrapper table.dataTable {
        width: 100% !important;
    }

    /* Colgroup tidak boleh menyisakan ruang untuk sel yang disembunyikan di layar kecil. */
    .dt-container table.dataTable > colgroup,
    .dataTables_wrapper table.dataTable > colgroup {
        display: none;
    }
}

@media (max-width: 767.98px) {
    /* HP menampilkan No., informasi utama, dan aksi dalam tabel yang sama. */
    .mobile-table-container {
        display: flex;
        flex-direction: column;
        gap: .75rem;
    }

    .mobile-table-container > .row,
    .mobile-table-container > .row > [class*="col-"] { display: contents !important; }
    .mobile-table-container .dt-search { order: 0; }
    .mobile-table-container .inventory-table-scroll { order: 1; }
    .mobile-table-container .dt-info { order: 2; }
    .mobile-table-container .dt-length { order: 3; }
    .mobile-table-container .dt-paging { order: 4; }
    .mobile-table-container .dt-search label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
    .mobile-table-container .dt-search input { width: 100% !important; flex-basis: 100%; }

    table[data-mobile-table] {
        display: table;
        width: 100% !important;
        min-width: 0 !important;
        table-layout: fixed;
        border-collapse: separate;
        border-spacing: 0;
        border: 1px solid var(--bs-border-color);
        border-radius: .625rem;
        overflow: hidden;
        margin-block: 0 !important;
    }
    table[data-mobile-table] > colgroup { display: none; }
    table[data-mobile-table] > :is(thead, tbody) > tr > [data-mobile-column="other"] { display: none !important; }
    table[data-mobile-table] > :is(thead, tbody) > tr > :is([data-mobile-column="number"], [data-mobile-column="title"], [data-mobile-column="actions"]) {
        display: table-cell !important;
        width: auto !important;
        padding: .875rem .625rem;
        border: 0;
        border-bottom: 1px solid var(--bs-border-color);
        vertical-align: top;
        white-space: normal;
        overflow-wrap: anywhere;
    }
    table[data-mobile-table] > thead > tr > [data-mobile-column] {
        padding-block: .75rem;
        font-size: .8125rem;
        vertical-align: middle;
    }
    table[data-mobile-table] > :is(thead, tbody) > tr > [data-mobile-column="number"] {
        width: 2.5rem !important;
        padding-inline: .375rem;
        white-space: nowrap;
        text-align: center;
        color: var(--bs-secondary-color);
        font-size: .75rem;
        font-variant-numeric: tabular-nums;
    }
    table[data-mobile-table] > :is(thead, tbody) > tr > [data-mobile-column="actions"] {
        width: 3.75rem !important;
        padding-inline: .375rem;
        text-align: center;
        white-space: normal;
    }
    table[data-mobile-table] > tbody > tr:last-child > td { border-bottom: 0; }
    table[data-mobile-table] > tbody > tr > td[colspan] {
        padding: 1.25rem .75rem;
        white-space: normal;
    }
    table[data-mobile-table] .mobile-table-title {
        font-size: .9375rem;
        font-weight: 600;
        line-height: 1.5;
        color: var(--bs-emphasis-color);
    }
    table[data-mobile-table] .mobile-table-title > .d-lg-none { display: none !important; }
    .mobile-table-summary { display: block; margin-top: .25rem; }
    .mobile-table-code,
    .mobile-table-date,
    .mobile-table-field {
        margin-top: .125rem;
        color: var(--bs-secondary-color);
        font-size: .8125rem;
        font-weight: 400;
        line-height: 1.6;
        overflow-wrap: anywhere;
    }
    .mobile-table-badges { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .375rem; }
    .mobile-table-badges > span {
        padding: .125rem .375rem;
        border-radius: .375rem;
        background: var(--bs-primary-bg-subtle);
        color: var(--bs-primary-text-emphasis);
        font-size: .75rem;
        font-weight: 500;
        line-height: 1.6;
    }
    table[data-mobile-table] .mobile-actions-trigger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 2.75rem;
        min-width: 2.75rem;
        height: 2.75rem;
        padding: .375rem;
        border-color: transparent;
        background: transparent;
        font-size: 1.125rem;
    }
    table[data-mobile-table] .mobile-table-actions { display: none; }
    table[data-mobile-table] .picker-action .btn { min-width: 0; min-height: 2.75rem; width: 100%; padding-inline: .25rem; }

    .dt-container > .row,
    .dataTables_wrapper > .row,
    .dt-container .dt-layout-row:not(.dt-layout-table) {
        row-gap: .75rem;
        margin-top: .5rem;
        margin-bottom: .75rem;
    }

    .dt-container > .row > [class*="col-"],
    .dataTables_wrapper > .row > [class*="col-"],
    .dt-container .dt-layout-row:not(.dt-layout-table) > .dt-layout-cell {
        width: 100%;
        min-width: 0;
        flex: 0 0 100%;
        padding-top: 0;
    }

    .dt-container :is(.dt-length, .dt-search),
    .dataTables_wrapper :is(.dataTables_length, .dataTables_filter) {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-start;
        gap: .375rem;
        width: 100%;
        margin: 0;
        text-align: start;
    }

    .dt-container :is(.dt-length, .dt-search) label,
    .dataTables_wrapper :is(.dataTables_length, .dataTables_filter) label {
        margin: 0;
    }

    .dataTables_wrapper .dataTables_filter label {
        display: flex;
        align-items: center;
        gap: .375rem;
        width: 100%;
    }

    .dt-container .dt-search input,
    .dataTables_wrapper .dataTables_filter input {
        flex: 1 1 10rem;
        width: auto !important;
        min-width: 0;
        max-width: 100%;
        margin: 0 !important;
    }

    .dt-container .dt-length select,
    .dataTables_wrapper .dataTables_length select {
        width: auto;
        margin: 0 .125rem;
    }

    .dt-container .dt-info,
    .dataTables_wrapper .dataTables_info {
        width: 100%;
        padding-top: 0;
        text-align: start !important;
        white-space: normal;
        font-size: .875rem;
    }

    .dt-container .dt-paging,
    .dataTables_wrapper .dataTables_paginate {
        max-width: 100%;
        overflow-x: auto;
        text-align: start;
    }

    .dt-container .pagination,
    .dataTables_wrapper .pagination {
        flex-wrap: nowrap;
        justify-content: flex-start !important;
        width: max-content;
        min-width: 0;
        margin: 0 !important;
        padding: .125rem 0;
    }

    .dt-container .page-link,
    .dataTables_wrapper .page-link {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 2.75rem;
        min-height: 2.75rem;
        padding: .375rem .5rem;
    }

    /* Teks asli tetap menjadi nama aksesibel; simbol menghemat ruang layar. */
    :is(.dt-container, .dataTables_wrapper) :is(.first, .previous, .next, .last) > .page-link,
    :is(.dt-container, .dataTables_wrapper) .page-link:is(.first, .previous, .next, .last) {
        font-size: 0;
    }

    :is(.dt-container, .dataTables_wrapper) .first > .page-link::before,
    :is(.dt-container, .dataTables_wrapper) .page-link.first::before { content: "«"; }
    :is(.dt-container, .dataTables_wrapper) .previous > .page-link::before,
    :is(.dt-container, .dataTables_wrapper) .page-link.previous::before { content: "‹"; }
    :is(.dt-container, .dataTables_wrapper) .next > .page-link::before,
    :is(.dt-container, .dataTables_wrapper) .page-link.next::before { content: "›"; }
    :is(.dt-container, .dataTables_wrapper) .last > .page-link::before,
    :is(.dt-container, .dataTables_wrapper) .page-link.last::before { content: "»"; }

    :is(.dt-container, .dataTables_wrapper) :is(.first, .previous, .next, .last) > .page-link::before,
    :is(.dt-container, .dataTables_wrapper) .page-link:is(.first, .previous, .next, .last)::before {
        font-size: 1.125rem;
        line-height: 1;
    }
}

@media (max-width: 575.98px) {
    .app-main .app-content,
    .app-main .app-content-header {
        padding-inline: 0;
    }

    .app-main > :is(.app-content, .app-content-header) > .container-fluid {
        padding-inline: 1rem;
    }

    .app-main .app-content-header {
        padding-top: .875rem;
        padding-bottom: .875rem;
    }

    .app-main .app-content-header h1 {
        font-size: 1.25rem !important;
        line-height: 1.4;
    }

    .app-main .card-header,
    .app-main .card-body,
    .app-main .card-footer {
        padding: 1rem;
    }

    .app-main .table > :not(caption) > * > *,
    .modal .table > :not(caption) > * > * {
        padding: .625rem .5rem;
    }

    .app-main .table,
    .modal .table {
        font-size: .875rem;
    }

    .app-main .table th,
    .modal .table th {
        white-space: nowrap;
    }

    .app-main .table :is(th, td):first-child,
    .modal .table :is(th, td):first-child {
        width: 2.75rem;
        white-space: nowrap;
    }

    .app-main .table td:last-child:has(.btn),
    .modal .table td:last-child:has(.btn) {
        white-space: nowrap;
    }

    .app-main .table .btn-sm,
    .modal .table .btn-sm {
        min-width: 2.75rem;
        min-height: 2.75rem;
        padding: .375rem .5rem;
    }

    /* Master Data memiliki tiga kolom terlihat di HP: No., Nama, dan Aksi. */
    #masterTable {
        table-layout: fixed;
    }

    #masterTable :is(th, td):last-child {
        width: 6.5rem;
    }

    #masterTable td:not(:first-child):not(:last-child) {
        overflow-wrap: anywhere;
    }

    .app-main :is(.form-control, .form-select),
    .modal :is(.form-control, .form-select),
    .login-page :is(.form-control, .form-select) {
        min-height: 2.75rem;
        font-size: 1rem;
    }

    .app-main textarea.form-control,
    .modal textarea.form-control {
        min-height: 6rem;
    }

    .app-main :is(.btn, .form-label),
    .modal .btn {
        white-space: normal;
    }

    .app-main .card-header .btn,
    .app-main .card-footer .btn,
    .app-main .btn:not(.btn-sm),
    .modal .btn:not(.btn-sm),
    .modal-footer .btn,
    .login-page .btn {
        min-height: 2.75rem;
    }

    .item-picker-input {
        gap: .5rem;
    }

    .item-picker-input > .form-control:not([type="hidden"]),
    .item-picker-input > .btn {
        flex: 1 0 100%;
        width: 100%;
        margin-inline-start: 0 !important;
        border-radius: var(--bs-border-radius) !important;
    }

    .app-main .card-footer.d-flex > .btn {
        flex: 1 1 8rem;
    }

    .modal-dialog {
        max-width: calc(100% - 1rem);
        margin: .5rem;
    }

    .modal-dialog-scrollable {
        height: calc(100% - 1rem);
    }

    .modal-dialog-scrollable .modal-content {
        max-height: calc(100vh - 1rem);
        max-height: calc(100dvh - 1rem);
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: .875rem;
    }

    .modal-title {
        min-width: 0;
        font-size: 1.0625rem !important;
        line-height: 1.4;
    }

    .modal-header .btn-close {
        flex-shrink: 0;
    }

    .modal-footer {
        gap: .5rem;
    }

    .modal-footer > * {
        margin: 0;
    }

    .app-header .nav-link {
        min-width: 2.75rem;
        min-height: 2.75rem;
    }

    .app-footer {
        padding: .75rem;
        padding-bottom: max(.75rem, env(safe-area-inset-bottom));
        font-size: .8125rem;
        line-height: 1.5;
        overflow-wrap: anywhere;
    }

    .dashboard-stat .card-body {
        flex-wrap: wrap;
        align-content: space-between;
    }

    .dashboard-stat .card-body > :last-child {
        margin-inline-start: auto;
    }

    .login-page > .container {
        padding-block: 1.5rem !important;
    }
}


/* AUDIT 2026-11-24: pilihan tabel tanpa kolom No. dan tanpa kolom Aksi. */
@media (max-width: 767.98px) {
  .inventory-app table[data-mobile-table].mobile-without-number > :is(thead,tbody) > tr > [data-mobile-column="title"] { width: calc(100% - 3.75rem) !important; }
  .inventory-app table[data-mobile-table].mobile-without-actions > :is(thead,tbody) > tr > [data-mobile-column="title"] { width: 100% !important; }
  .inventory-app table[data-mobile-table].mobile-without-number.mobile-without-actions > :is(thead,tbody) > tr > [data-mobile-column="title"] { width: 100% !important; }
  .inventory-app .mobile-table-container .inventory-table-scroll { width: 100%; }
  .inventory-app table[data-mobile-table] td .badge { display: inline-block; max-width: 100%; white-space: normal; }
  .inventory-app .mobile-table-field { display: block; }
  .inventory-app .mobile-table-title { min-width: 0; }
}

/* Readonly detail tables and selected-item form: cards on phone, normal table on desktop. */
@media (max-width: 639.98px) {
  .inventory-app table[data-card-table] { display: block; width: 100%; }
  .inventory-app table[data-card-table] thead { display: none; }
  .inventory-app table[data-card-table] tbody { display: grid; grid-template-columns: minmax(0,1fr); gap: .75rem; }
  .inventory-app table[data-card-table] tbody tr {
    display: grid; grid-template-columns: minmax(0,1fr); min-width: 0;
    border: 1px solid var(--bs-border-color); border-radius: .65rem;
    background: var(--bs-body-bg); padding: .625rem .75rem;
  }
  .inventory-app table[data-card-table] tbody tr > td {
    display: flex; flex-direction: column; align-items: flex-start;
    min-width: 0; width: 100% !important; border: 0 !important;
    border-bottom: 1px solid var(--bs-border-color) !important;
    white-space: normal !important; overflow-wrap: anywhere;
    padding: .5rem 0 !important;
    text-align: start !important;
  }
  .inventory-app table[data-card-table] tbody tr > td:last-child { border-bottom: 0 !important; }
  .inventory-app table[data-card-table] tbody tr > td::before {
    content: attr(data-cell-label); display: block;
    font-size: .6875rem; line-height: 1.5; font-weight: 600;
    color: var(--bs-secondary-color); margin-bottom: .125rem;
  }
  .inventory-app table[data-card-table] tbody tr > td :is(input, select, textarea) { width: 100%; }
  .inventory-app table[data-card-table] tbody tr > td > .btn { margin-top: .25rem; }
  .inventory-app .app-content .card-header > .d-flex { min-width: 0; flex-wrap: wrap; }
  .inventory-app .app-content .card-header .btn { white-space: normal; }
}

/* Mudah dioperasikan di perangkat sentuh dan laptop beresolusi kecil. */
@media (max-width: 575.98px) {
  .inventory-app .app-content .card-header > .btn,
  .inventory-app .app-content .card-header > .d-flex:last-child { max-width: 100%; }
  .inventory-app .form-actions > :is(.btn,button) { flex: 1 1 100%; width: 100%; }
  .inventory-app .form-actions > form { width: 100%; }
  .inventory-app .form-actions > form > .btn { width: 100%; }
  .inventory-app .dt-container .dt-search { min-width: 0; }
  .inventory-app .dt-container .dt-search input { max-width: 100%; }
  .inventory-app .app-header .navbar-nav { min-width: 0; }
  .inventory-app .app-header .dropdown-menu { max-width: calc(100vw - 1rem); }
}
@media (max-width: 359.98px) {
  .inventory-app .dashboard-stat { flex-basis: 100%; width: 100%; max-width: 100%; }
}
