/* =========================================================
   DeFiBillboards Coupon Maker — cpon-Style.css
   Premium UX skin + aligned IDs for app.js
   ========================================================= */

:root{
  --bg: #ffffff;
  --text: #0f1222;
  --muted: rgba(15,18,34,.68);
  --line: rgba(15,18,34,.12);

  --card: rgba(255,255,255,.78);
  --cardSolid: #ffffff;
  --shadow: 0 10px 30px rgba(0,0,0,.08);

  --accent: #00fff7;
  --accent2: #ff00ff;

  --radius: 16px;
  --radiusSm: 12px;

  --sidebarW: 300px;
  --editor-height: 900px;
}

/* ---------- Global reset ---------- */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  min-height: 100%;
  overflow-x: hidden;
  background: linear-gradient(180deg, #ffffff, #fbfbff);
  color: var(--text);
}

.hidden { display: none !important; }

.noscriptWarn{
  display:block;
  padding:12px;
  margin:12px;
  background:#fff;
  border-radius:12px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

/* ---------- Header ---------- */
header {
  position: sticky;
  top: 0;
  z-index: 50;

  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 10px 20px;
  flex-wrap: wrap;
}

header .logo,
header .couponMaker {
  width: clamp(180px, 28vw, 420px);
  height: auto;
}

header .couponMaker {
  transform: translateY(-14px);
  opacity: .98;
}

/* ---------- Main layout ---------- */
.container {
  display: flex;
  align-items: stretch;
  width: 100%;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebarW);
  flex: 0 0 var(--sidebarW);

  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(250,250,255,.9), rgba(245,245,250,.9));
  display: flex;
  flex-direction: column;

  position: sticky;
  top: 74px; /* header height-ish */
  align-self: flex-start;

  height: calc(170vh - 74px); /* 50% longer */
  overflow: auto;
}
.sidebar::-webkit-scrollbar { width: 10px; }
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,.18);
  border-radius: 999px;
  border: 3px solid rgba(255,255,255,.6);
}
.sidebar::-webkit-scrollbar-track { background: transparent; }

/* Tabs */
.tabs {
  list-style: none;
  padding: 10px 10px 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.sidebar li{
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;

  border: 1px solid var(--line);
  border-radius: 12px;

  background: rgba(255,255,255,.75);
  box-shadow: 0 6px 18px rgba(0,0,0,.05);

  font-weight: 900;
  text-align: center;
  letter-spacing: .2px;

  transition: transform .08s ease, background .2s ease, border-color .2s ease;
}
.sidebar li:hover{ transform: translateY(-1px); background: rgba(255,255,255,.9); }
.sidebar li.active{
  border-color: rgba(0,255,247,.55);
  box-shadow: 0 10px 24px rgba(0,255,247,.12);
  background: linear-gradient(180deg, rgba(0,255,247,.08), rgba(255,0,255,.06));
}

/* Tools */
.sidebar-tools {
  padding: 14px 14px 260px; /* pushes tool area farther down */
  border-top: 1px solid var(--line);
  overflow: visible;
  max-height: none;
}

.editor-controls { padding-top: 10px; }

/* ---------- Inputs ---------- */
.sidebar-tools input,
.sidebar-tools select,
.sidebar-tools textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-top: 10px;
  background: rgba(255,255,255,.9);
  color: var(--text);
  outline: none;
  box-shadow: 0 6px 16px rgba(0,0,0,.05);
}

.sidebar-tools input:focus,
.sidebar-tools select:focus,
.sidebar-tools textarea:focus{
  border-color: rgba(0,255,247,.7);
  box-shadow: 0 8px 18px rgba(0,255,247,.14);
}

.sidebar-tools input[type="range"]{
  padding: 0;
  height: 36px;
  box-shadow: none;
}

/* ---------- Buttons ---------- */
button {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0.2px;
  transition: transform 0.06s ease, background 0.15s ease, border-color 0.15s ease, box-shadow .15s ease;
  box-shadow: 0 8px 18px rgba(0,0,0,.06);
}

