/* ============================================================
   GlobalUpdate Pulse Market - Stylesheet
   Dark/Light theme with CSS custom properties
   ============================================================ */

:root {
  /* Dark theme (default) */
  --bg-primary: #0a0e17;
  --bg-secondary: #131826;
  --bg-tertiary: #1c2333;
  --bg-card: #161c2a;
  --bg-hover: #232b3d;
  --bg-input: #0d121d;

  --text-primary: #e8ecf4;
  --text-secondary: #a8b2c8;
  --text-tertiary: #6b7591;
  --text-muted: #4a5470;

  --border-color: #232b3d;
  --border-hover: #313b54;

  --accent-primary: #10b981;
  --accent-secondary: #059669;
  --accent-glow: rgba(16, 185, 129, 0.3);

  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --info: #3b82f6;

  --bull: #22c55e;
  --bear: #ef4444;
  --neutral: #6b7591;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-glow);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --header-height: 64px;
  --ticker-height: 36px;
  --indices-height: 40px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", monospace;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-hover: #f1f5f9;
  --bg-input: #ffffff;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --text-muted: #94a3b8;

  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;

  --accent-primary: #059669;
  --accent-secondary: #047857;
  --accent-glow: rgba(5, 150, 105, 0.2);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);
}

/* ============================================================
   Reset & Base
   ============================================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 15px;
  transition: background-color 0.3s ease, color 0.3s ease;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
img { max-width: 100%; display: block; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ============================================================
   Breaking News Ticker
   ============================================================ */
.breaking-ticker {
  height: var(--ticker-height);
  background: linear-gradient(90deg, #dc2626, #b91c1c);
  display: flex;
  align-items: center;
  overflow: hidden;
  color: white;
  font-size: 13px;
  font-weight: 600;
}

.ticker-label {
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.3);
  padding: 0 16px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 1px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

.ticker-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.ticker-track {
  display: inline-block;
  white-space: nowrap;
  animation: scroll-ticker 60s linear infinite;
  padding-left: 100%;
}

.ticker-track span {
  margin-right: 50px;
}

.ticker-track .bull { color: #4ade80; }
.ticker-track .bear { color: #fca5a5; }

@keyframes scroll-ticker {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

/* ============================================================
   Header
   ============================================================ */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.header-container {
  width: 100%;
  margin: 0;
  padding: 0 24px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 20px;
  box-sizing: border-box;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.menu-toggle {
  display: none;
  padding: 8px;
  color: var(--text-secondary);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: var(--shadow-glow);
}

.logo-icon.small {
  width: 32px;
  height: 32px;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.logo-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.logo-subtitle {
  font-size: 10px;
  color: var(--accent-primary);
  font-weight: 600;
  letter-spacing: 1.5px;
}

.header-center {
  flex: 1;
  max-width: 500px;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 12px;
  height: 40px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-box svg {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  padding: 0 10px;
  font-size: 14px;
}

.search-box input::placeholder { color: var(--text-muted); }

.search-clear {
  color: var(--text-tertiary);
  font-size: 20px;
  padding: 0 4px;
  line-height: 1;
}

.search-clear:hover { color: var(--text-primary); }

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.2s, color 0.2s;
}

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

.icon-btn .icon-sun { display: none; }
.icon-btn .icon-moon { display: block; }
[data-theme="light"] .icon-btn .icon-sun { display: block; }
[data-theme="light"] .icon-btn .icon-moon { display: none; }

.admin-btn:hover {
  color: var(--accent-primary);
  background: var(--accent-glow);
}

.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* Market Indices Ticker */
.indices-ticker {
  height: var(--indices-height);
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  overflow: hidden;
  display: flex;
  align-items: center;
}

.indices-track {
  display: flex;
  align-items: center;
  animation: scroll-indices 60s linear infinite;
  white-space: nowrap;
  padding-left: 100%;
}

@keyframes scroll-indices {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

.index-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  border-right: 1px solid var(--border-color);
  font-size: 12px;
}

.index-symbol {
  font-weight: 700;
  color: var(--text-primary);
}

.index-value {
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.index-change {
  font-weight: 600;
  font-family: var(--font-mono);
}

.index-change.up { color: var(--bull); }
.index-change.down { color: var(--bear); }

.loading-text {
  color: var(--text-muted);
  padding: 0 20px;
  font-size: 13px;
}

/* ============================================================
   Mobile Menu
   ============================================================ */
.mobile-menu {
  display: none;
  position: fixed;
  top: calc(var(--header-height) + var(--ticker-height) + var(--indices-height));
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 20px;
  z-index: 99;
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.mobile-menu.open { display: block; }

.mobile-menu h3 {
  font-size: 14px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 12px;
  letter-spacing: 1px;
}

.mobile-categories {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.mobile-cat-btn {
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-weight: 600;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-cat-btn:hover, .mobile-cat-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent-primary);
}

/* ============================================================
   Main Container
   ============================================================ */
.main-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 20px;
}

.category-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.category-tab {
  padding: 8px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-tab:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.category-tab.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

.category-tab .count {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.2);
  padding: 1px 6px;
  border-radius: 8px;
}

.category-tab:not(.active) .count {
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
}

/* Content Grid */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
}

/* ============================================================
   Sections
   ============================================================ */
.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title svg { color: var(--accent-primary); }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header .section-title { margin-bottom: 0; }

.refresh-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
}

.refresh-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.refresh-btn.spinning svg { animation: spin 1s linear infinite; }

@keyframes spin {
  100% { transform: rotate(360deg); }
}

.featured-section { margin-bottom: 32px; }

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

/* Article Cards */
.article-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  position: relative;
}

.article-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}

.article-card.featured-main {
  grid-row: span 2;
}

.article-image {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-tertiary);
  overflow: hidden;
}

.article-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.article-card:hover .article-image img { transform: scale(1.05); }

.article-impact-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  backdrop-filter: blur(4px);
}

.article-impact-badge.bullish { background: rgba(34, 197, 94, 0.9); color: white; }
.article-impact-badge.bearish { background: rgba(239, 68, 68, 0.9); color: white; }
.article-impact-badge.neutral { background: rgba(107, 117, 145, 0.9); color: white; }

.article-breaking-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 4px 10px;
  background: var(--danger);
  color: white;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.article-breaking-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

.article-content {
  padding: 16px;
}

.article-category {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-primary);
  margin-bottom: 8px;
}

