/* ================= TEMA ================= */
:root {
  --bg: #f3f4f6;
  --bg-panel: #ffffff;
  --bg-elev: #ffffff;
  --bg-hover: #eef0f3;
  --bg-active: #e3e8f2;
  --border: #dde1e7;
  --text: #1f2430;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, .14);
  --accent-text: #ffffff;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #16a34a;
  --shadow: 0 8px 30px rgba(0,0,0,.12);
  --page-shadow: 0 2px 10px rgba(0,0,0,.18);
  --sel: rgba(37, 99, 235, .55);
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #15171c;
  --bg-panel: #1e2128;
  --bg-elev: #262a33;
  --bg-hover: #2b303a;
  --bg-active: #323847;
  --border: #30353f;
  --text: #e6e8ec;
  --text-muted: #9aa1ad;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, .18);
  --accent-text: #ffffff;
  --shadow: 0 8px 30px rgba(0,0,0,.5);
  --page-shadow: 0 2px 12px rgba(0,0,0,.6);
  --sel: rgba(79, 140, 255, .6);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font); font-size: 13.5px; color: var(--text); background: var(--bg);
  display: flex; flex-direction: column; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg-elev); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
code { background: var(--bg-hover); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.muted { color: var(--text-muted); }

/* ================= BUTONLAR ================= */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-elev); transition: background .12s, border-color .12s;
}
.btn:hover:not(:disabled) { background: var(--bg-hover); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; justify-content: center; }
.icon-btn {
  width: 34px; height: 34px; border-radius: var(--radius); border: 1px solid transparent; background: transparent;
  display: inline-flex; align-items: center; justify-content: center; color: var(--text);
}
.icon-btn:hover:not(:disabled) { background: var(--bg-hover); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.mini { background: transparent; border: 1px solid transparent; border-radius: 5px; padding: 2px 7px; color: var(--text-muted); }
.mini:hover { background: var(--bg-hover); color: var(--text); }
.link { background: none; border: none; color: var(--accent); padding: 0; text-decoration: underline; }
.toggle { width: 32px; height: 30px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-elev); }
.toggle.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }

/* ================= ÜST ÇUBUK ================= */
.topbar {
  height: 50px; display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--bg-panel); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.brand { display: flex; align-items: center; white-space: nowrap; }
.brand .logo { height: 34px; width: auto; display: block; }
.logo-dark { display: none !important; }
:root[data-theme="dark"] .logo-light { display: none !important; }
:root[data-theme="dark"] .logo-dark { display: block !important; }
.filename { color: var(--text-muted); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-left: 8px; }
.topbar-center { display: flex; align-items: center; gap: 4px; margin: 0 auto; }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.zoom-label { background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; min-width: 56px; font-variant-numeric: tabular-nums; }
.zoom-label:hover { background: var(--bg-hover); }
.search-wrap { display: flex; align-items: center; gap: 4px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 2px 6px 2px 8px; }
.search-wrap svg { width: 15px; height: 15px; color: var(--text-muted); }
.search-wrap input { border: none; background: transparent; width: 180px; padding: 4px 2px; }
.search-wrap input:focus { outline: none; }
#searchCount { color: var(--text-muted); font-size: 12px; min-width: 36px; text-align: center; }
.ico-moon { display: none; }
:root[data-theme="dark"] .ico-sun { display: none; }
:root[data-theme="dark"] .ico-moon { display: block; }

/* dropdown */
.dropdown { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 250px; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); padding: 6px; z-index: 50; display: none;
}
.dropdown.open .menu { display: block; }
.menu button { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; padding: 7px 10px; border: none; background: transparent; border-radius: 6px; }
.menu button:hover { background: var(--bg-hover); }
.menu button small { color: var(--text-muted); font-size: 11.5px; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }

/* ================= GÖVDE ================= */
.workspace { flex: 1; display: flex; min-height: 0; }

.add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.add-grid .btn { justify-content: flex-start; padding: 8px 10px; }
.add-grid .btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.mode-banner { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 12px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.viewer.mode-erase .page-overlay, .viewer.mode-redact .page-overlay { cursor: crosshair; }
.span-box.new-flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0%, 60% { background: rgba(250, 204, 21, .5); } 100% { background: transparent; } }
.toolrail { width: 60px; background: var(--bg-panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding: 8px 0; gap: 4px; }
.toolrail button {
  width: 50px; height: 50px; border-radius: 10px; border: 1px solid transparent; background: transparent; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; color: var(--text-muted); font-size: 10.5px;
}
.toolrail button svg { width: 20px; height: 20px; }
.toolrail button:hover { background: var(--bg-hover); color: var(--text); }
.toolrail button.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); }

