/* ===================================================
   PDF to Image 変換ツール — スタイルシート
   文字コード: UTF-8
   =================================================== */

/* --- リセット & ベース -------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-secondary: #64748b;
  --color-secondary-hover: #475569;
  --color-bg: #f1f5f9;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-error-bg: #fef2f2;
  --color-error-border: #fca5a5;
  --color-error-text: #b91c1c;
  --color-success: #16a34a;
  --color-progress: #2563eb;
  --radius: 0.75rem;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
}

body {
  font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  padding: 2rem 1rem;
}

/* --- レイアウト --------------------------------------- */
.container {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* --- ヘッダー ---------------------------------------- */
header {
  text-align: center;
}

header h1 {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.01em;
}

.subtitle {
  margin-top: 0.5rem;
  color: var(--color-text-muted);
  font-size: 0.9375rem;
}

/* --- カード ------------------------------------------ */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.card h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--color-text);
}

/* --- ドロップゾーン ----------------------------------- */
#drop-zone {
  border: 2px dashed var(--color-border);
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}

#drop-zone.drag-over {
  border-color: var(--color-primary);
  background: #eff6ff;
}

.drop-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 1rem;
  text-align: center;
}

.drop-icon {
  width: 3rem;
  height: 3rem;
  fill: var(--color-primary);
  opacity: 0.7;
}


.drop-text {
  font-size: 1.0625rem;
  font-weight: 500;
}

.drop-sub {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* ファイル input は非表示にしてラベルで操作 */
#file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.file-name {
  font-size: 0.875rem;
  color: var(--color-success);
  font-weight: 500;
  min-height: 1.25rem;
}

/* --- エラーボックス ----------------------------------- */
.error-box {
  background: var(--color-error-bg);
  border: 1px solid var(--color-error-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  color: var(--color-error-text);
  font-size: 0.9375rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

/* hidden属性をdisplay:flexが上書きしないようにする */
.error-box[hidden] {
  display: none;
}

.error-box::before {
  content: '⚠';
  flex-shrink: 0;
  font-size: 1.1em;
}

/* --- 設定セクション ----------------------------------- */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setting-item label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.setting-item select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.9375rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1rem;
  padding-right: 2rem;
}

.setting-item select:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* 品質スライダー */
#quality-slider {
  width: 100%;
  accent-color: var(--color-primary);
  cursor: pointer;
}

#quality-slider:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* --- ボタン ------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.625rem 1.25rem;
  border-radius: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
  text-decoration: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-secondary {
  background: #f1f5f9;
  color: var(--color-secondary);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: #e2e8f0;
  color: var(--color-secondary-hover);
}

.btn-sm {
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
}

/* --- 進捗バー ---------------------------------------- */
#progress-section {
  text-align: center;
}

#progress-text {
  margin-bottom: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.progress-bar-wrap {
  background: var(--color-border);
  border-radius: 9999px;
  height: 0.625rem;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--color-progress);
  border-radius: 9999px;
  width: 0%;
  transition: width 0.2s ease;
}

/* --- プレビューセクション ----------------------------- */
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.preview-header h2 {
  margin-bottom: 0;
}

/* サムネイルグリッド */
.thumbnail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.thumbnail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  background: var(--color-bg);
  border-radius: 0.5rem;
  padding: 0.625rem;
  border: 1px solid var(--color-border);
}

.thumbnail-item img {
  width: 100%;
  height: auto;
  border-radius: 0.25rem;
  display: block;
  object-fit: contain;
  max-height: 180px;
}

.thumbnail-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-align: center;
  word-break: break-all;
}

/* --- ログセクション ----------------------------------- */
.log-card {
  background: #1e293b;
  color: #94a3b8;
}

.log-card h2 {
  color: #e2e8f0;
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.log-output {
  font-family: 'Consolas', 'Menlo', 'Monaco', monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
  max-height: 280px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: #94a3b8;
}

/* ログレベル色 */
.log-output .log-error { color: #f87171; }
.log-output .log-warn  { color: #fbbf24; }
.log-output .log-info  { color: #6ee7b7; }
.log-output .log-debug { color: #94a3b8; }

/* --- レスポンシブ ------------------------------------- */
@media (max-width: 500px) {
  body { padding: 1rem 0.5rem; }
  header h1 { font-size: 1.5rem; }
  .settings-grid { grid-template-columns: 1fr; }
  .thumbnail-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}
