/* ============================================================
   BoxDiegen — Mobile Responsive + Unit System
   ============================================================ */

/* ── Unit Toggle Bar — inside controls panel ── */
.unit-toggle-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 0 12px 0;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-2);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.unit-toggle-bar span { font-weight: 600; color: var(--text-3); margin-right: 4px; }
.unit-btn {
  padding: 5px 14px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--white);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-2);
  transition: all .15s;
  font-family: inherit;
}
.unit-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.unit-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.unit-hint {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 2px;
  display: block;
}

/* Input with unit label */
.input-unit-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-unit-wrap input {
  padding-right: 36px !important;
}
.input-unit-label {
  position: absolute;
  right: 8px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  pointer-events: none;
}

/* ── Mobile Bottom Export Bar ── */
.mobile-export-bar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  gap: 8px;
  z-index: 500;
  box-shadow: 0 -4px 12px rgba(0,0,0,.08);
}
.mobile-export-bar .btn-export {
  flex: 1;
  height: 44px;
  border-radius: 8px;
  font-size: 13px;
}

/* ── Mobile Tab Navigation ── */
.mobile-tabs {
  display: none;
  position: fixed;
  bottom: 68px; left: 0; right: 0;
  background: var(--white);
  border-top: 1px solid var(--border);
  z-index: 499;
  padding: 0;
}
.mobile-tabs-inner {
  display: flex;
}
.mobile-tab {
  flex: 1;
  padding: 10px 6px 8px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all .15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.mobile-tab svg {
  width: 18px; height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}
.mobile-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── RESPONSIVE BREAKPOINTS ── */
@media (max-width: 900px) {

  /* Hide desktop sidebar & info panel */
  .sidebar { display: none !important; }
  .info-panel { display: none !important; }
  .topbar-links { display: none !important; }

  /* Full width layout */
  .app-wrap {
    margin-left: 0 !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr !important;
    height: calc(100vh - var(--topbar-h) - 112px) !important;
    padding-bottom: 0;
  }

  /* Controls panel mobile - visible by default, JS switches tabs */
  .controls-panel {
    display: block;
    border-right: none !important;
    overflow-y: auto;
    max-height: calc(100vh - var(--topbar-h) - 112px);
    padding-bottom: 20px;
  }
  .controls-panel.mob-hidden { display: none !important; }
  .controls-panel.mob-active { display: block !important; }

  /* Preview area mobile */
  .preview-area {
    display: none;
    height: calc(100vh - var(--topbar-h) - 112px);
  }
  .preview-area.mob-active { display: flex !important; }

  /* Info panel mobile */
  .info-panel-mobile {
    display: none;
    overflow-y: auto;
    max-height: calc(100vh - var(--topbar-h) - 112px);
    background: var(--white);
    padding: 16px;
  }
  .info-panel-mobile.mob-active { display: block !important; }

  /* Show mobile UI */
  .mobile-export-bar { display: flex !important; }
  .mobile-tabs { display: block !important; }

  /* Topbar compact */
  .topbar { padding: 0 12px; }
  .topbar-brand .brand-tag { display: none; }
  .topbar-wa span { display: none; }

  /* Unit toggle compact */
  .unit-toggle-bar { padding: 6px 12px; }

  /* Form fields full width on mobile */
  .field-r { grid-template-columns: 1fr 90px !important; }
  .ctrl-select-full { grid-column: 1 / -1; }
  .options-grid { grid-template-columns: 1fr 1fr; }

  /* Preview legend bottom position adjust */
  .preview-legend { bottom: 8px; }
  .preview-badge { top: 8px; }
}

@media (max-width: 480px) {
  .unit-btn { padding: 4px 8px; font-size: 11px; }
  .mobile-tab { font-size: 10px; padding: 8px 4px 6px; }
  .topbar-brand { font-size: 14px; }
}

/* ── Cutter info in mobile info panel ── */
.mob-cutter-stat {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.mob-cutter-stat:last-child { border-bottom: none; }
.mob-cutter-stat .lbl { color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.mob-cutter-stat .val { font-weight: 600; color: var(--text); }
.mob-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

/* ── iPad (768px - 900px) specific ── */
@media (min-width: 769px) and (max-width: 900px) {
  .app-wrap {
    margin-left: 0 !important;
    grid-template-columns: 260px 1fr 0px !important;
  }
  .sidebar { width: 56px !important; }
  .sidebar .nav-item-link span { display: none; }
  .sidebar .nav-item-link { justify-content: center; }
  .sidebar .sidebar-label { display: none; }
  .info-panel { display: none !important; }
  .mobile-export-bar { display: flex !important; }
}