.thumbs { width: 170px; background: var(--bg-panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.thumbs-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px 6px; font-weight: 600; font-size: 12.5px; }
.thumbs-list { flex: 1; overflow-y: auto; padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.thumb { position: relative; border-radius: 6px; border: 2px solid transparent; padding: 4px; cursor: pointer; background: var(--bg); transition: border-color .12s; }
.thumb img { width: 100%; display: block; box-shadow: var(--page-shadow); background: #fff; border-radius: 2px; }
.thumb .n { position: absolute; left: 8px; bottom: 8px; font-size: 11px; background: rgba(0,0,0,.6); color: #fff; padding: 1px 6px; border-radius: 10px; }
.thumb.active { border-color: var(--accent); }
.thumb.drag-over { border-color: var(--ok); }
.thumb.dragging { opacity: .4; }
.thumbs-hint { padding: 6px 12px 10px; font-size: 11px; color: var(--text-muted); border-top: 1px solid var(--border); }

/* ================= TUVAL ================= */
.viewer { flex: 1; position: relative; overflow: auto; background: var(--bg); }
.viewer.hand { cursor: grab; }
.viewer.hand.grabbing { cursor: grabbing; }
.viewer.tool-text .page-overlay { cursor: text; }
.viewer.tool-image .page-overlay, .viewer.tool-erase .page-overlay, .viewer.tool-redact .page-overlay { cursor: crosshair; }
.pages { padding: 28px; display: flex; flex-direction: column; align-items: center; gap: 24px; min-width: fit-content; }
.page { position: relative; box-shadow: var(--page-shadow); background: #fff; flex-shrink: 0; }
.page img.render { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.page-overlay { position: absolute; inset: 0; }
.page.drag-target { outline: 3px dashed var(--accent); outline-offset: -3px; }

.span-box {
  position: absolute; border: 1px solid transparent; cursor: move; white-space: pre; overflow: visible;
  color: transparent; line-height: 1; user-select: none;
}
.span-box:hover { border-color: var(--sel); background: var(--accent-soft); }
.span-box.selected { border-color: var(--accent); background: var(--accent-soft); }
.span-box.editing {
  color: var(--text-edit, #000); background: #fff; border-color: var(--accent); outline: 2px solid var(--accent-soft); cursor: text; user-select: text;
  box-shadow: 0 2px 8px rgba(0,0,0,.2); z-index: 5; min-width: 8px; white-space: pre;
}
.span-box.ghost { opacity: .6; }
.span-box.fallback::after { content: "!"; position: absolute; right: -14px; top: -10px; width: 14px; height: 14px; border-radius: 50%; background: var(--warn); color: #fff; font-size: 10px; line-height: 14px; text-align: center; }

.img-box { position: absolute; border: 1px solid transparent; cursor: move; }
.img-box:hover { border-color: var(--sel); }
.img-box.selected { border-color: var(--accent); }
.img-box .h { position: absolute; width: 10px; height: 10px; background: var(--accent); border: 2px solid #fff; border-radius: 2px; display: none; }
.img-box.selected .h { display: block; }
.h.nw { left: -6px; top: -6px; cursor: nwse-resize; } .h.ne { right: -6px; top: -6px; cursor: nesw-resize; }
.h.sw { left: -6px; bottom: -6px; cursor: nesw-resize; } .h.se { right: -6px; bottom: -6px; cursor: nwse-resize; }
.orig-img { position: absolute; border: 1px dashed transparent; }
.orig-img:hover { border-color: var(--sel); }
.orig-img.selected { border-color: var(--accent); background: var(--accent-soft); }

.marquee { position: absolute; border: 1.5px dashed var(--accent); background: var(--accent-soft); pointer-events: none; }
.marquee.redact { background: rgba(0,0,0,.7); border-color: #000; }
.hit { position: absolute; background: rgba(250, 204, 21, .45); border-radius: 2px; pointer-events: none; }
.hit.current { background: rgba(249, 115, 22, .6); outline: 2px solid #f97316; }

/* bırakma alanı */
.dropzone { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 2; }
.dz-inner { text-align: center; color: var(--text-muted); border: 2px dashed var(--border); border-radius: 16px; padding: 48px 64px; background: var(--bg-panel); transition: border-color .15s, background .15s; }
.dz-inner h2 { margin: 12px 0 4px; color: var(--text); font-weight: 600; font-size: 18px; }
.dz-inner p { margin: 6px 0; }
.dz-small { font-size: 12px; }
.viewer.dragover .dz-inner { border-color: var(--accent); background: var(--accent-soft); }
.viewer.has-doc .dropzone { display: none; }

/* ================= ÖZELLİKLER ================= */
.props { width: 280px; background: var(--bg-panel); border-left: 1px solid var(--border); overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 14px; }
.props h3 { margin: 0 0 8px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.props h3 small { text-transform: none; letter-spacing: 0; font-weight: normal; }
.props-section { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.props-section:last-child { border-bottom: none; }
.props label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.props label.inline { flex: 1; }
.props label.check { flex-direction: row; align-items: center; gap: 6px; }
.props textarea { resize: vertical; min-height: 60px; }
.props .row { display: flex; gap: 6px; align-items: flex-end; margin-bottom: 8px; flex-wrap: wrap; }
.props .row.right { justify-content: flex-end; }
.props input[type="number"] { width: 100%; }
.props input[type="color"] { width: 100%; height: 32px; padding: 2px; }
.props-empty ul { padding-left: 16px; color: var(--text-muted); line-height: 1.7; margin: 4px 0; }
.props-empty p { margin: 0; }
.font-note { font-size: 11.5px; color: var(--warn); min-height: 14px; margin-bottom: 6px; }
.font-note.ok { color: var(--ok); }
.page-info { color: var(--text-muted); font-size: 12px; margin-bottom: 8px; }
.ops-list { display: flex; flex-direction: column; gap: 3px; font-size: 12px; max-height: 220px; overflow-y: auto; }
.ops-list div { padding: 4px 6px; border-radius: 5px; background: var(--bg); color: var(--text-muted); display: flex; justify-content: space-between; gap: 6px; }
.ops-list div span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ops-list div.future { opacity: .4; }
.ops-list div.last { color: var(--text); background: var(--accent-soft); }

/* ================= DURUM ================= */
.statusbar { height: 26px; display: flex; align-items: center; gap: 18px; padding: 0 12px; font-size: 12px; color: var(--text-muted); background: var(--bg-panel); border-top: 1px solid var(--border); flex-shrink: 0; }
.statusbar #statusHint { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.busy { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); }
.spinner { width: 12px; height: 12px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= MODAL ================= */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-box { width: 620px; max-width: 94vw; max-height: 88vh; overflow-y: auto; background: var(--bg-panel); border-radius: 14px; padding: 20px 22px; box-shadow: var(--shadow); }
.modal-box.small { width: 440px; }
.modal-box h2 { margin: 0 0 8px; font-size: 17px; }
.modal-box p { margin: 6px 0 12px; line-height: 1.5; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-box textarea { width: 100%; resize: vertical; }
.modal-box .row { display: flex; gap: 8px; margin-top: 12px; }
.modal-box .row.right { justify-content: flex-end; }
.font-drop { border: 2px dashed var(--border); border-radius: 10px; padding: 18px; text-align: center; color: var(--text-muted); margin-bottom: 12px; }
.font-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.font-list { display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow-y: auto; margin-bottom: 12px; }
.font-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; background: var(--bg); }
.font-row b { flex: 1; }
.font-row .tag { font-size: 10.5px; padding: 1px 6px; border-radius: 10px; background: var(--bg-hover); color: var(--text-muted); }
.font-row .tag.user { background: var(--accent-soft); color: var(--accent); }
.font-row .styles { color: var(--text-muted); font-size: 11.5px; }
.font-check label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); }

/* bağlam menüsü */
.ctx-menu { position: fixed; z-index: 120; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 5px; min-width: 180px; }
.ctx-menu button { display: block; width: 100%; text-align: left; padding: 7px 10px; border: none; background: transparent; border-radius: 6px; }
.ctx-menu button:hover { background: var(--bg-hover); }
.ctx-menu button.danger { color: var(--danger); }

/* toast */
.toasts { position: fixed; right: 16px; bottom: 40px; display: flex; flex-direction: column; gap: 8px; z-index: 150; }
.toast { background: var(--bg-elev); border: 1px solid var(--border); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; font-size: 13px; animation: toastin .18s ease-out; }
.toast.warn { border-left-color: var(--warn); }
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }

/* ================= GİRİŞ ================= */
.login-body { align-items: center; justify-content: center; }
.login-card { width: 360px; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.login-logo { display: flex; justify-content: center; margin-bottom: 10px; }
.login-logo .logo { width: 100%; max-width: 300px; height: auto; }
.login-title { font-size: 18px; font-weight: 600; color: var(--text); }
.login-sub { font-size: 12px; color: var(--text-muted); text-align: center; margin-bottom: 20px; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.login-card input { padding: 9px 10px; }
.login-err { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-bottom: 8px; }

@media (max-width: 1100px) { .props { width: 240px; } .thumbs { width: 140px; } .search-wrap input { width: 120px; } .filename { display: none; } }