button:hover {
  background: rgba(0,0,0,0.02);
  border-color: rgba(0,0,0,.18);
  transform: translateY(-1px);
}

button:active { transform: translateY(0px); }

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.ghostBtn{
  background: transparent;
  border: 1px solid rgba(0,0,0,.18);
  box-shadow: none;
}

.toolBtn.active{
  border-color: rgba(0,255,247,.75);
  box-shadow: 0 10px 24px rgba(0,255,247,.16);
  background: linear-gradient(180deg, rgba(0,255,247,.10), rgba(255,0,255,.06));
}

/* ---------- Main Content ---------- */
.content {
  flex: 1;
  min-width: 0;
  padding: 20px;
  position: relative;
}

/* ---------- Details (premium feel) ---------- */
details{
  border: 1px solid var(--line);
  background: rgba(255,255,255,.72);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-top: 12px;
  box-shadow: var(--shadow);
}

details summary{
  cursor: pointer;
  user-select: none;
  font-weight: 950;
  letter-spacing: .2px;
  list-style: none;
}

details summary::-webkit-details-marker{ display:none; }

details summary::after{
  content:"▾";
  float:right;
  opacity:.55;
  transform: translateY(1px);
}
details[open] summary::after{ content:"▴"; opacity:.65; }

.divider{
  height: 1px;
  background: var(--line);
  margin: 10px 0;
}

/* ---------- Tool helpers ---------- */
.tool-title{
  font-weight: 950;
  margin: 10px 0 6px;
  letter-spacing: .2px;
}

.tool-sub{
  font-size: 12px;
  opacity: .82;
  margin-top: 8px;
  line-height: 1.35;
  color: var(--muted);
}

.tool-row{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 10px;
}

.tool-section{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.tool-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
  align-items: end;
}

.field{
  display:flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.field > span{
  font-size: 12px;
  opacity: .9;
  font-weight: 800;
}

.inlineField{
  display:flex;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  opacity: .95;
}
.inlineField span{ font-weight: 900; opacity: .85; }

.checkRow{
  display:flex;
  gap: 10px;
  align-items:center;
  font-size: 12px;
  opacity: .9;
}

.pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.92);
  font-weight: 950;
  min-width: 56px;
}

/* screen-reader-only */
.srOnly{
  position:absolute !important;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border:0;
}

/* ---------- Dropzone + Canvas ---------- */
.dropzone,
#dropzone{
  width: 100%;
  height: var(--editor-height);
  min-height: 700px;

  border: 2px dashed rgba(0,0,0,.18);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  margin-bottom: 20px;

  position: relative;
  overflow: hidden;

  background:
    radial-gradient(circle at 18% 18%, rgba(0,255,247,.10), transparent 40%),
    radial-gradient(circle at 78% 22%, rgba(255,0,255,.08), transparent 44%),
    rgba(0,0,0,0.02);
  box-shadow: var(--shadow);
}

.dropzone.has-image,
#dropzone.has-image{
  cursor: default;
  border-color: rgba(0,0,0,.14);
}

/* Canvas fills entire rectangle */
#editorCanvas{
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;

  border: 1px solid rgba(0,0,0,.10);
  border-radius: calc(var(--radius) - 4px);

  touch-action: none; /* mobile pointer correctness */
  user-select: none;

  z-index: 2;
}

.dropzone.has-image #editorCanvas,
#dropzone.has-image #editorCanvas{ display: block; }

#editorCanvas.dragging{ cursor: grabbing; }

/* Dropzone hint overlay */
#dropzoneHint{
  position: absolute;
  inset: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 18px;
  text-align:center;
  pointer-events:none; /* never block canvas interactions */
  font-weight: 950;
  color: rgba(0,0,0,.60);
  z-index: 5;
}

/* FX overlays (optional DOM preview) */
.fxOverlay{
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
  z-index: 4;
}
.fxOverlay.on{ display:block; }

