/* ============================================================
   Alat PDF
   ============================================================ */

.pdf-body { overflow: hidden; }

.pdf-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: calc(100vh - 58px);
}

/* ------------------------------------------------------------ sidebar */

.pdf-side {
  background: #f7f9fc;
  border-right: 1px solid var(--line);
  padding: 14px 10px 32px;
  overflow-y: auto;
}

.side-group {
  margin: 16px 8px 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #93a0b2;
}

.side-group:first-child { margin-top: 0; }

.side-link {
  display: block;
  padding: 8px 10px;
  margin-bottom: 2px;
  border-radius: 7px;
  color: #3a4658;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.side-link:hover { background: #e9eef6; }

.side-link.active {
  background: var(--accent);
  color: #fff;
}

/* ------------------------------------------------------------ main */

.pdf-main {
  overflow-y: auto;
  padding: 22px 26px 60px;
}

.tool {
  max-width: 880px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 24px 26px;
}

.tool h1 {
  margin: 0 0 6px;
  font-size: 19px;
  letter-spacing: -.2px;
  color: var(--accent);
}

.tool-desc {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ------------------------------------------------------------ drop */

.drop {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 18px;
  border: 1.5px dashed #c4cede;
  border-radius: 10px;
  background: #fbfcfe;
  color: var(--muted);
  font-size: 13px;
  transition: border-color .15s ease, background .15s ease;
}

.drop.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop strong { color: var(--ink); font-size: 13.5px; }

/* ------------------------------------------------------------ buttons in light area */

.pdf-main .btn {
  border-color: var(--line);
  background: #fff;
  color: var(--accent);
}

.pdf-main .btn:hover { background: #f2f6fb; }

.pdf-main .btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.pdf-main .btn.primary:hover { filter: brightness(1.08); }

.pdf-main .btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  filter: none;
}

.pdf-main .btn.ghost-dark {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

/* ------------------------------------------------------------ rows & lists */

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.filelist {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.filelist li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12.5px;
}

.filelist .fname {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.filelist .fsize { color: var(--muted); font-size: 11.5px; }

.filelist .fbtns { display: flex; gap: 4px; }

.fileinfo {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.fileinfo b { color: var(--ink); }

/* ------------------------------------------------------------ options */

.options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
  margin-top: 16px;
}

.options .field.wide { grid-column: 1 / -1; }
.options .check { grid-column: 1 / -1; margin: 0; }

#splitRangeField { grid-column: 1 / -1; }

select,
input[type="number"],
input[type="password"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfe;
  color: var(--ink);
  font: 400 13.5px "Segoe UI", Arial, sans-serif;
}

select:focus,
input[type="number"]:focus,
input[type="password"]:focus,
input[type="color"]:focus,
input[type="range"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type="color"] {
  width: 100%;
  height: 38px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfe;
  cursor: pointer;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  margin-top: 6px;
}

/* ------------------------------------------------------------ warning */

.warning {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff8e6;
  border: 1px solid #f2dfae;
  color: #7a5a10;
  font-size: 12.5px;
  line-height: 1.5;
}

/* ------------------------------------------------------------ result */

.result { margin-top: 16px; }

.result .card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 14px;
  margin-top: 10px;
  border: 1px solid #cfe6d9;
  background: #f2fbf6;
  border-radius: 9px;
  font-size: 13px;
}

.result .card.err {
  border-color: #f0cdcb;
  background: #fdf3f2;
  color: var(--err);
}

.result .card .info { flex: 1; min-width: 180px; }
.result .card .info b { display: block; margin-bottom: 2px; }
.result .card .info span { color: var(--muted); font-size: 12px; }

.result .card a.btn { text-decoration: none; }

/* ------------------------------------------------------------ thumbs */

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.thumb {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f7f9fc;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.thumb.deleted { opacity: .35; }

.thumb canvas {
  width: 100%;
  height: auto;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}

.thumb .tnum {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}

.thumb .tbtns {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.thumb .tbtns button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 5px;
  padding: 3px 6px;
  font-size: 11px;
  cursor: pointer;
  color: var(--accent);
  line-height: 1.2;
}

.thumb .tbtns button:hover { background: var(--accent-soft); }
.thumb .tbtns button.del { color: var(--err); }

/* ------------------------------------------------------------ signature */

.sign-wrap {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfcfe;
}

.sign-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .8px;
}

#signPad {
  display: block;
  width: 100%;
  max-width: 600px;
  height: auto;
  aspect-ratio: 3 / 1;
  border: 1px dashed #b9c5d6;
  border-radius: 7px;
  background: #fff;
  touch-action: none;
  cursor: crosshair;
}

/* ------------------------------------------------------------ progress */

.progress { margin-top: 16px; }

.progress-bar {
  height: 8px;
  border-radius: 99px;
  background: #e4eaf2;
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .2s ease;
}

/* ------------------------------------------------------------ diff */

.diff-legend {
  display: flex;
  gap: 8px;
  margin: 16px 0 8px;
}

.badge {
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
}

.badge.del { background: #fdeceb; color: var(--err); }
.badge.add { background: #e6f6ee; color: var(--ok); }
.badge.same { background: #edf1f6; color: var(--muted); }

.diff {
  max-height: 60vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  font: 12.5px/1.55 Consolas, "Courier New", monospace;
  background: #fbfcfe;
}

.diff div {
  padding: 3px 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

.diff .d-add { background: #e9f8f0; color: #10603c; }
.diff .d-del { background: #fdeeed; color: #8f1b22; }
.diff .d-same { color: #586274; }

/* ------------------------------------------------------------ toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 9px;
  background: #1c2330;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  z-index: 50;
  max-width: 90vw;
}

.toast.err { background: var(--err); }
.toast.ok { background: var(--ok); }

/* ------------------------------------------------------------ responsive */

@media (max-width: 820px) {
  .pdf-body { overflow: auto; }

  .pdf-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .pdf-side {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px;
  }

  .side-group { display: none; }

  .side-link {
    margin: 0;
    white-space: nowrap;
    background: #fff;
    border: 1px solid var(--line);
  }

  .pdf-main { padding: 16px 12px 48px; }

  .tool { padding: 16px 14px 20px; }

  .options { grid-template-columns: 1fr; }

  .topbar { height: auto; min-height: 58px; flex-wrap: wrap; padding: 8px 12px; }
  .topbar-left { flex-wrap: wrap; gap: 8px; }
  .nav { flex-wrap: wrap; }
}
