/* =========================
   CEDAR NEWS TERMINAL - 终极版本
   v0业务逻辑 + v2现代化设计 + 橙色主题
   ========================= */

/* 主题变量系统 */
:root {
  /* 默认橙色主题 (Bloomberg风格) */
  --bg-0: #000000;         /* 纯黑背景 */
  --bg-1: #0A0A0A;         /* 次级面板 */
  --panel: #111111;        /* 面板 */
  --line: #2A2A2A;         /* 分隔线/描边 */
  --txt: #F5F5F5;          /* 主文字 */
  --txt-2: #CCCCCC;        /* 次级文字 */
  --muted: #999999;        /* 弱化文字 */

  --accent: #FF8C00;       /* 彭博橙色(主要) */
  --accent-2: #FFA500;     /* 彭博橙色(装饰) */
  --accent-3: #FFB84D;     /* 亮橙 hover */
  --danger: #FF4D4F;       /* 要闻红 */
  --danger-tint: #1A0A0A;  /* 要闻行底色 */
  --warn: #F59E0B;         /* 警示/波动 */
  --chip: #1A1200;         /* 来源 chip 背景 */

  --radius: 10px;          /* 现代化圆角 */
  --shadow: 0 8px 24px rgba(0,0,0,.18);
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Consolas', 'Monaco', 'Courier New', monospace;
}

/* 经典终端主题 */
body[data-theme="default"] {
  --bg-0: #000000;
  --bg-1: #001100;
  --panel: #002200;
  --line: #00ff00;
  --txt: #00ff00;
  --txt-2: #00cc00;
  --muted: #009900;
  --accent: #00ff00;
  --accent-2: #00dd00;
  --accent-3: #00ff88;
  --danger: #ff6666;
  --danger-tint: #220000;
  --warn: #ffcc00;
  --chip: #003300;
  --radius: 4px;
}

/* Neo-Terminal主题 */
body[data-theme="v2"] {
  --bg-0: #0B0F14;
  --bg-1: #0F141A;
  --panel: #111827;
  --line: #163325;
  --txt: #E6EDF3;
  --txt-2: #9FB0BE;
  --muted: #7C8B96;
  --accent: #22D3A8;
  --accent-2: #23D18B;
  --accent-3: #00ff88;
  --danger: #FF4D4F;
  --danger-tint: #2A1111;
  --warn: #F59E0B;
  --chip: #143026;
  --radius: 10px;
}

/* 基础样式重置 */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg-0);
  color: var(--txt);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.45;
  overflow-x: hidden;
  font-variant-numeric: tabular-nums;
}

.container {
  max-width: 1800px;
  margin: 0 auto;
  padding: 14px;
}

/* =========================
   顶部 Header
   ========================= */
.header {
  padding-bottom: 10px;
  margin-bottom: 14px;
  border-bottom: 2px solid var(--accent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 1px;
}

.brand h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
}

.brand .live-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent-2);
  box-shadow: 0 0 10px var(--accent-2);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: .6; transform: scale(.9); }
  50% { opacity: 1; transform: scale(1); }
}

.stats {
  margin-top: 6px;
  color: var(--txt-2);
  font-size: 11px;
  white-space: normal;
  overflow: hidden;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  opacity: .9;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 140, 0, 0.08);
  color: var(--txt-2);
  border: 1px solid rgba(255, 140, 0, 0.25);
  white-space: nowrap;
  transition: color .15s ease, border-color .15s ease;
}

body[data-theme="default"] .chip {
  background: rgba(0, 255, 0, 0.08);
  border-color: rgba(0, 255, 0, 0.25);
}

body[data-theme="v2"] .chip {
  background: rgba(34, 211, 168, 0.06);
  border-color: rgba(34, 211, 168, 0.12);
}

.chip:hover {
  color: var(--accent);
  border-color: var(--accent);
}

body[data-theme="default"] .chip:hover {
  border-color: rgba(0, 255, 0, 0.5);
}

body[data-theme="v2"] .chip:hover {
  border-color: rgba(34, 211, 168, 0.25);
}

.divider {
  opacity: .18;
  padding: 0 6px;
}

/* =========================
   控制面板
   ========================= */
