/*
 * style.css — YouTube Transcriber
 * デザイントークンは design/Warm-Friendly.html から流用（D-005）
 */

/* ── CSS 変数（デザイントークン）─────────────────────────────────────────────── */
:root {
  --bg: #faf5ec;
  --bg-2: #f5ecdc;
  --surface: #fffaf0;
  --surface-2: #fbf3e2;
  --border: #ead9b8;
  --border-strong: #d6bf91;
  --text: #3d2e1f;
  --text-muted: #836b51;
  --text-faint: #a89578;
  --accent: #e07a5f;
  --accent-hover: #c95f44;
  --accent-soft: #fbe5dc;
  --accent-2: #d4a373;
  --processing: #5a8cc6;
  --processing-soft: #dceaf6;
  --waiting: #a89578;
  --waiting-soft: #efe6d2;
  --done: #6a9b6e;
  --done-soft: #dcecdc;
  --danger: #c0392b;
  --danger-soft: #f8e0db;
  --interrupted: #c07a2b;
  --interrupted-soft: #fdf0dc;
  --cancelled: #8b7a6e;
  --cancelled-soft: #ede6e0;
  --radius: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(124, 90, 52, 0.06);
  --shadow: 0 2px 8px rgba(124, 90, 52, 0.08), 0 1px 2px rgba(124, 90, 52, 0.06);
  --shadow-lg: 0 12px 32px rgba(124, 90, 52, 0.12), 0 4px 8px rgba(124, 90, 52, 0.06);
}

/* ── リセット ────────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Nunito", "Zen Maru Gothic", -apple-system, "Hiragino Maru Gothic ProN",
    "Hiragino Kaku Gothic ProN", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input {
  font-family: inherit;
}

/* ── ログイン画面 ──────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(224, 122, 95, 0.08), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(212, 163, 115, 0.12), transparent 45%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 36px 36px;
  box-shadow: var(--shadow-lg);
  position: relative;
}

/* カード上部のアクセントライン */
.login-card::after {
  content: "";
  position: absolute;
  top: -8px;
  left: 24px;
  right: 24px;
  height: 8px;
  background: var(--accent);
  border-radius: 8px 8px 0 0;
  opacity: 0.85;
}

.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: white;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(224, 122, 95, 0.35);
  flex-shrink: 0;
}

.login-card .sub {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-bottom: 28px;
}

.login-card label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 7px;
}

/* ── 共通入力フィールド ────────────────────────────────────────────────────────── */
.input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

/* ── ボタン: プライマリ ────────────────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  height: 44px;
  margin-top: 18px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-weight: 700;
  transition: background 0.2s, transform 0.08s, box-shadow 0.2s;
  box-shadow: 0 2px 6px rgba(224, 122, 95, 0.3);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(224, 122, 95, 0.4);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* URL バー内で使う横並びバリエーション */
.btn-primary.inline {
  width: auto;
  margin: 0;
  height: 48px;
  padding: 0 24px;
  white-space: nowrap;
}

/* ── エラー・インフォメッセージ ──────────────────────────────────────────────── */
.error-msg {
  margin-top: 16px;
  padding: 11px 14px;
  background: var(--danger-soft);
  border: 1px solid rgba(192, 57, 43, 0.2);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

/* URL バー直下のバリデーションメッセージ */
.url-message {
  margin-top: 8px;
  margin-bottom: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}

.url-message.error {
  background: var(--danger-soft);
  border: 1px solid rgba(192, 57, 43, 0.2);
  color: var(--danger);
}

.url-message.info {
  background: var(--done-soft);
  border: 1px solid rgba(106, 155, 110, 0.25);
  color: var(--done);
}

/* キューアイテム内のエラーインライン表示 */
.error-inline {
  color: var(--danger) !important;
  font-size: 12px;
}

/* ── アプリ全体レイアウト ──────────────────────────────────────────────────────── */

/* スティッキーヘッダー */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(250, 245, 236, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 8px;
}

.brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-spacer {
  flex: 1;
}

/* ゴーストボタン（ログアウト等） */
.btn-ghost {
  height: 44px;
  min-width: 44px;
  padding: 0 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.2s, border-color 0.2s;
}

.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

/* モバイル用ハンバーガーボタン */
.menu-btn {
  display: none;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  color: var(--text);
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
}

/* モバイルドロワーメニュー */
.menu-drawer {
  display: none;
  position: absolute;
  top: 64px;
  right: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  z-index: 20;
  min-width: 160px;
}

.menu-drawer.open {
  display: block;
}

.menu-drawer button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  min-height: 44px;
}

.menu-drawer button:hover {
  background: var(--surface-2);
}

/* メインコンテンツ */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 28px 48px;
}

/* URL 入力バー */
.urlbar {
  display: flex;
  gap: 10px;
  margin-bottom: 4px;
}

