/* ============================================================
   RVSL Live Studio — STUDIO (owner dashboard)
   Light, friendly, mobile-first. Depends on tokens.css only.
   Filosofi: Simple, Fast, Clear, Functional. Buat pemilik warung.
   ============================================================ */

body {
  background: var(--bg);
  color: var(--ink);
  /* ruang buat action bar sticky di bawah (mobile) */
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}

.wrap {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 0;
}

/* ---------- Header ---------- */
.app-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 2px 14px;
}
.app-logo {
  width: 44px; height: 44px; flex: 0 0 44px;
  border-radius: 13px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-weight: 800; font-size: 22px;
  box-shadow: var(--shadow-sm);
}
.app-head h1 {
  margin: 0;
  font-size: var(--fs-h1);
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.15;
}
.app-head .sub {
  margin: 2px 0 0;
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  padding: 18px 16px;
  margin-bottom: 16px;
}
.card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.card-ic {
  width: 40px; height: 40px; flex: 0 0 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 20px;
  background: var(--accent-soft);
}
.card-head h2 {
  margin: 0;
  font-size: var(--fs-h2);
  font-weight: 800;
  letter-spacing: -.01em;
}
.card-head .help {
  margin: 3px 0 0;
  font-size: var(--fs-sm);
  color: var(--ink-2);
  line-height: 1.4;
}

/* ---------- Fields ---------- */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field > label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 7px;
}
.field .hint {
  font-weight: 500;
  color: var(--muted);
}

.input,
input[type="text"],
input[type="url"],
input[type="number"],
textarea,
select {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 16px; /* cegah zoom iOS */
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
textarea {
  min-height: 84px;
  resize: vertical;
  line-height: 1.5;
}
.input:focus,
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
::placeholder { color: var(--muted); }

.grid2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.grid2 .field { margin-bottom: 0; }

/* ---------- Color field ---------- */
.color-field { display: flex; align-items: center; gap: 12px; }
.color-field input[type="color"] {
  -webkit-appearance: none; appearance: none;
  width: 56px; height: 48px; min-height: 48px;
  padding: 4px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  flex: 0 0 auto;
}
.color-field input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-field input[type="color"]::-webkit-color-swatch { border: none; border-radius: 7px; }
.color-field .color-note { font-size: var(--fs-sm); color: var(--muted); }

/* ---------- Money input ---------- */
.money {
  display: flex; align-items: center;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  overflow: hidden;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.money:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.money .rp {
  flex: 0 0 auto;
  align-self: stretch;
  display: grid; place-items: center;
  padding: 0 12px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-weight: 800;
  font-size: 15px;
  border-right: 1.5px solid var(--line);
}
.money input {
  border: none;
  border-radius: 0;
  min-height: 46px;
}
.money input:focus { outline: none; box-shadow: none; }

/* ---------- Switch (toggle) ---------- */
.switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  cursor: pointer;
  user-select: none;
}
.switch-row .sw-text { flex: 1 1 auto; }
.switch-row .sw-title { font-weight: 700; font-size: var(--fs-body); }
.switch-row .sw-desc { font-size: var(--fs-xs); color: var(--muted); margin-top: 1px; }

.switch { position: relative; flex: 0 0 auto; display: inline-block; }
.switch input {
  position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer;
}
.switch .track {
  display: block;
  width: 52px; height: 30px;
  border-radius: 999px;
  background: #cfd2e0;
  transition: background .2s var(--ease);
  position: relative;
}
.switch .track::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .2s var(--ease);
}
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(22px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 4px var(--accent-soft); }

/* ---------- Range (kecepatan) ---------- */
.range-field .range-top {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 8px;
}
.range-val {
  font-weight: 800; color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 10px; border-radius: 999px; font-size: var(--fs-sm);
}
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 8px; min-height: 8px; padding: 0;
  background: var(--surface-2);
  border: none; border-radius: 999px;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent);
  border: 4px solid #fff;
  box-shadow: var(--shadow-sm);
}
input[type="range"]::-moz-range-thumb {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent);
  border: 4px solid #fff;
  box-shadow: var(--shadow-sm);
}
.range-scale {
  display: flex; justify-content: space-between;
  font-size: var(--fs-xs); color: var(--muted); margin-top: 6px;
}

/* ---------- Produk ---------- */
.product-item {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--r);
  padding: 14px;
  margin-bottom: 14px;
}
.product-item.is-new { animation: pop .3s var(--ease); }
@keyframes pop { from { transform: scale(.98); opacity: .5; } to { transform: scale(1); opacity: 1; } }

.ph-item-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.ph-item-head strong {
  font-size: var(--fs-body);
  display: inline-flex; align-items: center; gap: 8px;
}
.ph-num {
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: var(--fs-sm); font-weight: 800;
}

/* mini buttons di product row */
.mini {
  min-height: 40px; padding: 0 14px;
  border-radius: 10px; font-weight: 700; font-size: var(--fs-sm);
  background: var(--surface-2); color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
  display: inline-flex; align-items: center; gap: 6px;
}
.mini:active { transform: translateY(1px); }
.mini.danger {
  background: transparent; color: var(--danger);
  box-shadow: inset 0 0 0 1px #f3c6cf;
}

