/* =====================================================================
   Toplu Baskı Stüdyosu Pro — Modern, Sade ve Premium Tasarım Sistemi
   (Undo/Redo, QR Kod Katmanı ve Gizlilik Kartı Dahil)
   ===================================================================== */

:root,
:root[data-theme="light"] {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --panel-alt: #f8fafc;
  --stage: #dfe4ec;
  --stage-dot: rgba(15, 23, 42, 0.08);
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --violet: #7c3aed;
  --success: #059669;
  --danger: #dc2626;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-page: 0 8px 28px rgba(15, 23, 42, 0.16), 0 1px 3px rgba(15, 23, 42, 0.08);
  --radius: 10px;
}

:root[data-theme="dark"] {
  --bg: #0f131a;
  --panel: #161b24;
  --panel-alt: #1c222e;
  --stage: #0b0e14;
  --stage-dot: rgba(255, 255, 255, 0.05);
  --line: #273042;
  --line-strong: #37435a;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --violet: #8b5cf6;
  --success: #10b981;
  --danger: #ef4444;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-page: 0 14px 36px rgba(0, 0, 0, 0.55);
  --radius: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font: 13px/1.45 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* İnce Özel Kaydırma Çubukları */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11.5px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 5px;
}

.muted {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}

.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }

/* =====================================================================
   ÜST ARAÇ ÇUBUĞU
   ===================================================================== */
.topbar {
  height: 54px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 16px;
  box-shadow: 0 3px 10px rgba(79, 70, 229, 0.28);
}

.brand-text {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14.5px;
  letter-spacing: -0.015em;
}

.badge-pro {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.history-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sep {
  width: 1px;
  height: 22px;
  background: var(--line);
  margin: 0 2px;
}

/* =====================================================================
   BUTONLAR
   ===================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: 500 12.5px/1.2 inherit;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, border-color 0.15s, opacity 0.15s, transform 0.1s;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--panel-alt);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.ghost {
  background: transparent;
  box-shadow: none;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn.accent {
  background: var(--violet);
  border-color: var(--violet);
  color: #fff;
}
.btn.accent:hover:not(:disabled) { filter: brightness(1.08); }

.btn.success {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.btn.success:hover:not(:disabled) { filter: brightness(1.08); }

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn.sm {
  padding: 5px 9px;
  font-size: 11.5px;
  border-radius: 7px;
}

.btn.icon-btn {
  width: 34px;
  height: 32px;
  padding: 0;
  font-size: 14px;
}

.btn.icon-only {
  width: 26px;
  height: 26px;
  padding: 0;
  font-size: 15px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}
.btn-row.compact {
  margin-top: 0;
}

/* =====================================================================
   ANA 3 SÜTUNLU DÜZEN
   ===================================================================== */
.app {
  flex: 1;
  display: grid;
  grid-template-columns: 320px 1fr 330px;
  min-height: 0;
}

.sidebar {
  background: var(--panel);
  overflow-y: auto;
  padding: 10px 12px 24px;
  min-height: 0;
}

.sidebar.left { border-right: 1px solid var(--line); }
.sidebar.right { border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; }

/* =====================================================================
   SOL PANEL AKORDEON ADIMLARI (1 → 6)
   ===================================================================== */
details {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 9px;
  transition: border-color 0.15s;
}

details[open] {
  border-color: var(--line-strong);
}

summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

summary::-webkit-details-marker { display: none; }

summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  transition: transform 0.18s;
}

details:not([open]) summary::after {
  transform: rotate(-90deg);
}

.step-num {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

details > .body {
  padding: 4px 12px 12px;
  border-top: 1px solid var(--line);
}

/* =====================================================================
   FORM ELEMANLARI VE KUTULAR
   ===================================================================== */
.sub-head {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 10px 0 4px;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}

.row > label {
  flex: 0 0 98px;
  font-size: 12px;
  color: var(--muted);
}

.row > input:not([type="checkbox"]):not([type="color"]),
.row > select,
.row > textarea,
.row > .dual,
.row > .tgs,
.row > .rgb,
.row > .cut-color-wrap {
  flex: 1;
  min-width: 0;
}

.row.check {
  justify-content: space-between;
  padding: 2px 0;
}
.row.check > label {
  flex: 1;
  color: var(--text);
  cursor: pointer;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-alt);
  color: var(--text);
  font: 12.5px/1.3 inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea {
  resize: vertical;
  min-height: 62px;
}

input[type="color"] {
  width: 34px;
  height: 29px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-alt);
  cursor: pointer;
  flex-shrink: 0;
}

input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

input[type="range"] {
  accent-color: var(--accent);
  cursor: pointer;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 8px;
}
.grid2 .row > label {
  flex: 0 0 42px;
}

