/* ==========================================================
   GlobPay - Sección: Pagos y abonos (Panel del Vendedor)
   payments-panel.css
   
   Estructura visual fiel a la maqueta oficial:
   - Controles a la izquierda, vista previa interactiva a la derecha.
   - Tarjetas blancas, bordes delicados (#E2E8F0), acentos turquesa #0BB6B5.
   - Responsive para desktop (1366px) y móvil (390px, 360px, 430px) sin overflow.
   ========================================================== */

/* RESET SEGURO PARA EL PANEL */
#view-pagos,
#view-pagos *,
#view-pagos *::before,
#view-pagos *::after {
  box-sizing: border-box;
}

#view-pagos {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/* 1. ENCABEZADO DE SECCIÓN */
.payments-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-save-payments {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: #0BB6B5;
  color: #FFFFFF;
  border: none;
  border-radius: 8px;
  padding: 9px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  box-shadow: 0 1px 3px rgba(11, 182, 181, 0.25);
  min-height: 40px;
}

.btn-save-payments:hover:not(:disabled) {
  background-color: #09A3A2;
  box-shadow: 0 2px 6px rgba(11, 182, 181, 0.35);
}

.btn-save-payments:active:not(:disabled) {
  transform: scale(0.99);
}

.btn-save-payments:disabled {
  background-color: #0BB6B5;
  color: #FFFFFF;
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.65;
}

/* 2. NOTIFICACIÓN TOAST / BANNER */
.payments-status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 20px;
  animation: fadeInBanner 0.25s ease-out;
}

@keyframes fadeInBanner {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.payments-status-banner.is-success {
  background-color: #ECFDF5;
  border: 1px solid #A7F3D0;
  color: #065F46;
}

.payments-status-banner.is-error {
  background-color: #FEF2F2;
  border: 1px solid #FECACA;
  color: #991B1B;
}

.payments-toast-icon {
  font-size: 16px;
  font-weight: bold;
}

/* 3. GRID PRINCIPAL (2 COLUMNAS DESKTOP / 1 COLUMNA MÓVIL) */
.payments-layout-grid {
  display: grid;
  grid-template-columns: 1fr 390px;
  gap: 24px;
  align-items: start;
  width: 100%;
}

/* 4. COLUMNA IZQUIERDA: TARJETAS DE CONTROLES */
.payments-controls-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.payment-modality-card {
  background-color: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.payment-modality-card:hover {
  border-color: #CBD5E1;
}

.payment-modality-card.is-inactive {
  background-color: #F8FAFC;
  border-color: #E2E8F0;
}

.payment-modality-card.is-inactive .modality-icon-circle {
  background-color: #F1F5F9;
  color: #94A3B8;
}

.payment-modality-card.is-inactive .modality-main-title {
  color: #64748B;
}

.payment-modality-card.is-inactive .modality-main-sub {
  color: #94A3B8;
}

.payment-modality-card.is-inactive .modality-field-block {
  opacity: 0.55;
  pointer-events: none;
}

.modality-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.modality-icon-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background-color: #E6F7F5;
  color: #0BB6B5;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.modality-svg-icon {
  width: 20px;
  height: 20px;
}

.modality-text-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.modality-main-title {
  font-size: 15.5px;
  font-weight: 600;
  color: #0F172A;
  margin: 0 0 3px 0;
  line-height: 1.25;
}

.modality-main-sub {
  font-size: 13px;
  color: #64748B;
  margin: 0;
  line-height: 1.35;
}

/* Switch Toggle Accesible */
.payment-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}

.payment-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.payment-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #CBD5E1;
  border-radius: 24px;
  transition: background-color 0.2s ease;
}

.payment-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #FFFFFF;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease;
}

.payment-switch input:checked + .payment-slider {
  background-color: #0BB6B5;
}

.payment-switch input:checked + .payment-slider::before {
  transform: translateX(20px);
}

.payment-switch input:focus-visible + .payment-slider {
  outline: 2px solid #0BB6B5;
  outline-offset: 2px;
}

