/* ==========================================================================
   WooCommerce Bancaribe Gateway (Débito Inmediato) — Estilos principales
   Inspirado en Material UI (MUI) / Material Design
   ========================================================================== */

/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
    --bcb-debim-primary:         #1976d2;
    --bcb-debim-primary-dark:    #115293;
    --bcb-debim-primary-light:   #e3f2fd;
    --bcb-debim-primary-hover:   rgba(25, 118, 210, 0.08);
    --bcb-debim-text-primary:    rgba(0, 0, 0, 0.87);
    --bcb-debim-text-secondary:  rgba(0, 0, 0, 0.6);
    --bcb-debim-border:          rgba(0, 0, 0, 0.23);
    --bcb-debim-radius:          4px;
    --bcb-debim-transition:      0.2s ease;
    --bcb-debim-shadow-sm:       0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
}

/* ==========================================================================
   CHECKOUT — Formulario de pago
   ========================================================================== */

/* Clearfix para contener los form-row flotados de WooCommerce */
.bcb-debim-payment-form::after {
    content: '';
    display: table;
    clear: both;
}

/* ── Caja informativa (descripción para el cliente) ────────────────────── */
.bcb-debim-info-box {
    background: var(--bcb-debim-primary-light);
    border-left: 3px solid var(--bcb-debim-primary);
    border-radius: 0 var(--bcb-debim-radius) var(--bcb-debim-radius) 0;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 0.875rem;
    line-height: 1.8;
    color: var(--bcb-debim-text-primary);
}

.bcb-debim-info-box p {
    margin-top: 0 !important;
    margin-bottom: 8px;
}

/* ── Corrección de ancho y alto para selects dentro del gateway ─────────── */
.bcb-debim-payment-form .woocommerce-input-wrapper select {
    width: 100% !important;
    height: auto !important;
    min-height: 45px !important;
    padding: 10px 12px !important;
    line-height: 1.4 !important;
    box-sizing: border-box !important;
}

/* ── Campos siempre a ancho completo, sin columnas ─────────────────────── */
.bcb-debim-payment-form .form-row-first,
.bcb-debim-payment-form .form-row-last {
    float: none !important;
    width: 100% !important;
    margin-right: 0 !important;
}

/* ── Teléfono pagador: solo aplica a pagos Bancaribe (0114) ────────────── */
.bcb-debim-payment-form .bcb-debim-phone-field:not(.bcb-debim-visible) {
    display: none !important;
}

/* ── Normalizar color de labels en checkout clásico (shortcode) ─────────── */
#payment .payment_method_bancaribe_debim .form-row label,
#payment .payment_method_bancaribe_debim .form-row abbr.required {
    color: var(--bcb-debim-text-primary) !important;
}

/* ==========================================================================
   CHECKOUT — Modal de solicitud/confirmación de OTP
   ========================================================================== */

.bcb-debim-otp-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

.bcb-debim-otp-overlay.is-open { display: flex; }

