/* Belge yazı tipleri: cihazda Times New Roman / Arial varsa o, yoksa (ör. Android) aynı ölçülerdeki
   Liberation Serif / Sans — satır ve sayfa kırılımları her cihazda UYAP'takiyle aynı kalır. */
@font-face { font-family: "UDF Serif"; font-style: normal; font-weight: 400; src: local("Times New Roman"), local("TimesNewRomanPSMT"), url("vendor/fonts/LiberationSerif-Regular.ttf") format("truetype"); }
@font-face { font-family: "UDF Serif"; font-style: normal; font-weight: 700; src: local("Times New Roman Bold"), local("TimesNewRomanPS-BoldMT"), url("vendor/fonts/LiberationSerif-Bold.ttf") format("truetype"); }
@font-face { font-family: "UDF Serif"; font-style: italic; font-weight: 400; src: local("Times New Roman Italic"), local("TimesNewRomanPS-ItalicMT"), url("vendor/fonts/LiberationSerif-Italic.ttf") format("truetype"); }
@font-face { font-family: "UDF Serif"; font-style: italic; font-weight: 700; src: local("Times New Roman Bold Italic"), local("TimesNewRomanPS-BoldItalicMT"), url("vendor/fonts/LiberationSerif-BoldItalic.ttf") format("truetype"); }
@font-face { font-family: "UDF Sans"; font-style: normal; font-weight: 400; src: local("Arial"), local("ArialMT"), url("vendor/fonts/LiberationSans-Regular.ttf") format("truetype"); }
@font-face { font-family: "UDF Sans"; font-style: normal; font-weight: 700; src: local("Arial Bold"), local("Arial-BoldMT"), url("vendor/fonts/LiberationSans-Bold.ttf") format("truetype"); }
@font-face { font-family: "UDF Sans"; font-style: italic; font-weight: 400; src: local("Arial Italic"), local("Arial-ItalicMT"), url("vendor/fonts/LiberationSans-Italic.ttf") format("truetype"); }
@font-face { font-family: "UDF Sans"; font-style: italic; font-weight: 700; src: local("Arial Bold Italic"), local("Arial-BoldItalicMT"), url("vendor/fonts/LiberationSans-BoldItalic.ttf") format("truetype"); }

:root {
  --bg: #f4f4f2;
  --panel: #ffffff;
  --line: #deded9;
  --text: #1f2328;
  --muted: #6b6f76;
  --accent: #b3261e;
  --accent-soft: #fbeceb;
  --viewer: #d9dbdf;
  --sel: #eef3fb;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
/* iPhone/iPad: dar ekranda yazıların otomatik büyütülmesini kapat (sekme hizası ve sayfalama bozulur) */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--bg);
  display: flex; flex-direction: column; overflow: hidden;
}
button { font: inherit; color: inherit; }

/* ── araç çubuğu ── */
.toolbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; margin-right: 6px; }
.logo { background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; padding: 3px 5px; border-radius: 4px; letter-spacing: .5px; }
.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 5px 11px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f3f3f1; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.icon { width: 30px; padding: 5px 0; text-align: center; font-weight: 600; }
.btn:disabled { opacity: .45; cursor: default; }
.sep { width: 1px; height: 22px; background: var(--line); }
.grow { flex: 1; }
.zoom { min-width: 44px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 5px 11px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--text); color: #fff; }

