@font-face { font-family: 'CF1'; src: url('fonts/font-1.otf') format('opentype'); font-display: swap; }
@font-face { font-family: 'CF2'; src: url('fonts/font-2.otf') format('opentype'); font-display: swap; }
@font-face { font-family: 'CF3'; src: url('fonts/font-3.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'CF4'; src: url('fonts/font-4.otf') format('opentype'); font-display: swap; }
@font-face { font-family: 'CF5'; src: url('fonts/font-5.ttf') format('truetype'); font-display: swap; }

:root {
  --primary: #6C5CE7;
  --bg: #F5F5F5;
  --card: #FFFFFF;
  --text: #1A1A1A;
  --text-light: #999;
  --border: #E8E8E8;
  --success: #00B894;
  --danger: #E17055;
  --radius: 12px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { font-family: inherit; }
html, body { height: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; min-height: 100dvh; -webkit-font-smoothing: antialiased; }

/* Top Bar */
.top-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.top-bar.hidden { display: none; }

.gear-btn-inline {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: rgba(0,0,0,0.06); font-size: 16px; color: var(--text-light);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.gear-btn-inline:active { background: rgba(0,0,0,0.12); }
.gear-btn-inline.hidden { display: none; }

/* Step Dots */
.step-dots { display: flex; align-items: center; justify-content: center; gap: 0; flex: 1; }
.step-dot {
  width: 28px; height: 28px; border-radius: 50%; background: var(--border);
  transition: all 0.3s; border: none; cursor: pointer; padding: 0;
  font-size: 12px; color: var(--text-light);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.step-dot.active { background: var(--primary); color: white; }
.step-dot.completed { background: var(--success); color: white; }
.step-line { width: 16px; height: 2px; background: var(--border); flex-shrink: 0; }
.step-line.completed { background: var(--success); }

.btn-back {
  width: 40px; height: 40px; border-radius: 8px;
  border: 1.5px solid var(--border); background: var(--card);
  font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--text); flex-shrink: 0; padding: 0;
}
.btn-back:active { background: #eee; }
.btn-back.hidden { visibility: hidden; pointer-events: none; }

.btn-next {
  padding: 10px 16px; border-radius: 8px; border: none;
  background: var(--primary); color: white;
   font-size: 13px; cursor: pointer; flex-shrink: 0;
}
.btn-next:active { opacity: 0.8; }
.btn-next.hidden { visibility: hidden; pointer-events: none; }

/* Wizard */
.main-content { padding-top: 52px; padding-bottom: 20px; }
.wizard-step { display: none; padding: 0 16px; animation: fadeIn 0.25s ease; flex: 1; flex-direction: column; justify-content: center; align-items: center; }
.wizard-step.active { display: flex; }
#step1 { gap: 10px; max-width: 320px; margin: 0 auto; width: 100%; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.step-title { font-size: 16px; margin-bottom: 10px; text-align: center; flex-shrink: 0; }

/* Input */
.name-input-wrap { position: relative; width: 100%; }
.name-input { width: 100%; padding: 14px 36px 14px 16px; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: 16px; outline: none; background: var(--card); }
.name-input:focus { border-color: var(--primary); }
.name-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: 50%; border: none;
  background: var(--border); font-size: 16px; color: var(--text-light);
  cursor: pointer; display: none; align-items: center; justify-content: center; padding: 0;
}
.name-clear.show { display: flex; }

.name-history { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; justify-content: center; }
.name-history:empty { display: none; }
.name-hist-btn {
  padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--card); font-size: 13px; cursor: pointer;
  color: var(--text); transition: all 0.15s;
}
.name-hist-btn:active { background: var(--primary); color: white; border-color: var(--primary); }

/* Buttons */
.btn { width: 100%; padding: 14px; border: none; border-radius: var(--radius); font-size: 15px; cursor: pointer; }
.btn:active { opacity: 0.8; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:disabled { background: #D0D0D0; color: #999; cursor: not-allowed; }
.btn-secondary { background: var(--card); color: var(--text); border: 1.5px solid var(--border); }
.btn-danger { background: var(--danger); color: white; }
.btn-group { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.btn-group.three { grid-template-columns: 1fr 1fr 1fr; }

/* Font List */
.font-list { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.font-item { width: 100%; padding: 20px 100px; background: var(--card); border: 1.5px solid var(--border); border-radius: 10px; text-align: center; cursor: pointer; transition: all 0.15s; flex-shrink: 0; }
.font-item:active { transform: scale(0.98); }
.font-item.active { border-color: var(--primary); background: #F0EDFF; }
.font-item-name { font-size: 42px; line-height: 1.2; }
.font-1 { font-family: 'CF1', serif; }
.font-2 { font-family: 'CF2', serif; }
.font-3 { font-family: 'CF3', cursive; }
.font-4 { font-family: 'CF4', sans-serif; }
.font-5 { font-family: 'CF5', monospace; }

/* Color List */
.color-list { display: flex; flex-direction: column; gap: 8px; flex: 1; overflow-y: auto; }

.color-name-btn {
  width: 100%; padding: 20px 100px; border-radius: 12px;
  border: 1.5px solid var(--border); background: var(--card);
  cursor: pointer; transition: all 0.15s; overflow: hidden;
  text-align: center; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.color-name-btn:active { transform: scale(0.98); }
.color-name-btn.active { border-color: var(--primary); border-width: 2px; background: #F0EDFF; }

.cnb-text { font-size: 40px; display: block; line-height: 1; }

/* Category Tabs */
.category-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; flex-shrink: 0; }
.category-tab { padding: 12px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); font-size: 13px; cursor: pointer; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.category-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Image Grid */
.image-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; flex-shrink: 0; }
.image-card { height: 56px; border-radius: 8px; border: 1.5px solid transparent; overflow: hidden; cursor: pointer; background: #F0F0F0; display: flex; align-items: center; justify-content: center; }
.image-card:active { transform: scale(0.95); }
.image-card.active { border-color: var(--primary); border-width: 2px; }
.image-card img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* Position */
.pos-row { display: flex; gap: 6px; margin-top: 8px; flex-shrink: 0; }
.pos-btn { flex: 1; padding: 12px 16px; border: 1.5px solid var(--border); border-radius: 8px; background: var(--card); font-size: 13px; cursor: pointer; transition: all 0.15s; text-align: center; }
.pos-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Final Preview */
.final-preview { width: 100%; padding: 10px 16px; flex-shrink: 0; border-bottom: 1px solid var(--border); }
.final-preview.hidden { display: none; }
.fp-row { display: flex; align-items: center; justify-content: center; gap: 0; }
.fp-row.fp-left { flex-direction: row-reverse; }
.fp-text { line-height: 1; text-align: center; white-space: nowrap; font-size: 16px; }
.fp-img { flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.fp-img img { width: auto; height: 100%; object-fit: contain; }

/* Kotak Layout */
.fp-kotak { width: 200px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; }
.fp-kotak.hidden { display: none; }
.fp-kotak-img { width: 100%; height: 140px; display: flex; align-items: center; justify-content: center; }
.fp-kotak-img img { width: 100%; height: 100%; object-fit: contain; }
.fp-kotak-name { width: 60%; margin-top: -4px; padding: 8px 12px; border: 3px solid #000; border-radius: 15px; background: white; text-align: center; box-sizing: border-box; transition: border-color 0.15s; }
.fp-kotak-text { font-size: 20px; line-height: 1; white-space: nowrap; }

/* Border Color Picker (kotak mode) */
.border-color-row { display: flex; gap: 6px; margin-top: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.border-color-row.hidden { display: none; }
.bc-label { font-size: 12px; color: var(--text-light); margin-right: 4px; }
.bc-swatch { width: 32px; height: 32px; border-radius: 50%; border: 2.5px solid var(--border); cursor: pointer; transition: all 0.15s; }
.bc-swatch.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); transform: scale(1.1); }
.bc-swatch:active { transform: scale(0.9); }

/* Result */
.result-card { background: var(--card); border-radius: var(--radius); padding: 32px 20px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.result-preview { display: flex; align-items: center; justify-content: center; gap: 4px; margin-bottom: 14px; min-height: 80px; }
.result-preview .rp-img { height: 80px; width: auto; object-fit: contain; }
.result-preview .rp-text { font-size: 48px; line-height: 1; white-space: nowrap; }
.result-code { background: #F0F0F0; padding: 12px; border-radius: 8px; font-family: 'SF Mono', Monaco, monospace; font-size: 13px; color: var(--primary); word-break: break-all; margin: 0 auto; max-width: 300px; cursor: pointer; }
.result-info { font-size: 12px; color: var(--text-light); margin-top: 10px; }

/* Admin */
.admin-panel { position: fixed; inset: 0; background: var(--bg); z-index: 300; overflow-y: auto; padding: 16px; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.admin-header h2 { font-size: 18px; }
.admin-close { width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--border); font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.admin-section { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.admin-section h3 { font-size: 14px; margin-bottom: 8px; }
.admin-example { background: #F5F5F5; padding: 8px; border-radius: 6px; font-size: 10px; margin-bottom: 10px; }
.bulk-input { width: 100%; padding: 10px; border: 1.5px solid var(--border); border-radius: 8px; font-family: 'SF Mono', Monaco, monospace; font-size: 12px; resize: vertical; margin-bottom: 10px; outline: none; }
.bulk-input:focus { border-color: var(--primary); }
.order-stats { font-size: 12px; color: var(--text-light); margin-bottom: 10px; }
.order-item { background: #F8F9FA; border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.order-item__code { font-family: 'SF Mono', Monaco, monospace; font-size: 10px; color: var(--primary); word-break: break-all; margin-bottom: 6px; }
.order-item__preview { width: 100%; height: 50px; border-radius: 6px; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; overflow: hidden; margin: 6px 0; background: white; gap: 8px; padding: 0 10px; }
.order-item__preview .op-name { font-size: 10px; flex: 1; text-align: center; }
.order-item__preview .op-img { width: 36px; height: 36px; flex-shrink: 0; object-fit: contain; }
.order-item__actions { display: flex; gap: 6px; }
.order-item__actions button { flex: 1; padding: 6px; border-radius: 6px; border: none; font-size: 10px; cursor: pointer; }
.admin-actions { display: flex; gap: 8px; margin-top: 12px; }
.admin-actions button { flex: 1; padding: 10px; font-size: 13px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(100px); background: var(--text); color: white; padding: 8px 16px; border-radius: 8px; font-size: 12px; z-index: 400; transition: transform 0.25s ease; white-space: nowrap; }
.toast.show { transform: translateX(-50%) translateY(0); }

@media (min-width: 400px) { .image-grid { grid-template-columns: repeat(6, 1fr); } }
