/* Admin-wide responsive polish for table-heavy screens. */
:root {
    --admin-surface: #ffffff;
    --admin-soft: #f7f9fc;
    --admin-border: #d9e1ec;
    --admin-ink: #263244;
    --admin-muted: #667085;
    --admin-accent: #2f6fed;
    --admin-success: #148a42;
    --admin-warning: #b26b00;
}

.content {
    max-width: 100%;
}

.card,
.modal-content,
.variant-card {
    border-radius: 8px !important;
}

.card.shadow-sm,
.modal-content.shadow,
.variant-card {
    box-shadow: 0 8px 22px rgba(31, 42, 68, 0.07) !important;
}

.table-responsive {
    border-radius: 8px;
}

.table-hover tbody tr,
.btn,
.form-control,
.form-select,
.modal-content,
.variant-card,
.card {
    transition: box-shadow 180ms ease, transform 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.table-hover > tbody > tr:hover {
    background-color: #f8fbff;
}

.btn:hover {
    transform: translateY(-1px);
}

.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 0.18rem rgba(47, 111, 237, 0.14);
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--admin-border);
    border-radius: 6px;
    min-height: 36px;
}

.dataTables_wrapper .dataTables_filter input {
    padding: 0.35rem 0.75rem;
}

.dataTables_wrapper .pagination .page-link {
    border-radius: 6px;
    margin: 0 2px;
}

.dataTables_processing {
    border: 1px solid var(--admin-border) !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 24px rgba(31, 42, 68, 0.12);
}

.admin-page-ready .card,
.admin-page-ready .variant-card,
.admin-page-ready .modal.show .modal-content {
    animation: adminFadeUp 220ms ease both;
}

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

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media (max-width: 991.98px) {
    .content {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    .modal-dialog {
        margin: 0.75rem;
    }

    .modal-dialog.modal-xl,
    .modal-dialog.modal-lg {
        max-width: calc(100vw - 1.5rem);
    }

    .sticky-top {
        position: static !important;
    }
}

@media (max-width: 767.98px) {
    .content {
        padding-left: 0.65rem;
        padding-right: 0.65rem;
    }

    .content > .d-flex,
    #scrollspyTables {
        align-items: flex-start !important;
        gap: 0.65rem;
        margin-bottom: 1.25rem !important;
    }

    .content h3 {
        font-size: 1.15rem;
    }

    .content .row.align-items-center > [class*="col-"] {
        text-align: left !important;
    }

    .content .row.align-items-center .text-end {
        margin-top: 0.75rem;
        text-align: left !important;
    }

    .card-body,
    .modal-body {
        padding: 0.85rem !important;
    }

    .modal-footer {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .modal-footer .btn {
        width: 100%;
    }

    .dataTables_wrapper .row {
        row-gap: 0.75rem;
    }

    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        text-align: left !important;
    }

    .dataTables_wrapper .dataTables_filter label,
    .dataTables_wrapper .dataTables_filter input,
    .dataTables_wrapper .dataTables_length label,
    .dataTables_wrapper .dataTables_length select {
        width: 100%;
    }

    .dataTables_wrapper .dataTables_paginate .pagination {
        flex-wrap: wrap;
        justify-content: flex-start !important;
        row-gap: 0.35rem;
    }

    table.admin-enhanced-table {
        border-collapse: separate !important;
        border-spacing: 0 0.75rem !important;
    }

    table.admin-enhanced-table > thead {
        display: none;
    }

    table.admin-enhanced-table > tbody,
    table.admin-enhanced-table > tbody > tr,
    table.admin-enhanced-table > tbody > tr > td {
        display: block;
        width: 100%;
    }

    table.admin-enhanced-table > tbody > tr {
        background: var(--admin-surface);
        border: 1px solid var(--admin-border);
        border-radius: 8px;
        box-shadow: 0 6px 16px rgba(31, 42, 68, 0.06);
        margin-bottom: 0.75rem;
        overflow: hidden;
        padding: 0.35rem 0;
    }

    table.admin-enhanced-table > tbody > tr.table-danger {
        border-color: #ef9a9a;
        background: #fff7f7;
    }

    table.admin-enhanced-table > tbody > tr.table-warning {
        border-color: #f0c36d;
        background: #fffaf0;
    }

    table.admin-enhanced-table > tbody > tr > td {
        border: 0 !important;
        min-height: 38px;
        padding: 0.55rem 0.85rem !important;
        text-align: left !important;
        white-space: normal !important;
    }

    table.admin-enhanced-table > tbody > tr > td[data-label]::before {
        color: var(--admin-muted);
        content: attr(data-label);
        display: block;
        font-size: 0.7rem;
        font-weight: 800;
        letter-spacing: 0;
        line-height: 1.2;
        margin-bottom: 0.15rem;
        text-transform: uppercase;
    }

    table.admin-enhanced-table > tbody > tr > td[data-label=""]::before,
    table.admin-enhanced-table > tbody > tr > td.actions::before {
        display: none;
    }

    table.admin-enhanced-table > tbody > tr > td .text-end,
    table.admin-enhanced-table > tbody > tr > td.text-end {
        text-align: left !important;
    }

    table.admin-enhanced-table > tbody > tr > td:last-child .btn,
    table.admin-enhanced-table .btn-sm {
        margin-bottom: 0.25rem;
    }

    .variants-container {
        max-width: 100%;
    }

    .variants-container .table-responsive,
    .variants-container table,
    .nested-stock-table {
        min-width: 520px;
    }

    .variants-container > .border {
        overflow-x: auto;
    }

    .status-flag {
        min-width: calc(50% - 0.5rem);
    }

    .qty-container > .d-flex {
        align-items: stretch !important;
        flex-direction: column;
    }

    .qty-container > .d-flex > div,
    .qty-container > .d-flex > button {
        width: 100% !important;
    }

    .product-form-page > .row,
    .product-form-page .variant-card .row {
        margin-left: 0;
        margin-right: 0;
    }

    .product-form-page > .row > [class*="col-"],
    .product-form-page .variant-card .row > [class*="col-"] {
        min-width: 0;
    }

    .product-form-page .d-flex.justify-content-between.align-items-center {
        align-items: stretch !important;
        flex-direction: column;
        gap: 0.75rem;
    }

    .product-form-page #addVariant,
    .product-form-page #submitProduct {
        border-radius: 6px !important;
        width: 100%;
    }

    .product-form-page .variant-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.55rem;
        padding: 0.85rem;
    }

    .product-form-page .variant-header > span {
        line-height: 1.35;
    }

    .product-form-page .variant-header .btn {
        align-self: stretch;
        border: 1px solid #f0b7b7;
        border-radius: 6px;
        padding: 0.4rem 0.55rem !important;
        text-align: left;
    }

    .product-form-page .status-flag {
        flex: 0 0 100%;
        min-width: 100%;
    }

    .product-form-page .select2-container {
        max-width: 100%;
        width: 100% !important;
    }

    .product-form-page .select2-container .select2-selection {
        min-height: 38px;
    }

    .product-form-page .input-group {
        flex-wrap: nowrap;
    }

    .product-form-page .image-upload-zone {
        max-width: 220px;
        margin-left: auto;
        margin-right: auto;
    }

    .product-form-page .card.border-0.shadow-sm.mb-5 .card-body {
        align-items: stretch;
        flex-direction: column;
    }

    .product-form-page .alert {
        align-items: flex-start !important;
    }
}