/* Sürükle-Bırak Dosya Kutuları */
.dropzone {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  margin-top: 6px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 9px;
  background: var(--panel-alt);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone.compact {
  padding: 9px 10px;
}

.drop-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.drop-copy strong {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thumb {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

/* Kesim Çizgisi Özel Kutusu */
.cut-box {
  margin: 8px 0;
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--panel-alt);
  border: 1px solid var(--line);
}

.cut-color-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text);
  cursor: pointer;
}

.info-pill {
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
}

/* Veri Mini Tablo */
.table-wrap {
  max-height: 132px;
  overflow: auto;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

th, td {
  padding: 4px 7px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: var(--panel-alt);
  font-weight: 600;
  color: var(--muted);
}

.font-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.font-list li {
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--panel-alt);
  border: 1px solid var(--line);
  font-size: 11.5px;
}

.export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 10px;
}
.export-grid .btn:first-child {
  grid-column: span 2;
  padding: 8px 12px;
}

/* Gizlilik Bilgi Kartı */
.privacy-card {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  border-left: 3px solid var(--success);
  background: var(--panel-alt);
}

.privacy-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.privacy-card p {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}

/* =====================================================================
   MERKEZ SAHNE (ÖNİZLEME)
   ===================================================================== */
.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background-color: var(--stage);
  background-image: radial-gradient(var(--stage-dot) 1px, transparent 1px);
  background-size: 18px 18px;
}

.stage-bar {
  min-height: 44px;
  padding: 6px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.zoom {
  display: inline-flex;
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.zoom button {
  padding: 4px 9px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: 600 11.5px inherit;
  cursor: pointer;
}

.zoom button:hover {
  color: var(--text);
}

.zoom button.on {
  background: var(--accent);
  color: #fff;
}

.pager {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.pager input {
  width: 54px;
  text-align: center;
  padding: 4px 5px;
}

.stage-info {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
}

.pages {
  flex: 1;
  overflow: auto;
  padding: 28px 24px 48px;
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  align-content: flex-start;
  justify-content: center;
}

.page-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: none;
}

.page-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 0 2px;
}

.page {
  background: #ffffff;
  border-radius: 3px;
  box-shadow: var(--shadow-page);
  position: relative;
  cursor: default;
  touch-action: none;
}

.page canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 3px;
}

/* =====================================================================
   SAĞ PANEL: KATMANLAR VE DİNAMİK ÖZELLİKLER
   ===================================================================== */
.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
}

.block-head h3 {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.prop-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
}

.layers {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.layer {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-alt);
  transition: border-color 0.15s, background 0.15s;
}

.layer.sel {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.layer .nm {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  font-weight: 500;
  font-size: 12.5px;
  padding: 0 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer .ic {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 12.5px;
}

.layer .ic:hover {
  background: var(--panel);
  color: var(--accent);
}

/* Özellik Bölümleri */
.props-block {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.prop-section {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.prop-section:first-child {
  border-top: none;
  padding-top: 0;
}

.prop-section h4 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
}

.dual {
  display: flex;
  align-items: center;
  gap: 7px;
}
.dual input[type="range"] { flex: 1; min-width: 0; }
.dual input[type="number"] { width: 62px; flex: none; }

.hex {
  max-width: 86px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.rgb {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.tgs {
  display: flex;
  gap: 4px;
}

.tg {
  flex: 1;
  height: 29px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-alt);
  color: var(--text);
  cursor: pointer;
  font-size: 12.5px;
}

.tg.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 8px;
}

.chip {
  padding: 3px 8px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--accent-soft);
  color: var(--accent);
  font: 600 11px ui-monospace, SFMono-Regular, Consolas, monospace;
  cursor: pointer;
}
.chip:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.posgrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin: 6px 0 8px;
}

.pos-btn {
  padding: 5px 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-alt);
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
}
.pos-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Katlanabilir Efekt Kartları (Gölge / Kontur / Parlama) */
.effect-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 9px;
  margin: 6px 0;
  background: var(--panel-alt);
}

.effect-card .row.check {
  margin: 0;
}

.effect-body {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

/* =====================================================================
   MODALLAR VE TOAST BİLDİRİMLERİ
   ===================================================================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(9, 13, 22, 0.62);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 100;
}
.modal[hidden] { display: none; }

.modal .box {
  width: min(360px, 92vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 22px;
  text-align: center;
  box-shadow: var(--shadow-page);
}

.modal h3 {
  font-size: 14.5px;
  margin-bottom: 12px;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 99px;
  background: var(--panel-alt);
  border: 1px solid var(--line);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  transition: width 0.15s ease;
}

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 9px;
  padding: 9px 14px;
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: var(--shadow-page);
}
.toast.ok { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }

/* =====================================================================
   DUYARLI (RESPONSIVE) YERLEŞİM
   ===================================================================== */
@media (max-width: 1180px) {
  .app { grid-template-columns: 290px 1fr 295px; }
}

@media (max-width: 860px) {
  body { overflow: auto; height: auto; }
  .app { grid-template-columns: 1fr; }
  .sidebar { border: none; border-bottom: 1px solid var(--line); overflow: visible; }
  .stage { height: 72vh; }
}