/* ============================================================
   公用文チェッカー スタイル
   ============================================================ */

:root {
  --color-primary: #1a5276;
  --color-primary-light: #2980b9;
  --color-bg: #f5f6fa;
  --color-surface: #ffffff;
  --color-border: #dcdde1;
  --color-text: #2c3e50;
  --color-text-secondary: #636e72;
  --color-error: #e74c3c;
  --color-error-bg: #fde8e8;
  --color-error-border: #f5c6cb;
  --color-warning: #f39c12;
  --color-warning-bg: #fff8e1;
  --color-warning-border: #ffe0b2;
  --color-info: #3498db;
  --color-info-bg: #e8f4fd;
  --color-info-border: #bee5eb;
  --color-success: #27ae60;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic', 'Meiryo', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   ヘッダー
   ============================================================ */

.header {
  background: var(--color-primary);
  color: white;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.header-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.header-subtitle {
  font-size: 0.8rem;
  opacity: 0.85;
  margin-top: 2px;
}

.header-mode {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-label {
  font-size: 0.85rem;
  opacity: 0.9;
}

.mode-option {
  cursor: pointer;
}

.mode-option input {
  display: none;
}

.mode-btn {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  transition: all 0.2s;
}

.mode-option input:checked + .mode-btn {
  background: white;
  color: var(--color-primary);
  font-weight: 600;
  border-color: white;
}

.mode-btn:hover {
  background: rgba(255,255,255,0.25);
}

.mode-option input:checked + .mode-btn:hover {
  background: white;
}

/* ============================================================
   メインレイアウト
   ============================================================ */

.main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
  flex: 1;
  min-height: 0;
}

@media (max-width: 900px) {
  .main {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   パネル
   ============================================================ */

.panel {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}

.panel-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-primary);
}

.char-count {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

/* 入力エリア */
.panel-input {
  min-height: 400px;
}

.panel-input textarea {
  flex: 1;
  padding: 16px;
  border: none;
  outline: none;
  resize: none;
  font-size: 0.95rem;
  font-family: inherit;
  line-height: 1.8;
  color: var(--color-text);
  min-height: 300px;
}

.panel-input textarea::placeholder {
  color: #b2bec3;
}

.panel-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
}

/* ============================================================
   ボタン
   ============================================================ */

.btn {
  padding: 8px 20px;
  border: none;
  border-radius: 6px;
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

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

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

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

.btn-secondary:hover {
  background: var(--color-border);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}

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

.btn-sm {
  padding: 6px 14px;
  font-size: 0.82rem;
}

.btn.copied {
  background: var(--color-success);
}

/* ============================================================
   結果パネル
   ============================================================ */

.panel-result {
  min-height: 400px;
  overflow: hidden;
}

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--color-text-secondary);
  text-align: center;
  flex: 1;
}

.placeholder-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.placeholder p {
  font-size: 0.9rem;
  line-height: 1.8;
}

.rule-categories {
  margin-top: 24px;
  text-align: left;
}

.rule-categories h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--color-primary);
}

.rule-categories ul {
  list-style: none;
}

.rule-categories li {
  font-size: 0.82rem;
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   サマリー
   ============================================================ */

.summary {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}

.summary-ok {
  color: var(--color-success);
  font-weight: 600;
  text-align: center;
  padding: 8px;
}

.summary-count {
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.summary-details {
  font-size: 0.82rem;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.severity-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
}

.severity-badge.severity-error {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.severity-badge.severity-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.severity-badge.severity-info {
  background: var(--color-info-bg);
  color: var(--color-info);
}

/* ============================================================
   タブ
   ============================================================ */

.result-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
}

.tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--color-text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

.tab-btn:hover {
  color: var(--color-text);
  background: var(--color-bg);
}

.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  max-height: calc(100vh - 280px);
}

.tab-content.active {
  display: block;
}

/* ============================================================
   指摘一覧
   ============================================================ */

.issue-list {
  padding: 8px;
}

.no-issues {
  padding: 40px;
  text-align: center;
  color: var(--color-text-secondary);
}

.issue-category {
  margin-bottom: 8px;
}

.issue-category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--color-bg);
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 600;
}