.bcb-debim-otp-modal {
    background: #fff;
    border-radius: var(--bcb-debim-radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.24);
    width: 420px;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.bcb-debim-otp-header {
    padding: 14px 20px;
    border-bottom: 1px solid rgba(224, 224, 224, 1);
    font-size: 1rem;
    color: var(--bcb-debim-text-primary);
}

.bcb-debim-otp-body {
    padding: 20px;
    overflow: auto;
}

/* Neutralizar estilos del theme dentro del modal: label en bloque y campo a ancho completo */
.bcb-debim-otp-modal .form-row {
    float: none !important;
    width: 100% !important;
    margin: 0 0 14px !important;
    padding: 0 !important;
}

.bcb-debim-otp-modal .form-row label {
    display: block !important;
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    margin: 0 0 6px !important;
    color: var(--bcb-debim-text-primary) !important;
}

.bcb-debim-otp-modal .woocommerce-input-wrapper {
    display: block;
    width: 100%;
}

.bcb-debim-otp-modal input.input-text {
    display: block;
    width: 100% !important;
    box-sizing: border-box !important;
    min-height: 45px;
    padding: 10px 12px;
    font-size: 1.05rem;
    letter-spacing: 0.15em;
    border: 1px solid var(--bcb-debim-border);
    border-radius: var(--bcb-debim-radius);
    background: #fff;
    color: var(--bcb-debim-text-primary);
}

.bcb-debim-otp-modal input.input-text:focus {
    border-color: var(--bcb-debim-primary);
    outline: none;
    box-shadow: 0 0 0 1px var(--bcb-debim-primary);
}

.bcb-debim-otp-loading {
    display: none;
    text-align: center;
    padding: 12px 0;
}

.bcb-debim-otp-loading p {
    margin: 14px 0 4px;
    color: var(--bcb-debim-text-secondary);
    font-size: 0.9rem;
}

.bcb-debim-otp-step { display: none; }
.bcb-debim-otp-fail { display: none; }

.bcb-debim-otp-msg {
    margin: 0 0 12px;
    padding: 10px 14px;
    border-radius: var(--bcb-debim-radius);
    font-size: 0.85rem;
    line-height: 1.5;
    color: #1b5e20;
    background: #e8f5e9;
    border-left: 3px solid #2e7d32;
}

/* Reintento: el mensaje pasa a estado de error (código rechazado por el banco) */
.bcb-debim-otp-msg.is-error {
    color: #b71c1c;
    background: #ffebee;
    border-left-color: #c62828;
}

/* Intentos restantes del código vigente */
.bcb-debim-otp-hint {
    display: none;
    margin: -6px 0 12px;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--bcb-debim-text-secondary);
}

.bcb-debim-otp-hint.is-visible { display: block; }

.bcb-debim-otp-error {
    display: none;
    margin: 0 0 12px;
    padding: 10px 14px;
    border-radius: var(--bcb-debim-radius);
    font-size: 0.85rem;
    line-height: 1.5;
    color: #b71c1c;
    background: #ffebee;
    border-left: 3px solid #c62828;
}

.bcb-debim-otp-error.is-visible { display: block; }

.bcb-debim-otp-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* ── Botones del modal ─────────────────────────────────────────────────── */
.bcb-debim-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
    padding: 11px 16px;
    border: none;
    border-radius: var(--bcb-debim-radius);
    background: var(--bcb-debim-primary);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--bcb-debim-transition), opacity var(--bcb-debim-transition);
}

.bcb-debim-btn:hover:not(:disabled) {
    background: var(--bcb-debim-primary-dark);
}

.bcb-debim-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.bcb-debim-btn-secondary {
    background: #fff;
    color: var(--bcb-debim-primary);
    border: 1px solid var(--bcb-debim-primary);
}

.bcb-debim-btn-secondary:hover:not(:disabled) {
    background: var(--bcb-debim-primary);
    color: #fff;
}

/* ── Spinner ───────────────────────────────────────────────────────────── */
.bcb-debim-spinner {
    display: inline-block;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(25, 118, 210, 0.3);
    border-top-color: var(--bcb-debim-primary);
    border-radius: 50%;
    animation: bcb-debim-spin 0.7s linear infinite;
}

.bcb-debim-spinner-lg {
    width: 36px;
    height: 36px;
    border-width: 3px;
}

@keyframes bcb-debim-spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   ADMIN — Página de configuración del gateway
   ========================================================================== */

/* ── Tabs de configuración ─────────────────────────────────────────────── */
.bancaribe-debim-tab-content           { display: none; }
.bancaribe-debim-tab-content.is-active { display: block; }

.woocommerce_page_wc-settings .nav-tab { cursor: pointer; }

/* ── Títulos de sección dentro del tab ─────────────────────────────────── */
.bancaribe-debim-section-title {
    font-size: 1em;
    font-weight: 600;
    margin: 28px 0 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #c3c4c7;
    color: #1d2327;
}

/* ── Encabezado de la sección auditoría ────────────────────────────────── */
.bancaribe-debim-audit-count {
    margin-left: 8px;
    font-weight: 400;
    font-size: 0.9em;
    color: var(--bcb-debim-text-secondary);
}

