/* Takı mockup otomasyonu — sıcak, galeri hissi veren açık tema.
   Takı fotoğrafı nötr zeminde doğru görünsün diye tek moda sabit. */

:root {
  --bg: #FBF9F6;
  --surface: #FFFFFF;
  --surface-2: #F4EFE8;
  --border: #E4DCD1;
  --border-strong: #D3C7B7;
  --text: #2B2622;
  --text-dim: #7A7069;
  --accent: #8A6A3C;
  --accent-dark: #6E5330;
  --accent-soft: #F0E7D9;
  --danger: #B44A3C;
  --danger-soft: #FAEDEB;
  --ok: #3F7A4F;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(43, 38, 34, .04), 0 8px 24px rgba(43, 38, 34, .05);
}

* { box-sizing: border-box; }

/* .lightbox ve .btn gibi display tanımlayan sınıflar, tarayıcının varsayılan
   [hidden] kuralını ezip elemanı görünür bırakıyor. Bunu kesin olarak bastır. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 600; margin: 0; }

code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .88em;
       background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

.hint { color: var(--text-dim); font-size: 13px; margin: 4px 0 0; }

/* --- Üst bar --- */

.topbar {
  display: flex; flex-wrap: wrap; gap: 20px 32px;
  align-items: flex-end; justify-content: space-between;
  padding: 34px 40px 26px;
  max-width: 1360px; margin: 0 auto;
}
.brand h1 { font-size: 30px; letter-spacing: -.01em; }
.brand p { color: var(--text-dim); margin: 6px 0 0; font-size: 14px; max-width: 52ch; }

.engine { display: flex; flex-direction: column; gap: 7px; }
.engine-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .07em; }

.segmented { display: inline-flex; background: var(--surface-2); padding: 3px;
             border-radius: 10px; border: 1px solid var(--border); }
.segmented button {
  border: 0; background: transparent; color: var(--text-dim);
  font: inherit; font-size: 14px; font-weight: 500;
  padding: 8px 18px; border-radius: 7px; cursor: pointer;
  transition: background .15s, color .15s;
}
.segmented button:hover:not(.active) { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--accent-dark); box-shadow: var(--shadow); }
.segmented button .nokey { color: var(--danger); margin-left: 6px; font-size: 12px; }

/* --- Bölümler --- */

main { max-width: 1360px; margin: 0 auto; padding: 0 40px 80px; }

.step { margin-bottom: 40px; }
.step h2 { font-size: 19px; display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.num {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-dark);
  font: 600 12px/1 Inter, sans-serif; font-family: Inter, sans-serif;
}
.step > .hint { margin-bottom: 16px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 18px; }

@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .topbar, main { padding-left: 20px; padding-right: 20px; }
}

/* --- Kartlar / dropzone --- */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h3 { font-size: 16px; }

