/* ============================================================
   Snapeex Studio — app layout
   ============================================================ */

/* Studio now renders inside the Astra theme content area (no custom document
   chrome). The shell fills the space below Astra's header. */
.usage { font-size: .82rem; color: var(--muted); }

/* Three-column shell. --ast-height fallback ~ header height. */
.studio-shell {
  height: calc(100vh - 120px);
  min-height: 560px;
  display: grid; grid-template-columns: 312px 1fr 268px;
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  background: #fff;
}
.panel { background: #fff; min-height: 0; }
.panel-left { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.panel-right { border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.panel-center { background: var(--bg-soft-2); display: flex; flex-direction: column; }
.panel-scroll { overflow-y: auto; padding: 6px 18px 30px; }

/* Control groups */
.ctl-group { padding: 18px 0; border-bottom: 1px solid var(--line); }
.ctl-group:last-child { border-bottom: 0; }
.ctl-group h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 12px; }
.ctl-hint { font-size: .8rem; color: var(--muted); margin: -6px 0 12px; }
.ctl-hint.center { text-align: center; }

label { font-size: .82rem; color: var(--ink-2); font-weight: 500; }
input[type=number], input[type=text], select {
  width: 100%; font: inherit; font-size: .9rem; padding: .5em .65em;
  border: 1px solid var(--line-2); border-radius: 9px; background: #fff; color: var(--ink);
}
input[type=number]:focus, select:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(0,0,0,.10); }
.row { margin-bottom: 12px; }
.row label { display: block; margin-bottom: 5px; }
.row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row .val { font-size: .82rem; color: var(--muted); }

.switch-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; cursor: pointer; }
.switch-row span { font-size: .88rem; font-weight: 500; color: var(--ink); }
.switch-row input[type=checkbox] { appearance: none; width: 40px; height: 23px; border-radius: 999px; background: var(--line-2); position: relative; cursor: pointer; transition: background .18s; flex: none; }
.switch-row input[type=checkbox]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .18s; }
.switch-row input[type=checkbox]:checked { background: var(--brand); }
.switch-row input[type=checkbox]:checked::after { transform: translateX(17px); }

/* Segmented control */
.seg { display: flex; background: var(--bg-soft); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: transparent; font: inherit; font-size: .82rem; font-weight: 600; padding: .5em; border-radius: 8px; cursor: pointer; color: var(--muted); }
.seg button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }

/* Color row */
#bgColorRow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#bgColorRow label { margin: 0; }
input[type=color] { width: 40px; height: 32px; padding: 2px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; cursor: pointer; }
.swatches { display: flex; gap: 6px; }
.swatches button { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--line-2); cursor: pointer; }

