/**
 * Mobile layout: prevent page-level overflow / overlap below 768px.
 * Wide tables stay scrollable inside .table-responsive only.
 */
@media (max-width: 767.98px) {
    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    .wrapper,
    .content-wrapper,
    .content,
    .content-header,
    main {
        max-width: 100%;
        overflow-x: hidden;
    }

    img,
    video,
    canvas,
    svg {
        max-width: 100%;
        height: auto;
    }

    .content-header {
        padding: 0.75rem 0.75rem 1rem;
    }

    /* Admin 手機：店鋪下拉與下方內容拉開 */
    .content-header #shop-select,
    .content-header select#shop-select {
        margin-top: 0.25rem;
        margin-bottom: 0.5rem;
    }

    .content {
        padding: 0.5rem 0.75rem 1rem;
    }

    .content-header h1,
    .content-header .d-flex > h1 {
        font-size: 1.35rem;
        line-height: 1.3;
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .content-header .d-flex {
        flex-wrap: wrap !important;
        align-items: stretch !important;
        gap: 0.5rem;
    }

    .content-header select.form-control.w-auto,
    .content-header select.form-control {
        width: 100% !important;
        max-width: 100% !important;
    }

    .form-inline {
        display: flex;
        flex-direction: column;
        align-items: stretch !important;
    }

    .form-inline .form-group,
    .form-inline .form-control,
    .form-inline .btn {
        width: 100%;
        margin-right: 0 !important;
    }

    .btn-group {
        flex-wrap: wrap;
        max-width: 100%;
    }

    .btn-group > .btn {
        flex: 1 1 auto;
    }

    .card-header .d-flex,
    .mb-3.d-flex {
        flex-wrap: wrap !important;
        gap: 0.35rem;
    }

    .table-responsive {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .card-body.table-responsive,
    .card.table-responsive {
        overflow-x: auto;
    }

    .product-name {
        min-width: 0 !important;
        max-width: none !important;
    }

    .input-group-lg {
        flex-wrap: wrap;
    }

    .input-group-lg > .form-control,
    .input-group-lg > .btn {
        width: 100%;
        border-radius: 0.25rem !important;
        margin-top: 0.35rem;
    }

    .input-group-lg > .form-control:first-child {
        margin-top: 0;
    }

    .card-footer.d-flex {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .small-box h3 {
        font-size: 1.5rem;
    }

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

    .input-group[style*="320px"],
    .input-group[style*="width: 320"] {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* 列表工具列：直排全寬 */
    .product-toolbar,
    .list-toolbar {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.5rem;
        padding-bottom: 0.85rem !important;
    }

    .product-toolbar > a,
    .product-toolbar > button,
    .product-toolbar > div,
    .list-toolbar > a,
    .list-toolbar > button,
    .list-toolbar > div,
    .list-toolbar > form {
        width: 100%;
        margin-left: 0 !important;
        margin-right: 0 !important;
        margin-bottom: 0.5rem;
        padding-left: 0 !important;
    }

    .product-toolbar > :last-child,
    .list-toolbar > :last-child {
        margin-bottom: 0;
    }

    .product-toolbar .form-control,
    .product-toolbar .input-group,
    .product-toolbar select,
    .list-toolbar .form-control,
    .list-toolbar .input-group,
    .list-toolbar select,
    .list-toolbar .form-inline {
        width: 100% !important;
        max-width: 100% !important;
    }

}

/* 桌面：只靠 gap，避免再加 margin 造成空隙過大 */
.product-toolbar,
.list-toolbar {
    gap: 0.4rem;
}

@media (min-width: 768px) {
    .product-toolbar,
    .list-toolbar {
        padding-bottom: 0.65rem;
    }

    .product-toolbar-cube {
        min-width: 160px;
        max-width: 240px;
        margin-right: 0.5rem;
        margin-left: 0.15rem;
    }

    .product-toolbar-search,
    .list-toolbar-search {
        width: 260px;
    }

    /* 標題列店鋪下拉與內容區的距離 */
    .content-header {
        padding-bottom: 0.75rem;
    }

    .content-header + .content {
        padding-top: 0.35rem;
    }
}
