/**
 * ERP filter card — layout, controls, tags, buttons (RTL-safe utilities: ms-*, me-* in Blade).
 */

/* --- Card shell ---------------------------------------------------------- */
.erp-filter-card {
    --erp-filter-border: rgba(0, 0, 0, 0.12);
    --erp-filter-muted: var(--bs-secondary-color, #6c757d);
    border: 0.5px solid var(--erp-filter-border);
    border-radius: 12px;
    background: var(--bs-body-bg, #fff);
}

.erp-filter-card__inner {
    padding: 14px 16px;
}

.erp-filter-card__head {
    min-height: 1.25rem;
}

.erp-filter-gutter {
    --bs-gutter-x: 10px;
    --bs-gutter-y: 10px;
}

/* --- Labels -------------------------------------------------------------- */
.erp-filter-label {
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    line-height: 1.2;
    color: var(--erp-filter-muted);
    font-weight: 400;
}

/* --- Controls (34px) ------------------------------------------------------ */
.erp-ctrl {
    display: block;
    width: 100%;
    height: 34px;
    min-height: 34px;
    padding: 0 10px;
    font-size: 13px;
    line-height: 1.25;
    color: var(--bs-body-color);
    background-color: var(--bs-body-bg);
    border: 0.5px solid var(--erp-filter-border);
    border-radius: 8px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.erp-ctrl:focus {
    border-color: #1a6fc4;
    outline: 0;
    box-shadow: 0 0 0 2px rgba(26, 111, 196, 0.15);
}

select.erp-ctrl {
    cursor: pointer;
}

/* Select wrapper + custom chevron (RTL: arrow flips with dir on html) */
.erp-sel-wrap {
    position: relative;
    width: 100%;
}

.erp-sel-wrap select.erp-ctrl {
    appearance: none;
    -webkit-appearance: none;
    padding-inline-end: 28px;
}

.erp-sel-wrap::after {
    content: '';
    position: absolute;
    top: 50%;
    inset-inline-end: 10px;
    width: 0;
    height: 0;
    margin-top: -3px;
    border-inline-start: 4px solid transparent;
    border-inline-end: 4px solid transparent;
    border-top: 5px solid var(--erp-filter-muted);
    pointer-events: none;
}

.erp-sel-wrap--select2::after {
    display: none;
}

/* Select2 (Bootstrap 5 theme) inside filter card — match .erp-ctrl 34px, vertically centered text */
.erp-filter-card .select2-container {
    display: block !important;
    min-width: 0 !important;
}

.erp-filter-card .select2-container--bootstrap-5 .select2-selection {
    min-height: 34px !important;
    font-size: 13px;
}

.erp-filter-card .select2-container--bootstrap-5 .select2-selection--single {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    height: 34px !important;
    border-radius: 8px !important;
    border: 0.5px solid var(--erp-filter-border, rgba(0, 0, 0, 0.12)) !important;
}

.erp-filter-card .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    line-height: 1.25 !important;
    height: auto !important;
    padding-block: 0 !important;
    padding-inline-start: 10px;
    padding-inline-end: 28px;
    display: flex !important;
    align-items: center !important;
    flex: 1 1 auto;
    min-width: 0;
}

/* Theme keeps arrow absolute; fixed line-height on arrow column caused optical misalignment */
.erp-filter-card .select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    height: 100% !important;
    min-height: 34px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/*
 * Row 2: single horizontal band — [180px PO/field] [search flex:1] [Filter] [Reset]
 * nowrap keeps search on the same row as PO type + buttons (no full-width stack).
 */
.erp-filter-row2 {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 10px;
    margin-top: 10px;
    min-width: 0;
}

.erp-filter-row2__po {
    flex: 0 0 180px;
    width: 180px;
    max-width: 180px;
    min-width: 0;
}

.erp-filter-row2__search {
    flex: 1 1 0;
    min-width: 0;
}

.erp-filter-row2__actions {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 8px;
}

/* Same 34px band: inputs and action buttons share one baseline */
.erp-filter-row2 .erp-ctrl,
.erp-filter-row2 .erp-btn-filter,
.erp-filter-row2 .erp-btn-reset {
    align-self: flex-end;
}

@media (max-width: 575.98px) {
    .erp-filter-row2 {
        overflow-x: auto;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
    }

    .erp-filter-row2__po {
        flex: 0 0 160px;
        width: 160px;
        max-width: 160px;
    }
}

/* Legacy class kept for any external use */
.erp-filter-po-type {
    flex: 0 0 180px;
    width: 180px;
    max-width: 180px;
    min-width: 0;
}

.erp-filter-search-grow {
    flex: 1 1 0;
    min-width: 0;
}

/* --- Tag strip ----------------------------------------------------------- */
.erp-filter-tags-panel {
    border-top: 0.5px solid var(--erp-filter-border);
    margin-top: 10px;
    padding-top: 10px;
}

.erp-filter-tags-panel.is-hidden {
    display: none !important;
}

.erp-filter-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.erp-active-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 4px 8px 4px 10px;
    font-size: 12px;
    line-height: 1.2;
    color: #0c447c;
    background: #e6f1fb;
    border: 0.5px solid #b5d4f4;
    border-radius: 999px;
}

.erp-active-tag__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #0c447c;
    cursor: pointer;
    line-height: 1;
    flex-shrink: 0;
}

