/* ═══════════════════════════════════════════════════════
   QR Customizer — v8.0
   Updated UPI logo, green tick badge, transparent pill backgrounds
═══════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --qrc-accent:     var(--wp--preset--color--primary, #2563eb);
  --qrc-accent-dk:  color-mix(in srgb, var(--qrc-accent) 82%, black);
  --qrc-accent-lt:  color-mix(in srgb, var(--qrc-accent) 12%, white);
  --qrc-surface:    #ffffff;
  --qrc-bg:         #f7f8fa;
  --qrc-border:     #e4e7ed;
  --qrc-text:       #0f1117;
  --qrc-muted:      #6b7280;
  --qrc-ok:         #16a34a;
  --qrc-err:        #dc2626;
  --qrc-font:       'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --qrc-mono:       'SF Mono', 'Consolas', 'Courier New', monospace;
}

/* ── Reset ───────────────────────────────────────────── */
#qrc-overlay *, #qrc-overlay *::before, #qrc-overlay *::after {
  box-sizing: border-box;
}

/* ── Overlay ─────────────────────────────────────────── */
#qrc-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 999999;
  display: none !important;
  align-items: flex-end;
  justify-content: center;
  font-family: var(--qrc-font);
  -webkit-font-smoothing: antialiased;
}
#qrc-overlay.open { display: flex !important; }

/* ── Sheet ───────────────────────────────────────────── */
.qrc-sheet {
  background: var(--qrc-surface);
  width: 100%;
  height: 100dvh;          /* mobile: full screen */
  border-radius: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: qrcSlideUp .3s cubic-bezier(.22,1,.36,1) both;
}
@keyframes qrcSlideUp {
  from { transform: translateY(6px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

/* ── Header ──────────────────────────────────────────── */
.qrc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--qrc-border);
  flex-shrink: 0;
  background: var(--qrc-surface);
  position: sticky; top: 0; z-index: 10;
}
.qrc-header-left { display: flex; align-items: center; gap: 12px; }
.qrc-header-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--qrc-accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
}
.qrc-header h2 {
  margin: 0; font-size: .95rem; font-weight: 700;
  color: var(--qrc-text); line-height: 1.2;
  font-family: var(--qrc-font);
}
/* Remove the "Print-ready 4x6" subtitle entirely — hidden via JS, also hidden here */
.qrc-sub { display: none !important; }

.qrc-close-btn {
  width: 36px; height: 36px; border-radius: 50%;
  min-width: 36px; min-height: 36px; aspect-ratio: 1 / 1;
  background: var(--qrc-bg);
  border: 2px solid var(--qrc-border);
  display: flex; align-items: center; justify-content: center;
  color: var(--qrc-muted); cursor: pointer;
  transition: all .2s ease; flex-shrink: 0;
  padding: 0;
}
.qrc-close-btn:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
  transform: scale(1.05);
}
.qrc-close-btn:active {
  transform: scale(0.95);
}
.qrc-close-x {
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  font-family: var(--qrc-font);
}

/* ── Body ────────────────────────────────────────────── */
.qrc-body {
  display: flex;
  flex-direction: column;  /* mobile: controls first, preview below */
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Controls ─────────────────────────────────────────  */
.qrc-controls {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  min-height: 0;
  background: var(--qrc-surface);
}

/* ── Preview Panel ────────────────────────────────────── */
.qrc-preview-panel {
  background: #f0f2f5;   /* LIGHT background, not dark */
  border-top: 1px solid var(--qrc-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 16px 12px;
  gap: 10px;
  flex-shrink: 0;
  /* mobile: compact strip */
  height: 200px;
}
.qrc-prev-label {
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: #9ca3af;
  margin: 0;
  font-family: var(--qrc-font);
}

/* Canvas wrap */
.qrc-canvas-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  min-height: 0;
}

#qrc-live-canvas {
  height: 140px !important;
  width: auto !important;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,.15), 0 1px 4px rgba(0,0,0,.1);
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  display: none;
}

#qrc-ph {
  height: 140px;
  aspect-ratio: 2/3;
  background: #fff;
  border-radius: 8px;
  border: 2px dashed #d1d5db;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #9ca3af;
}
#qrc-ph p { font-size: .55rem; text-align: center; margin: 0; }