#blobOverlay{
  opacity: 0.85;
  mix-blend-mode: screen;
  background:
    radial-gradient(circle at 20% 25%, rgba(0, 255, 247, 0.35), transparent 40%),
    radial-gradient(circle at 70% 35%, rgba(255, 0, 255, 0.25), transparent 45%),
    radial-gradient(circle at 55% 80%, rgba(106, 90, 205, 0.25), transparent 50%);
}
#grainOverlay{
  opacity: 0.18;
  mix-blend-mode: overlay;
  background-image: url("../assets/textures/paper-grain.png");
  background-size: cover;
  background-position: center;
}
#holoOverlay{
  opacity: 0.28;
  mix-blend-mode: screen;
  background-image: url("../assets/textures/holo-foil.png");
  background-size: cover;
  background-position: center;
}

/* ---------- Layers panel ---------- */
#layersPanel{
  margin-top: 10px;
  display:flex;
  flex-direction: column;
  gap: 8px;
  max-height: none;
  overflow: visible;
  padding-right: 6px;
}

.layer-item{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.03);
  cursor:pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.layer-item:hover{ transform: translateY(-1px); background: rgba(0,0,0,.035); }
.layer-item.active{
  outline: 2px solid rgba(0,255,247,0.45);
  background: rgba(0,255,247,0.06);
}

.layer-left{
  display:flex;
  flex-direction: column;
  gap: 2px;
  min-width: 160px;
  flex: 1;
}
.layer-title{ font-weight: 950; font-size: 13px; }
.layer-sub{ font-size: 11px; opacity: .75; color: var(--muted); }

.layer-right{
  display:flex;
  align-items:center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.layer-right label{ font-size: 11px; opacity: .88; }

.layer-actions{
  display:flex;
  gap:10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* ---------- Sticker tray ---------- */
.stickerTray{
  margin-top: 10px;
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.stickerThumb{
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.92);
  object-fit: contain;
  cursor: grab;
  padding: 8px;
  box-shadow: 0 10px 18px rgba(0,0,0,.06);
  transition: transform .08s ease, box-shadow .15s ease;
}
.stickerThumb:hover{
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(0,0,0,.10);
}
.stickerThumb:active{ cursor: grabbing; }

.stickerHint{
  margin-top: 10px;
  font-size: 12px;
  opacity: .78;
  color: var(--muted);
}

/* ---------- Pay QR preview helpers ---------- */
.previewImg{
  display:none;
  max-width: 260px;
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-top: 10px;
  box-shadow: 0 12px 24px rgba(0,0,0,.08);
}
.payloadBox{
  display:none;
  white-space: pre-wrap;
  background: rgba(0,0,0,.04);
  padding: 10px;
  border-radius: 14px;
  margin-top: 10px;
  border: 1px solid var(--line);
}
.qrBox{
  padding: 10px;
  background: transparent;
  display:inline-block;
  border-radius: 14px;
  border: 1px solid var(--line);
}

/* ---------- Modal (Add Text) ---------- */
.modal{
  position: fixed;
  inset: 0;
  z-index: 99999;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 16px;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(8px);
}
.modalCard{
  width: min(560px, 96vw);
  border-radius: 18px;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(255,255,255,.75);
  box-shadow: 0 18px 40px rgba(0,0,0,.22);
  padding: 14px;
}
.modalTitle{
  font-weight: 1000;
  font-size: 16px;
  margin-bottom: 10px;
}
.modalRow{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
  margin-top: 10px;
}

/* ---------- Gallery + Leaders ---------- */
#galleryItems{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
#leadersList{
  display:flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px){
  .container{ flex-direction: column; }
  .sidebar{
    width: 100%;
    flex: 0 0 auto;
    position: relative;
    top: 0;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .tabs{ grid-template-columns: 1fr 1fr 1fr; padding: 10px; }
  #galleryItems{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px){
  header{ padding: 10px 14px; }
  .content{ padding: 14px; }
  #galleryItems{ grid-template-columns: 1fr; }
  .stickerTray{ grid-template-columns: repeat(2, 1fr); }
}