── Generic CRUD System Styles ──────────────────────────────────────────── */
/* Matches the device list layout (table-page-container pattern from site.css). */

/* ── Header row (column titles) ────────────────────────────────────────── */
.crud-grid-table thead .crud-header-row th {
    background-color: #6c757d;
    color: #fff;
    vertical-align: middle;
    white-space: nowrap;
    font-size: 0.8125rem;
    padding: 0.4rem 0.5rem;
    box-sizing: border-box;
    user-select: none;
}

/* ── Sort icons ────────────────────────────────────────────────────────── */
.crud-sort-icon-default {
    opacity: 0.35;
    font-size: 0.7rem;
}

/* ── Filter row inside thead ───────────────────────────────────────────── */
.crud-grid-table thead .crud-filter-row th {
    background-color: #f8f9fa;
    padding: 0.2rem 0.3rem;
    vertical-align: middle;
    box-sizing: border-box;
    white-space: normal;
    overflow: hidden;
    border-top: 1px solid #dee2e6;
}

.crud-filter-row.d-none {
    display: none;
}

.crud-filter-cell select,
.crud-filter-cell input {
    font-size: 0.72rem;
    padding: 0.15rem 0.3rem;
    height: 1.7rem;
    border-radius: 0.25rem;
}

.crud-filter-cell {
    min-width: 0;
}

.crud-filter-cell .crud-filter-control {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    width: 100%;
    min-width: 0;
}

.crud-filter-cell .crud-filter-op {
    flex: 0 0 2.2rem;
    width: 2.2rem;
    max-width: 2.2rem;
    padding: 0.15rem 0.1rem;
    text-align: center;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    cursor: pointer;
}

.crud-filter-cell .crud-filter-op::-webkit-calendar-picker-indicator {
    display: none !important;
}

.crud-filter-cell .crud-filter-val {
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}

.crud-filter-cell .crud-filter-val:disabled {
    background-color: #e9ecef;
}

.crud-filter-op-menu {
    position: fixed;
    z-index: 1080;
    min-width: max-content;
    max-height: min(22rem, calc(100vh - 1rem));
    overflow-y: auto;
    padding: 0.25rem 0;
}

.crud-filter-op-menu .crud-filter-op-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    white-space: nowrap;
}

.crud-filter-op-menu .crud-filter-op-symbol {
    flex: 0 0 1.75rem;
    width: 1.75rem;
    text-align: center;
    font-weight: 700;
}

/* ── Filter bar (legacy, kept for compatibility) ──────────────────────── */
.crud-filter-bar {
    background: #f8f9fa;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
}

.crud-filter-toggle {
    font-size: 0.8125rem;
}

.crud-filter-bar .crud-filter-operator {
    flex: 0 0 2.6rem;
    width: 2.6rem;
    max-width: 2.6rem;
    padding-right: 0.2rem;
    text-align: center;
    font-weight: 600;
}

.crud-filter-bar .crud-filter-operator::-webkit-calendar-picker-indicator {
    display: none !important;
}

/* ── CRUD page body (tablePage-like scroll container) ──────────────────── */
.crud-page-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;          /* parent controls clip, no nested scrollbar */
}

.crud-page-body .table-responsive {
    height: 100%;
    overflow-y: auto;          /* only the table wrapper scrolls */
}

/* ── Table wrapper — enables horizontal scroll on narrow viewports ────── */
.crud-table-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

/* ══════════════════════════════════════════════════════════════════════════
   GRID TABLE — desktop defaults
   ══════════════════════════════════════════════════════════════════════════ */
.crud-grid-table {
    margin-bottom: 0;
    font-size: 0.875rem;
    table-layout: fixed;
    width: 100%;
    min-width: 600px;
}

.crud-grid-table thead th {
    background-color: #6c757d;
    color: #fff;
    vertical-align: middle;
    white-space: nowrap;
    font-size: 0.8125rem;
    padding: 0.5rem 0.4rem;
    box-sizing: border-box;
    border-right: 1px solid #dee2e6;
}

