/* =====================================================================
   DexCuba — adaptación móvil compartida
   ---------------------------------------------------------------------
   Se carga después de los estilos de cada página, así que puede corregir
   lo que haga falta sin tocar el CSS individual de cada una.
   ===================================================================== */

/* Nunca desbordar horizontalmente: la causa nº1 de "no se ve bien en móvil" */
html, body { max-width: 100%; overflow-x: hidden; }
img, svg, table { max-width: 100%; }

/* ---------- Barra superior en móvil ---------- */
@media (max-width: 860px) {
  .topbar {
    height: auto;
    min-height: 56px;
    padding: 0 14px;
    gap: 10px;
    flex-wrap: nowrap;
  }
  .logo { font-size: 17px; gap: 8px; flex: none; }
  .logo-mark { width: 26px; height: 26px; }

  /* La navegación pasa a un panel desplegable desde la cabecera.
     No usamos barra fija abajo: los navegadores internos de las wallets
     (Trust, MetaMask, TronLink) tienen sus propias barras y gestos ahí,
     y tapaban o desplazaban la nuestra. */
  .nav-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; flex: none;
    border: 1px solid #243247; border-radius: 10px;
    background: #16202F; color: #EAF0F6; font-size: 17px; line-height: 1;
  }
  .nav-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(4,9,15,.6); z-index: 80;
  }
  .nav-backdrop.open { display: block; }

  .topnav {
    display: none;
    position: absolute; left: 8px; right: 8px; top: calc(100% + 6px);
    flex-direction: column; gap: 2px;
    margin: 0; padding: 8px;
    background: #101826;
    border: 1px solid #243247; border-radius: 14px;
    box-shadow: 0 18px 40px rgba(0,0,0,.5);
    z-index: 85;
  }
  .topnav.open { display: flex; }
  .topnav a, .topnav button {
    display: block; width: 100%;
    text-align: left;
    padding: 12px 14px;
    font-size: 15px;
    border-radius: 10px;
    white-space: nowrap;
  }
  .topnav a.active, .topnav button.active { background: rgba(31,199,182,.1); }

  /* Ya no hay barra inferior: el contenido no necesita hueco reservado */
  body { padding-bottom: 12px; }

  /* CRÍTICO: backdrop-filter crea bloque contenedor para hijos posicionados
     y rompía la navegación. En móvil, fondo opaco y sin filtro. La cabecera
     es además el ancla del panel desplegable. */
  .topbar {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: #0A1018;
    overflow: visible;
    z-index: 86;
  }

  .topbar-right { gap: 7px; min-width: 0; }
  /* La dirección de la wallet nunca debe ensanchar la cabecera */
  .wallet-btn, .connect-btn {
    padding: 8px 12px; font-size: 12px;
    max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .rate-pill, .bal-pill, .pill { display: none; }
  .net-badge { font-size: 9.5px; padding: 2px 6px; }
}

/* ---------- Contenido ---------- */
@media (max-width: 860px) {
  .wrap, .shell { padding: 16px 14px; }
  .card, .panel, section { padding: 16px 15px; border-radius: 12px; }
  .balance-card { padding: 20px 18px; }
  .balance-value { font-size: 30px; }

  h1 { font-size: 21px; }
  .card h2, .panel h2, section h2 { font-size: 15px; }

  /* Rejillas a una columna */
  .grid2, .cards-grid, .grid, .two, .btn-row, .stats { grid-template-columns: 1fr !important; }
  .stats { grid-template-columns: repeat(3, 1fr) !important; }

  /* Botones de acción: dos por fila en vez de cuatro apretadas */
  .actions { gap: 8px; }
  .actions .btn { flex: 1 1 calc(50% - 4px); min-width: 0; padding: 11px 8px; font-size: 13px; }

  /* Tablas: permitir desplazamiento lateral en vez de romper el layout */
  table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  thead, tbody, tr { display: table; width: 100%; table-layout: fixed; }
  th, td { padding: 10px 6px; font-size: 13px; }

  /* Modales pegados a los bordes */
  .modal, .tok-modal { padding: 20px 18px; border-radius: 14px; }
  .overlay { padding: 12px; align-items: flex-start; padding-top: 40px; }

  /* Direcciones largas: que corten en vez de desbordar */
  code, .v, .addr-row code, .tv-row .v, .prof-info span { word-break: break-all; }
}

/* ---------- Pantallas muy estrechas ---------- */
@media (max-width: 400px) {
  .balance-value { font-size: 26px; }
  .actions .btn { flex: 1 1 100%; }
  .topnav a, .topnav button { font-size: 10.5px; padding: 8px 2px; }
  .logo { font-size: 15px; }
  .stat b { font-size: 17px; }
}