/* Quick sizes */
.quick-sizes, .template-list { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-sizes { margin-top: 10px; }
.quick-sizes button { border: 1px solid var(--line-2); background: #fff; font: inherit; font-size: .8rem; font-weight: 600; padding: .4em .7em; border-radius: 8px; cursor: pointer; color: var(--ink-2); }
.quick-sizes button:hover { border-color: var(--brand); color: var(--brand); }

/* Templates */
.template-list { flex-direction: column; gap: 8px; }
.tpl {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 1px solid var(--line-2); background: #fff; border-radius: 10px; padding: 9px 11px; cursor: pointer; transition: .15s;
  color: var(--ink);
}
.tpl:hover, .tpl:focus, .tpl:active, .tpl:focus-visible { border-color: var(--brand); background: var(--brand-50); color: var(--ink); outline: none; }
.tpl.active, .tpl.active:hover, .tpl.active:focus, .tpl.active:focus-visible { border-color: var(--ink); background: var(--brand-50); box-shadow: 0 0 0 2px rgba(0,0,0,.10); color: var(--ink); }
.tpl .tpl-name, .tpl .tpl-sub, .tpl .tpl-ico { color: inherit; }
.tpl .tpl-sub { color: var(--muted) !important; }
.tpl .tpl-ico { width: 30px; height: 30px; border-radius: 7px; flex: none; display: grid; place-items: center; font-size: 15px; background: var(--bg-soft-2); }
.tpl .tpl-meta { min-width: 0; }
.tpl .tpl-name { font-size: .86rem; font-weight: 600; }
.tpl .tpl-sub { font-size: .74rem; color: var(--muted); }
.tpl .tpl-del { margin-left: auto; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; }
.tpl .tpl-del:hover { color: var(--danger); }

/* Padding grid */
.pad-grid {
  display: grid; gap: 8px; margin-bottom: 12px;
  grid-template-columns: 1fr 1.1fr 1fr;
  grid-template-areas: ".  t  ." "l  c  r" ".  b  .";
  align-items: center;
}
.pad-cell label { font-size: .72rem; }
.pad-cell input { padding: .4em; text-align: center; }
.pad-preview { display: grid; place-items: center; }
.pad-box { width: 56px; height: 56px; border: 2px dashed var(--brand-light); border-radius: 8px; position: relative; }
.pad-box::after { content: ""; position: absolute; inset: 22%; background: var(--brand); border-radius: 4px; }

/* ---------- Center: dropzone & stage ---------- */
.dropzone { flex: 1; display: grid; place-items: center; padding: 28px; }
.dz-inner {
  text-align: center; background: #fff; border: 2px dashed var(--line-2); border-radius: var(--radius-lg);
  padding: 56px 64px; max-width: 460px; transition: .2s;
}
.dropzone.drag .dz-inner { border-color: var(--brand); background: var(--brand-50); transform: scale(1.01); }
.dz-icon { width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 50%; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; font-size: 28px; }
.dz-inner h3 { margin-bottom: 6px; }
.dz-inner .btn { margin-top: 18px; }

.stage { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.stage-top { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: #fff; }
.stage-name { font-weight: 600; font-size: .9rem; }
.stage-status { font-size: .8rem; color: var(--muted); }
.stage-status.busy { color: var(--brand); }
.stage-status.done { color: var(--accent); }
.canvas-wrap {
  flex: 1; min-height: 0; display: grid; place-items: center; padding: 28px; overflow: auto; position: relative;
  background:
    conic-gradient(#e9e7f2 90deg, #f6f5fb 90deg 180deg, #e9e7f2 180deg 270deg, #f6f5fb 270deg) 0 0 / 24px 24px;
}
#preview { max-width: 100%; max-height: 100%; box-shadow: var(--shadow-md); border-radius: 4px; background: #fff; }

/* Loading overlay over the canvas */
.canvas-loading {
  position: absolute; inset: 0; display: none; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center; z-index: 5;
  background: rgba(247,247,247,.78); backdrop-filter: blur(2px);
}
.canvas-loading .cl-msg { font-size: .9rem; font-weight: 600; color: var(--ink); }
.spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid var(--line-2); border-top-color: var(--ink);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Right: batch ---------- */
.batch-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 10px; border-bottom: 1px solid var(--line); }
.batch-head h4 { margin: 0; font-size: .95rem; }
.batch-head .count { color: var(--muted); font-weight: 500; }
.thumbs { flex: 1; overflow-y: auto; padding: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-content: start; }
.thumbs .empty-hint { grid-column: 1/-1; text-align: center; font-size: .85rem; padding: 30px 6px; }
.thumb {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; cursor: pointer;
  border: 2px solid transparent; background:
    conic-gradient(#eee 90deg,#fff 90deg 180deg,#eee 180deg 270deg,#fff 270deg) 0 0 / 14px 14px;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb.active { border-color: var(--brand); }
.thumb .badge { position: absolute; top: 5px; left: 5px; font-size: .62rem; font-weight: 700; padding: .15em .45em; border-radius: 5px; background: rgba(20,18,31,.7); color: #fff; }
.thumb .badge.done { background: var(--accent); color: #06382c; }
.thumb .rm { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border: 0; border-radius: 50%; background: rgba(20,18,31,.65); color: #fff; cursor: pointer; font-size: .8rem; line-height: 1; display: grid; place-items: center; opacity: 0; transition: .15s; }
.thumb:hover .rm { opacity: 1; }
.batch-actions { padding: 14px; border-top: 1px solid var(--line); display: grid; gap: 9px; }

/* Toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: .8em 1.3em; border-radius: 999px;
  font-size: .9rem; font-weight: 500; box-shadow: var(--shadow-lg); z-index: 200;
}

/* Progress bar inside button */
.btn.loading { position: relative; pointer-events: none; opacity: .85; }

@media (max-width: 1080px) {
  .studio-shell { grid-template-columns: 280px 1fr 240px; }
}
@media (max-width: 820px) {
  .studio-body { overflow: auto; height: auto; }
  .studio-shell { grid-template-columns: 1fr; height: auto; }
  .panel-left, .panel-right { border: 0; border-bottom: 1px solid var(--line); }
  .panel-center { min-height: 60vh; }
}

/* Upgrade / limit modal (Snapeex WP additions) */
.snap-modal-backdrop { position: fixed; inset:0; background: rgba(10,10,10,.55); z-index: 500; display:none; align-items:center; justify-content:center; padding:20px; }
.snap-modal-backdrop.open { display:flex; }
.snap-modal { background:#fff; border-radius: var(--radius-lg); max-width: 420px; width:100%; padding: 34px 30px; text-align:center; box-shadow: var(--shadow-lg); }
.snap-modal h3 { margin-bottom: 10px; }
.snap-modal p { font-size:.95rem; }
.snap-modal .btn { margin-top: 14px; }
.snap-modal .snap-modal-close { margin-top:10px; background:none;border:0;color:var(--muted);font:inherit;cursor:pointer;font-size:.85rem; }
