/* The portal and sign-in pages on phones and touch screens (3.005, owner decisions 2026-10-31). Loaded after
   style.css on index.html and login.html, never on the public website. The browser picks these rules from the
   screen width; the switch points are the website's, 860px and 520px (site.css). Hiding here is display only:
   the server still checks every right. */

.phone-bar, .phone-menu-backdrop, .phone-only, .computer-only-notice, .order-buttons, .touch-only { display: none; }

/* ---------- Touch screens of any width: no mouse, so no dragging and nothing that needs hovering ---------- */

@media (hover: none) {
  .drag-grip, .rec-card .drag-handle { display: none; }
  .mouse-only { display: none; }
  .touch-only { display: inline; }

  /* Instead of dragging: ↑ ↓ (makeSortable in core.js) */
  .order-buttons { display: inline-flex; gap: 4px; flex-shrink: 0; }
  .order-btn {
    width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 8px;
    background: #fff; color: var(--navy); font-size: 16px; cursor: pointer;
  }
  .order-btn:disabled { opacity: 0.35; cursor: default; }
  .rec-card .order-buttons { position: absolute; top: 6px; right: 8px; z-index: 1; }

  .company-row .del { opacity: 1; padding: 6px 8px; }

  /* What a mouse shows as a tip stays readable: the pill carries its explanation */
  .pill[title] { display: block; margin: 6px 0 0 !important; border-radius: 8px; padding: 5px 9px; }
  .pill[title]::after { content: attr(title); display: block; font-size: 12px; opacity: 0.85; }
}

/* iPhones zoom into a form field whose text is under 16px and stay zoomed in */
@media (hover: none), (max-width: 860px) {
  input:not([type=checkbox], [type=radio], .code-input), textarea, select { font-size: 16px !important; }
}

/* ---------- Up to 860px: the phone layout ---------- */