.crud-grid-table thead th:last-child {
    border-right: 0;
}

.crud-grid-table tbody td {
    vertical-align: middle;
    padding: 0.35rem 0.4rem;
    height: 36px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-sizing: border-box;
    border-right: 1px solid #dee2e6;
}

.crud-grid-table tbody td:last-child {
    border-right: 0;
}

.crud-row {
    cursor: pointer;
    transition: background-color 0.15s ease;
    height: 36px;
}

/* ══════════════════════════════════════════════════════════════════════════
   FIXED-COLUMN MODE — locks desktop dimensions at every viewport width.
   Critical: uses px (not rem) so that html { font-size: 14px } in site.css
   does not shrink the table on narrow screens.
   Overrides Bootstrap .table and site.css global table selector.
   ══════════════════════════════════════════════════════════════════════════ */
.crud-grid-table.crud-grid-table-fixed {
    table-layout: auto !important;
    width: auto !important;
    font-size: 14px !important;           /* 0.875rem × 16px = 14px, locked */
}

.crud-grid-table.crud-grid-table-fixed thead th {
    font-size: 13px !important;           /* 0.8125rem × 16px = 13px */
    padding: 8px 6px !important;          /* reduced horizontal gap between columns */
    white-space: nowrap !important;
    border-right: 1px solid #dee2e6 !important;
}

.crud-grid-table.crud-grid-table-fixed thead th:last-child {
    border-right: 0 !important;
}

.crud-grid-table.crud-grid-table-fixed tbody td {
    padding: 5px 6px !important;          /* reduced horizontal gap between columns */
    height: 36px !important;
    font-size: 14px !important;
    white-space: nowrap !important;
    border-right: 1px solid #dee2e6 !important;
}

.crud-grid-table.crud-grid-table-fixed tbody td:last-child {
    border-right: 0 !important;
}

.crud-grid-table.crud-grid-table-fixed .crud-row {
    height: 36px !important;
}

/* ── Sticky header ─────────────────────────────────────────────────────── */
.crud-grid-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

/* ── Row hover ─────────────────────────────────────────────────────────── */
.crud-row:hover {
    background-color: rgba(108, 117, 125, 0.08);
}