.article-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-card.featured-main .article-title { font-size: 22px; }

.article-excerpt {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 12px;
}

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

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

.article-meta svg { width: 13px; height: 13px; }

/* Article Grid (latest) */
.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.sidebar-card-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-card-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.sidebar-card-header h3 svg { color: var(--accent-primary); }

.market-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.market-tab {
  flex: 1;
  padding: 6px 10px;
  border-radius: 4px;
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s;
}

.market-tab.active {
  background: var(--accent-primary);
  color: white;
}

.market-list, .indices-list, .tags-list {
  padding: 8px;
}

.market-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

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

.market-icon {
  width: 32px;
  height: 32px;
  background: var(--bg-tertiary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: var(--text-primary);
  flex-shrink: 0;
}

.market-info {
  flex: 1;
  min-width: 0;
}

.market-symbol {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.market-name {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.market-price {
  text-align: right;
  flex-shrink: 0;
}

.price-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.price-change {
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.price-change.up { color: var(--bull); }
.price-change.down { color: var(--bear); }

/* Indices List */
.index-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
}

.index-row:last-child { border-bottom: none; }

.index-row-info { flex: 1; }

.index-row-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.index-row-symbol {
  font-size: 11px;
  color: var(--text-tertiary);
}

.index-row-value {
  text-align: right;
}

.index-row-price {
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.index-row-change {
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.index-row-change.up { color: var(--bull); }
.index-row-change.down { color: var(--bear); }

/* Tags */
.tag-item {
  display: inline-block;
  padding: 4px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  margin: 3px;
  cursor: pointer;
  transition: all 0.2s;
}

.tag-item:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* ============================================================
   Ad Banner
   ============================================================ */
.ad-banner {
  margin: 24px 0;
  min-height: 90px;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* Full-width ad banner at the bottom of the main content viewer */
.ad-banner-bottom {
  width: 100%;
  margin: 32px 0 0;
  min-height: 120px;
  padding: 16px 24px;
}

/* When the banner has a real ad (not the placeholder), make it look like a slot */
.ad-banner.has-banner {
  padding: 12px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}
.ad-banner.has-banner::before {
  content: 'ADVERTISEMENT';
  display: block;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 8px;
}

/* Banner slot inside article preview modal — appears at the very bottom of the article body */
.modal-ad-banner {
  margin: 32px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--border-color);
  text-align: center;
}
.modal-ad-banner-label {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.modal-ad-banner-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
}
.modal-ad-banner-body:empty { display: none; }
.modal-ad-banner-body img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
}

.footer-banner {
  margin-top: 20px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   Modal (Article Detail)
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  backdrop-filter: blur(4px);
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
}

.modal-overlay.open { display: flex; }

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  max-width: 800px;
  width: 100%;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.3s ease;
}

.modal-content.small { max-width: 420px; }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.2s;
}

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

.modal-body { padding: 0; }

.modal-article-image {
  width: 100%;
  aspect-ratio: 21 / 9;
  background: var(--bg-tertiary);
  overflow: hidden;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-article-image img { width: 100%; height: 100%; object-fit: cover; }

.modal-article-content { padding: 32px; }

.modal-article-category {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-primary);
  margin-bottom: 12px;
}

.modal-article-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 16px;
}

.modal-article-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 24px;
  font-size: 13px;
  color: var(--text-tertiary);
}