@media (max-width: 860px) {
  /* Pages that need a computer: the owner's list of Admin pages, and the helper's set-up buttons */
  .computer-only { display: none !important; }
  .phone-only { display: block; }
  .computer-only-page .computer-only-notice { display: block; }
  .computer-only-page .panel.active { display: none; }

  /* The top bar, like the website's: logo and name on the left, ☰ on the right */
  .phone-bar {
    display: flex; align-items: center; position: sticky; top: 0; z-index: 45; height: 56px; padding: 0 16px;
    background: #fff; border-bottom: 1px solid var(--line);
  }
  .phone-bar-brand {
    display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--ink); text-decoration: none;
  }
  .phone-bar-brand img { width: 32px; height: 32px; }
  .user-menu { top: 6px; right: 16px; }
  .menu-btn { width: 44px; height: 44px; }
  .admin-menu-btn { width: auto; }
  .menu-panel { top: 50px; }
  body.phone-menu-open .menu-btn:not(.admin-menu-btn) span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  body.phone-menu-open .menu-btn:not(.admin-menu-btn) span:nth-child(2) { opacity: 0; }
  body.phone-menu-open .menu-btn:not(.admin-menu-btn) span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

  /* The sidebar slides in from the ☰; the account menu's links sit below it (phone-menu.js) */
  .shell { display: block; }
  .sidebar {
    position: fixed; top: 56px; right: 0; bottom: 0; z-index: 44; width: min(320px, 100%); max-height: none;
    padding: 14px 0 24px; overflow-y: auto; overscroll-behavior: contain;
    transform: translateX(100%); visibility: hidden; transition: transform 0.2s ease, visibility 0.2s;
  }
  body.phone-menu-open { overflow: hidden; }
  body.phone-menu-open .sidebar { transform: none; visibility: visible; }
  body.phone-menu-open .phone-menu-backdrop {
    display: block; position: fixed; inset: 56px 0 0 0; z-index: 43; background: rgba(20, 24, 30, 0.45);
  }
  .sidebar .brand { display: none; }
  /* A long property list scrolls on its own, so the account links stay in view below it */
  .properties-section { min-height: 180px; }
  .company-current { padding: 11px 12px; font-size: 15px; }
  .settings-btn { width: 44px; height: 44px; }
  .icon-btn { width: 36px; height: 36px; }
  .company-row { padding: 11px 8px; font-size: 15px; }
  .property-row, .account-nav .property-row { padding: 11px 10px; font-size: 15px; }
  .account-back { padding: 8px 10px 14px; font-size: 15px; }
  .sidebar .menu-panel, .sidebar .menu-panel[hidden] {
    position: static; display: flex; min-width: 0; margin: 6px 12px 0; padding: 12px 0 0; background: none;
    border: none; border-top: 1px solid var(--sidebar-line); border-radius: 0; box-shadow: none;
  }
  .sidebar .user-email { color: #93a0ad; font-size: 13px; padding: 0 10px 8px; margin: 0; border: none; }
  .sidebar .user-link { color: var(--sidebar-text); font-size: 15px; padding: 9px 10px; border-radius: 8px; }
  .sidebar .user-link:hover { background: rgba(255, 255, 255, 0.06); }
  .sidebar .user-link.selected { color: #fff; background: rgba(251, 208, 0, 0.16); }
  .sidebar .menu-version, .sidebar a.menu-version { color: #93a0ad; border: none; padding: 6px 10px 0; }

  /* The page */
  .main { max-width: none; padding: 18px 16px 60px; }
  .main-header h1 { font-size: 22px; }
  .view-as-banner { margin-right: 0; flex-wrap: wrap; }
  .card { padding: 16px; }
  .toast { left: 16px; right: 16px; bottom: 16px; z-index: 60; text-align: center; }

  /* The property tabs: one row that swipes sideways, edge to edge */
  .tabs {
    margin: 0 -16px 18px; padding: 0 16px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; padding: 12px 14px; white-space: nowrap; }

  /* Comfortable to tap: the website's 44px where there's room */
  .btn { min-height: 44px; padding: 10px 18px; }
  .btn.small { min-height: 36px; padding: 6px 12px; }
  .link-btn { padding: 6px 0; font-size: 14px; }
  .button-row, .auth-actions { flex-wrap: wrap; }
  input[type=date], input[type=number], input[type=datetime-local], input[type=time], .inline-form input {
    min-width: 0; max-width: 100%;
  }
  input[type=date], input[type=number] { padding: 8px 10px; border: 1.5px solid #c9ced5; border-radius: 8px; }
  input[type=file] { max-width: 100%; }

  /* Reservations and TVs: each row becomes a card, a cell's heading above its value */
  table.stack-table, table.stack-table tbody { display: block; }
  table.stack-table thead { display: none; }
  table.stack-table tr {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; padding: 12px; margin-bottom: 10px;
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  }
  table.stack-table td { display: block; min-width: 0; padding: 0; border: none; }
  table.stack-table td:empty { display: none; }
  table.stack-table td:not([data-label]), table.stack-table td.stack-wide { grid-column: 1 / -1; }
  table.stack-table td[data-label]::before {
    content: attr(data-label); display: block; font-size: 12px; color: var(--ink-soft); margin-bottom: 2px;
  }
  table.stack-table br { display: none; }
  table.stack-table .link-btn { margin: 0 16px 0 0; }
  table.res-table tr.double-booking { background: #f9e3e0; border-color: #e9b9b1; }
  table.res-table tr.double-booking .pill.no { display: none; }
  table.res-table tr.double-booking::after { content: attr(title); grid-column: 1 / -1; font-size: 12.5px; color: #8a2f24; }

  /* Other tables keep their columns and scroll sideways inside their box, like Logs */
  table.accounts-table:not(.stack-table), table.data-table { display: block; overflow-x: auto; }

  /* Recommendations: the categories above the places */
  .rec-layout { flex-direction: column; align-items: stretch; }
  .rec-categories { width: auto; }

  /* Guide Books: a block's text or picture takes the full width under its buttons */
  .guide-entry-header { flex-wrap: wrap; }
  .entry-row-header { padding: 12px; }
  .entry-row-body { padding: 4px 12px 14px; }
  .guide-element { flex-wrap: wrap; justify-content: space-between; align-items: center; }
  .guide-element-body, .guide-element-image { flex: 1 1 100%; order: 1; }
  .inline-form label.btn { font-size: 13.5px; text-align: center; }
  .guide-element-image { flex-direction: column; align-items: stretch; }
  .guide-element-image img { width: 100%; height: 150px; }
  .guide-element-del { margin-top: 0; padding: 8px 4px; font-size: 14px; }

  /* Pop-ups */
  .guide-modal { padding: 12px; }
  .guide-dialog { padding: 16px; }
  .guide-head .icon-btn { flex-shrink: 0; color: var(--navy); border-color: var(--line); }
  .text-dialog { margin-top: 6vh; }
  .guide-figure { width: 100%; }
}

/* ---------- Up to 520px: one column ---------- */

@media (max-width: 520px) {
  .style-row, .slot-choice { grid-template-columns: 1fr; }
  .totp-setup, .wifi-qr-row { flex-direction: column; align-items: stretch; }
  .wifi-qr-row > div { width: 100%; }
  /* The gallery opens under both buttons, across the card */
  .gallery-drop { position: static; }
  .bg-actions { position: relative; }
  .gallery-menu { right: 0; width: auto; max-width: none; grid-template-columns: repeat(2, 1fr); }
  .field-row { flex-wrap: wrap; }
  .field-row .value { text-align: left; }
}