/* ---------- Toque cómodo ---------- */
@media (hover: none) {
  .btn, .mini-btn, .contact-btn, .escrow-btn, .quick, .topnav a { min-height: 42px; }
  input, select, textarea { font-size: 16px; } /* evita el zoom automático en iOS */
}

/* ---------- Barras fijas y banners no se solapan ---------- */
@media (max-width: 860px) {
  #dxCookieBar, #dxPwaBar { bottom: 64px; }
  .toast { bottom: 76px; }
  .cookie-bar { bottom: 62px; }
}

/* Las etiquetas cortas (data-short) eran para la antigua barra inferior, que
   ocultaba el texto real y mostraba una abreviatura. El panel desplegable
   muestra el nombre completo, así que el pseudo-elemento debe desaparecer:
   si no, cada entrada se ve duplicada ("ConvertirConvertir"). */
@media (max-width: 860px) {
  .topnav a[data-short], .topnav button[data-short] { font-size: 15px; }
  .topnav a[data-short]::after, .topnav button[data-short]::after { content: none; }
}

/* ---------- Desplegables (select) en tema oscuro ---------- */
/* Sin esto, la lista de opciones sale con los colores del sistema
   (texto claro sobre fondo claro) y no se lee. */
html { color-scheme: dark; }
select {
  background: #16202F;
  color: #EAF0F6;
  border: 1px solid #243247;
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  appearance: auto;
}
select:focus { outline: none; border-color: #1FC7B6; }
select option { background: #16202F; color: #EAF0F6; }

/* Con 7 entradas, la barra inferior necesita letras algo más compactas */
@media (max-width: 860px) {
  .topnav a, .topnav button { padding: 9px 1px; font-size: 10.5px; letter-spacing: -0.01em; }
}
@media (max-width: 380px) {
  .topnav a, .topnav button { font-size: 9.5px; }
}


/* ---------- El botón de menú solo existe en móvil ---------- */
@media (min-width: 861px) {
  .nav-toggle { display: none !important; }
  .nav-backdrop { display: none !important; }
}

/* =====================================================================
   Botón flotante de ayuda (todas las pantallas)
   ===================================================================== */
.dx-help { position: fixed; right: 16px; bottom: 16px; z-index: 120; }

.dx-help-btn {
  width: 54px; height: 54px; border-radius: 50%;
  background: #101826; border: 1px solid #243247;
  box-shadow: 0 10px 26px rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform .15s ease, border-color .15s ease;
}
.dx-help-btn:hover { transform: translateY(-2px); border-color: #1FC7B6; }
.dx-help-btn img { display: block; border-radius: 8px; }
.dx-help.open .dx-help-btn { border-color: #1FC7B6; }

.dx-help-panel {
  display: none;
  position: absolute; right: 0; bottom: 66px;
  width: 258px; padding: 12px;
  background: #101826; border: 1px solid #243247; border-radius: 14px;
  box-shadow: 0 18px 44px rgba(0,0,0,.55);
}
.dx-help.open .dx-help-panel { display: block; }

.dx-help-title {
  font-size: 13px; font-weight: 600; color: #EAF0F6;
  margin-bottom: 8px;
}
.dx-help-item {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 9px 10px; margin-bottom: 5px;
  border-radius: 10px; background: #16202F;
  color: #EAF0F6; font-size: 12.5px; text-decoration: none; line-height: 1.35;
}
.dx-help-item:hover { background: rgba(31,199,182,.1); }
.dx-help-item i { color: #8DA0B8; font-style: normal; font-size: 11px; }
.dx-help-note {
  font-size: 10.5px; color: #8DA0B8; line-height: 1.4;
  border-top: 1px solid #243247; padding-top: 8px; margin-top: 6px;
}

/* En móvil, algo más discreto para no tapar contenido */
@media (max-width: 860px) {
  .dx-help { right: 12px; bottom: 12px; }
  .dx-help-btn { width: 48px; height: 48px; }
  .dx-help-panel { width: min(258px, calc(100vw - 34px)); }
}

/* Entrada "Instalar la app" dentro del menú móvil */
@media (max-width: 860px) {
  .topnav .nav-install {
    display: block; width: 100%;
    margin-top: 6px; padding: 12px 14px;
    border-top: 1px solid #243247;
    border-radius: 10px;
    background: rgba(31,199,182,.1);
    color: #1FC7B6; font-size: 15px; font-weight: 600;
    text-align: left;
  }
}
