/* ==========================================================================
   Chari Pay - Connexions (Marchand hosté / Marchand API)
   S'appuie sur dashboard.css (.cp-dash, .cp-page-header) et transactions.css
   (.cp-tx-search, .cp-tx-btn, .cp-tx-table).
   ========================================================================== */

/* ---------- Onglets segmentés ---------- */
.cp-seg {
    display: inline-flex;
    gap: 0.25rem;
    padding: 0.3rem;
    border-radius: 14px;
    background: var(--bs-gray-100, #f1f1f4);
    border: 1px solid var(--cp-border);
    max-width: 100%;
    overflow-x: auto;
}

.cp-seg__item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1rem;
    border-radius: 10px;
    color: var(--bs-gray-600);
    font-weight: 600;
    font-size: 0.92rem;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.cp-seg__item i,
.cp-seg__item span[class*="ki-"] {
    color: inherit;
}

.cp-seg__item:hover {
    color: var(--cp-text);
}

.cp-seg__item.is-active {
    background: var(--cp-card-bg);
    color: var(--bs-primary, #1b84ff);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 10px -4px rgba(15, 23, 42, 0.12);
}

/* ---------- Barre d'outils (onglets + recherche + actions) ---------- */
.cp-cx-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.cp-cx-toolbar .cp-tx-search {
    flex: 1 1 320px;
    justify-content: flex-end;
}

.cp-cx-toolbar .cp-tx-search__field {
    flex: 0 1 360px;
}

.cp-cx-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

/* Alertes de session */
.cp-dash .alert {
    border-radius: var(--cp-radius-sm);
    border: 0;
    font-weight: 500;
}

/* ---------- Tableau ---------- */
.cp-tx-table table.dataTable tbody td:first-child {
    color: var(--bs-gray-500);
    font-weight: 600;
}

.cp-tx-table table.dataTable tbody td:nth-child(2) {
    color: var(--cp-text);
    font-weight: 700;
}

/* Badge de statut */
.cp-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}

.cp-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.cp-badge--on  { background: var(--bs-success-light, #dfffea); color: #0e9f5b; }
.cp-badge--off { background: var(--bs-gray-100, #f1f1f4);      color: var(--bs-gray-600); }

/* Bouton modifier */
.cp-edit-btn.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border-radius: 10px;
    padding: 0.45rem 0.85rem;
    font-weight: 600;
}

/* Identifiant marchand en police mono */
.cp-tx-table table.dataTable tbody td.cp-col-mono {
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.9em;
    color: var(--bs-gray-700);
}

/* ==========================================================================
   Liste, fiches et formulaires des connexions (avec sites.css / merchant.css)
   ========================================================================== */

/* Onglets hosté / API sous l'en-tête */
.cp-cx-tabs {
    margin-bottom: 1.25rem;
}

/* Filtre de statut actif : mise en évidence */
.cp-mc-sort .form-select.is-filtered {
    background-color: var(--bs-primary-light, #e9f3ff);
    color: var(--bs-primary, #1b84ff);
}

/* Lignes cliquables */
.cp-tx-table tr.cp-row-link {
    cursor: pointer;
}

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

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

/* Marchand rattaché */
.cp-cx-site {
    display: inline-flex;
    align-items: center;
    max-width: 220px;
    padding: 0.25rem 0.65rem;
    border-radius: 8px;
    background: var(--bs-gray-100, #f6f8fb);
    color: var(--bs-gray-700);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Type de connexion (hostée / API) */
.cp-cx-type {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.cp-cx-type [class*="ki-"] { color: inherit; }
.cp-cx-type--hoste { background: #fff3ef; color: #c2410c; }
.cp-cx-type--api   { background: #f4f0ff; color: #6d28d9; }

.cp-cx-hero__tags,
.cp-cx-preview__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.cp-cx-preview__tags {
    margin: 1rem 0 0;
}

/* Marchand rattaché dans l'aperçu : nom (pas un code) -> police normale */
.cp-mf-preview__mid.cp-cx-preview__site {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-family: inherit;
    max-width: 100%;
}

.cp-cx-preview__site [class*="ki-"] {
    color: inherit;
    opacity: 0.75;
}

/* Lien vers une autre fiche */
.cp-cx-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--bs-primary, #1b84ff);
    font-weight: 700;
}

.cp-cx-link [class*="ki-"] { color: inherit; }
.cp-cx-link:hover { text-decoration: underline; }

.cp-cx-url {
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.85rem;
    color: var(--bs-gray-700);
}

/* Coordonnées */
.cp-cx-contact {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
    margin-bottom: 0.5rem;
}

.cp-cx-contact__item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    background: var(--bs-gray-100, #f6f8fb);
    min-width: 0;
}

.cp-cx-contact__icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--cp-card-bg);
    color: var(--bs-primary, #1b84ff);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.cp-cx-contact__icon [class*="ki-"] { color: inherit; }

.cp-cx-contact__label {
    display: block;
    color: var(--cp-muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.cp-cx-contact__value {
    display: block;
    color: var(--cp-text);
    font-weight: 700;
    overflow-wrap: anywhere;
}

/* Configuration : pastilles clé / valeur */
.cp-cx-chips {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.cp-cx-chip {
    padding: 0.85rem 1rem;
    border-radius: 14px;
    border: 1px solid var(--cp-border);
    min-width: 0;
}

.cp-cx-chip__label {
    display: block;
    color: var(--cp-muted);
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.cp-cx-chip__value {
    display: block;
    color: var(--cp-text);
    font-size: 1.1rem;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.cp-cx-note {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    margin: 1rem 0 0;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    background: var(--bs-success-light, #dfffea);
    color: #0e7a47;
    font-size: 0.88rem;
    font-weight: 600;
}

.cp-cx-note [class*="ki-"] { color: inherit; }

/* Connexion jumelle (hostée <-> API) */
.cp-cx-twin {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    padding: 1rem 1.1rem;
    border-radius: 14px;
    border: 1px solid var(--cp-border);
    color: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cp-cx-twin:hover,
.cp-cx-twin:focus-visible {
    border-color: var(--bs-primary, #1b84ff);
    box-shadow: 0 8px 20px -12px rgba(27, 132, 255, 0.6);
    outline: none;
}

.cp-cx-twin__meta {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    color: var(--bs-gray-600);
    font-size: 0.85rem;
}

.cp-cx-twin__go {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--bs-primary, #1b84ff);
    font-weight: 700;
    font-size: 0.88rem;
}

.cp-cx-twin__go [class*="ki-"] { color: inherit; }

/* Formulaire : logo */
.cp-cx-logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.cp-cx-logo__input.image-input-empty .image-input-wrapper,
.cp-cx-logo__preview {
    background-image: url('../media/svg/files/blank-image.svg');
}

[data-bs-theme="dark"] .cp-cx-logo__input.image-input-empty .image-input-wrapper {
    background-image: url('../media/svg/files/blank-image-dark.svg');
}

.cp-cx-logo__preview.image-input-wrapper {
    width: 96px;
    height: 96px;
    border-radius: 18px;
    background-size: cover;
    background-position: center;
}

.cp-cx-logo .image-input {
    border-radius: 18px;
}

.cp-cx-logo__text {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    color: var(--cp-muted);
    font-size: 0.82rem;
}

.cp-cx-logo__text strong {
    color: var(--cp-text);
    font-size: 0.9rem;
}

/* select2 dans les formulaires : même hauteur que les autres champs */
.cp-mf-form .select2-container .select2-selection--single {
    min-height: 48px;
    display: flex;
    align-items: center;
    border-radius: var(--cp-radius-sm, 12px);
}

@media (max-width: 991.98px) {
    .cp-cx-chips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 575.98px) {
    /* Statut et tri chacun sur sa ligne (deux listes côte à côte seraient tronquées) */
    [data-cp-cx-table] .cp-mc-toolbar__end .cp-mc-sort { flex: 1 1 100%; }
    .cp-cx-contact,
    .cp-cx-chips { grid-template-columns: minmax(0, 1fr); }
    .cp-cx-twin__go { margin-left: 0; }
}

@media (max-width: 767.98px) {
    .cp-seg { width: 100%; }
    .cp-seg__item { flex: 1 1 0; justify-content: center; }
    .cp-cx-toolbar .cp-tx-search__field { flex: 1 1 100%; }
    .cp-cx-actions { width: 100%; }
    .cp-cx-actions .btn { flex: 1 1 0; }
}
