/* ==========================================================
   PEP Think Tank — Design System
   IOG-inspired layout with PEP Blue palette
   ========================================================== */

/* ===== カスタムプロパティ ===== */
:root {
    --pep-blue: #303f9f;
    --pep-blue-dark: #1a237e;
    --pep-blue-light: #E8EAF6;
    --pep-blue-second: #7986CB;
    --pep-blue-hover: #283593;

    --text-primary: #23221e;
    --text-secondary: #4a4a4a;
    --text-muted: #7a7a7a;
    --text-on-dark: #ffffff;

    --bg-page: #fafafa;
    --bg-white: #ffffff;
    --bg-subtle: #f5f5f8;

    --border-main: #ddd;
    --border-light: #eee;
    --border-focus: var(--pep-blue-second);

    --radius: 6px;
    --radius-sm: 4px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}

/* ===== グローバルリセット ===== */
body {
    background: var(--bg-page);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
                 "Noto Sans JP", sans-serif;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    letter-spacing: -0.01em;
    font-weight: 700;
}

a {
    color: var(--pep-blue);
}

a:hover {
    color: var(--pep-blue-hover);
}

/* ===== ナビゲーション（IOG風） ===== */
.site-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-main);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0;
    padding-bottom: 0;
    min-height: 56px;
}

.site-logo {
    font-size: 1rem;
    font-weight: 700;
    color: var(--pep-blue);
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.site-logo:hover {
    color: var(--pep-blue-dark);
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-nav a {
    display: block;
    padding: 1rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.site-nav a:hover,
.site-nav a.active {
    color: var(--pep-blue);
    border-bottom-color: var(--pep-blue);
}

.site-nav a.nav-logout {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

.site-nav a.nav-logout:hover {
    color: var(--pep-blue);
}

/* ===== メインコンテンツ ===== */
main.container {
    max-width: 1100px;
    padding-top: 2rem;
    padding-bottom: 3rem;
}

/* ===== フッター ===== */
.site-footer {
    border-top: 1px solid var(--border-main);
    padding: 1.5rem 0;
    margin-top: 2rem;
}

.site-footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.site-footer a {
    color: var(--text-muted);
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--pep-blue);
}

/* ===== ページタイトル ===== */
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--pep-blue);
}

/* ===== トップページ ===== */
.top-hero {
    text-align: center;
    padding: 3rem 0 2rem;
}

.top-hero h1 {
    font-size: 1.8rem;
    color: var(--pep-blue);
    margin-bottom: 0.25rem;
}

.top-hero p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.tool-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    padding: 1rem 0;
}

.tool-card {
    text-align: center;
    padding: 2.5rem 1.5rem;
    background: var(--bg-white);
    border: 1px solid var(--border-main);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.15s;
}

.tool-card.active:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--pep-blue-second);
    transform: translateY(-2px);
}

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

.tool-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.tool-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

/* ===== サマリーカード ===== */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.summary-card {
    text-align: center;
    margin: 0;
    background: var(--bg-white);
    border: 1px solid var(--border-main);
    border-radius: var(--radius);
    overflow: hidden;
}

.summary-card header {
    padding: 0.6rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border-light);
}

.card-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--pep-blue);
    margin: 0;
    padding: 0.75rem 0 1rem;
}

/* ===== ダッシュボード 2カラム ===== */
.dashboard-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.dashboard-columns > section {
    background: var(--bg-white);
    border: 1px solid var(--border-main);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.dashboard-columns > section > h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--pep-blue);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

/* ===== テーブル共通 ===== */
table {
    font-size: 0.88rem;
}

table thead th {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    background: var(--bg-subtle);
    border-bottom: 2px solid var(--border-main);
    padding: 0.6rem 0.75rem;
    white-space: nowrap;
}

table tbody td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

table tbody tr:hover {
    background: var(--pep-blue-light);
}

table tbody td a {
    font-weight: 500;
}

/* ===== importance スコア色分け ===== */
.importance-high {
    color: #c62828;
    font-weight: bold;
}

.importance-medium {
    color: #e65100;
}

.importance-low {
    color: #2e7d32;
}