.erp-active-tag__remove:hover {
    background: rgba(12, 68, 124, 0.12);
}

.erp-active-tag__text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Buttons ------------------------------------------------------------- */
.erp-btn-filter,
.erp-btn-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 34px;
    min-height: 34px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    border-radius: 8px;
    white-space: nowrap;
    cursor: pointer;
    border: 0.5px solid transparent;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.erp-btn-filter {
    color: #fff;
    background: #1a6fc4;
    border-color: #1a6fc4;
}

.erp-btn-filter:hover {
    background: #155a9e;
    border-color: #155a9e;
    color: #fff;
}

.erp-btn-filter svg,
.erp-btn-reset svg {
    flex-shrink: 0;
}

.erp-btn-reset {
    color: var(--bs-secondary, #6c757d);
    background: transparent;
    border-color: var(--erp-filter-border);
}

.erp-btn-reset:hover {
    background: var(--bs-light, #f8f9fa);
    color: var(--bs-body-color);
}

/* Clear all (link style) */
.erp-filter-clear-all {
    font-size: 12px;
    color: #1a6fc4 !important;
}

.erp-filter-clear-all:hover {
    text-decoration: underline !important;
    color: #155a9e !important;
}

/* --- Summary cards row (RTL-safe grid) ----------------------------------- */
.erp-summary-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

@media (min-width: 768px) {
    .erp-summary-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1200px) {
    .erp-summary-row {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.erp-summary-row__cell {
    min-width: 0;
}

.erp-summary-card {
    height: 100%;
    padding-block: 12px;
    padding-inline: 16px;
    background: #fff;
    border: 0.5px solid var(--erp-filter-border, rgba(0, 0, 0, 0.12));
    border-radius: 8px;
    box-shadow: none;
}

/* Subtle left-edge accents (RTL-safe); enterprise-style scan hierarchy */
.erp-summary-card--accent-info {
    border-inline-start: 3px solid rgba(13, 110, 253, 0.42);
    background-color: rgba(13, 110, 253, 0.045);
}

.erp-summary-card--accent-primary {
    border-inline-start: 3px solid rgba(13, 110, 253, 0.78);
    background-color: rgba(13, 110, 253, 0.07);
}

.erp-summary-card--accent-metric {
    border-inline-start: 3px solid rgba(33, 37, 41, 0.28);
    background-color: rgba(33, 37, 41, 0.04);
}

.erp-summary-card--accent-warning {
    border-inline-start: 3px solid rgba(186, 117, 23, 0.65);
    background-color: rgba(186, 117, 23, 0.06);
}

.erp-summary-card--accent-success {
    border-inline-start: 3px solid rgba(59, 109, 17, 0.6);
    background-color: rgba(59, 109, 17, 0.06);
}

.erp-summary-label {
    font-size: 11px;
    font-weight: 400;
    line-height: 1.2;
    color: var(--bs-secondary-color, #6c757d);
    margin-bottom: 4px;
}

.erp-summary-value {
    font-size: 20px;
    font-weight: 500;
    line-height: 1.25;
    margin-bottom: 4px;
    word-break: break-word;
}

.erp-summary-value.is-neutral {
    color: var(--bs-body-color, #212529);
}

.erp-summary-value.is-info {
    color: #1a6fc4;
}

.erp-summary-value.is-primary {
    color: var(--bs-primary, #0d6efd);
}

.erp-summary-card--accent-primary .erp-summary-value.is-primary {
    font-weight: 600;
    letter-spacing: -0.01em;
}

.erp-summary-card--accent-info .erp-summary-value.is-info {
    font-weight: 500;
}

.erp-summary-card--accent-warning .erp-summary-value.is-warning {
    font-weight: 600;
}

.erp-summary-card--accent-success .erp-summary-value.is-success {
    font-weight: 600;
}

.erp-summary-value.is-warning {
    color: #ba7517;
}

.erp-summary-value.is-danger {
    color: var(--bs-danger, #dc3545);
}

.erp-summary-value.is-success {
    color: #3b6d11;
}

.erp-summary-sub {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 11px;
    line-height: 1.2;
    color: var(--bs-secondary-color, #6c757d);
}

.erp-summary-sub__text {
    min-width: 0;
}

.erp-dot {
    flex-shrink: 0;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

/* --- Table toolbar (above responsive table, inside card) ------------------ */
.erp-table-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-block-end: 12px;
    margin-block-end: 12px;
    border-block-end: 0.5px solid var(--erp-filter-border, rgba(0, 0, 0, 0.12));
}

.erp-table-toolbar--actions-only {
    justify-content: flex-end;
}

.erp-table-toolbar__start {
    flex: 1 1 auto;
    min-width: 0;
}

.erp-table-toolbar__end {
    flex: 0 0 auto;
}

.erp-table-toolbar__title {
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--bs-body-color, #212529);
}

.erp-table-toolbar__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    height: 34px;
    padding: 0 12px;
    font-size: 13px;
    line-height: 1;
    border-radius: 8px;
    white-space: nowrap;
}

.erp-table-toolbar__btn i {
    font-size: 1rem;
    line-height: 1;
}

/* --- Sortable table headers -------------------------------------------- */
.erp-th-sortable {
    white-space: nowrap;
    vertical-align: middle;
}

.erp-th-sortable__link {
    max-width: 100%;
}

.erp-th-sortable__link:hover .erp-th-sortable__caret--muted {
    opacity: 0.65;
}

.erp-th-sortable__caret {
    flex-shrink: 0;
    font-size: 0.7rem;
    line-height: 1;
    opacity: 0.9;
}

.erp-th-sortable__caret--muted {
    opacity: 0.35;
}

/* --- Table pagination (summary + per-page + Bootstrap links) ---------------- */
.erp-table-pagination {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--erp-filter-border, rgba(0, 0, 0, 0.12));
}

@media (min-width: 768px) {
    .erp-table-pagination {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.erp-table-pagination__meta {
    flex: 1 1 auto;
    min-width: 0;
}

.erp-table-pagination__controls {
    flex: 0 1 auto;
    justify-content: flex-end;
}

.erp-table-pagination__per-page {
    width: auto;
    min-width: 4.25rem;
}

.erp-table-pagination__links .pagination {
    margin-bottom: 0;
}

/* --- Row actions (compact icon toolbar, RTL-safe gap) -------------------- */
.erp-row-actions {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    vertical-align: middle;
}

.erp-row-actions__form {
    display: inline-flex;
    align-items: center;
    margin: 0;
    padding: 0;
    line-height: 0;
}

.erp-action-btn {
    --erp-action-size: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--erp-action-size);
    min-width: var(--erp-action-size);
    height: var(--erp-action-size);
    min-height: var(--erp-action-size);
    padding: 0;
    line-height: 1;
    border-radius: 8px;
    transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease, border-color 0.12s ease,
        background-color 0.12s ease, color 0.12s ease;
}

.erp-action-btn i {
    font-size: 1rem;
    line-height: 1;
}

.erp-action-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.erp-action-btn:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 2px rgba(26, 111, 196, 0.25);
}

.erp-row-actions__form .erp-action-btn:disabled {
    opacity: 0.55;
    pointer-events: none;
}
