/* ---------------------------------------------------------------------- *
 * Framework7 brand theming — NTHU purple (Pantone 259 C / #6D2077),
 * matching the admin side's --purple-500 token.
 * ---------------------------------------------------------------------- */
:root {
  --f7-theme-color: #6d2077;
  --f7-theme-color-rgb: 109, 32, 119;
  --f7-tabbar-link-active-color: var(--f7-theme-color);
}

.dark {
  --f7-theme-color: #a058ab;
  --f7-theme-color-rgb: 160, 88, 171;
}

html,
body {
  overscroll-behavior-y: none;
}

/* ---------------------------------------------------------------------- *
 * F7's own app-shell layout (.framework7-root > .view > .page >
 * .page-content, all height:100%/position:absolute) is designed to be
 * measured and managed by F7's JS App instance. We deliberately don't
 * load that JS — it hijacks every <a> click into its SPA router, which
 * conflicts with this being a normal multi-page Express+Eta site — so
 * without it the shell collapses to zero height (blank page). These
 * overrides swap it for plain sticky/fixed positioning instead, which
 * needs no JS and no measurement. F7's actual components (buttons,
 * lists, cards, segmented controls, badges) are untouched by this.
 * ---------------------------------------------------------------------- */
html,
body {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

#app,
.view,
.page {
  position: static;
  height: auto;
  overflow: visible;
}

.page-content {
  height: auto;
  overflow: visible;
  padding-top: 0;
  padding-bottom: calc(var(--f7-toolbar-height, 56px) + env(safe-area-inset-bottom) + 16px);
}

.navbar {
  position: sticky;
  top: 0;
  z-index: 20;
}

.toolbar.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
}

/* ---------------------------------------------------------------------- *
 * Checkout stepper (upload → quote → order) — no F7 equivalent.
 * ---------------------------------------------------------------------- */
.tz-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 4px;
}

.tz-stepper .tz-step {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--f7-text-color);
  opacity: 0.45;
  font-size: 12px;
  font-weight: 600;
}

.tz-stepper .tz-step .tz-dot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(var(--f7-theme-color-rgb), 0.12);
  color: var(--f7-theme-color);
  font-size: 11px;
  flex-shrink: 0;
}

.tz-stepper .tz-step.active,
.tz-stepper .tz-step.done {
  opacity: 1;
}

.tz-stepper .tz-step.active .tz-dot,
.tz-stepper .tz-step.done .tz-dot {
  background: var(--f7-theme-color);
  color: #fff;
}

.tz-stepper .tz-step-line {
  flex: 1;
  height: 1px;
  background: var(--f7-list-item-border-color, rgba(0, 0, 0, 0.1));
  min-width: 12px;
}

@media (max-width: 380px) {
  .tz-stepper .tz-step .tz-step-label {
    display: none;
  }
}

/* ---------------------------------------------------------------------- *
 * File drop zone + instant local preview — no F7 equivalent.
 * ---------------------------------------------------------------------- */
.tz-file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 130px;
  margin: 16px;
  padding: 24px;
  border: 2px dashed var(--f7-list-item-border-color, rgba(0, 0, 0, 0.15));
  border-radius: var(--f7-card-border-radius, 12px);
  color: var(--f7-text-color);
  opacity: 0.9;
  text-align: center;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}

.tz-file-drop:hover,
.tz-file-drop.drag-over {
  border-color: var(--f7-theme-color);
  background: rgba(var(--f7-theme-color-rgb), 0.06);
}

.tz-file-drop .tz-icon {
  font-size: 32px;
}

.tz-file-drop input[type='file'] {
  display: none;
}

.tz-file-preview {
  display: none;
  align-items: center;
  gap: 12px;
  margin: 0 16px 16px;
  padding: 10px;
  border: 1px solid var(--f7-list-item-border-color, rgba(0, 0, 0, 0.1));
  border-radius: var(--f7-card-border-radius, 12px);
}

.tz-file-preview.show {
  display: flex;
}

.tz-file-preview .tz-thumb {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 8px;
  object-fit: cover;
  background: rgba(var(--f7-theme-color-rgb), 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  overflow: hidden;
}

.tz-file-preview .tz-meta {
  flex: 1;
  min-width: 0;
}

.tz-file-preview .tz-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tz-file-preview .tz-size {
  opacity: 0.6;
  font-size: 12px;
}

.tz-file-preview .tz-remove {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  font-size: 18px;
  min-height: 32px;
  min-width: 32px;
  border-radius: 50%;
}

/* ---------------------------------------------------------------------- *
 * "More" slide-up sheet — reuses F7 visual language, plain CSS + a
 * few lines of vanilla JS to toggle (no F7 JS bundle is loaded).
 * ---------------------------------------------------------------------- */
.tz-sheet-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 40;
}