.cat-icon {
  display: inline-flex;
  width: 26px;
  height: 26px;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: white;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.cat-name {
  flex: 1;
}

.cat-count {
  font-size: 0.78rem;
  color: var(--color-text-secondary);
  font-weight: 400;
}

.issue-category-body {
  padding: 4px 0 4px 12px;
}

.issue-item {
  padding: 10px 12px;
  border-left: 3px solid transparent;
  border-radius: 0 6px 6px 0;
  margin: 4px 0;
  cursor: pointer;
  transition: all 0.15s;
}

.issue-item:hover {
  background: var(--color-bg);
}

.issue-item.flash {
  animation: flash-bg 1.5s;
}

@keyframes flash-bg {
  0% { background: #ffeaa7; }
  100% { background: transparent; }
}

.issue-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.severity-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  flex-shrink: 0;
}

.severity-tag.severity-error {
  background: var(--color-error);
  color: white;
}

.severity-tag.severity-warning {
  background: var(--color-warning);
  color: white;
}

.severity-tag.severity-info {
  background: var(--color-info);
  color: white;
}

.issue-matched {
  font-size: 0.82rem;
  color: var(--color-text);
  font-weight: 500;
}

.issue-message {
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  line-height: 1.6;
}

.issue-suggestion {
  font-size: 0.82rem;
  color: var(--color-success);
  font-weight: 500;
  margin-top: 2px;
}

.issue-ref {
  font-size: 0.72rem;
  color: #b2bec3;
  margin-top: 4px;
}

/* ============================================================
   ハイライト表示
   ============================================================ */

.highlight-legend {
  display: flex;
  gap: 16px;
  padding: 10px 16px;
  font-size: 0.78rem;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-color {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
}

.legend-error { background: var(--color-error-bg); border: 1px solid var(--color-error); }
.legend-warning { background: var(--color-warning-bg); border: 1px solid var(--color-warning); }
.legend-info { background: var(--color-info-bg); border: 1px solid var(--color-info); }

.highlighted-view {
  padding: 16px;
  padding-bottom: 60px;
  font-size: 0.95rem;
  position: relative;
  line-height: 2;
  white-space: pre-wrap;
  word-break: break-all;
}

.highlight {
  padding: 1px 2px;
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
}

.highlight-error {
  background: var(--color-error-bg);
  border-bottom: 2px solid var(--color-error);
}

.highlight-warning {
  background: var(--color-warning-bg);
  border-bottom: 2px solid var(--color-warning);
}

.highlight-info {
  background: var(--color-info-bg);
  border-bottom: 2px solid var(--color-info);
}

.highlight:hover {
  opacity: 0.8;
}

.highlight.flash {
  animation: flash-highlight 1.5s;
}

@keyframes flash-highlight {
  0% { background: #ffeaa7; transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* ハイライトのツールチップ */
.hl-tooltip {
  display: none;
  position: absolute;
  z-index: 100;
  max-width: 320px;
  padding: 8px 12px;
  background: var(--color-text);
  color: #fff;
  font-size: 0.82rem;
  line-height: 1.6;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  pointer-events: none;
}

.hl-tip-severity {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
}

.hl-tip-severity.severity-error { background: var(--color-error); color: #fff; }
.hl-tip-severity.severity-warning { background: var(--color-warning); color: #fff; }
.hl-tip-severity.severity-info { background: var(--color-info); color: #fff; }

.hl-tip-suggestion {
  margin-top: 4px;
  color: #a8e6cf;
  font-weight: 600;
}

/* ============================================================
   修正後テキスト
   ============================================================ */

.corrected-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
  gap: 12px;
}

.corrected-note {
  font-size: 0.78rem;
  color: var(--color-text-secondary);
}

.corrected-text {
  padding: 16px;
  font-size: 0.95rem;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 200px;
}

.diff-del {
  text-decoration: line-through;
  color: #b0b0b0;
  background: #fce4e4;
  border-radius: 2px;
  padding: 0 1px;
  font-size: 0.88em;
}

.diff-ins {
  color: #1a7f37;
  background: #dafbe1;
  border-radius: 2px;
  padding: 0 2px;
  font-weight: 600;
}

/* ============================================================
   設定ボタン
   ============================================================ */

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

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: white;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: rgba(255,255,255,0.25);
}

/* ============================================================
   設定モーダル
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  width: 90%;
  max-width: 640px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--color-text-secondary);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.modal-close:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
}

.settings-category {
  margin-bottom: 16px;
}

.settings-category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-primary);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 8px;
}

.settings-category-header .cat-icon {
  width: 22px;
  height: 22px;
  font-size: 0.65rem;
}

.settings-rule {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0 6px 4px;
  font-size: 0.84rem;
}

.settings-rule input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--color-primary);
}

.settings-rule-label {
  flex: 1;
  cursor: pointer;
  line-height: 1.5;
}

.settings-rule-name {
  font-weight: 500;
  color: var(--color-text);
}

.settings-rule-label .severity-tag {
  font-size: 0.65rem;
  padding: 0 5px;
  margin-left: 4px;
  vertical-align: middle;
}

.settings-rule-desc {
  font-size: 0.78rem;
  color: var(--color-text-secondary);
}

/* ============================================================
   フッター
   ============================================================ */

.footer {
  padding: 12px 24px;
  text-align: center;
  font-size: 0.72rem;
  color: var(--color-text-secondary);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.privacy-notice {
  margin-top: 4px;
  font-weight: 600;
}

.privacy-notice a,
.footer a {
  color: var(--color-text-secondary);
  margin-left: 8px;
}

/* ============================================================
   スクロールバー
   ============================================================ */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

/* ============================================================
   フィルタバー
   ============================================================ */

.issue-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.filter-group {
  display: flex;
  gap: 4px;
}

.filter-btn {
  padding: 4px 12px;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-surface);
  font-size: 0.75rem;
  font-family: inherit;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover {
  background: var(--color-border);
}

.filter-btn.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

/* ============================================================
   指摘アクションボタン（適用・無視）
   ============================================================ */

.issue-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.issue-action-btn {
  padding: 2px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  font-size: 0.7rem;
  font-family: inherit;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  opacity: 0;
}

.issue-item:hover .issue-action-btn {
  opacity: 1;
}

.issue-apply-btn:hover {
  background: var(--color-success);
  color: white;
  border-color: var(--color-success);
}

.issue-ignore-btn:hover {
  background: var(--color-text-secondary);
  color: white;
  border-color: var(--color-text-secondary);
}

/* ============================================================
   ドラッグ&ドロップ
   ============================================================ */

.panel-input textarea.drag-over {
  background: var(--color-info-bg);
  border: 2px dashed var(--color-info);
}

/* ============================================================
   ダークモード
   ============================================================ */

[data-theme="dark"] {
  --color-primary: #4a9eda;
  --color-primary-light: #6bb5e8;
  --color-bg: #1a1a2e;
  --color-surface: #16213e;
  --color-border: #2a2a4a;
  --color-text: #e0e0e0;
  --color-text-secondary: #a0a0b0;
  --color-error: #e74c3c;
  --color-error-bg: #3d1c1c;
  --color-error-border: #5c2a2a;
  --color-warning: #f39c12;
  --color-warning-bg: #3d3018;
  --color-warning-border: #5c4a2a;
  --color-info: #5dade2;
  --color-info-bg: #1c2d3d;
  --color-info-border: #2a4a5c;
  --color-success: #2ecc71;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

[data-theme="dark"] .header {
  background: #0f3460;
}

[data-theme="dark"] .panel-input textarea {
  background: var(--color-surface);
  color: var(--color-text);
}

[data-theme="dark"] .panel-input textarea::placeholder {
  color: #606080;
}

[data-theme="dark"] .diff-del {
  color: #888;
  background: #3d1c1c;
}

[data-theme="dark"] .diff-ins {
  color: #2ecc71;
  background: #1c3d1c;
}

[data-theme="dark"] .hl-tooltip {
  background: #2a2a4a;
  color: #e0e0e0;
}

[data-theme="dark"] .cat-icon {
  background: var(--color-primary);
}