/* ===== フィルタバー ===== */
.filter-bar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-white);
    border: 1px solid var(--border-main);
    border-radius: var(--radius);
}

.filter-bar input[type="search"] {
    flex: 1;
    min-width: 150px;
    margin-bottom: 0;
}

.filter-bar select {
    width: auto;
    min-width: 120px;
    margin-bottom: 0;
}

.filter-bar button {
    margin-bottom: 0;
    width: auto;
    background: var(--pep-blue);
    border-color: var(--pep-blue);
    color: var(--text-on-dark);
}

.filter-bar button:hover {
    background: var(--pep-blue-hover);
    border-color: var(--pep-blue-hover);
}

/* ===== 件数表示 ===== */
.count-info {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

/* ===== テーブルラッパ ===== */
.table-wrap {
    overflow-x: auto;
}

/* ===== ページネーション ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.3rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.pagination a,
.pagination strong,
.pagination span {
    padding: 0.35rem 0.7rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.85rem;
}

.pagination a {
    color: var(--text-secondary);
    border: 1px solid var(--border-main);
    background: var(--bg-white);
    transition: all 0.15s;
}

.pagination a:hover {
    background: var(--pep-blue-light);
    border-color: var(--pep-blue-second);
    color: var(--pep-blue);
}

.pagination strong.current {
    background: var(--pep-blue);
    color: var(--text-on-dark);
    border: 1px solid var(--pep-blue);
}

.pagination .disabled {
    opacity: 0.4;
}

.pagination .ellipsis {
    padding: 0.35rem 0.3rem;
    color: var(--text-muted);
}

/* ===== 詳細テーブル ===== */
.detail-table th {
    width: 160px;
    text-align: right;
    padding-right: 1rem;
    white-space: nowrap;
    vertical-align: top;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.85rem;
    text-transform: none;
    letter-spacing: 0;
    background: transparent;
    border-bottom: 1px solid var(--border-light);
}

.detail-table td {
    font-size: 0.9rem;
}

/* ===== importance バー ===== */
.importance-bar-wrap {
    display: inline-block;
    width: 100px;
    height: 8px;
    background: var(--border-main);
    border-radius: 4px;
    overflow: hidden;
    vertical-align: middle;
    margin-right: 0.5rem;
}

.importance-bar {
    height: 100%;
    background: var(--pep-blue-second);
    border-radius: 4px;
}

/* ===== タグ ===== */
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}