.modal-article-meta .meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-article-meta svg { width: 14px; height: 14px; }

.modal-article-excerpt {
  font-size: 16px;
  color: var(--text-secondary);
  font-weight: 500;
  line-height: 1.6;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--bg-tertiary);
  border-left: 3px solid var(--accent-primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

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

.modal-article-text p { margin: 0 0 16px 0; }
.modal-article-text p:last-child { margin-bottom: 0; }

.modal-article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.modal-article-tags .tag-item { margin: 0; }

/* ============================================================
   Login Modal
   ============================================================ */
.login-form {
  padding: 40px 32px;
  text-align: center;
}

.login-icon {
  width: 72px;
  height: 72px;
  background: var(--accent-glow);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  color: var(--accent-primary);
}

.login-form h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.login-subtitle {
  color: var(--text-tertiary);
  font-size: 14px;
  margin-bottom: 24px;
}

.form-group {
  text-align: left;
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group textarea { resize: vertical; min-height: 100px; }

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 18px;
}

.login-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 16px;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent-primary);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  transition: background 0.2s;
}

.btn-primary:hover { background: var(--accent-secondary); }

.btn-secondary {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
}

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

.btn-danger {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
}

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

/* ============================================================
   Admin Panel
   ============================================================ */
.admin-panel {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 999;
  overflow-y: auto;
}

.admin-panel.open { display: block; }

.admin-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-header h2 svg { color: var(--accent-primary); }

.admin-actions { display: flex; gap: 8px; }

.admin-tabs {
  display: flex;
  gap: 4px;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  position: sticky;
  top: 65px;
  z-index: 9;
}

.admin-tab {
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.2s;
}

.admin-tab.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

.admin-body { padding: 24px; max-width: 1200px; margin: 0 auto; }

.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.admin-section-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.admin-table {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.admin-table table { width: 100%; border-collapse: collapse; }

.admin-table th {
  background: var(--bg-tertiary);
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.admin-table td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--bg-hover); }

.admin-actions-cell { display: flex; gap: 6px; }

.action-btn {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s;
}

.action-btn.edit {
  background: var(--bg-tertiary);
  color: var(--info);
}

.action-btn.delete {
  background: var(--bg-tertiary);
  color: var(--danger);
}

.action-btn.edit:hover { background: var(--info); color: white; }
.action-btn.delete:hover { background: var(--danger); color: white; }

/* Admin Form */
.admin-form {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 24px;
}

.admin-form h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

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

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

/* Analytics */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.analytics-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
}