/* Current row (set on click, tracked by record id) */
.crud-row.crud-row-current {
    background-color: rgba(13, 110, 253, 0.12);
    box-shadow: inset 3px 0 0 0 var(--bs-primary, #0d6efd);
}

.crud-row.crud-row-current:hover {
    background-color: rgba(13, 110, 253, 0.16);
}

/* Campi CRUD mode: hide operator buttons, widen value inputs to full column width */
.crud-filter-row.crud-mode-edit .crud-filter-op {
    display: none !important;
}

.crud-filter-row.crud-mode-edit .crud-filter-val,
.crud-filter-row.crud-mode-edit .crud-multiselect-dd {
    width: 100% !important;
    flex: 1 1 100% !important;
}

/* Active toolbar action button (insert/edit awaiting completion) */
.crud-tb-btn.crud-tb-btn-active {
    background-color: var(--bs-warning, #ffc107);
    border-color: var(--bs-warning, #ffc107);
    color: #212529;
}


/* ── Placeholder row (for height measurement) ────────────────────────── */
.crud-placeholder-row td {
    color: transparent;
    user-select: none;
    pointer-events: none;
}

/* ── Sortable headers ────────────────────────────────────────────────── */
.crud-sortable {
    cursor: pointer;
    user-select: none;
}

.crud-sortable:hover {
    color: #fff;
    background-color: #5a6268;
}

/* ── Filter count badge ──────────────────────────────────────────────── */
.crud-filter-count {
    font-size: 0.65rem;
}

/* ── Action buttons ──────────────────────────────────────────────────── */
.crud-btn-edit,
.crud-btn-delete {
    padding: 0.125rem 0.375rem;
    font-size: 0.75rem;
    line-height: 1;
}

/* ── Create / Reload buttons ─────────────────────────────────────────── */
.crud-btn-create {
    background-color: #6c757d;
    border-color: #6c757d;
    color: #fff;
}
.crud-btn-create:hover {
    background-color: #5a6268;
    border-color: #5a6268;
    color: #fff;
}

.crud-btn-reload {
    background-color: #6c757d;
    border-color: #6c757d;
    color: #fff;
}
.crud-btn-reload:hover {
    background-color: #5a6268;
    border-color: #5a6268;
    color: #fff;
}

.crud-filter-apply {
    background-color: #6c757d;
    border-color: #6c757d;
    color: #fff;
}
.crud-filter-apply:hover {
    background-color: #5a6268;
    border-color: #5a6268;
    color: #fff;
}

/* ── Modal form ──────────────────────────────────────────────────────── */
.crud-modal-body {
    padding: 1.5rem;
}

.crud-form {
    font-size: 0.875rem;
}

.crud-form label {
    font-weight: 500;
    margin-bottom: 0.125rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: #6c757d;
}

.crud-form .form-control-plaintext {
    font-size: 0.875rem;
    padding: 0.375rem 0;
}

/* ── Multiselect dropdown filter ──────────────────────────────────── */
.crud-multiselect-dd {
    display: inline-flex;
    flex: 1 1 auto;
    min-width: 0;
}

.crud-multiselect-btn {
    font-size: 0.72rem;
    padding: 0.15rem 0.4rem;
    height: 1.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.crud-multiselect-menu {
    max-height: 300px;
    overflow-y: auto;
    min-width: 160px;
    font-size: 0.8rem;
}

.crud-multiselect-menu .crud-multiselect-item {
    cursor: pointer;
    user-select: none;
    padding: 0.2rem 0.5rem;
    font-size: 0.78rem;
}

.crud-multiselect-menu .crud-multiselect-item:hover {
    background-color: #e9ecef;
}

.crud-multiselect-cb {
    width: 0.8rem;
    height: 0.8rem;
    margin: 0;
    cursor: pointer;
}

/* ── Toolbar row ───────────────────────────────────────────────────── */
.crud-toolbar-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
}

/* Title on the left */
.crud-toolbar-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #495057;
    flex-shrink: 0;
}

/* Center section: pagination + action buttons */
.crud-toolbar-center {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0 auto;
    flex-shrink: 0;
}

/* Page info: combined text (Pagina x di y · N righe) */
.crud-page-info {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: #6c757d;
    white-space: nowrap;
    flex-shrink: 0;
}

.crud-page-info-sep {
    color: #adb5bd;
    font-weight: 300;
}

.crud-page-info-rows {
    color: #adb5bd;
}

/* Icon-only toolbar buttons — uniform size */
.crud-tb-btn {
    width: 2rem;
    height: 2rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

/* Linked-descriptor toolbar button group keeps compact toolbar height */
.btn-group.crud-tb-btn {
    width: auto;
}
.btn-group.crud-tb-btn > .btn {
    height: 2rem;
    padding: 0 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

/* Back-to-origin button: highlighted when a link context is active */
.crud-btn-linkback {
    background-color: #cfe2ff;
    border-color: #9ec5fe;
    color: #052c65;
}
.crud-btn-linkback:hover {
    background-color: #b6d4ff;
    border-color: #79aefd;
}

/* Filter button: blue tint when filters are active */
.crud-btn-filter.crud-btn-filter-active {
    background-color: #cfe2ff;
    border-color: #9ec5fe;
    color: #052c65;
}
.crud-btn-filter.crud-btn-filter-active:hover {
    background-color: #b6d4ff;
    border-color: #79aefd;
}

/* Clear-filters button: hidden by default, shown when filters applied */
.crud-btn-clear {
    display: none;
}

/* ══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — toolbar & responsive-mode table adjustments only
   Fixed-mode tables (.crud-grid-table-fixed) are completely excluded.
   ══════════════════════════════════════════════════════════════════════════ */

/* Tablet and below */
@media (max-width: 991.98px) {
    .table-page-container .table-page-card {
        padding: 0.5rem !important;
    }

    .crud-toolbar-row .btn,
    .crud-page-body .btn-group .btn {
        font-size: 0.75rem;
        padding: 0.2rem 0.4rem;
    }

    .section-title {
        font-size: 1rem;
    }
}

/* Phone */
@media (max-width: 767.98px) {
    /* ── Responsive-mode tables only ── */
    .crud-grid-table:not(.crud-grid-table-fixed) {
        table-layout: auto !important;
        width: auto !important;
        min-width: 500px;
        font-size: 0.8rem;
    }

    .crud-grid-table:not(.crud-grid-table-fixed) thead th {
        font-size: 0.72rem;
        padding: 0.35rem 0.4rem;
    }

    .crud-grid-table:not(.crud-grid-table-fixed) tbody td {
        padding: 0.25rem 0.4rem;
        height: 32px;
        font-size: 0.78rem;
    }

    .crud-grid-table:not(.crud-grid-table-fixed) .crud-row {
        height: 32px;
    }

    /* ── Wrapper always scrolls ── */
    .crud-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ── Action buttons ── */
    .crud-btn-edit,
    .crud-btn-delete {
        padding: 0.1rem 0.3rem;
        font-size: 0.68rem;
    }

    /* ── Filter row ── */
    .crud-filter-cell .crud-filter-op {
        flex: 0 0 1.8rem;
        width: 1.8rem;
        max-width: 1.8rem;
    }

    .crud-filter-cell select,
    .crud-filter-cell input {
        font-size: 0.68rem;
    }

    .crud-multiselect-btn {
        font-size: 0.68rem;
    }

    /* ── Toolbar: stack into two rows ── */
    .crud-toolbar-row {
        justify-content: space-between;
    }

    .crud-toolbar-title {
        font-size: 1rem;
    }

    .crud-toolbar-center {
        order: 2;
        margin: 0.2rem 0;
        width: 100%;
        justify-content: center;
    }

    .crud-page-info {
        font-size: 0.7rem;
    }

    .section-title {
        font-size: 0.95rem;
        margin-bottom: 0.35rem;
        padding-bottom: 0.25rem;
    }

    .crud-modal-body {
        padding: 1rem;
    }

    .crud-form .col-md-6 {
        width: 100%;
    }
}

/* Small phones */
@media (max-width: 575.98px) {
    /* ── Responsive-mode tables only ── */
    .crud-grid-table:not(.crud-grid-table-fixed) {
        table-layout: auto !important;
        width: auto !important;
        min-width: 400px;
        font-size: 0.75rem;
    }

    .crud-grid-table:not(.crud-grid-table-fixed) thead th {
        font-size: 0.68rem;
        padding: 0.25rem 0.3rem;
    }

    .crud-grid-table:not(.crud-grid-table-fixed) tbody td {
        padding: 0.2rem 0.3rem;
        height: 28px;
        font-size: 0.72rem;
    }

    .crud-grid-table:not(.crud-grid-table-fixed) .crud-row {
        height: 28px;
    }

    /* ── Toolbar: ultra-compact ── */
    .crud-toolbar-row .btn {
        font-size: 0.65rem;
        padding: 0.12rem 0.25rem;
    }

    .crud-toolbar-row .btn-group .btn {
        font-size: 0.65rem;
        padding: 0.12rem 0.25rem;
    }

    .crud-toolbar-row > small {
        font-size: 0.65rem;
    }

    .section-title {
        font-size: 0.85rem;
    }

    .crud-filter-cell .crud-filter-op {
        flex: 0 0 1.5rem;
        width: 1.5rem;
        max-width: 1.5rem;
        font-size: 0.6rem;
    }

    .crud-filter-cell select,
    .crud-filter-cell input {
        font-size: 0.62rem;
        padding: 0.1rem 0.2rem;
        height: 1.4rem;
    }

    .crud-multiselect-btn {
        font-size: 0.62rem;
        padding: 0.1rem 0.25rem;
        height: 1.4rem;
    }
}