/* Price Label PWA – same look as the Android app (purple background, white rounded cards, green buttons). */
:root {
  --brand: #800080;
  --green: #90ee90;
  --text: #000;
  --muted: #808080;
  --error: #ff0000;
  --corner: #800080;
  --radius: 10px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--brand);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--text); }

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: calc(12px + var(--safe-top)) 16px calc(8px + var(--safe-bottom));
  gap: 12px;
}

.card { background: #fff; border-radius: var(--radius); }
.muted { color: var(--muted); }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-button { background: none; border: 0; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.icon-button svg { width: 28px; height: 28px; fill: currentColor; }

.green-button {
  background: var(--green);
  border: 0;
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 500;
  letter-spacing: .02em;
}
.green-button:disabled { opacity: .6; }
.text-button { background: none; border: 0; padding: 12px; font-weight: 500; }
.text-button.light { color: #fff; }

/* Top bar */
.top-bar { position: relative; min-height: 48px; display: flex; align-items: center; justify-content: center; }
.shop-name { color: #fff; font-size: 24px; text-align: center; padding: 0 56px; }
.menu-button { position: absolute; right: 0; top: 0; width: 48px; height: 48px; color: #e3b5e3; }

/* Search */
.search-card { display: flex; align-items: center; padding: 6px 6px 6px 12px; }
.search-card input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 18px; padding: 10px 0;
  -webkit-appearance: none; appearance: none;
}
.search-card input::placeholder { color: var(--muted); }
.scan-button { width: 48px; height: 48px; color: #000; }
.scan-button svg { width: 32px; height: 32px; }

/* Middle: results / scanner */
.middle { flex: 1; min-height: 0; position: relative; }
.result-list { list-style: none; margin: 0; padding: 0; height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.result-list li { background: #fff; padding: 12px; font-size: 17px; border-bottom: 1px solid #000; }
.result-list li:active { background: #eee; }

.scanner-box { position: absolute; inset: 0; background: #000; border-radius: var(--radius); overflow: hidden; }
.scanner-box video { width: 100%; height: 100%; object-fit: cover; }
.scan-line { position: absolute; left: 8%; right: 8%; top: 50%; height: 2px; background: rgba(255, 0, 0, .75); box-shadow: 0 0 6px red; }
.close-scanner { position: absolute; top: 4px; right: 4px; width: 44px; height: 44px; color: #fff; font-size: 24px; text-shadow: 0 0 4px #000; }

/* Details */
.add-stock-button { align-self: flex-start; height: 40px; padding: 0 16px; margin-bottom: -4px; }
.detail-card { padding: 12px 16px; }
.detail-head { display: flex; justify-content: space-between; gap: 8px; font-size: 17px; }
.corner { color: var(--corner); white-space: nowrap; }
.detail-value { font-size: 24px; min-height: 32px; margin-top: 6px; word-break: break-word; }
.print-button { height: 52px; font-size: 16px; }
.powered { color: #fff; text-align: center; font-size: 15px; }

/* Screens (shop, PIN) */
.screen {
  position: fixed; inset: 0; z-index: 30; background: var(--brand);
  padding: calc(16px + var(--safe-top)) 16px 16px; display: flex; flex-direction: column; gap: 12px;
}
.screen .card { padding: 16px; }
.field-label { display: block; font-size: 17px; margin-bottom: 6px; }
.prefix-row { display: flex; align-items: center; gap: 4px; }
.prefix-row input { flex: 1; min-width: 0; border: 0; border-bottom: 1px solid var(--muted); padding: 8px 2px; font-size: 18px; outline: 0; }
.error-text { color: #ffd0d0; min-height: 20px; }
.next-button { align-self: flex-end; padding: 14px 28px; }
.pin-input {
  width: 100%; margin-top: 12px; border: 0; border-bottom: 2px solid #20c0b0; outline: 0; text-align: center;
  font-size: 32px; letter-spacing: .5em; padding: 8px 0;
  -webkit-text-security: disc; text-security: disc;
}
.pin-status { min-height: 24px; margin-top: 8px; text-align: center; color: var(--error); }
.pin-status.info { color: var(--text); }

/* Printer picker */
.printer-card { max-height: 75vh; overflow-y: auto; }
.printer-list { list-style: none; margin: 8px 0 0; padding: 0; }
.printer-list li { padding: 14px 4px; border-bottom: 1px solid #ddd; font-size: 17px; display: flex; justify-content: space-between; gap: 8px; }
.printer-list li.selected { color: var(--brand); font-weight: 600; }
.printer-list li .muted { font-size: 14px; }

/* Drawer */
.backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .45); }
.drawer {
  position: fixed; z-index: 41; top: 0; bottom: 0; left: 0; width: 72%; max-width: 320px; background: #fafafa;
  padding: calc(8px + var(--safe-top)) 0 8px; transform: translateX(-100%); transition: transform .2s ease;
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-item { text-align: left; background: none; border: 0; padding: 16px 24px; font-size: 16px; }

/* Add Stock sheet: fixed full height so it never changes size with the keyboard or messages */
.sheet {
  position: fixed; z-index: 51; left: 0; right: 0; top: var(--safe-top); bottom: 0; background: #fff;
  border-radius: 14px 14px 0 0; padding: 12px 16px calc(16px + var(--safe-bottom)); overflow-y: auto;
  animation: slide-up .2s ease;
}
#sheetBackdrop { z-index: 50; }
@keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-title { font-size: 20px; font-weight: 700; }
.sheet .muted { margin-bottom: 12px; }
.sheet .field-label { font-size: 15px; margin: 0 0 4px; }
.qty-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.qty-button { width: 56px; height: 44px; font-size: 22px; flex: none; }
.qty-row input { flex: 1; min-width: 0; text-align: center; font-size: 22px; border: 0; border-bottom: 2px solid #20c0b0; outline: 0; padding: 6px 0; }
.sheet select {
  width: 100%; height: 44px; margin-bottom: 12px; font-size: 17px; border: 0; border-bottom: 1px solid var(--muted);
  background: #fff; -webkit-appearance: none; appearance: none; border-radius: 0;
  background-image: linear-gradient(45deg, transparent 50%, #666 50%), linear-gradient(135deg, #666 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 8px) 50%; background-size: 6px 6px; background-repeat: no-repeat;
}
.cost-row { display: flex; align-items: center; gap: 4px; font-size: 20px; }
.cost-row input { flex: 1; min-width: 0; border: 0; border-bottom: 1px solid var(--muted); outline: 0; font-size: 20px; padding: 8px 2px; }
.sheet-status { height: 40px; display: flex; align-items: center; color: var(--error); font-size: 14px; overflow: hidden; }
.sheet-buttons { display: flex; gap: 12px; }
.sheet-buttons .text-button { flex: 1; }
.save-button { flex: 2; height: 48px; font-size: 18px; font-weight: 700; }

/* Toast */
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(96px + var(--safe-bottom)); transform: translateX(-50%);
  max-width: 88%; background: rgba(50, 50, 50, .95); color: #fff; padding: 12px 20px; border-radius: 24px;
  font-size: 15px; text-align: center;
}

/* Portrait only */
.rotate-notice { display: none; }
@media (orientation: landscape) and (max-height: 500px) {
  .rotate-notice {
    display: flex; position: fixed; inset: 0; z-index: 100; background: var(--brand); color: #fff;
    align-items: center; justify-content: center; font-size: 20px;
  }
}
