﻿/* ==========================================================================
   AJUSTES MÓVIL (2026-11-12): nada debe salirse del ancho de la pantalla.
   Causa común: los hijos de un grid/flex no se encogían (min-width:auto).
   ========================================================================== */
@media (max-width: 900px) {
  /* Columnas que sí pueden encogerse */
  .recharge-workspace-grid,
  .cuadre-workspace-grid,
  .reports-workspace-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .recharge-workspace-grid > *,
  .cuadre-workspace-grid > *,
  .reports-workspace-grid > *,
  .recharge-panel-left,
  .recharge-panel-right {
    min-width: 0;
    max-width: 100%;
  }

  /* ---------- Recargas ---------- */
  .recharge-type-toggle { overflow: hidden; }
  .recharge-type-btn {
    min-width: 0 !important;
    padding: 8px 4px !important;
    font-size: 11.5px !important;
    line-height: 1.15;
    white-space: normal !important;
    text-align: center;
  }
  .operators-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 6px !important; }
  .operator-card { min-width: 0; padding: 8px 4px !important; }
  .operator-logo-box { width: 100% !important; max-width: 84px; margin-inline: auto; }
  .operator-logo-box img { max-width: 100%; object-fit: contain; }
  .recharge-inputs-row { flex-direction: column !important; align-items: stretch !important; gap: 10px !important; }
  .recharge-inputs-row > * { width: 100% !important; max-width: 100% !important; min-width: 0; }
  #tab-recargas .recharge-amount-chips { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
  .recharge-submit-bar { flex-wrap: wrap; }
  .btn-recharge-submit {
    min-width: 0;
    height: auto !important;
    min-height: 42px;
    padding: 8px 10px !important;
    font-size: 12.5px !important;
    white-space: normal !important;
    line-height: 1.2;
  }
  .recharge-panel-right { overflow-x: auto; }
  .recharge-panel-right table:not(.rcards) { min-width: 560px; font-size: 12px; }

  /* ---------- Consulta ---------- */
  /* El botón "Ver" de cada fila repite "Ver tique digital": se oculta para que la tabla quepa */
  #tab-consulta .consult-table th:nth-child(5),
  #tab-consulta .consult-table td:nth-child(5) { display: none; }
  #tab-consulta .consult-table { min-width: 0 !important; width: 100%; font-size: 12.5px; }
  #tab-consulta .consult-table th, #tab-consulta .consult-table td { padding: 8px 6px !important; }
  .consultation-filters > button:last-child { grid-column: 1 / -1; width: 100%; }
  .consultation-filters {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px !important;
    align-items: center;
  }
  .consultation-filters > .input-label-sm { grid-column: 1 / -1; margin: 4px 0 -2px !important; }
  .consultation-filters > input,
  .consultation-filters > select { max-width: none !important; width: 100% !important; min-width: 0; height: 40px !important; font-size: 14px; }
  .consultation-filters > input[type="date"] { grid-column: 1 / -1; }
  .consultation-filters > select { grid-column: 1 / -1; }
  .consultation-filters > .btn-small-tool { margin-left: 0 !important; height: 40px; }
  .consultation-filters > #consult-num + .btn-small-tool { grid-column: 2; }
  .consultation-table-wrap { max-width: 100%; overflow-x: auto; }
  .consult-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px !important;
  }
  .consult-actions .btn-small-tool {
    min-width: 0;
    white-space: normal !important;
    line-height: 1.2;
    min-height: 44px;
    padding: 6px 8px !important;
  }

  /* ---------- Reportes: tabla de sorteos sin cortes ni saltos de hora ---------- */
  .reports-lotteries-table-wrap { max-width: 100%; overflow-x: auto; }
  .consult-table.reports-lot-table { min-width: 0 !important; width: 100%; font-size: 12px; }
  .reports-lot-table th, .reports-lot-table td { padding: 8px 5px !important; }
  .reports-lot-table td:nth-child(2) { white-space: nowrap; }
  .reports-lot-table th:nth-child(6), .reports-lot-table td:nth-child(6) { display: none; }
  .reports-lot-table .ticket-status-badge { padding: 2px 6px; font-size: 10px; }
  /* En teléfono: Sorteo, Cierre, Estado y Total Vendido (lo demás no cabe sin cortarse) */
  .reports-lot-table th:nth-child(4), .reports-lot-table td:nth-child(4) { display: none; }

  /* ---------- Cuadre: tablas con desplazamiento propio, sin ensanchar la página ---------- */
  .cuadre-wrap, .reports-wrap { max-width: 100%; overflow-x: hidden; }
  .cuadre-breakdown-table { font-size: 12px; }
}

/* Selector de loterías (hoja inferior): sin filtros, solo la lista */
.mobile-sheet-filters { display: none !important; }

/* ==========================================================================
   LOGOS: nunca recortados ni deformados (cuadro blanco, imagen completa)
   ========================================================================== */
