/* Tabela na uskom ekranu: red postaje kartica, zaglavlje traka za sortiranje. Pravilo i izuzeci: docs/tabele-na-telefonu.md */
@media screen and (max-width: 767.98px) {
    .table-responsive:not(.tabela-siroka *, .tabela-siroka) {
        overflow-x: visible;
    }

    .dtable-wrap:not(.tabela-siroka *, .tabela-siroka) {
        overflow: visible;
        border: 0;
        border-radius: 0;
        background: transparent;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *),
    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *) > :is(tbody, tfoot),
    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *) > :is(tbody, tfoot) > tr {
        display: block;
        width: 100%;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *) > :is(tbody, tfoot) > tr:is([hidden], .d-none, .collapse:not(.show)) {
        display: none;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *) thead {
        display: none;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *) thead:has(th a[href], th input) {
        display: block;
        margin-bottom: var(--space-lg);
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *) thead tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: var(--space-sm);
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *) thead:has(th a[href]) tr::before {
        content: "Sortiranje";
        flex: 0 0 100%;
        font-size: var(--font-size-sm);
        color: var(--color-text-muted);
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *) thead th {
        display: none;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *) thead th:has(a[href], input) {
        position: static;
        display: inline-flex;
        flex-wrap: wrap;
        align-items: center;
        gap: var(--space-sm);
        padding: 0;
        border: 0;
        background: transparent;
        font-size: 0;
        letter-spacing: 0;
        text-transform: none;
        white-space: nowrap;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *) thead th a[href],
    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *) thead th label:has(input) {
        display: inline-flex;
        align-items: center;
        gap: var(--space-xs);
        min-height: var(--btn-min-height);
        padding: 0 var(--space-lg);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-full);
        background: var(--color-bg);
        color: var(--color-text-secondary);
        font-size: var(--font-size-sm);
        font-weight: 500;
        text-decoration: none;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *) thead th a[href]:has(.bi-sort-up, .bi-sort-down) {
        border-color: var(--color-primary);
        background: var(--color-primary-light);
        color: var(--color-primary);
        font-weight: 600;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *) > :is(tbody, tfoot) > tr {
        margin-bottom: var(--space-lg);
        padding: var(--space-md) var(--space-xl);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        background: var(--color-bg);
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *) > tfoot > tr {
        background: var(--color-bg-subtle);
        font-weight: 600;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *) > :is(tbody, tfoot) > tr > :is(td, th) {
        position: relative;
        display: block;
        width: auto;
        min-width: 0;
        min-height: 2.25rem;
        padding: var(--space-sm) 0 var(--space-sm) 38%;
        border: 0;
        border-bottom: 1px solid var(--color-border-light);
        background: transparent;
        box-shadow: none;
        text-align: left !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *) > :is(tbody, tfoot) > tr > :is(td, th):last-child {
        border-bottom: 0;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *) > :is(tbody, tfoot) > tr > :is(td, th)::before {
        content: attr(data-label);
        position: absolute;
        top: var(--space-sm);
        left: 0;
        width: 34%;
        font-size: var(--font-size-sm);
        font-weight: 500;
        color: var(--color-text-muted);
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *) > :is(tbody, tfoot) > tr > :is(td, th):is([data-label=""], :not([data-label]), [colspan]) {
        padding-left: 0;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *) > :is(tbody, tfoot) > tr > :is(td, th):is([data-label=""], :not([data-label]), [colspan])::before {
        content: none;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *) > tbody > tr > .col-name,
    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *):has(> thead) > tbody > tr:not(:has(> .col-name)) > :first-child:not([colspan], :has(input, select)) {
        font-size: var(--font-size-lg);
        font-weight: 600;
        color: var(--color-text);
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *) > tbody > tr > td:is(:empty, [data-prazna]) {
        display: none;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *) > tbody > tr > td :is(.btn-row-action, .btn-action) {
        min-height: var(--btn-min-height);
        min-width: var(--btn-min-height);
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *) > tbody > tr > td :is(input:not([type="checkbox"], [type="radio"]), select, textarea) {
        width: 100%;
        min-width: 0;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *) thead th:has(input[type="checkbox"]):not(:has(a[href], label))::after {
        content: "Izaberite sve";
        margin-left: var(--space-sm);
        font-size: var(--font-size-sm);
        color: var(--color-text-secondary);
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *):not(:has(> thead)) > tbody > tr {
        margin-bottom: 0;
        padding: var(--space-sm) 0;
        border: 0;
        border-bottom: 1px solid var(--color-border-light);
        border-radius: 0;
        background: transparent;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *):not(:has(> thead)) > tbody > tr > th {
        padding-bottom: 0;
        border-bottom: 0;
        font-size: var(--font-size-sm);
        font-weight: 500;
        color: var(--color-text-muted);
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *):not(:has(> thead)) > tbody > tr > td {
        border-bottom: 0;
        color: var(--color-text);
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *) > tbody > tr:has(+ .red-nastavak:not([hidden], .d-none, .collapse:not(.show))) {
        margin-bottom: 0;
        border-bottom: 0;
        border-bottom-right-radius: 0;
        border-bottom-left-radius: 0;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *) > tbody > tr.red-nastavak {
        border-top: 0;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *) > tbody > tr:has(> .col-name):not([hidden], .d-none, .collapse:not(.show)) {
        display: flex;
        flex-direction: column;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *) > tbody > tr > .col-name {
        order: -1;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *) thead th:has(input[type="checkbox"]) > label.visually-hidden {
        position: static !important;
        width: auto !important;
        height: auto !important;
        margin: 0 0 0 var(--space-sm) !important;
        overflow: visible !important;
        clip: auto !important;
        white-space: nowrap !important;
        font-size: var(--font-size-sm);
        color: var(--color-text-secondary);
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *) > caption {
        display: block;
        text-align: left;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *) > :is(tbody, tfoot) > tr > .celija-siroka {
        padding-left: 0;
    }

    :is(.dtable, .table, .tabela-kartice):not(.tabela-siroka *, .tabela-svoj-raspored *) > :is(tbody, tfoot) > tr > .celija-siroka::before {
        position: static;
        display: block;
        width: auto;
        margin-bottom: var(--space-xs);
    }

    .dtable-footer:not(.tabela-siroka *) {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-md);
        border: 0;
        background: transparent;
    }
}