/* ── Accordion ────────────────────────────────────────── */
.qrc-acc {
  border: 1.5px solid var(--qrc-border);
  border-radius: 12px;
  margin-bottom: 8px;
  overflow: hidden;
  background: var(--qrc-surface);
}
.qrc-acc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
  color: var(--qrc-text);
  list-style: none;
  user-select: none;
  font-family: var(--qrc-font);
}
.qrc-acc-head::-webkit-details-marker { display: none; }
.qrc-acc-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--qrc-accent);
  color: #fff; font-size: .67rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.qrc-acc-head > span:nth-child(2) { flex: 1; }
.qrc-chevron { color: var(--qrc-muted); flex-shrink: 0; transition: transform .2s; }
details[open] .qrc-chevron { transform: rotate(180deg); }
.qrc-acc-body {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--qrc-border);
}

/* ── Upload zone ──────────────────────────────────────── */
.qrc-upload-zone {
  border: 2px dashed var(--qrc-border);
  border-radius: 10px;
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: var(--qrc-bg);
  display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.qrc-upload-zone:hover, .qrc-upload-zone.drag-over {
  border-color: var(--qrc-accent); background: var(--qrc-accent-lt);
}
.qrc-upload-zone.has-file { border-color: var(--qrc-ok); background: rgba(22,163,74,.05); }
#qrc-upload-idle { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--qrc-muted); }
#qrc-upload-idle strong { font-size: .82rem; color: var(--qrc-text); font-weight: 600; }
#qrc-upload-idle span   { font-size: .72rem; color: var(--qrc-muted); }
#qrc-upload-done { display: flex; align-items: center; gap: 8px; width: 100%; justify-content: center; }
#qrc-upload-done span { font-size: .8rem; font-weight: 500; flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#qrc-reupload {
  font-size: .7rem; font-family: var(--qrc-font);
  padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--qrc-border); background: #fff;
  cursor: pointer; color: var(--qrc-muted); white-space: nowrap;
}

/* ── Fields ───────────────────────────────────────────── */
.qrc-field { margin-bottom: 16px; }
.qrc-field:last-child { margin-bottom: 0; }
.qrc-lbl {
  display: block; font-size: .75rem; font-weight: 600;
  color: var(--qrc-text); margin-bottom: 8px;
  font-family: var(--qrc-font);
  letter-spacing: .01em;
}
.qrc-inp {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--qrc-border); border-radius: 10px;
  font-family: var(--qrc-font); font-size: .88rem;
  color: var(--qrc-text); outline: none;
  background: var(--qrc-surface); transition: border-color .15s;
}
.qrc-inp:focus { border-color: var(--qrc-accent); }
.qrc-inp-wrap { position: relative; }
.qrc-inp-ok { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); }

.qrc-hint { font-size: .72rem; color: var(--qrc-muted); margin: 5px 0 0; min-height: 14px; }
.qrc-hint.error   { color: var(--qrc-err); }
.qrc-hint.success { color: var(--qrc-ok); }

/* ── Swatches ─────────────────────────────────────────── */
.qrc-swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.qrc-sw {
  width: 26px; height: 26px; min-width: 26px; min-height: 26px;
  border-radius: 50%; border: 2.5px solid transparent;
  box-shadow: 0 0 0 1px rgba(0,0,0,.15);
  cursor: pointer; transition: transform .15s, box-shadow .15s;
  padding: 0; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.qrc-sw:hover    { transform: scale(1.2); }
.qrc-sw.active   { border-color: var(--qrc-accent); box-shadow: 0 0 0 3px rgba(37,99,235,.25); }
.qrc-sw-light    { box-shadow: 0 0 0 1px #cbd5e1; }
.qrc-sw-pick     { background: conic-gradient(red,yellow,lime,cyan,blue,magenta,red); position: relative; overflow: hidden; cursor: pointer; }
.qrc-sw-pick input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }

.qrc-hex-row { display: flex; align-items: center; gap: 8px; }
.qrc-hex-dot {
  width: 26px; height: 26px; min-width: 26px; border-radius: 50%;
  flex-shrink: 0; border: 1px solid rgba(0,0,0,.12); transition: background .2s;
}
.qrc-hex-inp {
  padding: 6px 10px; border: 1.5px solid var(--qrc-border); border-radius: 8px;
  font-family: var(--qrc-mono); font-size: .78rem; color: var(--qrc-text);
  outline: none; width: 110px; background: var(--qrc-surface);
  transition: border-color .15s;
}
.qrc-hex-inp:focus { border-color: var(--qrc-accent); }

/* ── Textures ─────────────────────────────────────────── */
.qrc-textures { display: flex; flex-wrap: wrap; gap: 6px; }
.qrc-tex {
  width: 46px; height: 46px; border-radius: 9px;
  border: 2px solid var(--qrc-border); background: var(--qrc-bg);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-direction: column; gap: 2px;
  color: var(--qrc-muted); font-size: .58rem; font-weight: 600;
  transition: all .15s; flex-shrink: 0; padding: 0;
  font-family: var(--qrc-font);
}
.qrc-tex:hover  { border-color: var(--qrc-accent); color: var(--qrc-accent); background: var(--qrc-accent-lt); }
.qrc-tex.active { border-color: var(--qrc-accent); background: var(--qrc-accent-lt); color: var(--qrc-accent); }

/* ── Toggle ───────────────────────────────────────────── */
.qrc-toggle-field { display: flex; align-items: center; justify-content: space-between; }
.qrc-tog { display: flex; align-items: center; cursor: pointer; }
.qrc-tog input { display: none; }
.qrc-tog-track {
  width: 38px; height: 22px; background: #d1d5db;
  border-radius: 99px; position: relative; transition: background .2s;
}
.qrc-tog input:checked + .qrc-tog-track { background: var(--qrc-accent); }
.qrc-tog-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; background: #fff;
  border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .2s;
}
.qrc-tog input:checked + .qrc-tog-track .qrc-tog-thumb { transform: translateX(16px); }