/* ── ana alan ── */
.main { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 290px; flex: none; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.side-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px 6px; font-weight: 600; }
.link { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 12px; }
.link:hover { color: var(--accent); }
.files { list-style: none; margin: 0; padding: 0 6px; overflow-y: auto; flex: 1; min-height: 60px; }
.files li {
  display: grid; grid-template-columns: 22px 16px 1fr auto; gap: 6px; align-items: center;
  padding: 7px 6px; border-radius: 6px; cursor: pointer; border: 1px solid transparent;
}
.files li:hover { background: #f6f6f4; }
.files li.selected { background: var(--sel); border-color: #cfdcf0; }
.files li.dragging { opacity: .4; }
.files li.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.files li.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.files .num { color: var(--muted); font-size: 12px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.files .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .meta { display: flex; gap: 4px; align-items: center; margin-top: 2px; font-size: 11px; color: var(--muted); }
.files .tag { font-size: 9.5px; font-weight: 700; padding: 1px 4px; border-radius: 3px; background: #ececea; color: #555; }
.files .tag.udf { background: var(--accent-soft); color: var(--accent); }
.files .tag.pdf { background: #e8eefb; color: #2a5bb8; }
.files .tag.img { background: #e9f5ec; color: #26773a; }
.files .signed { color: #8a6d00; }
.files .err { color: var(--accent); }
.files .acts { display: flex; gap: 2px; opacity: 0; }
.files li:hover .acts, .files li.selected .acts { opacity: 1; }
.files .acts button { border: 0; background: none; cursor: pointer; padding: 2px 4px; color: var(--muted); border-radius: 4px; }
.files .acts button:hover { background: #e9e9e6; color: var(--text); }
.files input[type=checkbox] { margin: 0; accent-color: var(--accent); }
.empty-hint { padding: 18px 16px; color: var(--muted); text-align: center; line-height: 1.6; }
.empty-hint small { display: block; margin-top: 8px; font-size: 11px; }
.info { border-top: 1px solid var(--line); padding: 10px 12px 12px; font-size: 12px; max-height: 45%; overflow-y: auto; }
.info h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.info dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 8px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; word-break: break-word; }
.info .signer { display: flex; gap: 6px; align-items: baseline; padding: 3px 0; }
.info .signer b { font-weight: 600; }
.info .signer small { color: var(--muted); }
.info .note { margin-top: 8px; padding: 6px 8px; background: #fff7df; border-radius: 6px; color: #6b5300; }

.viewer { flex: 1; overflow: auto; background: var(--viewer); position: relative; outline: none; }
.pages { padding: 24px 0 40px; display: flex; flex-direction: column; align-items: center; gap: 18px; transform-origin: top center; }
.doc-sep {
  font-size: 12px; color: #444; background: rgba(255,255,255,.7); padding: 3px 10px; border-radius: 12px; margin-bottom: -8px;
}
.welcome { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.welcome .drop {
  border: 2px dashed #9aa0a8; border-radius: 14px; padding: 40px 50px; text-align: center; color: #50555c; background: rgba(255,255,255,.5);
}
.welcome .big { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.drop-overlay {
  position: fixed; inset: 0; background: rgba(179,38,30,.12); border: 3px dashed var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 600; color: var(--accent); z-index: 50;
}
.status {
  display: flex; justify-content: space-between; gap: 12px; padding: 4px 12px; font-size: 12px; color: var(--muted);
  background: var(--panel); border-top: 1px solid var(--line);
}

/* ── ölçüm alanı (görünmez) ── */
.measure-host { position: absolute; left: -10000px; top: 0; visibility: hidden; }

/* ── belge sayfaları ── */
.udf-page, .img-page {
  position: relative; background: #fff; flex: none;
  box-shadow: 0 1px 3px rgba(0,0,0,.18), 0 4px 14px rgba(0,0,0,.08);
  color: #000; overflow: hidden;
}
.udf-body { position: absolute; }
.udf-header, .udf-footer { position: absolute; }
.udf-pageno { text-align: right; }
.udf-measure { font-family: "Times New Roman", Times, serif; font-size: 12pt; color: #000; }
.udf-p { white-space: pre-wrap; overflow-wrap: break-word; margin: 0; }
.udf-p .udf-tab { display: inline-block; text-indent: 0; }
.udf-leader-1 { border-bottom: 1px dotted #000; }
.udf-leader-2 { border-bottom: 1px dashed #000; }
.udf-leader-3, .udf-leader-4 { border-bottom: 1px solid #000; }
.udf-leader-5 { border-bottom: 3px double #000; }
.udf-img { vertical-align: bottom; max-width: 100%; object-fit: contain; }
.udf-tablewrap { }
.udf-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.udf-td { vertical-align: top; padding: 0 2pt; }
.udf-td-nested { padding: 0; }
.udf-border > tbody > tr > .udf-td, .udf-border > tr > .udf-td { border: 0.75pt solid #000; }
.udf-td-nested > .udf-tablewrap > .udf-table > tbody > tr > .udf-td { border-top: 0; border-bottom: 0; }
.udf-sidenote {
  position: absolute; left: 10pt; bottom: 20pt; transform-origin: left bottom; transform: rotate(-90deg) translateY(100%);
  font: 6.5pt Arial, sans-serif; color: #777; white-space: nowrap;
}
.img-page { display: flex; align-items: center; justify-content: center; }
.img-page img, .img-page canvas { max-width: 100%; max-height: 100%; display: block; }
.img-page .loading { color: #aaa; font-size: 12px; }
.page-err { padding: 30px; color: var(--accent); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1e20; --panel: #26282b; --line: #3a3d42; --text: #e7e7e5; --muted: #9a9ea5;
    --viewer: #151618; --sel: #2d3440; --accent-soft: #3a2221; color-scheme: dark;
  }
  :root:not([data-theme="light"]) .btn, :root:not([data-theme="light"]) .seg button { background: #2f3236; }
  :root:not([data-theme="light"]) .btn:hover { background: #383b40; }
  :root:not([data-theme="light"]) .seg button.on { background: #e7e7e5; color: #111; }
  :root:not([data-theme="light"]) .files li:hover { background: #2d2f33; }
  :root:not([data-theme="light"]) .files .tag { background: #3a3d42; color: #ccc; }
  :root:not([data-theme="light"]) .info .note { background: #3b3320; color: #e8d59a; }
  :root:not([data-theme="light"]) .welcome .drop { background: rgba(0,0,0,.2); color: #aaa; border-color: #555; }
  :root:not([data-theme="light"]) .doc-sep { background: rgba(0,0,0,.5); color: #ddd; }
}

/* ── yazdırma: yalnızca sayfalar, her biri bir kâğıt ── */
@page { size: A4; margin: 0; }
@page landscape { size: A4 landscape; margin: 0; }
@media print {
  body { display: block; overflow: visible; background: #fff; height: auto; }
  .toolbar, .sidebar, .status, .welcome, .doc-sep, .drop-overlay { display: none !important; }
  .main, .viewer { display: block; overflow: visible; background: #fff; }
  .pages { padding: 0; gap: 0; display: block; zoom: 1 !important; transform: none !important; }
  .udf-page, .img-page { box-shadow: none; margin: 0; break-after: page; page-break-after: always; }
  .udf-page:last-child, .img-page:last-child { break-after: auto; page-break-after: auto; }
  .landscape { page: landscape; }
}
.udf-webid {
  margin-top: 3pt; padding-top: 2pt; border-top: 0.75pt solid #000;
  font: 6.5pt "Times New Roman", Times, serif; color: #000; white-space: nowrap; overflow: hidden;
}
.udf-webid b { font: 600 9pt Arial, sans-serif; letter-spacing: .3pt; }

/* ── marka ve Hakkında penceresi ── */
.brand-sub { font-weight: 400; color: var(--muted); }
.welcome .disclaimer { margin-top: 14px; font-size: 11.5px; color: var(--muted); }
.logo.big { font-size: 15px; padding: 8px 9px; border-radius: 8px; }
.about {
  width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 60px); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px 22px; background: var(--panel); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.about::backdrop { background: rgba(0,0,0,.35); }
.about-head { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.about h2 { margin: 0; font-size: 17px; }
.about h3 { font-size: 13px; margin: 16px 0 4px; }
.about .muted { color: var(--muted); font-size: 12px; margin: 0; }
.about .warn { background: #fff7df; color: #4d3c00; border-radius: 8px; padding: 10px 14px; font-size: 12.5px; }
.about .warn ul { margin: 6px 0 0; padding-left: 18px; }
.about .warn li { margin: 3px 0; }
.about .lic { width: 100%; height: 190px; border: 1px solid var(--line); border-radius: 8px; margin-top: 6px; background: #fff; }
.about-foot { display: flex; justify-content: flex-end; margin-top: 14px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .about .warn { background: #3b3320; color: #eadbb0; }
  :root:not([data-theme="light"]) .about .lic { background: #26282b; }
}
@media print { .about { display: none !important; } }
.files input.rename {
  width: 100%; font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--accent); border-radius: 4px; padding: 1px 4px; outline: none;
}
.side-tools { display: flex; align-items: center; gap: 8px; }
#sortSel {
  font: inherit; font-size: 12px; font-weight: 400; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 5px; padding: 2px 4px; max-width: 120px;
}

/* ───────────── telefon / tablet ───────────── */
.tb-more, .zoom-row { display: contents; }
.mobile-label { display: none; }
.mobile-only { display: none !important; }
.touch-only { display: none !important; }
html:not(.app-shell) .welcome .hint2 { display: none !important; }
.drawer-backdrop { display: none; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

/* dokunmatik ekran: üzerine gelme yok → düğmeler hep görünür, dokunma alanları büyük */
@media (hover: none) {
  .touch-only { display: revert !important; }
  .empty-hint small.touch-only { display: block !important; }
  .desktop-only { display: none !important; }
  .welcome .touch-only.big, .welcome .hint2 { display: block; }
  .welcome .hint2 { margin-top: 10px; font-size: 13px; }
  .files .acts { opacity: 1; }
  .files .acts button { padding: 6px 7px; font-size: 15px; }
  .files li { padding: 9px 6px; }
  .files input[type=checkbox] { width: 18px; height: 18px; }
  .btn { padding: 7px 12px; }
  .btn.icon { width: 36px; padding: 7px 0; }
  #sortSel { font-size: 13px; padding: 4px; }
}

/* dar ekran (telefon): liste soldan açılan çekmece, işlemler ⋯ menüsünde */
@media (max-width: 760px) {
  .mobile-only { display: inline-flex !important; align-items: center; gap: 4px; }
  .grow.mobile-only { display: block !important; flex: 1; }
  .toolbar { flex-wrap: nowrap; gap: 6px; padding: 6px 8px; position: relative; z-index: 30; }
  .brand, .toolbar > .sep { display: none; }
  .seg button { padding: 7px 11px; font-size: 13px; white-space: nowrap; }
  .lbl-long { display: none; }
  #openLabel { padding: 7px 10px; }
  #docsCount:empty { display: none; }
  #docsCount { background: var(--accent); color: #fff; border-radius: 9px; font-size: 11px; padding: 0 6px; line-height: 17px; }

  /* ⋯ menüsü */
  .tb-more { display: none; }
  .toolbar.more-open .tb-more {
    display: flex; flex-direction: column; align-items: stretch; gap: 6px;
    position: absolute; right: 8px; top: calc(100% + 4px); width: 230px; padding: 10px;
    background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  }
  .toolbar.more-open .tb-more .sep, .toolbar.more-open .tb-more .grow { display: none; }
  .toolbar.more-open .tb-more .btn { width: 100%; text-align: left; padding: 9px 12px; }
  .toolbar.more-open .tb-more .zoom-row { display: flex; gap: 6px; align-items: center; }
  .toolbar.more-open .tb-more .zoom-row .btn { width: auto; flex: none; text-align: center; }
  .toolbar.more-open .tb-more .zoom-row #zoomFit { flex: 1; }
  .toolbar.more-open .tb-more #aboutBtn { width: 100%; }
  .toolbar.more-open .mobile-label { display: inline; }

  /* belge listesi: çekmece */
  .sidebar {
    position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: min(88vw, 360px);
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: 0 0 40px rgba(0,0,0,.3);
  }
  body.drawer-open .sidebar { transform: none; }
  body.drawer-open .drawer-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.35); }
  .info { max-height: 38%; }

  .pages { padding: 12px 0 30px; gap: 12px; }
  .welcome .drop { padding: 26px 20px; margin: 0 16px; }
  .status { font-size: 11px; padding: 4px 10px; }
  #statusMsg { text-align: right; }
}

/* baskıda çentik/durum çubuğu boşluğu (safe-area) uygulanmaz; yoksa her sayfa aşağı kayıp kâğıttan taşar */
@media print {
  /* iPhone'da baskı dar ekran düzeninde yapılır: telefon stillerinin eklediği boşluklar sayfaları
     kâğıttan taşırıp araya boş sayfa sokmasın diye baskı ölçüleri burada kesinleştirilir */
  body { padding: 0 !important; }
  .pages { padding: 0 !important; gap: 0 !important; display: block !important; }
  .udf-page, .img-page { margin: 0 !important; box-shadow: none !important; }
  /* iOS baskı motoru, kâğıdı tam dolduran öğeden sonra gelen "sonra sayfa sonu" kuralına fazladan boş
     sayfa ekliyor: iPhone/iPad'de sayfa sonu her sayfanın ÖNÜNE konur ve sayfa A4'ten biraz kısa tutulur */
  html.native-ios .udf-page, html.native-ios .img-page {
    break-after: auto !important; page-break-after: auto !important;
    break-before: page !important; page-break-before: always !important;
    height: 838pt !important; overflow: hidden !important;
  }
  html.native-ios .udf-page.landscape, html.native-ios .img-page.landscape { height: 592pt !important; }
  html.native-ios .pages > .udf-page:first-child, html.native-ios .pages > .img-page:first-child,
  html.native-ios .pages > .doc-sep:first-child + .udf-page, html.native-ios .pages > .doc-sep:first-child + .img-page {
    break-before: auto !important; page-break-before: auto !important;
  }
}

.site-link { color: inherit; text-decoration: none; }
.site-link:hover { color: var(--accent); text-decoration: underline; }
/* Android: tarayıcının kendi yakınlaştırması yerine uygulamanınki (iki parmak) */
html.touch-pinch .viewer { touch-action: pan-x pan-y; }