.badge {
  min-width: 26px; text-align: center; padding: 2px 9px; border-radius: 20px;
  background: var(--surface-2); color: var(--text-dim);
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.badge.filled { background: var(--accent-soft); color: var(--accent-dark); }

.dropzone { transition: border-color .15s, background .15s; }
.dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .btn.ghost { margin-top: 14px; }
.drop-hint { display: inline-block; margin-left: 10px; }

.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.thumb { position: relative; width: 74px; height: 74px; border-radius: 9px; overflow: hidden;
         border: 1px solid var(--border); background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button {
  position: absolute; top: 3px; right: 3px; width: 19px; height: 19px;
  border: 0; border-radius: 50%; cursor: pointer; line-height: 1;
  background: rgba(43, 38, 34, .72); color: #fff; font-size: 13px;
  display: grid; place-items: center; padding: 0;
}
.thumb button:hover { background: var(--danger); }

/* --- Butonlar --- */

.btn {
  font: inherit; font-weight: 500; cursor: pointer;
  border-radius: 9px; padding: 10px 18px; border: 1px solid transparent;
  transition: background .15s, border-color .15s, opacity .15s;
  text-decoration: none; display: inline-block; text-align: center;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn.ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent-dark); }
.btn.link { background: none; border: 0; color: var(--accent-dark); padding: 4px 6px; font-size: 13px; }
.btn.link:hover { text-decoration: underline; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* --- Ayar paneli --- */

.panel { background: var(--surface); border: 1px solid var(--border);
         border-radius: var(--radius); box-shadow: var(--shadow); }
.panel summary {
  cursor: pointer; padding: 15px 20px; font-weight: 500; list-style: none;
  display: flex; align-items: center; gap: 9px;
}
.panel summary::-webkit-details-marker { display: none; }
.panel summary::before {
  content: "›"; font-size: 17px; color: var(--text-dim);
  transition: transform .18s; display: inline-block;
}
.panel[open] summary::before { transform: rotate(90deg); }
.panel-body { padding: 4px 20px 22px; border-top: 1px solid var(--border); }

.field { margin-top: 18px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.field textarea, .field input[type=text], .field input:not([type]), .field select {
  width: 100%; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: 9px; padding: 10px 12px;
}
.field textarea { resize: vertical; line-height: 1.6; font-size: 14px; }
.field textarea:focus, .field input:focus, .field select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field input[type=range] { width: 100%; accent-color: var(--accent); }

/* Anahtar (toggle) */
.switch { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; padding-top: 18px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.track {
  flex: none; width: 40px; height: 23px; border-radius: 20px;
  background: var(--border-strong); position: relative; transition: background .18s; margin-top: 1px;
}
.knob {
  position: absolute; top: 3px; left: 3px; width: 17px; height: 17px;
  border-radius: 50%; background: #fff; transition: transform .18s;
  box-shadow: 0 1px 3px rgba(0,0,0,.22);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track .knob { transform: translateX(17px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-soft); }
.switch-text { font-size: 14px; font-weight: 500; }
.switch-text em { display: block; font-style: normal; font-weight: 400;
                  color: var(--text-dim); font-size: 13px; margin-top: 3px; max-width: 68ch; }

/* --- Eylem satırı --- */

.action { display: flex; align-items: center; gap: 18px; margin-top: 20px; flex-wrap: wrap; }
.action .btn.primary { padding: 12px 26px; font-size: 15px; }
.summary { color: var(--text-dim); font-size: 14px; margin: 0; }
.summary b { color: var(--text); }
.summary.error { color: var(--danger); }

/* --- İlerleme --- */

.progress { margin-top: 22px; background: var(--surface); border: 1px solid var(--border);
            border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.bar { height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--accent); transition: width .35s ease; }
.progress-meta { display: flex; align-items: center; justify-content: space-between;
                 margin-top: 10px; font-size: 14px; }
.log {
  margin: 12px 0 0; padding: 12px 14px; max-height: 220px; overflow: auto;
  background: var(--surface-2); border-radius: 9px;
  font: 12px/1.65 ui-monospace, Menlo, Consolas, monospace;
  color: var(--text-dim); white-space: pre-wrap; word-break: break-word;
}

/* --- Sonuç galerisi --- */

.results-bar { display: flex; align-items: center; justify-content: space-between;
               gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.results-bar .hint { margin: 0; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }

.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
        overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.tile-img { position: relative; aspect-ratio: 1; background: var(--surface-2); }
.tile-img img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.tile-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.tile-title { font-size: 13.5px; font-weight: 500; line-height: 1.4; }
.tile-actions { display: flex; gap: 8px; margin-top: auto; }
.tile-actions .btn { flex: 1; padding: 7px 10px; font-size: 13px; }

.tile.pending .tile-img { display: grid; place-items: center; }
.tile.failed .tile-img { background: var(--danger-soft); display: grid; place-items: center;
                         padding: 18px; text-align: center; }
.tile.failed .err { color: var(--danger); font-size: 12.5px; line-height: 1.5;
                    overflow: auto; max-height: 100%; }

.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.prompt-box { border-top: 1px solid var(--border); }
.prompt-box summary { cursor: pointer; font-size: 12.5px; color: var(--text-dim);
                      padding: 9px 14px; list-style: none; }
.prompt-box summary::-webkit-details-marker { display: none; }
.prompt-box p { margin: 0; padding: 0 14px 14px; font-size: 12.5px; color: var(--text-dim);
                line-height: 1.6; max-height: 200px; overflow: auto; }

/* --- Geçmiş --- */

.history { display: flex; flex-direction: column; gap: 8px; }
.history-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 16px; font-size: 14px;
}
.history-row .when { font-variant-numeric: tabular-nums; }
.history-row .meta { color: var(--text-dim); font-size: 13px; }
.history-row .spacer { flex: 1; }

/* --- Lightbox --- */

.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(30, 26, 22, .88);
            display: grid; place-items: center; padding: 40px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; display: block; }
.lightbox-close { position: absolute; top: 18px; right: 24px; background: none; border: 0;
                  color: #fff; font-size: 36px; line-height: 1; cursor: pointer; padding: 6px; }

/* --- Bildirim --- */

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 11px 20px;
  border-radius: 10px; font-size: 14px; z-index: 60; max-width: 88vw;
  box-shadow: 0 8px 28px rgba(0,0,0,.22);
}
.toast.error { background: var(--danger); color: #fff; }

/* --- Ürün kartı ------------------------------------------------------------ */

.product-card { max-width: 620px; }
.product-empty { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.product-filled { display: flex; gap: 18px; align-items: flex-start; }
.product-filled img {
  width: 128px; height: 128px; object-fit: contain; flex: none;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); padding: 6px;
}
.product-meta { flex: 1; min-width: 0; }
.product-name { font-weight: 500; word-break: break-all; }
.product-actions { display: flex; gap: 8px; margin-top: 12px; }

/* --- Araç çubuğu ----------------------------------------------------------- */

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.btn.small { padding: 7px 13px; font-size: 13px; }
.selected-count {
  font-size: 13px; color: var(--accent-dark); font-weight: 500;
  background: var(--accent-soft); padding: 5px 12px; border-radius: 20px;
}

/* --- Kütüphane ------------------------------------------------------------- */

.library { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; }

.bg-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column;
  transition: border-color .15s, box-shadow .15s;
}
.bg-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.bg-card.busy { opacity: .6; pointer-events: none; }

.bg-top { display: flex; gap: 12px; padding: 12px; align-items: flex-start; }
.bg-thumb {
  width: 96px; height: 96px; flex: none; border-radius: 9px; overflow: hidden;
  border: 1px solid var(--border); background: var(--surface-2); cursor: zoom-in;
}
.bg-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.bg-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.bg-head { display: flex; align-items: center; gap: 9px; }
.bg-head input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); flex: none; cursor: pointer; }
.bg-name {
  flex: 1; min-width: 0; font: inherit; font-weight: 500; font-size: 14px;
  border: 1px solid transparent; background: transparent; color: var(--text);
  border-radius: 6px; padding: 4px 6px;
}
.bg-name:hover { border-color: var(--border); }
.bg-name:focus { outline: none; border-color: var(--accent); background: var(--bg); }

.pill { font-size: 11.5px; padding: 2px 9px; border-radius: 20px; font-weight: 500; white-space: nowrap; }
.pill.ok { background: #E7F0E9; color: var(--ok); }
.pill.missing { background: #FBECE9; color: var(--danger); }

.bg-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.bg-actions .btn { padding: 5px 11px; font-size: 12.5px; }

.bg-prompt { border-top: 1px solid var(--border); }
.bg-prompt summary {
  cursor: pointer; list-style: none; padding: 10px 14px;
  font-size: 12.5px; color: var(--text-dim); display: flex; align-items: center; gap: 7px;
}
.bg-prompt summary::-webkit-details-marker { display: none; }
.bg-prompt summary::before { content: "›"; transition: transform .18s; display: inline-block; font-size: 15px; }
.bg-prompt[open] summary::before { transform: rotate(90deg); }
.bg-prompt .body { padding: 0 14px 14px; }
.bg-prompt textarea {
  width: 100%; font: inherit; font-size: 12.5px; line-height: 1.6; color: var(--text);
  background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 9px 11px; resize: vertical;
}
.bg-prompt textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.bg-prompt .row { display: flex; align-items: center; gap: 9px; margin-top: 9px; }
.bg-prompt .dirty { font-size: 12px; color: var(--danger); }

.empty-note {
  background: var(--surface-2); border: 1px dashed var(--border-strong);
  border-radius: var(--radius); padding: 22px; text-align: center;
  color: var(--text-dim); font-size: 14px;
}

/* --- Kayıt tablosu --------------------------------------------------------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius);
              background: var(--surface); box-shadow: var(--shadow); }
table.logs { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 800px; }
table.logs th, table.logs td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
table.logs th { font-weight: 500; font-size: 12px; color: var(--text-dim);
                text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
table.logs tbody tr:last-child td { border-bottom: 0; }
table.logs tbody tr:hover { background: var(--surface-2); }
table.logs .num-col { text-align: right; font-variant-numeric: tabular-nums; }
table.logs .bgs { color: var(--text-dim); font-size: 12.5px; max-width: 280px; }
table.logs .state-done { color: var(--ok); }
table.logs .state-error { color: var(--danger); }
table.logs .state-running { color: var(--accent-dark); }

/* --- Detay penceresi ------------------------------------------------------- */

.modal { position: fixed; inset: 0; z-index: 55; background: rgba(30, 26, 22, .6);
         display: grid; place-items: center; padding: 30px; }
.modal-box { background: var(--surface); border-radius: var(--radius); max-width: 760px;
             width: 100%; max-height: 84vh; display: flex; flex-direction: column;
             box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head { display: flex; align-items: center; justify-content: space-between;
              padding: 16px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; }
.modal-head .lightbox-close { position: static; color: var(--text-dim); font-size: 28px; }
.modal-body { padding: 18px 22px 24px; overflow: auto; font-size: 13.5px; }
.modal-body dl { display: grid; grid-template-columns: 160px 1fr; gap: 8px 18px; margin: 0; }
.modal-body dt { color: var(--text-dim); font-size: 12.5px; }
.modal-body dd { margin: 0; word-break: break-word; }
.modal-body h4 { font-family: Inter, sans-serif; font-size: 13px; margin: 20px 0 10px;
                 color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
.modal-body ol { margin: 0; padding-left: 20px; }
.modal-body li { margin-bottom: 6px; }

.engine-label { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.engine-label .logout {
  color: var(--text-dim); text-decoration: none; text-transform: none;
  letter-spacing: 0; font-size: 12px; border-bottom: 1px solid transparent;
}
.engine-label .logout:hover { color: var(--danger); border-bottom-color: currentColor; }