.analytics-card .label {
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.analytics-card .value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
}

.analytics-card .change {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 40px 20px 0;
  margin-top: 60px;
}

.footer-container {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
  padding-bottom: 32px;
}

.footer-section h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
}

.footer-section ul { list-style: none; }

.footer-section ul li {
  margin-bottom: 8px;
}

.footer-section ul li a {
  font-size: 13px;
  color: var(--text-tertiary);
  transition: color 0.2s;
}

.footer-section ul li a:hover { color: var(--accent-primary); }

.footer-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.footer-section p {
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.6;
}

.footer-bottom {
  border-top: 1px solid var(--border-color);
  padding: 20px 0;
  text-align: center;
}

.footer-bottom p {
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================================
   Notifications Dropdown
   ============================================================ */
.notif-dropdown {
  display: none;
  position: absolute;
  top: calc(var(--header-height) + 4px);
  right: 80px;
  width: 320px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 200;
}

.notif-dropdown.open { display: block; }

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

.notif-header h3 { font-size: 14px; font-weight: 700; }

.notif-clear {
  font-size: 12px;
  color: var(--accent-primary);
}

.notif-list {
  max-height: 360px;
  overflow-y: auto;
}

.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.2s;
}

.notif-item:hover { background: var(--bg-hover); }
.notif-item:last-child { border-bottom: none; }

.notif-item .title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.notif-item .desc {
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.4;
}