.tz-sheet {
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  transform: translateY(100%);
  transition: transform 0.25s ease;
  background: var(--f7-page-bg-color, #fff);
  border-radius: 16px 16px 0 0;
  max-height: 70vh;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom);
}

.tz-sheet-open .tz-sheet-backdrop {
  display: block;
}

.tz-sheet-open .tz-sheet {
  transform: translateY(0);
}

.tz-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: var(--f7-list-item-border-color, rgba(0, 0, 0, 0.15));
  margin: 10px auto;
}

/* ---------------------------------------------------------------------- *
 * Small stat tiles, price-breakdown rows, quick-action tiles — none of
 * these have a direct F7 built-in, so they're custom but themed with F7's
 * own CSS variables to stay visually consistent.
 * ---------------------------------------------------------------------- */
.tz-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 8px 16px 0;
}

.tz-stat {
  text-align: center;
  padding: 10px 4px;
  border-radius: var(--f7-card-border-radius, 12px);
  background: rgba(var(--f7-theme-color-rgb), 0.06);
}

.tz-stat .tz-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
}

.tz-stat .tz-label {
  display: block;
  font-size: 11px;
  opacity: 0.6;
  margin-top: 2px;
}

.tz-summary {
  margin: 16px;
  padding-top: 4px;
}

.tz-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  opacity: 0.75;
  padding: 4px 0;
}

.tz-summary-row.tz-total {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px dashed var(--f7-list-item-border-color, rgba(0, 0, 0, 0.15));
  font-size: 17px;
  font-weight: 700;
  opacity: 1;
}

.tz-summary-row.tz-total .tz-value {
  color: var(--f7-theme-color);
}

.tz-action-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 8px 16px 0;
}

@media (max-width: 480px) {
  .tz-action-tiles {
    grid-template-columns: 1fr;
  }
}

.tz-action-tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border-radius: var(--f7-card-border-radius, 12px);
  background: var(--f7-card-bg-color, #fff);
  box-shadow: var(--f7-card-box-shadow, 0 2px 6px rgba(0, 0, 0, 0.08));
  color: inherit;
}

.tz-action-tile .tz-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(var(--f7-theme-color-rgb), 0.1);
  font-size: 20px;
}

.tz-action-tile .tz-title {
  font-weight: 700;
  font-size: 15px;
}

.tz-action-tile .tz-desc {
  font-size: 12px;
  opacity: 0.6;
}

/* ---------------------------------------------------------------------- *
 * F7's bare `.card` has no built-in padding without a nested
 * `.card-content`, and its `.badge` has no color unless you add one of
 * F7's own `.color-*` modifiers — our JS renders semantic ok/warn/err/info
 * modifiers instead (shared with the admin side's lib/http.js), so map
 * them onto real colors here rather than touching the shared JS helper.
 * ---------------------------------------------------------------------- */
a.card,
div.card {
  display: block;
  padding: 16px;
  color: inherit;
}

.badge.ok {
  background: var(--f7-color-green, #4cd964);
}

.badge.warn {
  background: var(--f7-color-orange, #ff9500);
}

.badge.err {
  background: var(--f7-color-red, #ff3b30);
}

.badge.info {
  background: var(--f7-color-blue, #2196f3);
}

/* ---------------------------------------------------------------------- *
 * Small utility classes still used by the order/scan history JS
 * (workspace.js, scan.js, orders-ui.js) that render server-agnostic list
 * markup shared conceptually with the admin side's lib/http.js helpers.
 * ---------------------------------------------------------------------- */
.muted {
  opacity: 0.6;
  font-size: 13px;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.badge-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  opacity: 0.6;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

a.btn,
button.small,
a.btn.small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 999px;
  border: none;
  background: var(--f7-theme-color);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

button.small.secondary,
a.btn.secondary {
  background: rgba(var(--f7-theme-color-rgb), 0.1);
  color: var(--f7-theme-color);
}

.flash {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
}

.flash.error {
  background: rgba(var(--f7-color-red-rgb, 255, 59, 48), 0.12);
  color: var(--f7-color-red, #ff3b30);
}

dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  max-width: 28rem;
  width: 90%;
  box-shadow: var(--f7-card-box-shadow, 0 12px 32px rgba(0, 0, 0, 0.2));
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}
