/* ============================================================
   reports.css — Tab Báo cáo Phân tích (RSS Stockbiz)
   ============================================================ */

/* ---- Panel container ---- */
#reports-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: calc(100vh - 0px);
  background: var(--bg-primary);
  overflow-y: auto;
  overflow-x: hidden;
}

/* ---- Header banner ---- */
.reports-header {
  background: linear-gradient(135deg, #0d1526 0%, #0a1628 50%, #060c18 100%);
  border-bottom: 1px solid var(--border-strong);
  padding: 1.6rem 1.8rem 1.4rem;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.reports-header::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59,130,246,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.reports-header-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}

.reports-header-title i {
  font-size: 1.25rem;
  color: var(--accent);
  filter: drop-shadow(0 0 8px rgba(59,130,246,0.5));
}

.reports-header-title h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.02em;
  margin: 0;
}

.reports-header-title span {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-left: 0.25rem;
}

/* ---- Stats bar ---- */
.reports-stats-bar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.reports-stat-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.85rem;
  min-width: 110px;
  transition: background 0.2s;
}

.reports-stat-card:hover {
  background: rgba(255,255,255,0.07);
}

.reports-stat-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.reports-stat-icon.blue  { background: rgba(59,130,246,0.15); color: #60a5fa; }
.reports-stat-icon.green { background: rgba(0,230,118,0.1);   color: var(--clr-up); }
.reports-stat-icon.purple{ background: rgba(168,85,247,0.12); color: #c084fc; }

.reports-stat-data {
  display: flex;
  flex-direction: column;
}

.reports-stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.reports-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  margin-top: 1px;
}

/* ---- Toolbar ---- */
.reports-toolbar {
  padding: 0.85rem 1.8rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.reports-search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 380px;
}

.reports-search-box i.search-ic {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.8rem;
  pointer-events: none;
}

.reports-search-box input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.82rem;
  padding: 0.52rem 0.75rem 0.52rem 2.1rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.reports-search-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

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

.reports-search-clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
  font-size: 0.8rem;
  line-height: 1;
  display: none;
  transition: color 0.2s;
}

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

.reports-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.reports-select-wrap i {
  position: absolute;
  left: 0.65rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  pointer-events: none;
  z-index: 1;
}

.reports-select-wrap select {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.8rem;
  padding: 0.52rem 0.7rem 0.52rem 2rem;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  transition: border-color 0.2s;
  min-width: 140px;
}

.reports-select-wrap select:focus {
  outline: none;
  border-color: var(--accent);
}

.reports-refresh-btn {
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.52rem 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: opacity 0.2s, transform 0.15s;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}

.reports-refresh-btn:hover { opacity: 0.88; transform: translateY(-1px); }
.reports-refresh-btn:active { transform: translateY(0); }

/* ---- Category Tabs ---- */
.reports-category-nav {
  padding: 0 1.8rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.reports-category-nav::-webkit-scrollbar { display: none; }

.reports-cat-tabs {
  display: flex;
  gap: 0;
  min-width: max-content;
}

.rpt-cat-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.7rem 1rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.rpt-cat-btn i { font-size: 0.82rem; }

.rpt-cat-btn:hover {
  color: var(--text-primary);
}

.rpt-cat-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ---- Table area ---- */
.reports-content-area {
  flex: 1;
  padding: 0.85rem 1.8rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-height: 0;
}

/* Loading */
.reports-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  gap: 0.8rem;
}

.reports-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: rpt-spin 0.8s linear infinite;
}

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

.reports-loader p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Error / No results */
.reports-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1rem;
  gap: 0.6rem;
  text-align: center;
}

.reports-empty-state i {
  font-size: 2.2rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.reports-empty-state h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0;
}

.reports-empty-state p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
}

.reports-empty-state button {
  margin-top: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.8rem;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}

.reports-empty-state button:hover { background: var(--bg-card-hover); }

/* ---- Table ---- */
.reports-table-scroll {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.reports-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 560px;
}

.reports-table thead tr {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-strong);
}

.reports-table thead th {
  padding: 0.65rem 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  text-align: left;
}

.reports-table thead th.center { text-align: center; }