.controls {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

label {
  font-size: 12px;
  color: var(--txt-2);
}

select, input[type="checkbox"] {
  background: var(--bg-0);
  color: var(--txt);
  border: 1px solid var(--line);
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  border-radius: calc(var(--radius) / 2);
  outline: none;
}

select:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px rgba(255, 140, 0, 0.2);
}

body[data-theme="default"] select:focus {
  box-shadow: 0 0 0 2px rgba(0, 255, 0, 0.2);
}

body[data-theme="v2"] select:focus {
  box-shadow: 0 0 0 2px rgba(34, 211, 168, 0.15);
}

.btn {
  padding: 6px 10px;
  border-radius: calc(var(--radius) / 2);
  border: 1px solid var(--line);
  background: var(--bg-0);
  color: var(--txt);
  cursor: pointer;
  font-size: 12px;
  transition: transform .08s ease, background .15s ease, border .15s ease;
}

.btn:hover {
  background: var(--bg-1);
  border-color: var(--accent);
}

.btn:active {
  transform: translateY(1px);
}

.btn-accent {
  border-color: rgba(255, 140, 0, 0.6);
  color: var(--accent);
}

body[data-theme="default"] .btn-accent {
  border-color: rgba(0, 255, 0, 0.6);
  color: var(--accent);
}

body[data-theme="v2"] .btn-accent {
  border-color: rgba(34, 211, 168, 0.5);
  color: var(--accent);
}

.btn-danger {
  border-color: rgba(255, 77, 79, 0.45);
  color: #ffb3b4;
}

.refresh-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

/* =========================
   "有新快讯" 提示条
   ========================= */
.new-banner {
  position: sticky;
  top: 8px;
  z-index: 10;
  margin-bottom: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 140, 0, 0.12);
  border: 1px solid rgba(255, 140, 0, 0.5);
  color: var(--accent);
  cursor: pointer;
  user-select: none;
}

body[data-theme="default"] .new-banner {
  background: rgba(0, 255, 0, 0.12);
  border-color: rgba(0, 255, 0, 0.5);
}

body[data-theme="v2"] .new-banner {
  background: rgba(34, 211, 168, 0.08);
  border-color: rgba(34, 211, 168, 0.35);
}

.new-banner.show {
  display: flex;
}

/* =========================
   新闻列表
   ========================= */
.news-list {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(10, 10, 10, 0.5);
}

body[data-theme="v2"] .news-list {
  background: rgba(9, 14, 12, 0.5);
}

.news-item {
  position: relative;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px 8px 12px;
  transition: background .12s ease, border-color .12s ease;
}

.news-item:hover {
  background: var(--bg-1);
}

body[data-theme="v2"] .news-item:hover {
  background: #0f1915;
}

.row-stripe {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent-2);
}

.news-item.important {
  background: var(--danger-tint);
}

.news-item.important .row-stripe {
  width: 4px;
  background: var(--danger);
}

.news-item.new .row-stripe {
  animation: glow 1.6s ease-out 2;
  box-shadow: 0 0 0 rgba(255, 165, 0, 0);
}

body[data-theme="default"] .news-item.new .row-stripe {
  animation-name: glow-green;
}

body[data-theme="v2"] .news-item.new .row-stripe {
  animation-name: glow-neo;
}

@keyframes glow {
  0% { box-shadow: 0 0 0 rgba(255, 165, 0, .0); }
  30% { box-shadow: 0 0 14px rgba(255, 165, 0, .8); }
  100% { box-shadow: 0 0 0 rgba(255, 165, 0, .0); }
}

@keyframes glow-green {
  0% { box-shadow: 0 0 0 rgba(0, 255, 0, .0); }
  30% { box-shadow: 0 0 14px rgba(0, 255, 0, .8); }
  100% { box-shadow: 0 0 0 rgba(0, 255, 0, .0); }
}

@keyframes glow-neo {
  0% { box-shadow: 0 0 0 rgba(35, 209, 139, .0); }
  30% { box-shadow: 0 0 14px rgba(35, 209, 139, .65); }
  100% { box-shadow: 0 0 0 rgba(35, 209, 139, .0); }
}