/* Pie de tarjeta (Contraentrega) */
.modality-card-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #F1F5F9;
  display: flex;
  align-items: center;
}

.modality-note-text {
  font-size: 12.5px;
  color: #64748B;
  font-weight: 500;
  background-color: #F1F5F9;
  padding: 3px 10px;
  border-radius: 6px;
}

/* Campos de entrada numéricos */
.modality-field-block {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #F1F5F9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modality-field-label {
  font-size: 13.5px;
  font-weight: 500;
  color: #334155;
}

.payment-input-group {
  display: inline-flex;
  align-items: center;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  background-color: #FFFFFF;
  overflow: hidden;
  width: 110px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.payment-input-group:focus-within {
  border-color: #0BB6B5;
  box-shadow: 0 0 0 3px rgba(11, 182, 181, 0.15);
}

.payment-input-group.has-error {
  border-color: #EF4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.payment-number-input {
  border: none;
  outline: none;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 600;
  color: #0F172A;
  width: 100%;
  min-width: 0;
  text-align: right;
  background: transparent;
  -moz-appearance: textfield;
}

.payment-number-input::-webkit-outer-spin-button,
.payment-number-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.payment-input-suffix {
  padding: 8px 10px;
  background-color: #F8FAFC;
  border-left: 1px solid #E2E8F0;
  color: #64748B;
  font-size: 13px;
  font-weight: 500;
}

.modality-inline-error {
  font-size: 12px;
  color: #DC2626;
  margin-top: 8px;
  font-weight: 500;
}

/* Sub-métodos para Abono */
.modality-submethods-wrap {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #F1F5F9;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.method-selector-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.method-pill-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #E2E8F0;
  background-color: #FFFFFF;
  color: #334155;
  transition: all 0.15s ease;
  user-select: none;
}

.method-pill-option input[type="radio"] {
  accent-color: #0BB6B5;
  margin: 0;
}

.method-pill-option.is-active {
  border-color: #0BB6B5;
  background-color: #EEFBFB;
  color: #087877;
  font-weight: 600;
}

.method-pill-option.is-disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: #F8FAFC;
  border-color: #E2E8F0;
  color: #94A3B8;
}

.pending-dropi-badge {
  font-size: 10.5px;
  font-weight: 600;
  background-color: #FEF3C7;
  color: #B45309;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #FDE68A;
}

.modality-deposit-helper {
  font-size: 12.5px;
  color: #64748B;
  margin: 0;
  line-height: 1.35;
}

/* Llamado informativo inferior */
.payment-info-callout {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: #F0FDF4;
  border: 1px solid #BBF7D0;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: #166534;
  line-height: 1.4;
}

.callout-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: #16A34A;
}

/* 5. COLUMNA DERECHA: VISTA PREVIA INTERACTIVA */
.payments-preview-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.payment-preview-card {
  background-color: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.preview-card-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #F1F5F9;
}

.preview-header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.preview-title {
  font-size: 16px;
  font-weight: 700;
  color: #0F172A;
  margin: 0;
  letter-spacing: -0.2px;
}

.preview-simulation-pill {
  font-size: 11.5px;
  font-weight: 600;
  background-color: #E0F2FE;
  color: #0284C7;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid #BAE6FD;
}

.preview-subcontext {
  font-size: 12.5px;
  color: #64748B;
  margin-top: 4px;
}

/* Lista de opciones activas en la vista previa */
.preview-options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.preview-option-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1.5px solid #E2E8F0;
  border-radius: 10px;
  padding: 12px 14px;
  background-color: #FFFFFF;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.preview-option-item:hover {
  border-color: #CBD5E1;
  background-color: #F8FAFC;
}

.preview-option-item.is-selected {
  border-color: #0BB6B5;
  background-color: #EEFBFB;
}

.preview-radio-circle {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #CBD5E1;
  background-color: #FFFFFF;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.preview-option-item.is-selected .preview-radio-circle {
  border-color: #0BB6B5;
}

.preview-option-item.is-selected .preview-radio-circle::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #0BB6B5;
}