.notif-item .time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================================
   Toast Notifications
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-primary);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.3s ease;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(100px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast .toast-message {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
}

.toast .toast-close {
  color: var(--text-tertiary);
  font-size: 18px;
}

/* ============================================================
   Loading Spinner
   ============================================================ */
.loading-spinner {
  padding: 40px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 14px;
}

.loading-spinner.small { padding: 20px; font-size: 12px; }

.loading-spinner::before {
  content: '';
  display: block;
  width: 30px;
  height: 30px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

.loading-spinner.small::before {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

/* Empty State */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-tertiary);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  color: var(--text-muted);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
  .content-grid { grid-template-columns: 1fr; }
  .sidebar { display: grid; grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .menu-toggle { display: flex; }
  .header-center { display: none; }
  .featured-grid { grid-template-columns: 1fr; }
  .article-card.featured-main { grid-row: auto; }
  .sidebar { grid-template-columns: 1fr; }
  .footer-container { grid-template-columns: 1fr 1fr; }
  .modal-article-content { padding: 20px; }
  .modal-article-title { font-size: 22px; }
  .form-row { grid-template-columns: 1fr; }
  .admin-body { padding: 16px; }
  .admin-tabs { padding: 12px 16px; }
}

@media (max-width: 480px) {
  .footer-container { grid-template-columns: 1fr; }
  .header-container { padding: 0 12px; gap: 8px; }
  .logo-text { display: none; }
  .main-container { padding: 16px 12px; }
  .article-grid { grid-template-columns: 1fr; }
  .notif-dropdown { right: 12px; left: 12px; width: auto; }
}

/* Print */
@media print {
  .header, .footer, .sidebar, .breaking-ticker, .indices-ticker, .category-tabs, .refresh-btn, .admin-btn, .icon-btn { display: none !important; }
  body { background: white; color: black; }
}

/* ============================================================
   v3 Enhancements - Banners, Bot, Analytics Charts, Bulk Actions
   ============================================================ */

/* ----- Bot Panel ----- */
.bot-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.bot-info {
  padding: 16px;
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 10px;
}
.bot-info h4 { margin: 0 0 6px 0; color: #10b981; font-size: 16px; }
.bot-info p { margin: 0; font-size: 13px; color: var(--muted-foreground); line-height: 1.5; }
.bot-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.bot-form .form-group { display: flex; flex-direction: column; gap: 6px; }
.bot-form label { font-size: 12px; color: var(--muted-foreground); font-weight: 600; }
.bot-form select, .bot-form input {
  padding: 8px 12px;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--foreground);
  font-size: 14px;
}
.bot-success {
  padding: 16px;
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 10px;
}
.bot-success h4 { margin: 0 0 12px 0; color: #10b981; }
.bot-article-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.bot-article-item {
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.bot-article-item strong { font-size: 14px; display: block; margin-bottom: 4px; }
.bot-article-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--muted-foreground);
  align-items: center;
  flex-wrap: wrap;
}
.badge-featured {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
}
.badge-breaking {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
}

/* ----- Analytics Charts (CSS bar charts) ----- */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.analytics-card {
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.analytics-card .label { font-size: 11px; color: var(--muted-foreground); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.analytics-card .value { font-size: 26px; font-weight: 700; margin: 4px 0; }
.analytics-card .change { font-size: 11px; color: var(--muted-foreground); }

.device-bars { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.device-bar {
  display: grid;
  grid-template-columns: 60px 1fr 30px;
  gap: 8px;
  align-items: center;
  font-size: 11px;
}
.device-bar span { color: var(--muted-foreground); }

.chart-row {
  display: grid;
  grid-template-columns: 100px 1fr 36px;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  font-size: 12px;
}
.chart-label {
  color: var(--muted-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  transition: width 0.4s ease;
  border-radius: 4px;
}

/* ----- Banner Active/Inactive Badges ----- */
.badge-active {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-inactive {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(107, 114, 128, 0.15);
  color: var(--muted-foreground);
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}
.banner-preview-cell img { display: block; }

/* ----- Bulk Select for Articles Table ----- */
.admin-table table th.col-bulk,
.admin-table table td.col-bulk {
  width: 36px;
  text-align: center;
}
.admin-table table th.col-bulk input,
.admin-table table td.col-bulk input {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #10b981;
}
.bulk-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
}
.bulk-actions strong { color: #ef4444; }

/* ----- Admin Form Row Layout ----- */
.admin-form .form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.admin-form .form-row .form-group { margin-bottom: 0; }

/* ----- Responsive: hide sidebar in admin tabs on mobile ----- */
@media (max-width: 768px) {
  .bot-form { grid-template-columns: 1fr; }
  .analytics-grid { grid-template-columns: 1fr; }
  .chart-row { grid-template-columns: 80px 1fr 30px; }
}

/* ============================================================
   v4 Enhancements - Realtime Live Badges, Refresh Buttons, Source Tags
   ============================================================ */

/* ----- LIVE Badge ----- */
.live-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-left: 6px;
  vertical-align: middle;
  gap: 4px;
}
.live-badge.live {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.live-badge.live::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  animation: live-pulse 1.5s ease-in-out infinite;
}
.live-badge.static {
  background: rgba(107, 114, 128, 0.15);
  color: var(--muted-foreground);
  border: 1px solid rgba(107, 114, 128, 0.3);
}
.live-badge.updating {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.4); }
}

/* ----- Mini Refresh Button ----- */
.refresh-mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  margin-left: 6px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted-foreground);
  cursor: pointer;
  vertical-align: middle;
  transition: all 0.2s;
}
.refresh-mini-btn:hover {
  background: var(--accent);
  color: var(--foreground);
  border-color: var(--accent-foreground);
}
.refresh-mini-btn.spinning svg {
  animation: spin 1s linear infinite;
}
.refresh-mini-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ----- Market Source Indicator ----- */
.market-source {
  font-size: 10px;
  color: var(--muted-foreground);
  padding: 4px 0 8px 0;
  font-style: italic;
}

/* ----- Market / Index Source Tag (per-item) ----- */
.market-source-tag {
  color: #10b981;
  font-size: 8px;
  vertical-align: super;
  margin-left: 2px;
  animation: live-pulse 2s ease-in-out infinite;
}

/* ----- Header Title with inline elements ----- */
.sidebar-card-header h3 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

/* ----- Forex market items (USD/JPY symbol has slash) ----- */
.market-symbol {
  word-break: keep-all;
}

/* ----- Responsive: stack the live badges ----- */
@media (max-width: 768px) {
  .sidebar-card-header h3 { font-size: 14px; }
  .live-badge { font-size: 8px; padding: 1px 6px; }
  .refresh-mini-btn { width: 20px; height: 20px; }
}