/* tombol Buat Skrip AI */
.btn-script {
  width: 100%;
  min-height: var(--tap);
  border-radius: var(--r-sm);
  font-weight: 800; font-size: var(--fs-body);
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--accent);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 4px;
}
.btn-script:active { transform: translateY(1px); }

.price-preview {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 10px 0 12px;
  font-size: var(--fs-sm);
}
.price-preview .now { font-weight: 800; color: var(--ink); font-size: 16px; }
.price-preview .was { color: var(--muted); text-decoration: line-through; }
.price-preview .save-tag {
  background: var(--ok-soft); color: var(--ok);
  font-weight: 700; font-size: var(--fs-xs);
  padding: 3px 9px; border-radius: 999px;
}

/* kotak hasil skrip */
.script-out {
  margin-top: 8px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  line-height: 1.55;
  white-space: pre-wrap;
}
.script-out.has-script {
  background: #fff;
  border-style: solid;
  border-color: var(--accent-soft);
  border-left: 4px solid var(--accent);
  color: var(--ink);
}

/* tombol tambah produk */
.btn-add {
  width: 100%;
  min-height: 54px;
  border-radius: var(--r);
  font-weight: 800; font-size: var(--fs-body);
  color: var(--ink);
  background: var(--surface);
  border: 2px dashed var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn-add:active { transform: translateY(1px); }

/* ---------- Upsell (klip) ---------- */
.upsell {
  display: flex; align-items: center; gap: 12px;
  margin-top: 14px;
  padding: 12px 14px;
  background: linear-gradient(180deg, var(--accent-soft), #fff);
  border: 1px solid var(--accent-soft);
  border-radius: var(--r);
}
.upsell .up-ic { font-size: 24px; flex: 0 0 auto; }
.upsell .up-body { flex: 1 1 auto; }
.upsell .up-title { font-weight: 800; font-size: var(--fs-sm); }
.upsell .up-desc { font-size: var(--fs-xs); color: var(--ink-2); margin-top: 1px; }

/* ---------- Sticky action bar ---------- */
.action-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: flex; gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px rgba(20,21,28,.06);
}
.action-bar .wrap-inner {
  width: 100%; max-width: 720px; margin: 0 auto;
  display: flex; gap: 10px;
}
.action-bar .btn { flex: 1 1 0; min-height: 52px; }
#saveBtn { flex: 1.1 1 0; }

/* reset kecil di dalam konten */
.reset-line {
  text-align: center;
  padding: 4px 0 8px;
}
.reset-line button {
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-decoration: underline;
  min-height: var(--tap);
  padding: 0 12px;
}
.reset-line button:hover { color: var(--danger); }

/* ---------- Desktop enhance ---------- */
@media (min-width: 560px) {
  .grid2 { grid-template-columns: 1fr 1fr; }
  .grid2 .full { grid-column: 1 / -1; }
  .wrap { padding: 24px 24px 0; }
}

/* ============================================================
   Segmented control (mode suara / checkout) + Perekam suara
   ============================================================ */
.seg {
  display: flex; gap: 6px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 4px;
}
.seg-btn {
  flex: 1; min-height: 42px; border-radius: 8px;
  background: transparent; color: var(--ink-2); font-weight: 700; font-size: var(--fs-sm);
  transition: background .15s var(--ease), color .15s var(--ease);
  white-space: nowrap; padding: 0 8px;
}
.seg-btn.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

.recorder {
  border: 1px solid var(--line); border-radius: var(--r); padding: 12px;
  background: var(--surface-2); margin-bottom: 12px;
}
.rec-head { font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.45; margin-bottom: 10px; }
.rec-row {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 12px; margin-bottom: 8px;
}
.rec-row.recorded { border-color: var(--ok); }
.rec-info { flex: 1 1 200px; min-width: 0; }
.rec-label { font-weight: 700; font-size: var(--fs-sm); }
.rec-text { font-size: var(--fs-xs); color: var(--muted); line-height: 1.4; margin-top: 2px; }
.rec-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rec-btn {
  min-height: 40px; padding: 0 12px; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: var(--fs-sm);
}
.rec-btn.ghost { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.rec-btn.recording { background: var(--danger); animation: recPulse 1s ease-in-out infinite; }
@keyframes recPulse { 50% { opacity: .6; } }
.rec-status { font-size: var(--fs-xs); font-weight: 700; color: var(--ok); }

/* ============================================================
   Baris akun (status login + sinkron)
   ============================================================ */
.acct-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 14px; margin-bottom: 16px;
}
.acct-status { font-size: var(--fs-sm); color: var(--ink-2); font-weight: 600; flex: 1 1 auto; min-width: 0; }
.acct-btn {
  flex: 0 0 auto; min-height: 40px; padding: 0 16px; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: var(--fs-sm);
  text-decoration: none; display: inline-flex; align-items: center;
}
#logoutBtn { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
