/* ==============================================================
   PDF文字変換 — スタイルシート
   ダークモードベース / グラスモーフィズム / モダンUI
   ============================================================== */

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

:root {
  /* カラーパレット */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-card-hover: rgba(24, 34, 56, 0.8);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-active: rgba(99, 146, 255, 0.4);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent: #6392ff;
  --accent-hover: #7ba3ff;
  --accent-glow: rgba(99, 146, 255, 0.15);
  --accent-gradient: linear-gradient(135deg, #6392ff 0%, #a855f7 100%);

  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.1);
  --error: #f87171;
  --error-bg: rgba(248, 113, 113, 0.1);
  --warning: #fbbf24;

  /* タイポグラフィ */
  --font-base: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* スペーシング */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* シャドウ */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 30px var(--accent-glow);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-base);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* 背景グラデーション */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(99, 146, 255, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(168, 85, 247, 0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* --- ヘッダー --- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-glass);
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 28px;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.logo h1 {
  font-size: 1.25rem;
  font-weight: 600;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}

.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
}

.status-dot.disconnected {
  background: var(--error);
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.5);
}

/* --- メイン --- */
.main {
  flex: 1;
  position: relative;
  z-index: 1;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* --- カード共通 --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 28px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-md);
  transition: border-color 0.3s, box-shadow 0.3s;
}

.card:hover {
  border-color: var(--border-active);
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.section-icon {
  font-size: 1.2rem;
}

/* --- ドラッグ＆ドロップ --- */
.dropzone {
  border: 2px dashed var(--border-glass);
  border-radius: var(--radius-md);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--bg-glass);
}

.dropzone:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-glow);
  box-shadow: var(--shadow-glow);
  transform: scale(1.01);
}

.dropzone-icon {
  color: var(--text-muted);
  margin-bottom: 16px;
  transition: color 0.3s;
}

.dropzone:hover .dropzone-icon,
.dropzone.dragover .dropzone-icon {
  color: var(--accent);
}

.dropzone-text {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.dropzone-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.dropzone-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 16px;
}

/* --- オプション行 --- */
.options-row {
  display: flex;
  gap: 16px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.option-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.select {
  padding: 10px 16px;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-base);
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.3s;
  min-width: 180px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.select:focus {
  border-color: var(--accent);
}

/* --- OCRエンジン情報 --- */
.ocr-options {
  padding: 16px 0;
  border-top: 1px solid var(--border-glass);
}

.engine-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.engine-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--accent-glow);
  border: 1px solid rgba(99, 146, 255, 0.3);
  border-radius: 20px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
}

.engine-features {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.checkbox-label:hover {
  background: var(--bg-glass);
}

.checkbox-label input[type="checkbox"] {
  display: none;
}

.checkbox-custom {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-glass);
  border-radius: 4px;
  background: var(--bg-secondary);
  position: relative;
  transition: all 0.2s;
  flex-shrink: 0;
}

.checkbox-label input:checked + .checkbox-custom {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox-label input:checked + .checkbox-custom::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 6px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.checkbox-label input:checked ~ .checkbox-text {
  color: var(--text-primary);
}

/* --- 選択ファイル表示 --- */
.selected-file {
  margin-top: 20px;
  padding: 14px 18px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  animation: fadeSlideIn 0.3s ease;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-icon {
  font-size: 1.5rem;
}

.file-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.file-name {
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}

.file-size {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.btn-icon:hover {
  color: var(--error);
  background: var(--error-bg);
}

/* --- ボタン --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-base);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 20px rgba(99, 146, 255, 0.3);
  transform: translateY(-1px);
}

.btn-convert {
  width: 100%;
  margin-top: 20px;
  padding: 16px;
  font-size: 1rem;
  font-weight: 600;
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-convert:hover:not(:disabled) {
  box-shadow: 0 6px 24px rgba(99, 146, 255, 0.35);
  transform: translateY(-2px);
}

.btn-convert:active:not(:disabled) {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  padding: 10px 18px;
  font-size: 0.85rem;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-active);
}

/* --- プログレス --- */
.progress-section {
  animation: fadeSlideIn 0.4s ease;
}

.progress-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  font-weight: 500;
}

.progress-icon {
  font-size: 1.3rem;
  animation: pulse 1.5s ease-in-out infinite;
}

.progress-bar-container {
  height: 6px;
  background: var(--bg-glass);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent-gradient);
  border-radius: 3px;
  transition: width 0.5s ease;
  animation: progressIndeterminate 2s ease-in-out infinite;
}

.progress-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 12px;
}

/* --- 結果 --- */
.result-section {
  animation: fadeSlideIn 0.4s ease;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}

.result-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  gap: 16px;
}

.action-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.result-text-container {
  position: relative;
}

.result-text {
  width: 100%;
  min-height: 300px;
  max-height: 600px;
  padding: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-base);
  font-size: 0.95rem;
  line-height: 1.8;
  resize: vertical;
  outline: none;
  transition: border-color 0.3s;
}

.result-text:focus {
  border-color: var(--accent);
}

/* --- エラー --- */
.error-section {
  border-color: rgba(248, 113, 113, 0.2);
  animation: fadeSlideIn 0.4s ease;
}

.error-content {
  text-align: center;
  padding: 16px 0;
}

.error-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 12px;
}

.error-message {
  font-size: 1rem;
  font-weight: 500;
  color: var(--error);
  margin-bottom: 8px;
}

.error-detail {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  word-break: break-all;
}

/* --- フッター --- */
.footer {
  text-align: center;
  padding: 24px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-glass);
  position: relative;
  z-index: 1;
}

/* --- トースト通知 --- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  animation: toastSlideIn 0.3s ease, toastFadeOut 0.3s ease 2.7s forwards;
  max-width: 360px;
}

.toast.success {
  background: var(--success-bg);
  border: 1px solid rgba(52, 211, 153, 0.3);
  color: var(--success);
}

.toast.error {
  background: var(--error-bg);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--error);
}

.toast.info {
  background: var(--accent-glow);
  border: 1px solid rgba(99, 146, 255, 0.3);
  color: var(--accent);
}

/* --- スピナー --- */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* --- アニメーション --- */
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes progressIndeterminate {
  0% { width: 5%; margin-left: 0; }
  50% { width: 40%; margin-left: 30%; }
  100% { width: 5%; margin-left: 95%; }
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastFadeOut {
  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

/* --- レスポンシブ --- */
@media (max-width: 640px) {
  .header-inner {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }

  .container {
    padding: 16px;
  }

  .card {
    padding: 20px;
  }

  .dropzone {
    padding: 32px 16px;
  }

  .action-bar {
    flex-direction: column;
  }

  .btn-secondary {
    width: 100%;
  }

  .result-header {
    flex-direction: column;
  }

  .result-meta {
    flex-direction: column;
    gap: 4px;
  }
}