.preview-option-body {
  flex: 1 1 auto;
  min-width: 0;
}

.preview-option-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.preview-opt-title {
  font-size: 14px;
  font-weight: 600;
  color: #0F172A;
}

.preview-savings-badge {
  font-size: 11px;
  font-weight: 700;
  background-color: #DCFCE7;
  color: #15803D;
  padding: 1px 6px;
  border-radius: 4px;
}

.preview-opt-sub {
  font-size: 12.5px;
  color: #475569;
  line-height: 1.35;
}

.preview-opt-sub strong {
  color: #0F172A;
}

.preview-opt-note {
  font-size: 11.5px;
  color: #64748B;
  margin-top: 3px;
}

/* Advertencia cuando todas están desactivadas */
.preview-empty-warning {
  border: 1.5px dashed #F87171;
  border-radius: 10px;
  background-color: #FEF2F2;
  padding: 16px;
  text-align: center;
  margin-bottom: 16px;
}

.warning-svg {
  width: 24px;
  height: 24px;
  color: #DC2626;
  margin: 0 auto 6px;
}

.warning-title {
  font-size: 14px;
  font-weight: 700;
  color: #991B1B;
  margin: 0 0 4px 0;
}

.warning-desc {
  font-size: 12px;
  color: #7F1D1D;
  margin: 0;
  line-height: 1.35;
}

/* Desglose de totales */
.preview-totals-box {
  background-color: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #475569;
}

.totals-row.is-highlight {
  font-weight: 700;
  color: #0F172A;
  font-size: 14px;
  padding: 4px 0;
  border-top: 1px dashed #E2E8F0;
  border-bottom: 1px dashed #E2E8F0;
}

.totals-val {
  font-weight: 600;
}

.totals-row.is-highlight .totals-val {
  color: #087877;
}

/* Botón dinámico del cliente en la previsualización */
.preview-cta-wrap {
  margin-bottom: 12px;
}

.btn-preview-cta {
  width: 100%;
  border: none;
  background-color: #0BB6B5;
  color: #FFFFFF;
  padding: 12px 16px;
  font-size: 14.5px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 0.15s ease;
  min-height: 44px;
}

.btn-preview-cta:hover:not(:disabled) {
  background-color: #09A3A2;
}

.btn-preview-cta:disabled {
  background-color: #CBD5E1;
  color: #94A3B8;
  cursor: not-allowed;
}

.preview-disclaimer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11.5px;
  color: #94A3B8;
  text-align: center;
}

.disclaimer-icon {
  width: 14px;
  height: 14px;
}

/* 6. TARJETA DE ESTADO DE CONEXIÓN (PAGOS EN LÍNEA) */
.payment-connection-card {
  background-color: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.connection-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.connection-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.connection-svg {
  width: 18px;
  height: 18px;
  color: #64748B;
}

.connection-title {
  font-size: 14px;
  font-weight: 600;
  color: #0F172A;
  margin: 0;
}

.connection-badge-pending {
  font-size: 11px;
  font-weight: 600;
  background-color: #FEF3C7;
  color: #B45309;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid #FDE68A;
  white-space: nowrap;
}

.connection-desc {
  font-size: 12.5px;
  color: #64748B;
  margin: 0 0 10px 0;
  line-height: 1.35;
}

.connection-link {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: #087877;
  text-decoration: none;
  transition: color 0.15s ease;
}

.connection-link:hover {
  color: #09A3A2;
  text-decoration: underline;
}

/* 7. BARRA INFERIOR FIJA (CAMBIOS SIN GUARDAR / DIRTY BAR) */
.payments-dirty-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #0F172A;
  color: #FFFFFF;
  padding: 14px 24px;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.2);
  z-index: 999;
  animation: slideUpDirty 0.25s ease-out;
}