.news-meta {
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 11px;
  color: var(--txt-2);
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.news-time {
  min-width: 120px;
  color: var(--muted);
}

.news-source {
  min-width: 120px;
  color: var(--accent);
}

.badge {
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #ccc;
}

.badge-important {
  color: #ffb3b4;
  border-color: rgba(255, 77, 79, 0.45);
  background: rgba(255, 77, 79, 0.08);
}

.news-title {
  font-size: 13px;
  margin-bottom: 2px;
  letter-spacing: .2px;
}

.news-title a {
  color: var(--accent);
  text-decoration: none;
  margin-left: 6px;
}

.news-title a:hover {
  color: var(--accent-3);
  text-decoration: underline;
}

.news-category {
  color: var(--accent-3);
  opacity: .9;
  font-size: 11px;
  margin-left: 8px;
}

body[data-theme="v2"] .news-category {
  color: #b6ff87;
}

.news-content {
  font-size: 11px;
  color: var(--txt-2);
  margin-top: 4px;
  max-width: 1100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: opacity .2s ease;
}

.news-content:hover {
  opacity: .9;
}

.news-content.expanded {
  white-space: normal;
  word-wrap: break-word;
}

/* news-content中的HTML元素样式 */
.news-content p {
  display: inline;
  margin: 0;
}

.news-content.expanded p {
  display: block;
  margin: 8px 0;
}

.news-content strong,
.news-content b {
  color: var(--accent-2);
  font-weight: bold;
}

.news-content em,
.news-content i {
  font-style: italic;
  color: var(--txt);
}

.news-content a {
  color: var(--accent-2);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent-2);
}

.news-content a:hover {
  color: var(--accent-3);
}

.news-content br {
  display: none;
}

.news-content.expanded br {
  display: block;
}

.news-content h2,
.news-content h3 {
  display: inline;
  font-size: inherit;
  font-weight: bold;
  color: var(--accent);
  margin: 0;
}

.news-content.expanded h2,
.news-content.expanded h3 {
  display: block;
  margin: 12px 0 6px 0;
}

.news-content ul,
.news-content ol {
  display: none;
}

.news-content.expanded ul,
.news-content.expanded ol {
  display: block;
  margin: 8px 0;
  padding-left: 20px;
}

.news-content li {
  margin: 4px 0;
}

.news-content-toggle {
  color: var(--accent);
  opacity: .6;
  margin-left: 6px;
}

.loading {
  text-align: center;
  padding: 20px;
  color: var(--muted);
}

.error {
  color: #ff9a9c;
  padding: 20px;
  text-align: center;
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-1);
}

::-webkit-scrollbar-thumb {
  background: var(--accent-2);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-3);
}

/* 响应式设计 */
@media (max-width: 720px) {
  .news-time { min-width: auto; }
  .news-source { min-width: auto; }
  .control-row { gap: 10px; }
  .refresh-status {
    width: 100%;
    justify-content: flex-end;
  }
}

/* =========================
   全文模态框样式
   ========================= */
.modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.modal.show {
  display: block;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  cursor: pointer;
}

.modal-content {
  position: relative;
  background: var(--panel);
  margin: 5vh auto;
  padding: 0;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  width: 90%;
  max-width: 1000px;
  max-height: 85vh;
  overflow: hidden;
  box-shadow: var(--shadow);
  z-index: 10000;
}

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

.modal-news-title {
  font-size: 18px;
  font-weight: bold;
  color: var(--accent);
  margin: 0;
  flex: 1;
  line-height: 1.4;
}

.modal-close {
  background: none;
  border: none;
  color: var(--txt);
  font-size: 32px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
  flex-shrink: 0;
  margin-left: 16px;
}

.modal-close:hover {
  color: var(--accent);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(85vh - 80px);
}

.modal-meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.modal-meta span {
  margin-right: 12px;
}

.modal-fulltext {
  color: var(--txt);
  line-height: 1.8;
  word-wrap: break-word;
  font-size: 14px;
}

/* 正文HTML元素样式 */
.modal-fulltext p {
  margin: 12px 0;
  line-height: 1.8;
}

.modal-fulltext h2,
.modal-fulltext h3 {
  color: var(--accent);
  margin: 20px 0 12px 0;
  font-weight: bold;
  line-height: 1.5;
}