.tag {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    background: var(--pep-blue-light);
    color: var(--pep-blue);
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.tag-region {
    background: #e8f5e9;
    color: #2e7d32;
}

/* ===== バッジ ===== */
.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.badge-article_analysis { background: var(--pep-blue-light); color: var(--pep-blue); }
.badge-weekly           { background: #ede7f6; color: #4527a0; }
.badge-comparison       { background: #fff3e0; color: #e65100; }
.badge-factcheck        { background: #e8f5e9; color: #2e7d32; }
.badge-matching         { background: #fce4ec; color: #b71c1c; }
.badge-cross_insight    { background: #e1f5fe; color: #01579b; }

.badge-reviewed {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-expired {
    background: #fff3e0;
    color: #e65100;
}

/* ===== Insight ヘッダー ===== */
.insight-header {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

/* ===== 警告・情報ボックス ===== */
.warning-box {
    background: #fff8e1;
    border-left: 4px solid #ffa000;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.warning-box h4 {
    margin-bottom: 0.3rem;
    font-size: 0.95rem;
}

.warning-box p {
    margin-bottom: 0;
}

/* ===== レビュー・プライマリボタン ===== */
.review-btn {
    background: #2e7d32;
    border-color: #2e7d32;
    color: var(--text-on-dark);
}

.btn-primary {
    background: var(--pep-blue);
    border-color: var(--pep-blue);
    color: var(--text-on-dark);
}

.btn-primary:hover {
    background: var(--pep-blue-hover);
    border-color: var(--pep-blue-hover);
}

/* ===== 本文表示 ===== */
.content-body {
    border: 1px solid var(--border-main);
    padding: 2rem 2.5rem;
    border-radius: var(--radius);
    background: var(--bg-white);
    line-height: 1.9;
    font-size: 0.95rem;
    color: var(--text-primary);
    max-height: 600px;
    overflow-y: auto;
}

.content-body h1,
.content-body h2,
.content-body h3,
.content-body h4 {
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

.content-body h1:first-child,
.content-body h2:first-child,
.content-body h3:first-child {
    margin-top: 0;
}

.content-body p {
    margin-bottom: 1.2rem;
}

.content-body ul,
.content-body ol {
    margin-bottom: 1.2rem;
    padding-left: 1.5rem;
}

.content-body li {
    margin-bottom: 0.4rem;
}

.content-body blockquote {
    border-left: 3px solid var(--pep-blue-second);
    padding: 0.75rem 1.25rem;
    margin: 1.2rem 0;
    background: var(--pep-blue-light);
    color: var(--text-secondary);
}

.content-body a {
    color: var(--pep-blue);
}

.content-body a:hover {
    color: var(--pep-blue-hover);
}

/* 詳細ページの本文は高さ制限を外す */
.detail-content .content-body {
    max-height: none;
    overflow-y: visible;
}

/* ===== 使用率バー ===== */
.usage-bar-wrap {
    width: 100%;
    height: 14px;
    background: var(--border-main);
    border-radius: 7px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.usage-bar {
    height: 100%;
    background: var(--pep-blue-second);
    border-radius: 7px;
    transition: width 0.3s;
}

.usage-bar.usage-warning {
    background: #ff9800;
}

.usage-bar.usage-danger {
    background: #c62828;
}

/* ===== ログレベルバッジ ===== */
.badge-log-error   { background: #ffcdd2; color: #b71c1c; }
.badge-log-warning { background: #fff3e0; color: #e65100; }
.badge-log-info    { background: var(--pep-blue-light); color: var(--pep-blue); }

/* ===== ログ行の背景色 ===== */
tr.log-error   { background: #fff5f5; }
tr.log-warning { background: #fffbe6; }

/* ===== フォームエラー・警告 ===== */
.form-errors {
    background: #ffcdd2;
    color: #b71c1c;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.form-errors p,
.form-warnings p {
    margin: 0.2rem 0;
}

.form-warnings {
    background: #fff3e0;
    color: #e65100;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* ===== チェックボックスグリッド ===== */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.3rem 1rem;
    margin-bottom: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    margin: 0;
    width: auto;
}

/* ===== 操作リンク ===== */
.action-links {
    white-space: nowrap;
}

.action-links a {
    margin-right: 0.5rem;
    font-size: 0.82rem;
}

.link-danger {
    color: #c62828;
}

/* ===== 無効行 ===== */
tr.row-inactive {
    opacity: 0.45;
}

/* ===== 削除ボタン ===== */
.btn-danger {
    background: #c62828;
    border-color: #c62828;
    color: var(--text-on-dark);
}

/* ===== レポート生成グリッド ===== */
.generate-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 0.5rem;
}

.generate-card {
    border: 1px solid var(--border-main);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    background: var(--bg-white);
}

/* ===== 小ボタン ===== */
.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
}

/* ===== レポート操作バー ===== */
.report-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

/* ===== コピー成功メッセージ ===== */
.copy-status {
    font-size: 0.82rem;
    color: #2e7d32;
    font-weight: 600;
}

/* ===== daily_briefing / weekly_report バッジ ===== */
.badge-daily_briefing { background: var(--pep-blue-light); color: var(--pep-blue); }
.badge-weekly_report  { background: #e0f2f1; color: #00695c; }

/* ===== ソース状態バッジ ===== */
.badge-source-ok     { background: #e8f5e9; color: #2e7d32; }
.badge-source-error  { background: #fff3e0; color: #e65100; }
.badge-source-paused { background: #eceff1; color: #546e7a; }

/* ===== カテゴリ選択グリッド ===== */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.category-card {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 1.25rem 1rem;
    border: 1px solid var(--border-main);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    background: var(--bg-white);
    transition: box-shadow 0.2s, border-color 0.2s;
}

.category-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--pep-blue-second);
}

/* ==========================================================
   詳細ページ（レポート・インサイト・記事）
   ========================================================== */

.back-link {
    display: inline-block;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 0.5rem;
    transition: color 0.15s;
}

.back-link:hover {
    color: var(--pep-blue);
}

.detail-page h2 {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    border: none;
    padding-bottom: 0;
}

.detail-date {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.detail-page h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--pep-blue);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--pep-blue);
    margin-bottom: 1rem;
    margin-top: 2.5rem;
}

.detail-page h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.detail-section {
    background: var(--bg-white);
    border: 1px solid var(--border-main);
    border-radius: var(--radius);
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
}

.detail-section h3 {
    margin-top: 0;
}

/* メタ情報テーブル（詳細ページ用） */
.detail-page .detail-table th {
    font-weight: 500;
    font-size: 0.82rem;
}

/* 出典リスト */
.source-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.source-list li {
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.88rem;
    line-height: 1.5;
}

.source-list li:last-child {
    border-bottom: none;
}

.source-list a {
    color: var(--pep-blue);
    text-decoration: none;
    word-break: break-all;
}

.source-list a:hover {
    text-decoration: underline;
    color: var(--pep-blue-hover);
}

/* 不確実性ボックス（詳細ページ内） */
.detail-page .warning-box {
    background: #fff8e1;
    border-left-color: #ffa000;
}

/* 操作ボタンバー（詳細ページ） */
.detail-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    padding: 0.75rem 0;
    margin-bottom: 1rem;
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
}

/* ==========================================================
   一覧ページ（Insights / Reports / Articles）
   ========================================================== */

.list-page table thead th {
    background: var(--pep-blue-light);
    border-bottom: 2px solid var(--pep-blue-second);
    color: var(--pep-blue);
}

.list-page table tbody td a {
    color: var(--text-primary);
    text-decoration: none;
}

.list-page table tbody td a:hover {
    color: var(--pep-blue);
}

/* ==========================================================
   公開共有ページ
   ========================================================== */

.share-page {
    max-width: 720px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

.share-page h2 {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.share-page .insight-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-main);
}

.share-page .content-body {
    border: none;
    padding: 0;
    max-height: none;
    overflow-y: visible;
    line-height: 2;
    font-size: 1rem;
}

.share-page h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--pep-blue);
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--pep-blue);
    margin-bottom: 1rem;
    margin-top: 2.5rem;
}

.share-footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-main);
    text-align: center;
    color: var(--text-muted);
}

/* ==========================================================
   ログインページ
   ========================================================== */

.login-card {
    max-width: 400px;
    margin: 3rem auto;
    background: var(--bg-white);
    border: 1px solid var(--border-main);
    border-radius: var(--radius);
    overflow: hidden;
}

.login-card header {
    background: var(--pep-blue);
    color: var(--text-on-dark);
    padding: 1.5rem;
    text-align: center;
}

.login-card header h2 {
    color: var(--text-on-dark);
    margin: 0;
    font-size: 1.2rem;
}

.login-card .login-body {
    padding: 2rem 1.5rem;
}

.login-card button[type="submit"] {
    background: var(--pep-blue);
    border-color: var(--pep-blue);
    color: var(--text-on-dark);
    width: 100%;
}

.login-card button[type="submit"]:hover {
    background: var(--pep-blue-hover);
    border-color: var(--pep-blue-hover);
}

/* ==========================================================
   ダッシュボード追加セクション
   ========================================================== */

.dashboard-section {
    background: var(--bg-white);
    border: 1px solid var(--border-main);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.dashboard-section h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--pep-blue);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

/* ==========================================================
   レスポンシブ
   ========================================================== */

@media (max-width: 768px) {
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-columns {
        grid-template-columns: 1fr;
    }

    .site-header .container {
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
    }

    .site-nav {
        flex-wrap: wrap;
        gap: 0;
    }

    .site-nav a {
        padding: 0.6rem 0.5rem;
        font-size: 0.78rem;
    }

    .detail-section {
        padding: 1rem;
    }

    .content-body {
        padding: 1.25rem;
    }

    .detail-page h2 {
        font-size: 1.3rem;
    }

    .filter-bar {
        padding: 0.75rem;
    }
}
