/* シナリオ生成 - 5画面のスタイル定義
   既存のCSS変数（base.css）を100%流用
   命名規則: .sg-{component}-{modifier} */

/* ===== 共通 ===== */
.sg-container { max-width: 1200px; margin: 0 auto; padding: 24px; }
.sg-steps { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.sg-step-indicator {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-sub);
  transition: all .2s;
}
.sg-step-indicator.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.sg-step-indicator.done { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
[data-theme="dark"] .sg-step-indicator.done { background: #064e3b; color: #6ee7b7; border-color: #065f46; }
.sg-step-num { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; background: var(--border); color: var(--text-sub); }
.sg-step-indicator.active .sg-step-num { background: rgba(255,255,255,.3); color: #fff; }
.sg-step-indicator.done .sg-step-num { background: #065f46; color: #d1fae5; }
.sg-section-title { font-size: 20px; font-weight: 700; margin-bottom: 16px; color: var(--text); }
.sg-section-desc { font-size: 14px; color: var(--text-sub); margin-bottom: 24px; line-height: 1.6; }
.sg-hidden { display: none !important; }
.sg-btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 24px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; border: none; transition: all .15s; }
.sg-btn-primary { background: var(--accent); color: #fff; }
.sg-btn-primary:hover { opacity: .9; transform: translateY(-1px); }
.sg-btn-primary:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.sg-btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.sg-btn-secondary:hover { border-color: var(--accent); }
.sg-btn-danger { background: #ef4444; color: #fff; }
.sg-btn-sm { padding: 6px 14px; font-size: 12px; }
.sg-actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

/* ===== 画面1: 初期入力フォーム ===== */
.sg-form { max-width: 860px; }
.sg-field { margin-bottom: 20px; }
.sg-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.sg-label .sg-required { color: #ef4444; font-size: 12px; margin-left: 4px; }
.sg-label .sg-optional { color: var(--text-sub); font-size: 12px; margin-left: 4px; }
.sg-input, .sg-select, .sg-textarea {
  width: 100%; padding: 10px 14px; border-radius: 8px; font-size: 14px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  font-family: inherit; transition: border-color .15s;
}
.sg-input:focus, .sg-select:focus, .sg-textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217,119,6,.15); }
.sg-input.error, .sg-textarea.error { border-color: #ef4444; }
.sg-error-msg { font-size: 12px; color: #ef4444; margin-top: 4px; }
.sg-textarea { resize: vertical; min-height: 60px; }
.sg-hint { font-size: 12px; color: var(--text-sub); margin-top: 4px; }
.sg-scenario-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 8px; }
.sg-scenario-card {
  padding: 12px; border-radius: 8px; cursor: pointer; text-align: center;
  background: var(--surface); border: 2px solid var(--border); transition: all .15s;
}
.sg-scenario-card:hover { border-color: var(--accent); }
.sg-scenario-card.selected { border-color: var(--accent); background: rgba(217,119,6,.08); }
.sg-scenario-card-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.sg-scenario-card-type { font-size: 11px; color: var(--text-sub); }

/* ===== 画面2: ヒアリング対話 ===== */
.sg-hearing { display: grid; grid-template-columns: 1fr 320px; gap: 20px; height: calc(100vh - var(--header-h) - 140px); min-height: 500px; }
@media (max-width: 900px) { .sg-hearing { grid-template-columns: 1fr; height: auto; } }
.sg-chat-panel { display: flex; flex-direction: column; background: var(--surface); border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.sg-chat-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.sg-chat-timer { font-size: 13px; font-weight: 600; color: var(--text-sub); }
.sg-chat-timer.warn { color: #f59e0b; }
.sg-chat-timer.danger { color: #ef4444; }
.sg-chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.sg-msg { max-width: 90%; padding: 12px 16px; border-radius: 12px; font-size: 15px; line-height: 1.7; word-break: break-word; white-space: pre-wrap; }
.sg-msg-ai { align-self: flex-start; background: var(--bg); color: var(--text); border-bottom-left-radius: 4px; }
.sg-msg-user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.sg-msg-system { align-self: center; font-size: 12px; color: var(--text-sub); background: transparent; padding: 4px 12px; }
.sg-chat-input-area { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); align-items: flex-end; }
.sg-chat-input { flex: 1; padding: 10px 14px; border-radius: 20px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 14px; font-family: inherit; resize: none; max-height: 120px; min-height: 40px; }
.sg-chat-input:focus { outline: none; border-color: var(--accent); }
.sg-voice-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--surface); color: var(--text-sub); display: flex; align-items: center; justify-content: center;
  transition: all .15s; flex-shrink: 0;
}
.sg-voice-btn:hover { background: var(--accent); color: #fff; }
.sg-voice-btn.recording { background: #ef4444; color: #fff; animation: sg-pulse 1.5s infinite; }
@keyframes sg-pulse { 0%,100%{opacity:1} 50%{opacity:.6} }
.sg-send-btn { width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sg-send-btn:disabled { opacity: .4; cursor: not-allowed; }
.sg-typing { display: flex; gap: 4px; padding: 8px 12px; }
.sg-typing-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-sub); animation: sg-bounce .6s infinite alternate; }
.sg-typing-dot:nth-child(2) { animation-delay: .2s; }
.sg-typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes sg-bounce { to { transform: translateY(-6px); } }

/* プログレスパネル */
.sg-progress-panel { background: var(--surface); border-radius: 12px; border: 1px solid var(--border); padding: 20px; overflow-y: auto; }
@media (max-width: 900px) { .sg-progress-panel { order: -1; } }
.sg-progress-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; }
.sg-progress-item { margin-bottom: 14px; }
.sg-progress-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.sg-progress-name { font-weight: 500; }
.sg-progress-pct { font-weight: 700; color: var(--accent); }
.sg-progress-bar { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.sg-progress-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .5s ease; }
.sg-progress-fill.high { background: #10b981; }
.sg-progress-overall { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.sg-progress-overall-text { font-size: 24px; font-weight: 700; text-align: center; color: var(--accent); }
.sg-progress-overall-label { font-size: 12px; text-align: center; color: var(--text-sub); margin-top: 4px; }
.sg-hearing-actions { display: flex; gap: 8px; margin-top: 16px; }

/* ===== 画面3: 完了確認 ===== */
.sg-complete { max-width: 1000px; }
.sg-complete-header { text-align: center; margin-bottom: 32px; }
.sg-complete-icon { font-size: 48px; margin-bottom: 12px; }
.sg-complete-scores { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.sg-score-card { padding: 14px; border-radius: 10px; background: var(--bg); text-align: center; }
.sg-score-card-label { font-size: 12px; color: var(--text-sub); margin-bottom: 4px; }
.sg-score-card-value { font-size: 22px; font-weight: 700; color: var(--accent); }
.sg-complete-summary { padding: 20px; border-radius: 10px; background: var(--bg); line-height: 1.8; font-size: 14px; margin-bottom: 24px; white-space: pre-wrap; }

/* ===== 画面4: マルチデバイスプレビュー ===== */
.sg-preview { height: calc(100vh - var(--header-h) - 140px); display: flex; flex-direction: column; }
.sg-preview-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.sg-device-select { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; }
.sg-preview-info { font-size: 12px; color: var(--text-sub); }
.sg-preview-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; flex: 1; overflow: hidden; }
@media (max-width: 768px) { .sg-preview-panels { grid-template-columns: 1fr; } }
.sg-preview-col { display: flex; flex-direction: column; overflow: hidden; }
.sg-preview-col-header { font-size: 14px; font-weight: 700; padding: 10px 0; display: flex; align-items: center; gap: 8px; }
.sg-preview-mail-list { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; flex-shrink: 0; }
.sg-preview-mail-tab {
  padding: 6px 12px; border-radius: 16px; font-size: 12px; font-weight: 500;
  white-space: nowrap; cursor: pointer; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-sub); transition: all .15s;
}
.sg-preview-mail-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.sg-device-frame {
  flex: 1; margin: 0 auto; border: 3px solid var(--border); border-radius: 24px;
  overflow: hidden; background: #fff; position: relative; transition: width .3s;
}
[data-theme="dark"] .sg-device-frame { background: #1a1a2e; }
.sg-device-notch { width: 120px; height: 24px; background: var(--border); border-radius: 0 0 12px 12px; margin: 0 auto; }
.sg-device-content { padding: 12px; overflow-y: auto; height: calc(100% - 24px); font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.sg-line-warn { background: rgba(239,68,68,.1); border-left: 3px solid #ef4444; padding: 2px 4px; }

/* ===== 画面5: コンテンツ編集＋音声修正 ===== */
.sg-editor { display: grid; grid-template-columns: 1fr 300px; gap: 20px; height: calc(100vh - var(--header-h) - 140px); }
@media (max-width: 900px) { .sg-editor { grid-template-columns: 1fr; height: auto; } }
.sg-editor-main { display: flex; flex-direction: column; overflow: hidden; }
.sg-editor-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; flex-shrink: 0; }
.sg-editor-tab { padding: 6px 14px; border-radius: 16px; font-size: 12px; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text-sub); white-space: nowrap; }
.sg-editor-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.sg-editor-textarea {
  flex: 1; width: 100%; padding: 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 14px; font-family: 'Noto Sans JP', sans-serif;
  line-height: 1.8; resize: none;
}
.sg-editor-textarea:focus { outline: none; border-color: var(--accent); }
.sg-editor-voice-area { display: flex; gap: 8px; padding: 12px 0; align-items: center; flex-shrink: 0; }
.sg-editor-voice-input { flex: 1; padding: 10px 14px; border-radius: 20px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 13px; }

/* ルールサイドパネル */
.sg-rules-panel { background: var(--surface); border-radius: 12px; border: 1px solid var(--border); padding: 16px; overflow-y: auto; }
.sg-rules-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.sg-rule-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12px; line-height: 1.6; }
.sg-rule-item:last-child { border-bottom: none; }
.sg-rule-status { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.sg-rule-status.ok { background: #10b981; }
.sg-rule-status.warn { background: #f59e0b; }
.sg-rule-status.error { background: #ef4444; }

/* ===== モバイル最適化 ===== */
@media (max-width: 600px) {
  .sg-container { padding: 12px; }
  .sg-msg { max-width: 95%; font-size: 15px; padding: 10px 12px; }
  .sg-chat-messages { padding: 10px; }
  .sg-chat-input-area { padding: 8px 10px; }
  .sg-device-content { padding: 10px; font-size: 15px; }
  .sg-editor-textarea { font-size: 15px; padding: 12px; }
  .sg-complete { max-width: 100%; }
  .sg-form { max-width: 100%; }
  .sg-complete-scores { grid-template-columns: repeat(2, 1fr); }
  .sg-preview-panels { grid-template-columns: 1fr; }
}
.sg-editor-stats { margin-top: 12px; padding: 10px; background: var(--bg); border-radius: 8px; font-size: 12px; }
.sg-editor-stats-item { display: flex; justify-content: space-between; padding: 3px 0; }

/* 差分表示 */
.sg-diff { padding: 12px; border-radius: 8px; background: var(--bg); margin-top: 12px; font-size: 13px; line-height: 1.6; }
.sg-diff-del { background: #fecaca; color: #991b1b; text-decoration: line-through; padding: 0 2px; }
.sg-diff-add { background: #bbf7d0; color: #166534; padding: 0 2px; }
[data-theme="dark"] .sg-diff-del { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .sg-diff-add { background: #052e16; color: #86efac; }

/* ===== トースト通知 ===== */
.sg-toast-container { position: fixed; top: 80px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.sg-toast {
  padding: 12px 20px; border-radius: 10px; font-size: 13px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  box-shadow: var(--shadow-hover); animation: sg-toast-in .3s ease;
  max-width: 360px;
}
.sg-toast.info { border-left: 4px solid var(--accent); }
.sg-toast.warn { border-left: 4px solid #f59e0b; }
.sg-toast.error { border-left: 4px solid #ef4444; }
.sg-toast.success { border-left: 4px solid #10b981; }
@keyframes sg-toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ===== 生成進捗 ===== */
.sg-generating { display: flex; align-items: center; gap: 16px; padding: 24px; background: var(--bg); border-radius: 12px; font-size: 14px; line-height: 1.8; color: var(--text-sub); }
.sg-spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: sg-spin 1s linear infinite; flex-shrink: 0; }
@keyframes sg-spin { to { transform: rotate(360deg); } }
.sg-complete-badge { padding: 16px 24px; background: #ecfdf5; border: 1px solid #10b981; border-radius: 12px; font-size: 16px; font-weight: 600; color: #065f46; text-align: center; animation: sg-badge-in .5s ease; }
[data-theme="dark"] .sg-complete-badge { background: #052e16; color: #6ee7b7; border-color: #065f46; }
@keyframes sg-badge-in { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }

/* ===== モーダル ===== */
.sg-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 900; display: flex; align-items: center; justify-content: center; }
.sg-modal { background: var(--surface); border-radius: 16px; padding: 28px; max-width: 480px; width: 90%; box-shadow: var(--shadow-hover); }
.sg-modal-title { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.sg-modal-body { font-size: 14px; color: var(--text-sub); line-height: 1.6; margin-bottom: 20px; }
.sg-modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ===== レスポンシブ ===== */
@media (max-width: 480px) {
  .sg-container { padding: 12px; }
  .sg-steps { gap: 4px; }
  .sg-step-indicator { padding: 4px 10px; font-size: 11px; }
  .sg-hearing { min-height: 400px; }
  .sg-msg { max-width: 95%; }
}
