@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:wght@300;400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg        : #0c0c0c;
  --bg2       : #141414;
  --bg3       : #1c1c1c;
  --border    : #2a2a2a;
  --accent    : #B8CC86;
  --accent-d  : #8fa55f;
  --text      : #e8e8e8;
  --text-dim  : #888;
  --text-muted: #555;
  --sidebar-w : 274px;
  --toolbar-h : 52px;
  --order-w   : 360px;
}

html, body {
  height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text); font-family: 'DM Sans', sans-serif;
}

/* ── Layout ── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ── Toolbar — safe area aware ── */
#toolbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: calc(var(--toolbar-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  padding-left:  calc(14px + env(safe-area-inset-left,  0px));
  padding-right: calc(14px + env(safe-area-inset-right, 0px));
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  overflow: hidden;
}
#logoLink { display: flex; align-items: center; text-decoration: none; flex-shrink: 0; }
#logoImg  { height: 28px; width: auto; }
#logoFallback {
  display: none; align-items: center;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px; letter-spacing: 2px; color: var(--accent);
}
#toolbarCenter {
  flex: 1; font-family: 'Bebas Neue', sans-serif;
  font-size: 15px; letter-spacing: 1.5px; color: var(--text-dim);
  text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.tb-group { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.tb-btn {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; cursor: pointer;
  transition: background .15s, border-color .15s;
  font-family: 'DM Sans', sans-serif; font-size: 13px;
  height: 34px; padding: 0 12px; gap: 6px; white-space: nowrap;
}
.tb-btn:hover { background: #242424; border-color: #3a3a3a; }
.tb-btn.accent { background: var(--accent); border-color: var(--accent); color: #111; font-weight: 600; }
.tb-btn.accent:hover { background: var(--accent-d); border-color: var(--accent-d); }
.tb-btn.icon-only { width: 34px; min-width: 34px; padding: 0; flex-shrink: 0; }
#zoomLabel { font-size: 12px; color: var(--text-dim); min-width: 36px; text-align: center; }
#installBtn { display: none; flex-shrink: 0; }

/* ── ORDER TRIGGER BUTTON (toolbar, desktop) ── */
.order-trigger-btn {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #111 !important;
  font-weight: 600 !important;
}
.order-trigger-btn:hover {
  background: var(--accent-d) !important;
  border-color: var(--accent-d) !important;
}
.order-trigger-btn.active {
  background: var(--accent-d) !important;
  border-color: var(--accent-d) !important;
}

/* ── Sidebar ── */
aside {
  position: fixed;
  top: calc(var(--toolbar-h) + env(safe-area-inset-top, 0px));
  bottom: 0; left: 0;
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 50;
}
.aside-scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 0;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.aside-scroll::-webkit-scrollbar { width: 4px; }
.aside-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.aside-section-title {
  font-family: 'Bebas Neue', sans-serif; font-size: 11px;
  letter-spacing: 2px; color: var(--text-muted); padding: 6px 16px;
}

/* ── Sidebar list items ── */
.img-item {
  display: flex; align-items: center; padding: 9px 14px;
  cursor: pointer; border-left: 3px solid transparent;
  transition: background .12s, border-color .12s; gap: 10px; user-select: none;
}
.img-item:hover { background: var(--bg3); }
.img-item.active { background: rgba(184,204,134,.08); border-left-color: var(--accent); }
.img-item-num { font-family: 'Bebas Neue', sans-serif; font-size: 18px; color: var(--text-muted); min-width: 26px; line-height: 1; }
.img-item.active .img-item-num { color: var(--accent); }
.img-item-label { font-size: 13px; font-weight: 500; color: var(--text); flex: 1; }
.img-item.active .img-item-label { color: var(--accent); }
.img-item-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border); flex-shrink: 0; transition: background .12s; }
.img-item.active .img-item-dot { background: var(--accent); }

/* ── Company card ── */
.company-card { border-top: 1px solid var(--border); padding: 14px 16px; }
.c-name { font-family: 'Bebas Neue', sans-serif; font-size: 14px; letter-spacing: 1.5px; color: var(--accent); margin-bottom: 8px; }
.c-row { display: flex; align-items: baseline; gap: 6px; margin-bottom: 3px; }
.c-label { font-size: 10px; color: var(--text-muted); letter-spacing: 1px; text-transform: uppercase; min-width: 42px; flex-shrink: 0; }
.c-val  { font-size: 12px; color: var(--text-dim); }
.c-link { font-size: 12px; color: var(--accent-d); text-decoration: none; }
.c-link:hover { color: var(--accent); text-decoration: underline; }

/* ── Main ── */
#main {
  margin-left: var(--sidebar-w);
  margin-top: calc(var(--toolbar-h) + env(safe-area-inset-top, 0px));
  flex: 1;
  height: calc(100vh - var(--toolbar-h) - env(safe-area-inset-top, 0px));
  overflow-y: auto; overflow-x: auto; background: #111;
  scrollbar-width: thin; scrollbar-color: #2a2a2a transparent;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transition: margin-right .35s cubic-bezier(.4,0,.2,1);
}
#main::-webkit-scrollbar { width: 6px; }
#main::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 3px; }