/* ── Actions bar ──────────────────────────────────────── */
.qrc-actions {
  padding: 10px 16px 16px;
  border-top: 1px solid var(--qrc-border);
  background: var(--qrc-surface);
  flex-shrink: 0;
}
.qrc-act-row { display: flex; gap: 8px; }

.qrc-btn-ghost {
  display: flex; align-items: center; gap: 5px;
  padding: 9px 13px;
  border: 1.5px solid var(--qrc-border);
  border-radius: 10px; background: var(--qrc-surface);
  font-family: var(--qrc-font); font-size: .78rem; font-weight: 600;
  color: var(--qrc-muted); cursor: pointer; transition: all .15s;
  white-space: nowrap; flex-shrink: 0;
}
.qrc-btn-ghost:hover { background: var(--qrc-bg); color: var(--qrc-text); }

.qrc-btn-outline {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 14px;
  border: 1.5px solid var(--qrc-accent);
  border-radius: 10px; background: var(--qrc-accent-lt);
  font-family: var(--qrc-font); font-size: .82rem; font-weight: 600;
  color: var(--qrc-accent); cursor: pointer; transition: all .15s;
}
.qrc-btn-outline:hover:not(:disabled) { background: rgba(37,99,235,.15); }
.qrc-btn-outline:disabled { opacity: .4; cursor: not-allowed; }

.qrc-btn-primary {
  flex: 1.4; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px;
  border: none; border-radius: 10px;
  background: var(--qrc-accent);
  font-family: var(--qrc-font); font-size: .82rem; font-weight: 700;
  color: #fff; cursor: pointer;
  box-shadow: 0 4px 16px rgba(37,99,235,.3);
  transition: all .15s;
}
.qrc-btn-primary:hover:not(:disabled) { background: var(--qrc-accent-dk); transform: translateY(-1px); }
.qrc-btn-primary:active:not(:disabled) { transform: scale(.98); }
.qrc-btn-primary:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }

/* ── Product page button ──────────────────────────────── */
.qrc-wrap { margin: 10px 0; }
.qrc-open-modal.button, a.qrc-open-modal.button {
  display: inline-flex !important; align-items: center !important; gap: 7px !important;
  background: var(--qrc-accent) !important; border-color: var(--qrc-accent) !important;
  color: #fff !important; font-family: var(--qrc-font) !important;
  font-weight: 600 !important; padding: 12px 22px !important;
  border-radius: 10px !important;
}

/* ── Status hint ──────────────────────────────────────── */
#qrc-save-status { text-align: center; min-height: 16px; font-size: .74rem; margin-bottom: 6px; }