@keyframes slideUpDirty {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.dirty-bar-content {
  max-width: 1060px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.dirty-bar-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
}

.dirty-icon {
  width: 20px;
  height: 20px;
  color: #F59E0B;
  flex-shrink: 0;
}

.dirty-bar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-discard-payments {
  background-color: transparent;
  color: #E2E8F0;
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 38px;
}

.btn-discard-payments:hover {
  background-color: #1E293B;
  color: #FFFFFF;
  border-color: #64748B;
}

@media (min-width: 768px) {
  .payments-dirty-bar {
    left: 240px;
  }
}

/* 8. RESPONSIVIDAD Y CONTROLES TÁCTILES ACCESIBLES (MÓVIL) */
@media (max-width: 900px) {
  .payments-layout-grid {
    grid-template-columns: 1fr;
    gap: 20px;
    width: 100%;
    min-width: 0;
  }

  .payments-header {
    flex-direction: column;
    align-items: stretch;
  }

  .page-header-actions {
    width: 100%;
  }

  .btn-save-payments {
    width: 100%;
  }

  .dirty-bar-content {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .dirty-bar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .btn-discard-payments,
  .dirty-bar-actions .btn-save-payments {
    flex: 1;
    text-align: center;
  }
}

@media (max-width: 640px) {
  .dashboard-main-content {
    padding: 16px 12px 40px 12px !important;
  }

  .payments-controls-col,
  .payments-preview-col {
    width: 100%;
    min-width: 0;
  }

  .payment-modality-card,
  .payment-preview-card,
  .payment-connection-card {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 14px 12px;
  }

  .modality-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-width: 0;
  }

  .modality-icon-circle {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
  }

  .modality-svg-icon {
    width: 18px;
    height: 18px;
  }

  .modality-text-wrap {
    min-width: 0;
    flex: 1 1 auto;
  }

  .modality-main-title {
    font-size: 14px;
    line-height: 1.25;
    word-break: break-word;
    overflow-wrap: break-word;
  }

  .modality-main-sub {
    font-size: 12px;
    line-height: 1.35;
    word-break: break-word;
    overflow-wrap: break-word;
  }

  .payment-switch {
    width: 40px;
    height: 22px;
    flex-shrink: 0;
  }

  .payment-slider::before {
    height: 16px;
    width: 16px;
  }

  .payment-switch input:checked + .payment-slider::before {
    transform: translateX(18px);
  }

  .preview-header-main {
    flex-wrap: wrap;
    gap: 6px;
  }

  .method-selector-pills {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 8px;
  }

  .method-pill-option {
    width: 100%;
    box-sizing: border-box;
    justify-content: space-between;
    padding: 8px 10px;
  }

  .modality-field-block {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
  }

  .payment-input-group {
    width: 100%;
    max-width: 140px;
  }

  .payment-info-callout {
    padding: 10px 12px;
    font-size: 12px;
  }

  .preview-option-item {
    padding: 10px 12px;
    width: 100%;
    box-sizing: border-box;
  }

  .preview-option-title-row {
    flex-wrap: wrap;
    gap: 4px;
  }

  .preview-opt-sub {
    word-break: break-word;
    overflow-wrap: break-word;
  }
}

/* MODOS DE PREVISUALIZACIÓN MÓVIL ESTRICTA */
body.preview-360,
body.preview-360 .shopify-admin-wrapper,
body.preview-360 .dashboard-canvas,
body.preview-360 .dashboard-main-content,
body.preview-360 #view-pagos {
  width: 360px !important;
  max-width: 360px !important;
  box-sizing: border-box !important;
  overflow-x: hidden !important;
}

body.preview-390,
body.preview-390 .shopify-admin-wrapper,
body.preview-390 .dashboard-canvas,
body.preview-390 .dashboard-main-content,
body.preview-390 #view-pagos {
  width: 390px !important;
  max-width: 390px !important;
  box-sizing: border-box !important;
  overflow-x: hidden !important;
}

body.preview-430,
body.preview-430 .shopify-admin-wrapper,
body.preview-430 .dashboard-canvas,
body.preview-430 .dashboard-main-content,
body.preview-430 #view-pagos {
  width: 430px !important;
  max-width: 430px !important;
  box-sizing: border-box !important;
  overflow-x: hidden !important;
}
