/**
 * market-trend-style.css
 * Phase 3.3β Recovery Market Monitor - Trend Tab Styles
 */

/* ========================================
 * タブナビゲーション
 * ======================================== */
.tab-navigation {
  display: flex;
  gap: 8px;
  margin: 20px 0;
  border-bottom: 2px solid #e5e7eb;
}

.tab-btn {
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
  color: #6b7280;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: #111827;
  background: #f9fafb;
}

.tab-btn.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
}

/* ========================================
 * タブコンテンツ
 * ======================================== */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================
 * Trendタブレイアウト
 * ======================================== */
.trend-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}

.trend-section {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 20px;
}

.trend-section h2 {
  font-size: 18px;
  font-weight: 700;
  color: #111827;
  margin: 0 0 16px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.trend-section.full-width {
  grid-column: 1 / -1;
}

/* ========================================
 * Timeline Chart
 * ======================================== */
.timeline-chart {
  min-height: 300px;
  position: relative;
}

.timeline-chart canvas {
  max-height: 300px;
}

/* ========================================
 * Network Graph
 * ======================================== */
.network-graph {
  min-height: 500px;
  position: relative;
  background: #f9fafb;
  border-radius: 4px;
  overflow: hidden;
}

.network-graph svg {
  width: 100%;
  height: 500px;
}

.network-node {
  stroke: #fff;
  stroke-width: 2px;
  cursor: pointer;
  transition: all 0.2s;
}

.network-node:hover {
  stroke: #2563eb;
  stroke-width: 3px;
}

.network-link {
  stroke: #d1d5db;
  stroke-opacity: 0.6;
}

.network-label {
  font-size: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  pointer-events: none;
  user-select: none;
}

.network-tooltip {
  position: absolute;
  background: rgba(17, 24, 39, 0.95);
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 1000;
}

.network-tooltip.show {
  opacity: 1;
}

/* ========================================
 * Keyword Cards
 * ======================================== */
.keyword-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.keyword-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 12px;
  transition: all 0.2s;
  position: relative;
}

.keyword-card:hover {
  border-color: #2563eb;
  box-shadow: 0 4px 6px rgba(37, 99, 235, 0.1);
}

.keyword-card .keyword-rank {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 18px;
  font-weight: 800;
  color: #3b82f6;
  opacity: 0.3;
}

.keyword-card .keyword-name {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 4px;
}

.keyword-card .keyword-score {
  font-size: 20px;
  font-weight: 700;
  color: #2563eb;
  margin-bottom: 8px;
}

.keyword-card .keyword-delta {
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.keyword-delta.rising {
  color: #10b981;
}

.keyword-delta.rising::before {
  content: "↑";
}

.keyword-delta.falling {
  color: #ef4444;
}

.keyword-delta.falling::before {
  content: "↓";
}

.keyword-delta.stable {
  color: #6b7280;
}

.keyword-delta.stable::before {
  content: "→";
}

.keyword-card .keyword-sources {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
}

/* ========================================
 * Beta Badge
 * ======================================== */
.beta-badge {
  display: inline-block;
  background: #fbbf24;
  color: #78350f;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  margin-left: 8px;
}

.trend-disclaimer {
  margin-top: 12px;
  padding: 12px;
  background: #fffbeb;
  border: 1px solid #fbbf24;
  border-radius: 6px;
  font-size: 12px;
  color: #78350f;
}

/* ========================================
 * Article Modal (Timeline Click)
 * ======================================== */
.article-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s;
}

.article-modal-content {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 700px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.article-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 2px solid #e5e7eb;
}

.article-modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: #111827;
  margin: 0;
}

.article-modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: #6b7280;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.article-modal-close:hover {
  background: #f3f4f6;
  color: #111827;
}

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

.article-modal-item {
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 12px;
  transition: all 0.2s;
}

.article-modal-item:hover {
  border-color: #3b82f6;
  background: #f9fafb;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.article-modal-item a {
  text-decoration: none;
  display: block;
}

.article-modal-title {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 8px;
  line-height: 1.5;
}

.article-modal-item:hover .article-modal-title {
  color: #2563eb;
}

.article-modal-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: #6b7280;
}

.article-modal-source {
  font-weight: 500;
}

.article-modal-date {
  opacity: 0.8;
}

.no-articles {
  text-align: center;
  color: #9ca3af;
  padding: 40px 20px;
  font-size: 14px;
}

/* ========================================
 * レスポンシブ
 * ======================================== */