/* ═══════════════════════════════════════════════════════
   DESKTOP: 720px+ — side-by-side layout, modal style
═══════════════════════════════════════════════════════ */
@media (min-width: 720px) {
  #qrc-overlay {
    align-items: center;
    padding: 20px;
    background: rgba(0,0,0,.55);
  }

  .qrc-sheet {
    max-width: 880px;
    height: auto;
    max-height: 90vh;
    border-radius: 18px;
    box-shadow: 0 24px 80px rgba(0,0,0,.3);
    animation: qrcPopIn .28s cubic-bezier(.22,1,.36,1) both;
  }
  @keyframes qrcPopIn {
    from { transform: scale(.94) translateY(16px); opacity: 0; }
    to   { transform: scale(1) translateY(0); opacity: 1; }
  }

  .qrc-body {
    flex-direction: row;
    overflow: hidden;
    flex: 1;
    min-height: 0;
  }

  .qrc-controls {
    flex: 1;
    border-right: 1px solid var(--qrc-border);
    padding: 20px 24px;
    overflow-y: auto;
  }

  .qrc-preview-panel {
    width: 300px;
    flex-shrink: 0;
    border-top: none;
    border-left: none;
    background: #f0f2f5;
    padding: 28px 24px;
    justify-content: center;
    overflow-y: auto;
    height: auto;
  }

  #qrc-live-canvas {
    height: 260px !important;
    width: auto !important;
  }
  #qrc-ph {
    height: 260px;
  }
}

@media (min-width: 1024px) {
  .qrc-sheet { max-width: 980px; }
  .qrc-preview-panel { width: 320px; }
  #qrc-live-canvas { height: 300px !important; }
  #qrc-ph { height: 300px; }
}

/* ═══════════════════════════════════════════════════════
   QR Customizer — Button overrides (v1.1)
   
   On customizer-enabled single product pages we ADD our
   button at priority 29 and CSS-hide the default buttons.
   We NEVER call remove_action() so Buy Now from other
   plugins (Modern Cart Starter etc.) is never destroyed —
   it simply gets hidden here and comes back the moment
   this plugin is deactivated.
═══════════════════════════════════════════════════════ */

/* ── Single product: hide the entire default cart form ─ */
.qrc-product-active form.cart,
.qrc-product-active .woocommerce-variation-add-to-cart {
    display: none !important;
}

/* ── Single product: hide common Buy-Now button variants ─
   Covers WooCommerce Buy Now, Modern Cart Starter, and
   most other Buy-Now plugins without knowing their exact
   class names in advance.                               */
/* Exclude #qrc-overlay so our own modal Buy Now button is never hidden */
.qrc-product-active .wc-buy-now:not(#qrc-overlay *),
.qrc-product-active .mcs-buy-now:not(#qrc-overlay *),
.qrc-product-active .buy-now-button:not(#qrc-overlay *),
.qrc-product-active .buynow:not(#qrc-overlay *),
.qrc-product-active [class*="buy-now"]:not(.qrc-open-modal):not(#qrc-overlay *),
.qrc-product-active [class*="buy_now"]:not(.qrc-open-modal):not(#qrc-overlay *),
.qrc-product-active [id*="buy-now"]:not(#qrc-overlay *),
.qrc-product-active [id*="buy_now"]:not(#qrc-overlay *) {
    display: none !important;
}

/* ── Mobile preview toggle button (sits between controls & footer) ── */
.qrc-preview-toggle {
  display: none; /* hidden on desktop — shown via media query below */
  align-items: center;
  gap: 6px;
  width: calc(100% - 32px);
  margin: 8px 16px;
  padding: 10px 16px;
  border: 1.5px solid var(--qrc-accent);
  border-radius: 10px;
  background: var(--qrc-accent-lt);
  color: var(--qrc-accent);
  font-size: .85rem;
  font-weight: 600;
  font-family: var(--qrc-font);
  cursor: pointer;
  transition: background .15s;
  justify-content: center;
}
.qrc-preview-toggle:hover { background: var(--qrc-accent); color: #fff; }

/* Close button inside the fullscreen preview overlay */
.qrc-preview-close-btn {
  display: none; /* shown only when fullscreen active */
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  padding: 10px 20px;
  border: 1.5px solid var(--qrc-border);
  border-radius: 10px;
  background: var(--qrc-surface);
  color: var(--qrc-text);
  font-size: .85rem;
  font-weight: 600;
  font-family: var(--qrc-font);
  cursor: pointer;
}

/* ── Mobile layout ───────────────────────────────────── */
@media (max-width: 700px) {
  /* Show the "Preview" toggle button */
  .qrc-preview-toggle { display: inline-flex; }

  /* Hide the static preview panel — user sees it via the JS body overlay instead */
  .qrc-preview-panel { display: none; }
}

/* Full-screen preview overlay — appended to <body> by JS, escapes all clipping */
#qrc-fs-preview {
  font-family: var(--qrc-font);
}