.reports-table tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.reports-table tbody tr:last-child { border-bottom: none; }

.reports-table tbody tr:nth-child(even) {
  background: rgba(255,255,255,0.015);
}

.reports-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.reports-table td {
  padding: 0.65rem 0.9rem;
  vertical-align: middle;
}

/* Ticker badge */
.rpt-ticker-tag {
  display: inline-block;
  padding: 0.22rem 0.55rem;
  border-radius: 5px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, rgba(59,130,246,0.2), rgba(139,92,246,0.2));
  color: #93c5fd;
  border: 1px solid rgba(59,130,246,0.25);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.rpt-ticker-tag.market {
  background: linear-gradient(135deg, rgba(168,85,247,0.2), rgba(236,72,153,0.2));
  color: #d8b4fe;
  border-color: rgba(168,85,247,0.25);
}

/* Title */
.rpt-title-text {
  color: var(--text-primary);
  font-weight: 500;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 480px;
}

/* Broker badge */
.rpt-broker-tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
  transition: background 0.15s;
}

tr:hover .rpt-broker-tag {
  background: rgba(255,255,255,0.09);
}

/* Date */
.rpt-date-cell {
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* PDF button */
.rpt-pdf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.2);
  color: #fca5a5;
  font-size: 0.82rem;
  text-decoration: none;
  transition: background 0.2s, transform 0.15s;
}

.rpt-pdf-btn:hover {
  background: rgba(239,68,68,0.22);
  transform: scale(1.1);
}

/* ---- Pagination ---- */
.reports-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0;
  flex-wrap: wrap;
}

.rpt-page-btn {
  min-width: 32px;
  height: 32px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.78rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s;
  font-family: inherit;
  padding: 0 0.5rem;
}

.rpt-page-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

.rpt-page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

.rpt-page-btn.disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.rpt-page-ellipsis {
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 0 0.2rem;
}

/* ---- Sync time ---- */
.reports-sync-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 1.8rem 0.5rem;
  gap: 0.35rem;
  flex-shrink: 0;
}

.reports-sync-row i { font-size: 0.75rem; color: var(--clr-up); }
.reports-sync-row span { font-size: 0.78rem; color: var(--text-muted); }
.reports-sync-time { color: var(--text-secondary) !important; font-variant-numeric: tabular-nums; }

/* ============================================================
   MODAL Chi Tiết Báo Cáo
   ============================================================ */
.report-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  overflow-y: auto;
}

.report-modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.report-modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 780px;
  position: relative;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.25s ease;
  overflow: hidden;
  flex-shrink: 0;
}

.report-modal-overlay.open .report-modal-card {
  transform: translateY(0) scale(1);
}

.report-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: background 0.2s, color 0.2s;
  z-index: 2;
}

.report-modal-close:hover {
  background: rgba(255,255,255,0.12);
  color: var(--text-primary);
}

.report-modal-header {
  padding: 1.4rem 1.5rem 1rem;
  background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-card) 100%);
  border-bottom: 1px solid var(--border);
}

.report-modal-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}

#rpt-modal-ticker {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 800;
  background: linear-gradient(135deg, rgba(59,130,246,0.25), rgba(139,92,246,0.25));
  color: #93c5fd;
  border: 1px solid rgba(59,130,246,0.3);
  letter-spacing: 0.05em;
}

.report-modal-author,
.report-modal-date-info {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.report-modal-author i,
.report-modal-date-info i {
  font-size: 0.7rem;
  color: var(--text-muted);
}

#rpt-modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.45;
  margin: 0;
}

.report-modal-divider {
  height: 1px;
  background: var(--border);
}