.modal-fulltext h2 {
  font-size: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.modal-fulltext h3 {
  font-size: 15px;
}

.modal-fulltext a {
  color: var(--accent-2);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent-2);
  transition: color 0.2s;
}

.modal-fulltext a:hover {
  color: var(--accent-3);
  border-bottom-color: var(--accent-3);
}

.modal-fulltext strong {
  color: var(--accent);
  font-weight: bold;
}

.modal-fulltext ul,
.modal-fulltext ol {
  margin: 12px 0;
  padding-left: 24px;
}

.modal-fulltext li {
  margin: 6px 0;
}

.modal-fulltext blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  background: var(--bg-1);
  color: var(--txt-2);
}

.modal-fulltext code {
  background: var(--bg-1);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--font-mono);
  color: var(--accent-2);
}

.modal-fulltext pre {
  background: var(--bg-1);
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 12px 0;
}

.modal-fulltext pre code {
  background: none;
  padding: 0;
}

.modal-fulltext img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 16px 0;
  border-radius: 6px;
}

.modal-fulltext hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

/* 表格样式 */
.modal-fulltext table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

.modal-fulltext th,
.modal-fulltext td {
  border: 1px solid var(--line);
  padding: 8px 12px;
  text-align: left;
}

.modal-fulltext th {
  background: var(--bg-1);
  color: var(--accent);
  font-weight: bold;
}

/* 模态框打开时禁止body滚动 */
body.modal-open {
  overflow: hidden;
}

/* 全文按钮样式 - 高亮显示，提醒用户可点击 */
.btn-fulltext {
  background: var(--accent);
  border: none;
  color: var(--bg-0);
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  font-weight: bold;
  padding: 2px 6px;
  margin-left: 6px;
  border-radius: 3px;
  transition: all 0.2s ease;
  box-shadow: 0 0 8px rgba(255, 140, 0, 0.3);
  animation: fulltext-pulse 2s ease-in-out infinite;
}

.btn-fulltext:hover {
  background: var(--accent-3);
  color: var(--bg-0);
  box-shadow: 0 0 12px rgba(255, 140, 0, 0.6);
  transform: scale(1.05);
  animation: none; /* 停止脉冲动画 */
}

/* 脉冲动画 - 微妙提示可点击 */
@keyframes fulltext-pulse {
  0%, 100% {
    box-shadow: 0 0 8px rgba(255, 140, 0, 0.3);
  }
  50% {
    box-shadow: 0 0 16px rgba(255, 140, 0, 0.5);
  }
}

/* 经典主题 - 全文按钮适配 */
body[data-theme="default"] .btn-fulltext {
  box-shadow: 0 0 8px rgba(0, 255, 0, 0.3);
  animation: fulltext-pulse-green 2s ease-in-out infinite;
}

body[data-theme="default"] .btn-fulltext:hover {
  box-shadow: 0 0 12px rgba(0, 255, 0, 0.6);
}

@keyframes fulltext-pulse-green {
  0%, 100% {
    box-shadow: 0 0 8px rgba(0, 255, 0, 0.3);
  }
  50% {
    box-shadow: 0 0 16px rgba(0, 255, 0, 0.5);
  }
}

/* Neo-Terminal主题 - 全文按钮适配 */
body[data-theme="v2"] .btn-fulltext {
  box-shadow: 0 0 8px rgba(34, 211, 168, 0.3);
  animation: fulltext-pulse-neo 2s ease-in-out infinite;
}

body[data-theme="v2"] .btn-fulltext:hover {
  box-shadow: 0 0 12px rgba(34, 211, 168, 0.6);
}

@keyframes fulltext-pulse-neo {
  0%, 100% {
    box-shadow: 0 0 8px rgba(34, 211, 168, 0.3);
  }
  50% {
    box-shadow: 0 0 16px rgba(34, 211, 168, 0.5);
  }
}

/* 模态框响应式设计 */
@media (max-width: 720px) {
  .modal-content {
    width: 95%;
    margin: 2vh auto;
    max-height: 95vh;
  }

  .modal-header {
    padding: 16px;
  }

  .modal-news-title {
    font-size: 16px;
  }

  .modal-body {
    padding: 16px;
    max-height: calc(95vh - 70px);
  }

  .modal-fulltext {
    font-size: 13px;
  }
}