/* ==========================================================================
   ADMIN — Tabla de Auditoría (estilo MUI)
   ========================================================================== */

/* Contenedor tarjeta */
.bancaribe-debim-audit-wrap {
    background: #fff;
    border-radius: var(--bcb-debim-radius);
    box-shadow: var(--bcb-debim-shadow-sm);
    overflow-x: auto;
    margin-top: 8px;
}

/* Tabla */
.bancaribe-debim-audit-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.875rem;
}

/* Cabecera */
.bancaribe-debim-audit-table thead tr {
    border-bottom: 1px solid rgba(224, 224, 224, 1);
}

.bancaribe-debim-audit-table th {
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bcb-debim-text-secondary);
    text-align: left;
    white-space: nowrap;
    background: #fff;
}

/* Celdas */
.bancaribe-debim-audit-table td {
    padding: 14px 16px;
    color: var(--bcb-debim-text-primary);
    border-bottom: 1px solid rgba(224, 224, 224, 0.8);
    vertical-align: middle;
    line-height: 1.5;
}

.bancaribe-debim-audit-table tbody tr:last-child td {
    border-bottom: none;
}

.bancaribe-debim-audit-table tbody tr:hover td {
    background: rgba(0, 0, 0, 0.03);
    cursor: default;
}

/* ── Chips de estado ───────────────────────────────────────────────────── */
.bancaribe-debim-chip {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
}

.bancaribe-debim-chip-ok {
    color: #1b5e20;
    background: #e8f5e9;
}

.bancaribe-debim-chip-error {
    color: #b71c1c;
    background: #ffebee;
}

.bancaribe-debim-chip-pendiente {
    color: #006064;
    background: #e0f7fa;
}

/* ── Estado vacío ──────────────────────────────────────────────────────── */
.bancaribe-debim-audit-empty {
    padding: 24px 16px;
    color: var(--bcb-debim-text-secondary);
    font-size: 0.875rem;
}

/* ── Paginación ────────────────────────────────────────────────────────── */
.bancaribe-debim-audit-pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 16px;
    border-top: 1px solid rgba(224, 224, 224, 0.8);
}

.bancaribe-debim-audit-pagination a,
.bancaribe-debim-audit-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: var(--bcb-debim-radius);
    font-size: 0.875rem;
    text-decoration: none;
    color: var(--bcb-debim-text-primary);
    transition: background var(--bcb-debim-transition), color var(--bcb-debim-transition);
}

.bancaribe-debim-audit-pagination a:hover {
    background: var(--bcb-debim-primary-hover);
    color: var(--bcb-debim-primary);
}

.bancaribe-debim-audit-pagination .current {
    background: var(--bcb-debim-primary);
    color: #fff;
    font-weight: 600;
    pointer-events: none;
}

/* Salto entre bloques de páginas */
.bancaribe-debim-audit-pagination .ellipsis {
    min-width: 16px;
    padding: 0 2px;
    color: var(--bcb-debim-text-secondary);
    pointer-events: none;
}

/* ── Link "Ver" en celdas de auditoría ─────────────────────────────────── */
.bcb-debim-json-view {
    color: var(--bcb-debim-primary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
}

.bcb-debim-json-view:hover {
    text-decoration: underline;
}

/* ── Modal de JSON ─────────────────────────────────────────────────────── */
.bcb-debim-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

.bcb-debim-modal {
    background: #fff;
    border-radius: var(--bcb-debim-radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.24);
    width: 560px;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.bcb-debim-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(224, 224, 224, 1);
    font-size: 0.9rem;
}

.bcb-debim-modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: var(--bcb-debim-text-secondary);
    padding: 0 4px;
}

.bcb-debim-modal-close:hover {
    color: var(--bcb-debim-text-primary);
}

.bcb-debim-modal-body {
    padding: 16px 20px;
    overflow: auto;
}

.bcb-debim-modal-body pre {
    margin: 0;
    font-size: 0.8rem;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--bcb-debim-text-primary);
    line-height: 1.6;
}
