/* ==========================================================================
   responsive.css — Adaptación a laptop, tablet y smartphone.
   ========================================================================== */

/* ---------------------------------------------------------------- laptop */
@media (max-width: 1240px) {
  .summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat--progress { grid-column: 1 / -1; }
  .stats-panel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .app-header { grid-template-columns: minmax(0, 1fr) minmax(260px, 420px) auto; }
}

/* ---------------------------------------------------------------- tablet */
@media (max-width: 1024px) {
  .app { padding: 16px 20px 40px; }
  .tabs { margin: 0 -20px 16px; padding: 8px 20px; }

  .view--plano:not([hidden]) { grid-template-columns: 1fr; }
  .unassigned-panel { position: static; max-height: none; }
  .chip-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 2px 6px;
    max-height: 280px;
  }
  .event-form { grid-template-columns: 1fr 1fr; }
  .event-form .field:first-child { grid-column: 1 / -1; }
  .event-form-actions { grid-column: 1 / -1; }
  .legend-tip { margin-left: 0; width: 100%; }
}

@media (max-width: 860px) {
  .app-header { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
  .header-search { grid-column: 1 / -1; grid-row: 2; }
  #consulta-btn .btn-label { display: none; }
  #consulta-btn { width: 38px; padding: 0; }
}

/* ------------------------------------------------------------ smartphone */
@media (max-width: 720px) {
  body { font-size: 15px; }
  .app { padding: 12px 14px calc(96px + env(safe-area-inset-bottom)); }

  .app-header { padding-bottom: 12px; }
  .brand-mark { width: 36px; height: 36px; border-radius: 11px; }
  .brand-mark svg { width: 24px; height: 24px; }
  .event-name { font-size: 18px; }
  #undo-btn .btn-label { display: none; }
  .sync-pill { padding: 0 10px; font-size: 12px; }
  .sync-pill.is-ok .sync-label { display: none; }
  #undo-btn { width: 38px; padding: 0; }
  .search-kbd { display: none; }

  /* Resumen compacto: una fila de cifras y la barra de progreso */
  .summary { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
  .stat { padding: 9px 8px 8px; border-radius: var(--radius); align-items: center; text-align: center; }
  .stat-label { font-size: 10px; letter-spacing: 0.04em; }
  .stat-value { font-size: 21px; order: -1; }
  .stat-sub { display: none; }
  .stat--progress { align-items: stretch; text-align: left; padding: 10px 12px; gap: 8px; }
  .progress-head .stat-label { font-size: 13.5px; }
  .progress-pct { font-size: 18px; }
  .status-chips { font-size: 12px; gap: 4px 12px; }

  /* Navegación inferior tipo app */
  .tabs {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
    gap: 2px;
    border-bottom: 0;
    border-top: 1px solid var(--border);
    z-index: 40;
  }
  .tab {
    flex: 1;
    flex-direction: column;
    gap: 2px;
    height: 54px;
    padding: 0 4px;
    font-size: 11.5px;
    border-radius: 12px;
  }
  .tab .icon { width: 22px; height: 22px; }
  .tab[aria-current="page"] { box-shadow: none; background: var(--accent-soft); color: var(--accent-strong); }

  .move-banner {
    bottom: calc(76px + env(safe-area-inset-bottom));
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
  }
  .move-banner-actions { justify-content: flex-end; }
  .toast-region {
    left: 12px;
    right: 12px;
    bottom: calc(80px + env(safe-area-inset-bottom));
    align-items: stretch;
  }
  body.is-moving .toast-region { bottom: calc(196px + env(safe-area-inset-bottom)); }
  body.is-moving .app { padding-bottom: calc(230px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }

  .view-head { align-items: flex-start; flex-direction: column; gap: 10px; }
  .view-head .btn { width: 100%; }
  .view-title { font-size: 23px; }

  /* Plano: una mesa grande por fila, nunca mesas diminutas */
  :root { --table-size: 272px; }
  .floor-wrap { padding: 10px 8px 18px; border-radius: var(--radius-lg); }
  .floor { grid-template-columns: 1fr; gap: 22px; justify-items: stretch; }
  .table { width: 100%; display: flex; flex-direction: column; align-items: center; }
  .table-ring { width: var(--table-size); }
  .table-names { width: 100%; }
  .floor-legend { font-size: 12px; gap: 6px 12px; }
  .chip-list { grid-template-columns: 1fr; max-height: 300px; }
  .chip-actions { opacity: 1; }

  /* Lista de invitados como tarjetas */
  .toolbar { display: grid; grid-template-columns: 1fr 1fr; padding: 12px; }
  .toolbar-field { min-width: 0; }
  .toolbar-field--sort { margin-left: 0; }

  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 12px;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
  }
  .data-table tbody tr:first-child { border-top: 0; }
  .data-table td { padding: 2px 0; border: 0; font-size: 13.5px; }
  .data-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-3);
  }
  .data-table td.cell-name { grid-column: 1 / -1; font-size: 16px; }
  .data-table td.cell-name::before,
  .data-table td.cell-actions::before { display: none; }
  .data-table td.cell-actions { grid-column: 1 / -1; text-align: left; padding-top: 6px; }
  .row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
  .row-actions .btn { background: var(--surface-2); border: 1px solid var(--border); }

  .stats-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tables-grid { grid-template-columns: 1fr; }
  .tools-grid { grid-template-columns: 1fr; }
  .event-form { grid-template-columns: 1fr; }
  .tool-actions .btn { flex: 1; }

  /* Modales tipo hoja inferior */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal,
  .modal--sm,
  .modal--lg {
    width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: sheet-in 0.24s var(--ease);
  }
  .modal-footer { padding: 12px 16px 16px; }
  .modal-footer-end { width: 100%; }
  .modal-footer-end .btn { flex: 1; }
  .modal-header { padding: 18px 16px 4px 18px; }
  .modal-body { padding: 10px 18px 16px; }
  .field-row { grid-template-columns: 1fr; }
  .preview-table-wrap { max-height: 42vh; }
  .preview-table th:nth-child(3),
  .preview-table td:nth-child(3) { display: none; }

  .tedit-row { grid-template-columns: 34px 74px minmax(0, 1fr); }
  .tedit-occ { display: none; }

  /* Consulta */
  .consulta:not([hidden]) { min-height: calc(100vh - 40px); }
  .consulta-title { font-size: 32px; }
  .consulta-input { height: 62px; font-size: 21px; }
  .answer-value { font-size: 56px; }
  .consulta-results.is-single .answer-value { font-size: 76px; }
  body.consulta-mode .app { padding-bottom: 24px; }
}

@media (max-width: 380px) {
  .stat-value { font-size: 18px; }
  .stat-label { font-size: 9px; }
  .tab .tab-label { font-size: 10.5px; }
  :root { --table-size: 248px; }
}

/* En pantallas táctiles las acciones siempre son visibles y no hay tooltips. */
@media (hover: none) {
  .tab:not([aria-current="page"]):hover { background: transparent; color: var(--text-2); }
  .btn--ghost:hover:not(:disabled) { background: transparent; }
  .chip-actions { opacity: 1; }
  .seat.is-occupied::after { display: none; }
  .seat:hover { transform: translate(-50%, -50%); }
}

@keyframes sheet-in {
  from { transform: translateY(40px); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}
