/* ============================================================
   image-tools.css — 画像ツール用コンポーネント（tiptiphives デザイン）
   style.css → brand.css の後に読み込む（:root 変数を利用）。
   フラット・影なし（box-shadow は brand.css で全廃）。
   ============================================================ */

/* ツールページのリード文（pdf-tools.css と共通の見た目） */
.tool-lead { color: var(--muted); margin: 0 0 18px; }

/* ---------- ドロップゾーン ---------- */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 36px 20px; text-align: center; color: var(--muted);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone__icon { font-size: 2rem; color: var(--primary); line-height: 1; margin-bottom: 6px; }
.dropzone__or { color: var(--muted); font-size: .82rem; margin: 8px 0; }
.dropzone__hint { color: var(--muted); font-size: .78rem; margin: 10px 0 0; }

/* ---------- ツールバー（設定行） ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
  margin: 18px 0 6px;
}
.toolbar__group { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.toolbar__label { font-weight: 700; font-size: .9rem; color: var(--text); }
.toolbar__hint { color: var(--muted); font-size: .78rem; }

.sel-input, .num-input {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 9px 12px; font-size: .95rem; background: #fff; color: var(--text); font-family: inherit;
}
.num-input { width: 92px; }
.sel-input:focus, .num-input:focus { outline: none; border-color: var(--primary); }
.toolbar label { font-size: .9rem; color: var(--text); display: inline-flex; align-items: center; gap: 5px; }

/* ---------- セグメント（小/中/大・比率・媒体など） ---------- */
.seg { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.seg__btn {
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  padding: 9px 14px; border-radius: var(--radius); cursor: pointer;
  font-weight: 600; font-size: .9rem; line-height: 1.25; text-align: center; font-family: inherit;
}
.seg__btn small { display: block; font-weight: 400; font-size: .68rem; color: var(--muted); }
.seg__btn.is-active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); }
.seg__btn.is-active small { color: var(--primary-dark); }
.seg-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-width: 280px; }

/* ---------- 注記 ---------- */
.list-hint { color: var(--muted); font-size: .82rem; margin: 12px 0 0; line-height: 1.6; }
.list-hint b { color: var(--text); }

/* ---------- キュー（読み込んだ画像） / 結果グリッド ---------- */
.queue-wrap { margin-top: 20px; }
.result-wrap { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.list-head, .result-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 12px;
}
.list-head__count { font-size: .9rem; color: var(--muted); }
.list-head__count b { color: var(--text); font-size: 1.05rem; }
.result-head__title { margin: 0; font-size: 1.05rem; }

.img-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px;
}
.img-card {
  position: relative; border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; overflow: hidden; display: flex; flex-direction: column; user-select: none;
}
.img-card.is-clickable { cursor: pointer; }
.img-card.is-selected { outline: 2px solid var(--primary); outline-offset: -2px; }
.img-card.is-done { opacity: .55; }