.lot-logo-sm, .pz-lot img, .mobile-chip-logo, .modal-lot-logo {
  object-fit: contain !important;
  background: #fff;
  border-radius: 6px !important;
  flex-shrink: 0;
}
.lot-logo-sm { width: 28px; height: 28px; padding: 1px; border: 1px solid #e2e8f0; }
.pz-lot img { width: 28px !important; height: 28px !important; padding: 1px; border: 1px solid #e2e8f0; }
.mobile-chip-logo { width: 20px !important; height: 20px !important; }

/* ==========================================================================
   REPORTE A LA CARTA (ventana para elegir los cuadros)
   ========================================================================== */
.report-sections-dialog { max-width: 440px; width: calc(100vw - 24px); }
.report-sections-help { margin: 0 0 8px; font-size: 13px; color: #475569; }
.report-sections-quick { display: flex; gap: 8px; margin-bottom: 10px; }
.report-sections-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.report-section-opt {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; min-height: 52px;
  border: 1px solid #cbd5e1; border-radius: 10px; background: #f8fafc; cursor: pointer;
}
.report-section-opt:has(input:checked) { border-color: #1e3a8a; background: #eff6ff; }
.report-section-opt input { width: 22px; height: 22px; flex-shrink: 0; accent-color: #1e3a8a; }
.report-section-opt span { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.report-section-opt b { font-size: 14px; color: #0f172a; }
.report-section-opt small { font-size: 11.5px; color: #64748b; }

@media (max-width: 900px) {
  /* ---------- Reportes: lo importante arriba, sin cabecera gigante ---------- */
  #tab-reportes .reports-badge,
  #tab-reportes .reports-subtitle { display: none !important; }
  #tab-reportes .reports-header-banner { padding: 10px 12px !important; gap: 8px !important; }
  #tab-reportes .reports-title { font-size: 16px !important; line-height: 1.25; margin: 0 !important; }
  #tab-reportes .reports-header-controls {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px !important;
    align-items: center;
  }
  #tab-reportes .reports-date-picker-wrap { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
  #tab-reportes .reports-date-input { flex: 1; min-width: 0; height: 40px; }
  #tab-reportes .btn-cuadre-print-top { height: 40px; white-space: nowrap; }

  /* Pestañas de cuadros en una sola fila deslizable */
  #tab-reportes .reports-view-tabs {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; padding-bottom: 2px; margin-inline: -2px;
  }
  #tab-reportes .reports-view-tabs::-webkit-scrollbar { display: none; }
  #tab-reportes .rview-btn { flex: 0 0 auto; white-space: nowrap; height: 40px; padding: 0 14px; }

  /* ---------- Cuadros de tickets: cada fila es una tarjeta ---------- */
  .reports-list-card { padding: 10px !important; }
  .reports-list-summary { gap: 6px 14px !important; }
  .reports-list-card .consultation-table-wrap { overflow-x: visible; }
  .rcards { display: block; width: 100%; min-width: 0 !important; border: 0 !important; }
  .rcards thead { display: none; }
  .rcards tbody { display: block; }
  .rcards tr {
    display: block; margin-bottom: 10px; padding: 8px 12px;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
  }
  .rcards td {
    display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
    padding: 5px 0 !important; border: 0 !important; text-align: right !important;
    font-size: 13px; word-break: break-word;
  }
  .rcards td::before {
    content: attr(data-label); flex-shrink: 0;
    font-size: 11px; font-weight: 700; letter-spacing: .02em; color: #64748b; text-transform: uppercase; text-align: left;
  }
  .rcards td:first-child {
    font-size: 15px; padding-bottom: 7px !important; margin-bottom: 3px;
    border-bottom: 1px solid #f1f5f9 !important;
  }

  /* Premios del día y demás tablas de reportes: caben sin desplazarse */
  .prizes-table th, .prizes-table td { padding-inline: 2px; }
  .prizes-table .pz-lot { font-size: 12px; gap: 6px; }
}

@media (max-width: 900px) {
  /* Resumen por operadora: nombre arriba, monto abajo, sin apretarse */
  .recharge-op-summary-row { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px !important; }
  .rop-pill { display: flex !important; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 10px !important; min-width: 0; }
  .rop-pill strong { font-size: 13px; white-space: nowrap; }
  .recharge-history-table-wrap { overflow-x: visible !important; }
  .recharge-history-table.rcards td[colspan] { display: block; text-align: center !important; }
  .recharge-history-table.rcards td[colspan]::before { content: none; }
}

/* ==========================================================================
   RECARGAS: flujo guiado (compañía -> datos -> repetir datos -> clave)
   ========================================================================== */
.rc-hint {
  margin: 0 0 10px; padding: 10px 12px; border-radius: 10px;
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; font-size: 13px; font-weight: 700;
}
.rc-error {
  margin: 8px 0; padding: 10px 12px; border-radius: 10px;
  background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; font-size: 13px; font-weight: 700;
}
.rc-confirm-note {
  margin-bottom: 10px; padding: 10px 12px; border-radius: 10px;
  background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; font-size: 13px; font-weight: 700;
}
.rc-step2-info { margin-bottom: 10px; font-size: 14px; font-weight: 800; color: #0f172a; }
.rc-pkg-summary {
  margin: 4px 0 8px; padding: 10px 12px; border-radius: 10px;
  background: #ecfdf5; border: 1px solid #86efac; color: #166534; font-size: 13.5px; font-weight: 800;
}
/* Bloqueado hasta elegir la compañía */
.rc-locked .recharge-inputs-row,
.rc-locked #recharge-amount-group,
.rc-locked .recharge-packages-grid { opacity: .45; }
.rc-locked .package-card, .rc-locked .amt-chip { pointer-events: none; }
#recharge-form.rc-locked #rc-btn-main { opacity: .5; cursor: not-allowed; }
/* Paquete elegido: marca clara */
.package-card { position: relative; }
.package-card.selected { outline: 3px solid #16a34a; outline-offset: -1px; background: #f0fdf4; }
.package-card.selected::after {
  content: '✔'; position: absolute; top: 6px; right: 8px;
  width: 22px; height: 22px; border-radius: 50%; background: #16a34a; color: #fff;
  font-size: 13px; line-height: 22px; text-align: center; font-weight: 900;
}
.recharge-confirm-dialog { max-width: 440px; width: calc(100vw - 24px); }
.rc-confirm-text { margin: 0 0 14px; font-size: 15px; line-height: 1.45; color: #0f172a; }