/* ── Image stage ── */
#imgStage {
  display: flex; flex-direction: column; align-items: center;
  padding: 32px 20px; gap: 20px; min-height: 100%;
}
.img-page-wrap {
  background: #fff; box-shadow: 0 4px 32px rgba(0,0,0,.6);
  border-radius: 2px; overflow: hidden; position: relative; transition: width .2s;
}
.img-page-wrap img { display: block; width: 100%; height: auto; user-select: none; }
.img-page-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  text-align: center; padding: 3px 0; font-size: 11px; color: #aaa;
  background: rgba(0,0,0,.35); letter-spacing: 1px;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.img-page-wrap:hover .img-page-label { opacity: 1; }
.img-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; height: 200px; width: 100%; }
.spinner { width: 28px; height: 28px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════
   ORDER PANEL
   ═══════════════════════════════════ */

/* Overlay */
#orderOverlay {
  display: none;
  position: fixed; inset: 0; z-index: 98;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
#orderOverlay.show { display: block; }

/* Panel */
.order-panel {
  position: fixed;
  top: calc(var(--toolbar-h) + env(safe-area-inset-top, 0px));
  right: 0; bottom: 0;
  width: var(--order-w);
  background: var(--bg2);
  border-left: 1px solid var(--border);
  z-index: 99;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .38s cubic-bezier(.4,0,.2,1);
  overflow: clip; /* clip border-radius but allow sticky */
  box-shadow: -8px 0 40px rgba(0,0,0,.5);
}
.order-panel.open { transform: translateX(0); }

/* Panel header — sticky so it stays visible even if iOS miscalculates panel top */
.order-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky; top: 0; z-index: 2;
  background: var(--bg2);
  background: linear-gradient(135deg, rgba(184,204,134,.08) 0%, var(--bg2) 60%);
}
.order-panel-title-group {
  display: flex; align-items: center; gap: 8px;
}
.order-panel-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 17px; letter-spacing: 2px; color: var(--accent);
  line-height: 1;
}
.order-close-btn {
  width: 30px; height: 30px; flex-shrink: 0;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.order-close-btn:hover { background: #242424; color: var(--text); }

/* Panel body — overflow auto here makes sticky header work in panel */
.order-panel-body {
  flex: 1; overflow-y: auto; padding: 16px 18px;
  display: flex; flex-direction: column; gap: 14px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.order-panel-body::-webkit-scrollbar { width: 4px; }
.order-panel-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Hint */
.order-hint {
  font-size: 12px; color: var(--text-muted);
  background: rgba(184,204,134,.06);
  border: 1px solid rgba(184,204,134,.15);
  border-radius: 8px; padding: 9px 12px;
  line-height: 1.5;
}

/* Divider */
.order-divider {
  height: 1px; background: var(--border);
  margin: 2px 0;
}

/* Fields */
.order-field { display: flex; flex-direction: column; gap: 6px; }
.order-field label {
  font-size: 10px; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--text-muted);
  font-weight: 500;
}
.order-field textarea,
.order-field input {
  width: 100%;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 10px 12px;
  font-family: 'DM Sans', sans-serif;
  /* 16px minimum prevents iOS Safari auto-zoom on focus */
  font-size: 16px; line-height: 1.6;
  outline: none; resize: vertical;
  transition: border-color .2s, box-shadow .2s;
}
.order-field textarea:focus,
.order-field input:focus {
  border-color: rgba(184,204,134,.5);
  box-shadow: 0 0 0 3px rgba(184,204,134,.07);
}
.order-field textarea {
  min-height: 140px;
}
.order-field textarea::placeholder,
.order-field input::placeholder {
  color: var(--text-muted);
}

/* Required field marker */
.req { color: #ff7b7b; font-size: 11px; }

/* Submit button */
.order-submit-btn {
  width: 100%;
  padding: 12px 12px;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  background: var(--accent); border: none; border-radius: 10px;
  color: #111; font-family: 'DM Sans', sans-serif;
  font-size: 16px; font-weight: 700; letter-spacing: .3px;
  cursor: pointer; transition: background .15s, transform .1s, opacity .15s;
}
.order-submit-btn:hover  { background: var(--accent-d); }
.order-submit-btn:active { transform: scale(.98); }
.order-submit-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* Footer note */
.order-footer-note {
  font-size: 11px; color: var(--text-muted);
  text-align: center; line-height: 1.8;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.order-footer-note strong { color: var(--text-dim); }

/* Success screen */
.order-success-screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; gap: 16px;
  padding: 40px 32px;
  background: var(--bg2);
}
.success-icon {
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(184,204,134,.12);
  border: 2px solid rgba(184,204,134,.4);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  animation: successPop .4s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes successPop { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.success-title {
  font-family: 'Bebas Neue', sans-serif; font-size: 26px;
  letter-spacing: 2px; color: var(--accent);
}
.success-msg {
  font-size: 13px; color: var(--text-dim); line-height: 1.7;
  max-width: 280px;
}
.success-close-btn {
  margin-top: 8px; height: 40px; padding: 0 28px;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; cursor: pointer;
  font-family: 'DM Sans', sans-serif; font-size: 13px;
  transition: background .15s;
}
.success-close-btn:hover { background: #242424; }

/* ── Share modal ── */
#shareModal {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.75); backdrop-filter: blur(4px);
  align-items: flex-end; justify-content: center;
}
#shareModal.open { display: flex; }
.share-sheet {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 20px 20px calc(32px + env(safe-area-inset-bottom, 0px));
  width: 100%; max-width: 480px; animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.share-title { font-family: 'Bebas Neue', sans-serif; font-size: 18px; letter-spacing: 2px; color: var(--accent); margin-bottom: 16px; }
.share-link-row { display: flex; gap: 8px; margin-bottom: 16px; }
#linkInput { flex: 1; background: var(--bg3); border: 1px solid var(--border); color: var(--text-dim); border-radius: 6px; padding: 8px 10px; font-size: 12px; font-family: monospace; outline: none; }
#copyBtn { background: var(--bg3); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 8px 14px; font-size: 13px; cursor: pointer; white-space: nowrap; transition: background .15s; }
#copyBtn:hover, #copyBtn.copied { background: var(--accent); color: #111; border-color: var(--accent); }
.share-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.share-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 10px 14px;
  font-size: 13px; cursor: pointer; font-family: 'DM Sans', sans-serif; font-weight: 500;
  transition: background .15s, border-color .15s;
}
.share-btn:hover { background: #242424; border-color: #3a3a3a; }
.share-btn.full { grid-column: 1/-1; }

/* ── QR Panel ── */
.qr-panel {
  display: none; margin-top: 16px;
  animation: slideUp .2s ease;
}
.qr-panel.open { display: block; }
.qr-panel-inner {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.qr-label {
  font-size: 12px; font-weight: 600; letter-spacing: .5px;
  color: #333; text-transform: uppercase; text-align: center;
}
.qr-url {
  font-size: 13px; font-weight: 700; color: #111;
  font-family: 'Bebas Neue', sans-serif; letter-spacing: 1.5px;
}
#qrCanvas canvas { display: block; }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1f1f1f; border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 10px 20px; font-size: 13px;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 300; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── iOS banner ── */
#iosBanner { display: none; position: fixed; inset: 0; z-index: 250; background: rgba(0,0,0,.7); align-items: flex-end; justify-content: center; padding: 0 16px calc(24px + env(safe-area-inset-bottom, 0px)); }
#iosBanner.show { display: flex; }
.ios-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; padding: 20px; width: 100%; max-width: 400px; text-align: center; }
.ios-card h3 { font-family: 'Bebas Neue', sans-serif; font-size: 18px; color: var(--accent); margin-bottom: 10px; letter-spacing: 2px; }
.ios-card p  { font-size: 13px; color: var(--text-dim); line-height: 1.6; margin-bottom: 16px; }
.ios-close { background: var(--bg3); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 8px 24px; font-size: 13px; cursor: pointer; }

/* ═══════════════════════════════════════
   MOBILE ≤ 700px
   ═══════════════════════════════════════ */
#asideToggle { display: none; }

@media (max-width: 700px) {

  /* ORDER TRIGGER hidden on mobile (replaced by badge btn) */
  #orderBtn { display: none !important; }

  /* Sidebar slides up from bottom */
  aside {
    top: auto; bottom: 0; left: 0; right: 0; width: 100%;
    height: 80vh;
    border-right: none;
    border-top: none;
    border-radius: 18px 18px 0 0;
    transform: translateY(calc(100% - 80px));
    transition: transform .38s cubic-bezier(.4,0,.2,1);
    z-index: 80;
    box-shadow: 0 -12px 60px rgba(0,0,0,.7);
    overflow: hidden;
  }
  aside.open { transform: translateY(0); }

  /* ── Toggle bar ── */
  #asideToggle {
    display: flex !important;
    align-items: center;
    height: 80px;
    flex-shrink: 0;
    cursor: pointer;
    user-select: none;
    background: linear-gradient(180deg, #1a1f12 0%, #141414 100%);
    border-top: 2px solid var(--accent);
    border-radius: 18px 18px 0 0;
    padding: 0 16px;
    gap: 12px;
    position: relative;
    overflow: hidden;
  }

  #asideToggle::after {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: var(--accent);
    box-shadow: 0 0 16px 4px rgba(184,204,134,.5);
  }

  #toggle-pill {
    position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
    width: 44px; height: 4px; border-radius: 2px;
    background: rgba(184,204,134,.4);
    transition: background .2s, width .2s;
  }
  aside.open #toggle-pill { background: var(--accent); width: 32px; }

  #toggle-icon {
    width: 40px; height: 40px; flex-shrink: 0;
    background: rgba(184,204,134,.15);
    border: 1.5px solid rgba(184,204,134,.5);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: var(--accent);
    transition: background .2s, transform .38s;
  }
  aside.open #toggle-icon { background: rgba(184,204,134,.25); transform: rotate(180deg); }

  #toggle-text { display: flex; flex-direction: column; gap: 2px; flex: 1; }

  #toggle-label {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 18px; letter-spacing: 2px;
    color: var(--accent); line-height: 1;
    transition: color .2s;
  }
  aside.open #toggle-label { color: var(--text-dim); }

  #toggle-sublabel {
    font-size: 11px; color: var(--text-muted);
    letter-spacing: .5px;
  }

  /* ── Mobile ORDER button (replacing badge) ── */
  .order-badge-btn {
    display: flex !important;
    align-items: center; gap: 6px;
    background: var(--accent);
    color: #111; border: none;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 15px; letter-spacing: 1.5px;
    padding: 8px 14px; border-radius: 8px;
    flex-shrink: 0; cursor: pointer;
    transition: background .15s, transform .1s;
    box-shadow: 0 0 12px rgba(184,204,134,.25);
  }
  .order-badge-btn:active { transform: scale(.95); }

  /* ── Order panel on mobile ── */
  .order-panel {
    /* Anchor top below toolbar + safe area — close button always reachable */
    top: calc(var(--toolbar-h) + env(safe-area-inset-top, 0px) + 12px);
    bottom: 0;
    left: 0; right: 0;
    width: 100%;
    height: auto; /* height = bottom - top */
    overflow: clip; /* clip rounded corners, allow sticky header */
    border-left: none;
    border-top: 2px solid var(--accent);
    border-radius: 18px 18px 0 0;
    transform: translateY(calc(100% + 20px));
    z-index: 99;
    box-shadow: 0 -12px 60px rgba(0,0,0,.7);
  }
  .order-panel.open { transform: translateY(0); }

  /* ── Hide zoom on mobile ── */
  #zoomGroup { display: none !important; }

  /* Main — full width */
  #main {
    margin-left: 0;
    margin-right: 0 !important;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }

  /* Toolbar simplify */
  #toolbarCenter { display: none; }
  #zoomLabel { display: none; }

  /* Stage padding */
  #imgStage { padding: 14px 8px; gap: 14px; }

  .order-panel-body { padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
}

/* Hide order badge btn on desktop */
@media (min-width: 701px) {
  .order-badge-btn { display: none; }
}
