/* ========================================================================
   NEWS FEED STYLING
   ======================================================================== */

.news-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--primary-bg);
  color: var(--text-primary);
}

/* Header with source menu and search */
.news-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 5px;
  position: sticky;
  margin-bottom: 20px;
  z-index: 10;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.news-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.news-header-title-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.news-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.news-header-menu-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}

.news-header-menu-btn:hover,
.news-header-menu-btn:focus-visible {
  background: rgba(124, 58, 237, 0.12);
  color: var(--gradient-start);
  outline: none;
}

.news-header-menu-btn i {
  font-size: 18px;
}

.news-source-menu {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.news-source-btn {
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.news-source-btn:hover,
.news-source-btn.active {
  background: var(--gradient-start);
  color: white;
  border-color: var(--gradient-start);
}

/* Search box */
.news-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(124, 58, 237, 0.08);
  border: 1px solid rgba(124, 58, 237, 0.2);
  padding: 8px 12px;
  border-radius: 8px;
}

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

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

.news-search-box i {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Date range controls */
.news-date-range {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.news-date-presets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.news-date-preset-btn {
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.news-date-preset-btn:hover,
.news-date-preset-btn.active {
  background: var(--gradient-start);
  color: white;
  border-color: var(--gradient-start);
}

.news-date-inputs {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.news-date-input {
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  flex: 1;
  min-width: 120px;
}

.news-date-input:focus {
  border-color: rgba(124, 58, 237, 0.5);
  box-shadow: 0 0 4px rgba(124, 58, 237, 0.2);
}

.news-date-apply-btn {
  padding: 6px 12px;
  background: var(--gradient-start);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.news-date-apply-btn:hover {
  opacity: 0.9;
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.3);
}

/* Controls row (page size selector) */
.news-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
}

.news-page-size {
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
}

/* News feed container */
.news-feed {
  flex: 1;
  overflow-y: auto;
  padding: 0px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Individual news card */
.news-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  padding-right: clamp(180px, 26vw, 320px);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.2s ease;
  position: relative;
}

.news-card:hover {
  border-color: rgba(124, 58, 237, 0.4);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.1);
}

.news-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.news-card-fav-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: var(--muted, var(--text-secondary));
}

.news-card-fav-btn:hover {
  opacity: 0.8;
  transform: scale(1.1);
}

.news-card-fav-btn:focus {
  outline: none;
}

.news-card-symbol {
  font-size: 16px;
  font-weight: 700;
  color: var(--gradient-start);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.news-card-symbol:hover {
  background: rgba(124, 58, 237, 0.1);
}

.news-card-price {
  font-size: 12px;
  color: var(--text-secondary);
}

.news-card-symbol-text {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--gradient-start);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.news-card-symbol-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.news-card-financials-inline {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}
.news-card-financials-float {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
  width: min(420px, 100%);
}
.news-card-financials-inline .news-financials {
  background: transparent;
  border: none;
  padding: 0;
  gap: 4px;
  display: grid;
  grid-template-columns: repeat(3, minmax(60px, auto));
  grid-auto-rows: auto;
  justify-content: flex-end;
  align-items: stretch;
  width: max-content;
}
.news-card-financials-inline .news-financial-item {
  padding: 0;
}
.news-financial-value.news-financial-change {
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.news-financial-value.news-financial-change.positive {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
}
.news-financial-value.news-financial-change.negative {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}
.news-card-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: color 0.2s ease;
  margin: 0;
  padding: 0;
  line-height: 1.4;
}

.news-card-title:hover {
  color: var(--gradient-start);
}

.news-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.news-card-content {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-card-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-secondary);
  align-items: center;
  flex-wrap: wrap;
}

.news-source-tag {
  background: rgba(124, 58, 237, 0.1);
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
}

/* Financial metrics box */
.news-financials {
  display: flex;
  gap: 8px;
  padding: 8px;
  background: rgba(124, 58, 237, 0.04);
  border-radius: 6px;
  flex-wrap: wrap;
}

.news-financial-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 60px;
}

.news-financial-label {
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
}

.news-financial-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Pagination */
.news-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: var(--card-bg);
  border-top: 1px solid var(--border-color);
}

.news-pagination-btn {
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
}

.news-pagination-btn:hover {
  background: rgba(124, 58, 237, 0.1);
  border-color: rgba(124, 58, 237, 0.3);
}

.news-pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.news-pagination-btn.active {
  background: var(--gradient-start);
  color: white;
  border-color: var(--gradient-start);
}

.news-pagination-info {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0 8px;
}

/* Empty state */
.news-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: var(--text-secondary);
  font-size: 14px;
}

.news-empty i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

/* Loading state */
.news-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  color: var(--text-secondary);
  font-size: 13px;
  gap: 12px;
  min-height: 200px;
}

.news-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(124, 58, 237, 0.2);
  border-top-color: rgb(124, 58, 237);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

/* Responsive */
@media (max-width: 768px) {
  .news-header-top {
    flex-direction: column;
    align-items: stretch;
  }

  .news-source-menu {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }

  .news-date-inputs {
    flex-direction: column;
  }

  .news-date-input {
    min-width: 100%;
  }

  .news-date-apply-btn {
    min-width: 100%;
  }

  .news-card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .news-card-financials-inline {
    justify-content: flex-start;
  }

  .news-card-financials-inline .news-financials {
    display: flex;
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .news-card-financials-inline .news-financial-item {
    flex: 0 0 auto;
    min-width: 90px;
  }

  .news-card-financials-inline .news-financials::-webkit-scrollbar {
    height: 5px;
  }

  .news-card-financials-inline .news-financials::-webkit-scrollbar-thumb {
    background: rgba(124, 58, 237, 0.4);
    border-radius: 99px;
  }

  .news-card {
    padding-right: 12px;
  }

  .news-card-financials-float {
    position: static;
    width: 100%;
    margin-top: 6px;
    pointer-events: auto;
    order: 99; /* push to the bottom of the card (card is column flex) */
    background: transparent;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .news-card-financials-float .news-financials {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding: 6px 2px;
  }

  .news-card-financials-float .news-financials::-webkit-scrollbar {
    height: 6px;
  }

  .news-card-financials-float .news-financials::-webkit-scrollbar-thumb {
    background: rgba(124, 58, 237, 0.25);
    border-radius: 99px;
  }
}