.urlbar .input {
  flex: 1;
  height: 48px;
  font-size: 15px;
}

/* 2カラムグリッド（キュー + プレビュー）*/
.grid-2col {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 22px;
  margin-top: 16px;
}

/* パネル共通 */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
}

.panel-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
}

.panel-body {
  padding: 16px;
}

/* ── キューパネル ──────────────────────────────────────────────────────────────── */
.queue-group {
  margin-bottom: 20px;
}

.queue-group:last-of-type {
  margin-bottom: 0;
}

.group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 4px 12px;
}

/* ステータスバッジ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 700;
}

.badge.processing {
  background: var(--processing-soft);
  color: var(--processing);
}

.badge.waiting {
  background: var(--waiting-soft);
  color: var(--waiting);
}

.badge.done {
  background: var(--done-soft);
  color: var(--done);
}

.badge.interrupted {
  background: var(--interrupted-soft);
  color: var(--interrupted);
}

.badge.cancelled-badge {
  background: var(--cancelled-soft);
  color: var(--cancelled);
}

.badge.error-badge {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ステータスドット */
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* 処理中ドットのパルスアニメーション */
.badge.processing .dot {
  animation: pulse 1.4s ease-in-out infinite;
}

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

/* キューアイテム */
.qitem {
  padding: 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  background: var(--surface);
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.qitem:last-child {
  margin-bottom: 0;
}

.qitem:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* 処理中アイテム（アクティブ状態） */
.qitem.active {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--surface) 60%);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.qitem-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.qitem-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qitem-meta {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 3px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* キューが空の状態 */
.queue-empty {
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  padding: 20px 16px;
}

/* ── 進捗バー ────────────────────────────────────────────────────────────────── */
.progress-block {
  margin-top: 12px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  background-image: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 50%, var(--accent) 100%);
  background-size: 200% 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
  animation: shimmer 2.4s linear infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

/* 進捗ステップ（展開時） */
.progress-steps {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.step {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 0;
  color: var(--text-muted);
}

.step.done {
  color: var(--text);
}

.step.active {
  color: var(--accent);
  font-weight: 700;
}

.step.pending {
  color: var(--text-faint);
}

.step-icon {
  width: 16px;
  text-align: center;
  font-size: 12px;
  flex-shrink: 0;
}

.step.done .step-icon {
  color: var(--done);
}

/* ── プレビューパネル ────────────────────────────────────────────────────────── */
.preview-body {
  padding: 22px 24px;
  min-height: 380px;
  font-size: 14px;
  line-height: 1.75;
}

.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  color: var(--text-faint);
  font-size: 13.5px;
  gap: 12px;
}

.preview-placeholder svg {
  opacity: 0.35;
}

.preview-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
  color: var(--text);
}

.preview-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 20px;
  font-weight: 500;
}

/* frontmatter 表示 */
.frontmatter {
  font-family: "SF Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  background: var(--bg);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
  color: var(--text);
  white-space: pre-wrap;
  margin-bottom: 20px;
  line-height: 1.65;
  overflow-x: auto;
}

/* 本文テキスト */
.transcript p {
  margin: 0 0 14px;
  color: var(--text);
}

/* ── SSE 進捗表示エリア ──────────────────────────────────────────────────────── */
.sse-status {
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-faint);
  font-family: "SF Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ── 履歴セクション ────────────────────────────────────────────────────────────── */
.history {
  margin-top: 22px;
}

.hist-placeholder {
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  padding: 32px 16px;
}

.hist-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  transition: background 0.2s;
}

.hist-row:first-of-type {
  border-top: none;
}

.hist-row:hover {
  background: var(--surface-2);
}

.hist-date {
  font-family: "SF Mono", ui-monospace, monospace;
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.hist-title {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── ミニボタン ──────────────────────────────────────────────────────────────── */
.btn-mini {
  padding: 5px 12px;
  height: 44px;
  min-width: 44px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-mini:hover {
  background: var(--bg-2);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-mini.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
}

.btn-mini.primary {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
}

.btn-mini.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 2px 6px rgba(224, 122, 95, 0.3);
}

/* ── レスポンシブ（900px 以下）─────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .header {
    padding: 0 18px;
  }

  .container {
    padding: 18px;
  }

  /* 1カラムに変更 */
  .grid-2col {
    grid-template-columns: 1fr;
  }

  /* ハンバーガーメニューを表示し、ログアウトボタンを非表示 */
  .menu-btn {
    display: flex;
  }

  .header .btn-ghost {
    display: none;
  }

  /* URL バーを縦並びに */
  .urlbar {
    flex-direction: column;
  }

  .btn-primary.inline {
    width: 100%;
  }

  /* 履歴テーブルを調整 */
  .hist-row {
    grid-template-columns: 100px 1fr auto;
    gap: 12px;
    padding: 12px;
  }
}