.report-modal-body-wrap {
  padding: 1.2rem 1.5rem;
  max-height: 55vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.report-modal-body-wrap::-webkit-scrollbar { width: 5px; }
.report-modal-body-wrap::-webkit-scrollbar-track { background: transparent; }
.report-modal-body-wrap::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.report-modal-body {
  font-size: 0.84rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.report-modal-body p,
.report-modal-body div { margin-bottom: 0.5rem; color: var(--text-secondary); }
.report-modal-body strong { color: var(--text-primary); }
.report-modal-body ul, .report-modal-body ol { padding-left: 1.2rem; }
.report-modal-body li { margin-bottom: 0.3rem; }

.report-modal-footer {
  padding: 0.9rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: var(--bg-secondary);
}

.rpt-modal-pdf-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  transition: opacity 0.2s, transform 0.15s;
  font-family: inherit;
}

.rpt-modal-pdf-btn:hover { opacity: 0.88; transform: translateY(-1px); }

.rpt-modal-stockbiz-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.78rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: background 0.2s, color 0.2s;
}

.rpt-modal-stockbiz-link:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* ============================================================
   RESPONSIVE — Mobile
   ============================================================ */
@media (max-width: 768px) {
  .reports-header {
    padding: 1.1rem 1rem 1rem;
  }

  .reports-stats-bar {
    gap: 0.5rem;
  }

  .reports-stat-card {
    flex: 1;
    min-width: 90px;
    padding: 0.45rem 0.65rem;
  }

  .reports-toolbar {
    padding: 0.7rem 1rem;
    gap: 0.5rem;
  }

  .reports-search-box {
    max-width: 100%;
    flex: 1 1 100%;
    order: -1;
  }

  .reports-select-wrap select {
    min-width: 100px;
    font-size: 0.75rem;
  }

  .reports-category-nav {
    padding: 0 1rem;
  }

  .rpt-cat-btn {
    font-size: 0.75rem;
    padding: 0.6rem 0.8rem;
  }

  .reports-content-area {
    padding: 0.65rem 0.75rem 1.2rem;
  }

  .reports-sync-row {
    padding: 0 0.75rem 0.4rem;
  }

  .reports-table {
    font-size: 0.78rem;
  }

  .reports-table thead th,
  .reports-table td {
    padding: 0.55rem 0.65rem;
  }

  .rpt-title-text {
    max-width: 240px;
  }

  /* Modal mobile */
  .report-modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .report-modal-card {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    max-width: 100%;
  }

  .report-modal-body-wrap {
    max-height: none;
    flex: 1;
    overflow-y: auto;
  }

  .report-modal-header {
    padding: 1rem 1.1rem 0.8rem;
  }

  #rpt-modal-title {
    font-size: 0.9rem;
  }

  .report-modal-footer {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
  }
}

/* ---- LIGHT THEME OVERRIDES FOR BETTER CONTRAST ---- */
[data-theme="light"] .rpt-ticker-tag {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(139, 92, 246, 0.12));
  color: #1d4ed8 !important;
  border-color: rgba(59, 130, 246, 0.35);
}

[data-theme="light"] .rpt-ticker-tag.market {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.12), rgba(236, 72, 153, 0.12));
  color: #6d28d9 !important;
  border-color: rgba(168, 85, 247, 0.35);
}

[data-theme="light"] #rpt-modal-ticker {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(139, 92, 246, 0.15));
  color: #1d4ed8 !important;
  border-color: rgba(59, 130, 246, 0.4);
}

[data-theme="light"] .rpt-pdf-btn {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.25);
  color: #b91c1c;
}

[data-theme="light"] .rpt-pdf-btn:hover {
  background: rgba(239, 68, 68, 0.18);
  color: #991b1b;
}

[data-theme="light"] .report-modal-close:hover {
  background: rgba(0, 0, 0, 0.12);
  color: var(--text-primary);
}

/* ---- TOP TICKERS / HOT SECTION ---- */
.rpt-hot-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.8rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 0.8rem;
}

.rpt-hot-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.rpt-hot-title i {
  color: #f97316;
}

.rpt-hot-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.rpt-hot-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.65rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
}

.rpt-hot-chip:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.rpt-hot-chip.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(139, 92, 246, 0.2));
  border-color: var(--accent);
  color: var(--text-primary);
  font-weight: 700;
  box-shadow: 0 0 0 1px var(--accent-glow);
}

.rpt-hot-chip .chip-sym {
  font-weight: 700;
  color: var(--accent);
}

.rpt-hot-chip .chip-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

[data-theme="light"] .rpt-hot-chip .chip-count {
  background: rgba(0, 0, 0, 0.05);
}

