/* =====================
   TimeTrending Main CSS
   ===================== */

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

:root {
  --color-bg: #ffffff;
  --color-surface: #f8f9fa;
  --color-border: #e2e8f0;
  --color-text: #1a202c;
  --color-text-muted: #718096;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-green: #16a34a;
  --color-red: #dc2626;
  --color-header-bg: #0f172a;
  --color-ticker-bg: #1e293b;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --sidebar-width: 320px;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--color-primary); }
img { max-width: 100%; height: auto; display: block; }

/* ===================== HEADER ===================== */
.site-header {
  background: var(--color-header-bg);
  color: #fff;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.header-inner {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  gap: 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  text-decoration: none;
  flex-shrink: 0;
}
.logo:hover { color: #93c5fd; }
.logo-icon { font-size: 20px; }
.logo-text { letter-spacing: -0.5px; }

.header-tabs {
  display: flex;
  gap: 4px;
  margin-left: 24px;
}

.tab-btn {
  padding: 6px 14px;
  border-radius: 6px;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.tab-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }
.tab-btn.active { color: #fff; background: var(--color-primary); }

.header-right {
  margin-left: auto;
  color: #94a3b8;
  font-size: 13px;
  white-space: nowrap;
}

/* ===================== TICKER ===================== */
.ticker-bar {
  background: var(--color-ticker-bg);
  padding: 0 20px;
  height: 44px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.ticker-inner {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
}

.ticker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
}

.ticker-name {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.ticker-price {
  color: #f1f5f9;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.ticker-change {
  font-size: 12px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
}
.ticker-change.positive { color: #4ade80; background: rgba(74,222,128,0.1); }
.ticker-change.negative { color: #f87171; background: rgba(248,113,113,0.1); }

.ticker-separator {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.1);
}

/* ===================== LAYOUT ===================== */
.main-layout {
  display: flex;
  flex: 1;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  gap: 20px;
  align-items: flex-start;
}

.simple-layout {
  display: block;
  padding: 40px 20px;
}

/* ===================== CHARTS ===================== */
.charts-section {
  flex: 1;
  min-width: 0;
}

.section-title {
  margin-bottom: 16px;
}
.section-title h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.chart-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.chart-card:first-child {
  grid-column: 1 / -1;
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-wrap: wrap;
  gap: 8px;
}

.chart-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.chart-timeframes {
  display: flex;
  gap: 4px;
}

.tf-btn {
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: white;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}
.tf-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.tf-btn.active { background: var(--color-primary); color: white; border-color: var(--color-primary); }

.tradingview-widget-container {
  height: 300px;
}
.chart-card:first-child .tradingview-widget-container {
  height: 380px;
}

/* ===================== NEWS SIDEBAR ===================== */
.news-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: sticky;
  top: 104px;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.news-list {
  overflow-y: auto;
  flex: 1;
}

.news-item {
  border-bottom: 1px solid var(--color-border);
}
.news-item:last-child { border-bottom: none; }

.news-item-link {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  transition: background 0.15s;
}
.news-item-link:hover { background: var(--color-surface); }

.news-thumb {
  width: 64px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
  background: var(--color-border);
}
.news-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.news-content {
  flex: 1;
  min-width: 0;
}

.news-source {
  font-size: 10px;
  font-weight: 600;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 2px;
}

.news-time {
  font-size: 10px;
  color: var(--color-text-muted);
  float: right;
  margin-left: 4px;
}

.news-title {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--color-text);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.news-item-link:hover .news-title { color: var(--color-primary); }

.no-news {
  padding: 24px;
  text-align: center;
  color: var(--color-text-muted);
}

.ad-slot {
  padding: 12px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

/* ===================== ARTICLE ===================== */
.article-section {
  flex: 1;
  min-width: 0;
  max-width: 800px;
}

.article-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 20px;
}
.article-breadcrumb a:hover { color: var(--color-primary); }

.article-header {
  margin-bottom: 20px;
}

.article-title {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--color-text);
  margin-bottom: 12px;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--color-text-muted);
  font-size: 13px;
}

.article-source {
  font-weight: 600;
  color: var(--color-primary);
}

.article-thumb {
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
  max-height: 360px;
}
.article-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.article-body {
  margin-bottom: 24px;
}

.ai-briefing {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.ai-briefing-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.ai-badge {
  background: var(--color-primary);
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
}

.ai-badge-desc {
  font-size: 12px;
  color: var(--color-text-muted);
}

.briefing-text {
  font-size: 15px;
  line-height: 1.8;
  color: var(--color-text);
}

.article-original {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}
.article-original h4 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}
.article-original p { font-size: 14px; line-height: 1.6; margin-bottom: 8px; }
.original-text { color: var(--color-text-muted); }

.ad-article-mid {
  margin: 24px 0;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  min-height: 90px;
}

.article-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  font-family: var(--font);
  text-decoration: none;
}
.btn-primary {
  background: var(--color-primary);
  color: white;
}
.btn-primary:hover { background: var(--color-primary-hover); color: white; }
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-border); }

.related-news { margin-top: 32px; }
.related-news h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-border);
}
.related-list { display: flex; flex-direction: column; gap: 12px; }
.related-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: all 0.15s;
}
.related-item:hover { background: var(--color-surface); border-color: var(--color-primary); }
.related-item img {
  width: 80px;
  height: 56px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.related-content p {
  font-size: 13px;
  line-height: 1.4;
  color: var(--color-text);
  margin-top: 4px;
}

/* ===================== CONTENT PAGES ===================== */
.content-section {
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}
.content-section h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}
.policy-date {
  color: var(--color-text-muted);
  font-size: 13px;
  margin-bottom: 32px;
}
.content-body h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 24px 0 10px;
}
.content-body p { margin-bottom: 12px; line-height: 1.7; }
.content-body ul {
  list-style: disc;
  padding-left: 24px;
  margin-bottom: 12px;
}
.content-body li { margin-bottom: 6px; line-height: 1.6; }

.error-page {
  text-align: center;
  padding: 80px 20px;
}
.error-page h1 {
  font-size: 80px;
  font-weight: 800;
  color: var(--color-primary);
  margin-bottom: 16px;
}
.error-page p {
  font-size: 18px;
  color: var(--color-text-muted);
  margin-bottom: 32px;
}

/* ===================== FOOTER ===================== */
.site-footer {
  background: var(--color-header-bg);
  color: #94a3b8;
  padding: 24px 20px;
  margin-top: auto;
}
.footer-inner {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-weight: 700;
}
.footer-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-links a { color: #94a3b8; font-size: 13px; }
.footer-links a:hover { color: #fff; }
.footer-disclaimer {
  margin-left: auto;
  text-align: right;
  font-size: 11px;
}
.footer-disclaimer p { line-height: 1.6; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 1024px) {
  .main-layout {
    flex-direction: column;
    padding: 16px;
  }
  .news-sidebar {
    width: 100%;
    position: static;
    max-height: 480px;
  }
  .chart-grid {
    grid-template-columns: 1fr;
  }
  .chart-card:first-child {
    grid-column: 1;
  }
}

@media (max-width: 768px) {
  .header-inner { gap: 12px; }
  .header-tabs { display: none; }
  .header-date { display: none; }
  .ticker-item { padding: 0 10px; }
  .ticker-item:nth-child(n+6) { display: none; }
  .article-title { font-size: 18px; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
  .footer-disclaimer { text-align: left; margin-left: 0; }
}
