/* ==========================================================================
   Chari Pay - Liste des transactions
   S'appuie sur les tokens .cp-dash de dashboard.css (chargé avant ce fichier).
   Fichier externe : la CSP (style-src 'self' 'nonce-…') bloque les styles inline.
   ========================================================================== */

/* ---------- Carte filtres ---------- */
.cp-tx-filters .card-body {
    padding: 1.5rem;
}

.cp-tx-search {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.cp-tx-search__field {
    position: relative;
    flex: 1 1 320px;
    min-width: 0;
}

.cp-tx-search__icon {
    position: absolute;
    top: 50%;
    left: 1rem;
    transform: translateY(-50%);
    color: var(--cp-muted);
    pointer-events: none;
}

.cp-tx-search__input.form-control {
    height: 48px;
    padding-left: 2.9rem;
    border-radius: var(--cp-radius-sm);
    font-size: 0.95rem;
}

.cp-tx-btn.btn {
    height: 48px;
    border-radius: var(--cp-radius-sm);
    padding-inline: 1.25rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.cp-tx-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1.25rem;
}

.cp-tx-field .form-label {
    color: var(--bs-gray-600);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.45rem;
}

.cp-tx-field .form-select,
.cp-tx-field .form-control {
    height: 46px;
    border-radius: var(--cp-radius-sm);
    font-size: 0.95rem;
}

/* Période : un libellé, deux champs date (début / fin) sur deux colonnes */
.cp-tx-field--period {
    grid-column: span 2;
}

.cp-tx-dates {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
}

.cp-tx-date.cp-tx-date--plain .form-control {
    padding-left: 1rem;
}

/* Dates de début / fin : tout le champ ouvre le calendrier */
.cp-tx-date {
    position: relative;
    cursor: pointer;
}

.cp-tx-date > [class*="ki-"] {
    position: absolute;
    left: 0.95rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.cp-tx-date .form-control {
    padding-left: 2.6rem;
    font-weight: 600;
    color: var(--cp-text);
    cursor: pointer;
}

/* L'icône native est masquée : le clic n'importe où sur le champ ouvre le calendrier */
.cp-tx-date input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 0;
    cursor: pointer;
}

/* Champs de filtre : curseur main sur les listes */
.cp-tx-field .form-select:not(:disabled) {
    cursor: pointer;
}

/* Raccourcis de période + filtres actifs */
.cp-tx-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px dashed var(--cp-border);
}

.cp-tx-presets,
.cp-tx-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.cp-tx-preset {
    border: 1px solid var(--cp-border);
    background: var(--cp-card-bg);
    color: var(--bs-gray-700);
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.cp-tx-preset:hover,
.cp-tx-preset:focus-visible {
    border-color: var(--bs-primary);
    color: var(--bs-primary);
    background: var(--bs-primary-light, #e9f3ff);
    outline: none;
}

.cp-tx-chips__label {
    color: var(--cp-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.cp-tx-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.5rem 0.3rem 0.8rem;
    border-radius: 999px;
    background: var(--bs-primary-light, #e9f3ff);
    color: var(--bs-primary, #1b84ff);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
}

.cp-tx-chip:hover {
    color: var(--bs-primary-active, #056ee9);
}

.cp-tx-chip__x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(27, 132, 255, 0.15);
    font-size: 0.75rem;
    line-height: 1;
}

.cp-tx-reset {
    color: var(--bs-danger, #f8285a);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
}

.cp-tx-reset:hover {
    text-decoration: underline;
    color: var(--bs-danger, #f8285a);
}

/* ---------- Tableau ---------- */
.cp-tx-table .card-header {
    border-bottom: 0;
    padding-top: 1.25rem;
    min-height: auto;
}

.cp-tx-table .card-body {
    padding-top: 0.5rem;
}

.cp-tx-table table.dataTable {
    margin-top: 0 !important;
}

.cp-tx-table table.dataTable thead th {
    background: var(--bs-gray-100, #f9f9f9);
    color: var(--bs-gray-600);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    padding-top: 0.9rem;
    padding-bottom: 0.9rem;
    border-bottom: 0;
}

.cp-tx-table table.dataTable thead th:first-child {
    border-top-left-radius: var(--cp-radius-sm);
    border-bottom-left-radius: var(--cp-radius-sm);
    padding-left: 1rem;
}

.cp-tx-table table.dataTable thead th:last-child {
    border-top-right-radius: var(--cp-radius-sm);
    border-bottom-right-radius: var(--cp-radius-sm);
    padding-right: 1rem;
}

.cp-tx-table table.dataTable tbody td {
    padding-top: 0.9rem;
    padding-bottom: 0.9rem;
    color: var(--bs-gray-800);
    vertical-align: middle;
}

.cp-tx-table table.dataTable tbody td:first-child {
    padding-left: 1rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Montant (2e colonne) */
.cp-tx-table table.dataTable tbody td:nth-child(2) {
    font-weight: 700;
    color: var(--cp-text);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.cp-tx-table table.dataTable tbody tr {
    transition: background-color 0.12s ease;
}

.cp-tx-table table.dataTable tbody tr:hover > td {
    background: var(--bs-gray-100, #f9f9f9);
}

.cp-tx-table .badge {
    border-radius: 999px;
    font-weight: 600;
}

/* Lignes cliquables (data-href) */
tr.cp-row-link {
    cursor: pointer;
}

tr.cp-row-link:focus-visible {
    outline: 2px solid var(--bs-primary, #1b84ff);
    outline-offset: -2px;
}

.cp-tx-table table.dataTable tbody tr.cp-row-link:hover > td:first-child {
    box-shadow: inset 3px 0 0 var(--bs-primary, #1b84ff);
}

/* Pagination / longueur */
.cp-tx-table .dataTables_wrapper .pagination .page-item .page-link {
    border-radius: 8px;
}

.cp-tx-table .dataTables_wrapper .dataTables_length select {
    border-radius: 8px;
}

/* ---------- Responsive ---------- */
@media (max-width: 767.98px) {
    .cp-tx-filters .card-body { padding: 1.1rem; }
    .cp-tx-field--period { grid-column: auto; }
    .cp-tx-search .cp-tx-btn { flex: 1 1 auto; }
    .cp-tx-toolbar { flex-direction: column; align-items: flex-start; }
}
