/* =====================================================================
   Lundia Shelving Designer — tablet & mobile layout
   Loaded by both 12inch_deep_x_84/96inch_high_shelving_designer.html
   (added by _apply_designer_patches.sh, patch 11). Desktop is unchanged.
   ===================================================================== */

/* ---------- Touch devices (any width): tap-to-move controls ---------- */
.lm-move {
  display: none;
  position: absolute;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  gap: 6px;
  z-index: 3;
}
.lm-move button {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--accent-dark, #3d2f1c);
  color: #fff;
  font-size: 15px; line-height: 1;
  font-family: Arial, Helvetica, sans-serif;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  cursor: pointer;
  padding: 0;
}
.lm-move button:disabled { opacity: 0.3; }

@media (hover: none), (max-width: 900px) {
  .placed.selected .lm-move { display: flex; }
  .placed .remove { width: 30px; height: 30px; font-size: 18px; top: -14px; right: -14px; }
  .placed:hover { transform: none; }
}

/* ---------- Tablets: narrower side panels ---------- */
@media (min-width: 901px) and (max-width: 1200px) {
  .app { grid-template-columns: 230px minmax(0, 1fr) 300px !important; }
  .topbar { padding: 12px 16px; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .canvas-stage { padding: 30px 20px; }
}

/* ---------- Phones & small tablets: stacked layout ---------- */
@media (max-width: 900px) {
  html, body { height: auto !important; overflow: visible !important; }
  body { display: block !important; padding-bottom: 76px; }

  /* Top bar: compact, buttons wrap */
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 14px; }
  .brand h1 { font-size: 18px; }
  .brand .sub { font-size: 10px; letter-spacing: 1px; }
  .topbar-actions { flex-wrap: wrap; gap: 6px; }
  .topbar-actions button, .topbar-actions a.btn { padding: 8px 10px; font-size: 13px; }
  .topbar-actions a.btn { flex-basis: 100%; text-align: center; }
  .topbar-actions .help-link { margin-right: 0; }

  /* Stack: drawing first, then units, then totals/parts */
  .app { display: flex !important; flex-direction: column; }
  .canvas-wrap { order: 1; overflow-x: auto; overflow-y: visible; min-height: 0; }
  .sidebar     { order: 2; border-right: none; border-top: 1px solid var(--line); overflow: visible; }
  .summary     { order: 3; border-left: none; border-top: 1px solid var(--line); overflow: visible; }
  .panel-title { position: static; }

  /* Drawing area */
  .canvas-header { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
  .canvas-info { font-size: 11px; }
  .canvas-zoom button { min-width: 34px; min-height: 34px; }
  .canvas-stage {
    padding: 56px 16px 16px;
    justify-content: flex-start;   /* long runs scroll instead of being cut off */
    min-height: 240px;
  }
  .canvas-floor { margin: 0 auto; }
  .canvas-empty { padding: 28px 18px; }
  .placed .label { font-size: 9px; padding: 2px 5px; }
  .placed .badge { font-size: 10px; }
  .validation { top: 56px; max-width: 92%; font-size: 12px; }

  /* Unit catalog: two cards per row */
  .unit-catalog {
    padding: 8px 12px 16px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .catalog-section-title { grid-column: 1 / -1; margin-bottom: 0; }
  .unit-card { margin-bottom: 0; align-items: flex-start; }
  .unit-card:hover { transform: none; }
  .unit-card .price-cell { font-size: 10px; }

  /* Modals fit the screen */
  .modal-bg { padding: 10px; }
  .modal { padding: 20px 16px; }
  .welcome-modal { max-height: 92vh; }
}

@media (max-width: 420px) {
  .unit-catalog { grid-template-columns: 1fr; }
}

/* ---------- Pinned total bar (phones) ---------- */
#lmTotalBar { display: none; }

@media (max-width: 900px) {
  #lmTotalBar {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 50;
    align-items: center;
    gap: 10px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--accent-dark, #3d2f1c);
    color: #fff;
    font-family: Arial, Helvetica, sans-serif;
    box-shadow: 0 -4px 14px rgba(0,0,0,0.25);
  }
  #lmTotalBar .lm-totals { flex: 1; min-width: 0; line-height: 1.25; }
  #lmTotalBar .lm-main { font-size: 16px; font-weight: 700; }
  #lmTotalBar .lm-main small { font-size: 11px; font-weight: 400; opacity: 0.85; }
  #lmTotalBar .lm-sub { font-size: 11px; opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #lmTotalBar button {
    flex: 0 0 auto;
    background: var(--accent-soft, #e0c291);
    color: var(--accent-dark, #3d2f1c);
    border: none; border-radius: 4px;
    padding: 9px 12px;
    font-weight: 700; font-size: 13px;
    cursor: pointer;
  }

  /* "Added" confirmation toast */
  #lmToast {
    position: fixed;
    left: 50%; bottom: 84px;
    transform: translateX(-50%) translateY(10px);
    z-index: 60;
    background: #1f7a2e;
    color: #fff;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px; font-weight: 700;
    padding: 9px 16px; border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    white-space: nowrap;
  }
  #lmToast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media print {
  #lmTotalBar, #lmToast, .lm-move { display: none !important; }
}