.img-card__thumb {
  position: relative; background: #f1f5f9; aspect-ratio: 4 / 3;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.img-card__thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.img-card__badge {
  position: absolute; top: 5px; left: 5px;
  font-family: 'Outfit', sans-serif; font-size: 9px; font-weight: 700; letter-spacing: .5px;
  color: #fff; background: var(--primary); padding: 2px 6px; border-radius: var(--radius);
}
.img-card__del {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  cursor: pointer; font-size: .9rem; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.img-card__del:hover { background: #fde8e8; color: var(--danger); border-color: var(--danger); }
.img-card__doneov {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(36,96,167,.10); color: var(--primary-dark); font-weight: 700; font-size: .9rem;
}

.img-card__body { padding: 9px 10px; display: flex; flex-direction: column; gap: 6px; }
.img-card__name {
  font-size: .8rem; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.img-card__meta { font-size: .76rem; color: var(--muted); line-height: 1.5; }
.img-card__meta .arrow { color: var(--muted); }
.img-card__meta .down { color: #16a34a; font-weight: 700; }
.img-card__meta .up { color: var(--danger); font-weight: 700; }

.img-card__dl, .img-card__crop {
  margin-top: 2px; width: 100%; border: 1px solid var(--primary); background: var(--primary); color: #fff;
  border-radius: var(--radius); padding: 8px 10px; font-size: .82rem; font-weight: 700; cursor: pointer; font-family: inherit;
}
.img-card__dl:hover, .img-card__crop:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* ---------- 実行ボタン行 ---------- */
.actions { margin-top: 20px; }

/* ---------- ボタン補助（pdf-tools.css と同等の見た目） ---------- */
.btn-ghost {
  display: inline-block; background: #fff; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 18px;
  font-size: .92rem; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-ghost:hover { background: var(--primary-soft); }

/* ---------- トリミング／用途別 プレビュー ---------- */
.crop-preview { margin: 16px 0 4px; }
.crop-stage-wrap {
  display: flex; justify-content: center; background: #f1f5f9;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; overflow: auto;
}
.crop-stage { position: relative; line-height: 0; touch-action: none; }
.crop-stage canvas { display: block; max-width: 100%; }

.crop-frame {
  position: absolute; box-sizing: border-box; border: 2px solid var(--primary);
  background: rgba(36,96,167,.12); cursor: move; touch-action: none;
}
.crop-frame.is-locked { cursor: default; background: rgba(36,96,167,.08); border-style: dashed; }
.crop-handle {
  position: absolute; width: 14px; height: 14px; background: #fff;
  border: 2px solid var(--primary); border-radius: 2px;
}
.crop-handle.nw { top: -8px; left: -8px; cursor: nwse-resize; }
.crop-handle.ne { top: -8px; right: -8px; cursor: nesw-resize; }
.crop-handle.sw { bottom: -8px; left: -8px; cursor: nesw-resize; }
.crop-handle.se { bottom: -8px; right: -8px; cursor: nwse-resize; }

/* ---------- 用途別変換：用途リスト ---------- */
.uc-list { margin: 14px 0 8px; }
.uc-cat {
  font-size: .82rem; font-weight: 700; color: var(--primary-dark);
  margin: 14px 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--border);
}
.uc-cat:first-child { margin-top: 0; }
.uc-cat-items { display: flex; flex-wrap: wrap; gap: 8px; }
.uc-chip {
  border: 1px solid var(--border); background: #fff; border-radius: var(--radius);
  padding: 8px 12px; cursor: pointer; text-align: left; font-family: inherit; line-height: 1.3;
}
.uc-chip:hover { border-color: var(--primary); background: var(--primary-soft); }
.uc-chip.is-active { border-color: var(--primary); background: var(--primary-soft); }
.uc-chip__name { display: block; font-size: .86rem; font-weight: 700; color: var(--text); }
.uc-chip__meta { display: block; font-size: .72rem; color: var(--muted); margin-top: 2px; }
.uc-info {
  font-size: .82rem; color: var(--muted); background: var(--primary-soft);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin: 6px 0 0;
}

/* ---------- 処理中オーバーレイ ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 1000; background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center;
}
.overlay[hidden] { display: none; }
.overlay__box {
  background: #fff; border-radius: var(--radius); padding: 24px 30px; text-align: center; min-width: 200px;
}
.spinner {
  width: 34px; height: 34px; margin: 0 auto 12px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--primary); animation: ik-spin .8s linear infinite;
}
@keyframes ik-spin { to { transform: rotate(360deg); } }

/* ---------- トースト ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: #1f2933; color: #fff; padding: 12px 20px; border-radius: var(--radius);
  font-size: .9rem; opacity: 0; transition: opacity .2s, transform .2s; z-index: 1100;
  max-width: 90vw; text-align: center; white-space: pre-line;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--danger); }

/* ---------- モーダル（alert/confirm） ---------- */
.modal {
  border: none; border-radius: var(--radius); padding: 0; max-width: 420px; width: 90vw;
}
.modal::backdrop { background: rgba(15,23,42,.5); }
.modal__body { padding: 24px 24px 8px; white-space: pre-wrap; line-height: 1.7; }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px 20px; }
.btn-sm {
  display: inline-block; background: #fff; color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 9px 16px; font-size: .9rem; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-sm:hover { background: var(--primary-soft); }

/* ---------- レスポンシブ ---------- */
@media (max-width: 600px) {
  .img-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
  .toolbar { gap: 8px 12px; }
}