@media (max-width: 968px) {
  .trend-container {
    grid-template-columns: 1fr;
  }

  .trend-section.full-width {
    grid-column: 1;
  }

  .keyword-cards {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .network-graph svg {
    height: 400px;
  }

  .article-modal-content {
    width: 95%;
    max-height: 90vh;
  }
}

@media (max-width: 640px) {
  .tab-navigation {
    gap: 4px;
  }

  .tab-btn {
    padding: 10px 16px;
    font-size: 14px;
  }

  .keyword-cards {
    grid-template-columns: 1fr;
  }

  .network-graph svg {
    height: 350px;
  }

  .article-modal-header {
    padding: 16px;
  }

  .article-modal-header h3 {
    font-size: 16px;
  }

  .article-modal-body {
    padding: 12px 16px 16px;
  }
}

/* ========================================
 * Phase 3.6.3α - Keyword Context Sidebar
 * ======================================== */
.keyword-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  z-index: 20000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.keyword-sidebar.show {
  opacity: 1;
  pointer-events: all;
}

.keyword-sidebar-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.keyword-sidebar-content {
  position: absolute;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 90vw;
  height: 100%;
  background: white;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.2);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.keyword-sidebar.show .keyword-sidebar-content {
  transform: translateX(0);
}

.keyword-sidebar-header {
  padding: 20px;
  border-bottom: 2px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: start;
  flex-shrink: 0;
}

.keyword-sidebar-title {
  flex: 1;
}

.keyword-sidebar-title h3 {
  font-size: 22px;
  font-weight: 700;
  color: #111827;
  margin: 0 0 8px 0;
}

.dominant-layer-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  color: white;
}

.keyword-sidebar-close {
  background: none;
  border: none;
  font-size: 32px;
  color: #9ca3af;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
  flex-shrink: 0;
  margin-left: 12px;
}

.keyword-sidebar-close:hover {
  background: #f3f4f6;
  color: #111827;
}

.keyword-sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Attention Breakdown */
.attention-breakdown {
  margin-bottom: 24px;
}

.attention-score-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding: 16px;
  background: linear-gradient(135deg, #f9fafb, #ffffff);
  border-radius: 12px;
  border: 1px solid #e5e7eb;
}

.attention-score-value {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.score-grade {
  font-size: 48px;
  font-weight: 800;
  line-height: 1;
}

.score-number {
  font-size: 32px;
  font-weight: 700;
  color: #374151;
}

.attention-score-label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  color: #6b7280;
  font-weight: 500;
}

.trend-7d {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  align-self: flex-start;
}

.trend-7d.up {
  background: #d1fae5;
  color: #065f46;
}

.trend-7d.down {
  background: #fee2e2;
  color: #991b1b;
}

/* Layer Breakdown */
.layer-breakdown h4 {
  font-size: 14px;
  font-weight: 700;
  color: #374151;
  margin: 0 0 12px 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.layer-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.layer-bar {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.layer-bar-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.layer-bar-value {
  font-size: 16px;
  font-weight: 700;
}

.layer-bar-track {
  height: 8px;
  background: #f3f4f6;
  border-radius: 4px;
  overflow: hidden;
}

.layer-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.layer-formula {
  margin-top: 16px;
  padding: 12px;
  background: #f9fafb;
  border-radius: 6px;
  text-align: center;
}

.layer-formula small {
  color: #6b7280;
  font-size: 12px;
}

/* Related Articles */
.related-articles {
  margin-top: 24px;
}

.related-articles h4 {
  font-size: 16px;
  font-weight: 700;
  color: #111827;
  margin: 0 0 12px 0;
}

.no-articles {
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
  padding: 32px 16px;
}

.article-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.article-item {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  transition: all 0.2s;
}

.article-item:hover {
  border-color: #3b82f6;
  background: #f9fafb;
}

.article-item a {
  text-decoration: none;
  display: block;
}

.article-title {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 6px;
  line-height: 1.4;
}

.article-item:hover .article-title {
  color: #2563eb;
}

.article-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: #9ca3af;
}

.article-source {
  font-weight: 500;
}

/* Responsive */
@media (max-width: 640px) {
  .keyword-sidebar-content {
    width: 100%;
    max-width: 100%;
  }

  .attention-score-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ========================================
 * Phase 3.6.3α - Zoom Hint
 * ======================================== */
.zoom-hint {
  position: absolute;
  bottom: 16px;
  right: 16px;
  background: rgba(17, 24, 39, 0.9);
  color: white;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  pointer-events: none;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ========================================
 * Phase 3.6.3α - Multi-Layer Colors
 * ======================================== */
.network-node[data-layer="emotion"] {
  fill: #fb923c !important;  /* Orange */
}

.network-node[data-layer="intention"] {
  fill: #3b82f6 !important;  /* Blue */
}

.network-node[data-layer="behavior"] {
  fill: #22c55e !important;  /* Green */
}

/* ========================================
 * Phase 3.6.4 - Semantic Zoom UI
 * ======================================== */
.zoom-level-indicator {
  position: fixed;
  top: 80px;
  right: 20px;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px 20px;
  min-width: 200px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.zoom-layer-name {
  font-size: 18px;
  font-weight: 700;
  color: #3b82f6;
  margin-bottom: 4px;
}

.zoom-layer-desc {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 12px;
}

.zoom-level-bar {
  height: 6px;
  background: #f3f4f6;
  border-radius: 3px;
  overflow: hidden;
}

.zoom-level-fill {
  height: 100%;
  background: #3b82f6;
  transition: width 0.3s ease, background 0.3s ease;
  border-radius: 3px;
}

/* Semantic Layers */
.clusters-layer,
.keywords-layer,
.articles-layer {
  transition: opacity 500ms ease;
}

@media (max-width: 640px) {
  .zoom-level-indicator {
    top: 60px;
    right: 10px;
    min-width: 160px;
    padding: 12px 16px;
  }

  .zoom-layer-name {
    font-size: 16px;
  }
}
