/* Components: Modular Blocks, Chat, Media, Watchlist, News, Charts */

/* ==================== MODULAR BLOCK FRAME ==================== */
.modular-block {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-surface);
  position: relative;
  flex: 1 1 0;
  min-height: 0;
}

.block-header {
  height: 38px;
  padding: 0 10px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #10141e;
  flex-shrink: 0;
  z-index: 6;
}

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

.block-type-dropdown-wrapper {
  position: relative;
}

.block-type-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 12px;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.block-type-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-blue);
}

.block-type-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: #141924;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 4px;
  min-width: 170px;
  display: none;
  flex-direction: column;
  z-index: 50;
}

.block-type-menu.show {
  display: flex;
}

.type-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 11px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  text-align: left;
  width: 100%;
}

.type-menu-item:hover {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
}

.type-menu-item.active {
  color: var(--accent-blue);
  font-weight: 600;
  background: rgba(59, 130, 246, 0.08);
}

.block-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.block-action-btn {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.03);
}

.block-action-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-blue);
}

.block-v-resizer {
  height: 4px;
  background-color: var(--border-color);
  cursor: row-resize;
  flex-shrink: 0;
  z-index: 4;
}

.block-v-resizer:hover {
  background-color: var(--accent-blue);
}

.block-body {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Tab Sub-headers */
.sub-tabs {
  display: flex;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 8px;
  gap: 4px;
  flex-shrink: 0;
}

.sub-tab-btn {
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
}

.sub-tab-btn:hover {
  color: var(--text-primary);
}

.sub-tab-btn.active {
  color: var(--accent-blue);
  border-bottom-color: var(--accent-blue);
  font-weight: 600;
}

/* Up & Down Indicators */
.val-up { color: var(--color-up); }
.val-down { color: var(--color-down); }
.val-neutral { color: var(--color-neutral); }

.badge-up {
  background: var(--color-up-bg);
  color: var(--color-up);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.badge-down {
  background: var(--color-down-bg);
  color: var(--color-down);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* ==================== 1. NEWS BLOCK ==================== */
.news-block-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  height: 100%;
}

.news-feed {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}

.news-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.news-card:hover {
  border-color: #3b4560;
  background: var(--bg-card-hover);
}

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

.news-source {
  font-size: 9px;
  color: var(--accent-blue);
  font-weight: 700;
  text-transform: uppercase;
}

.news-time {
  font-size: 9px;
  color: var(--text-muted);
}

.news-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  margin-bottom: 4px;
}

.news-snippet {
  font-size: 10.5px;
  color: var(--text-secondary);
  line-height: 1.3;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 9.5px;
  color: var(--text-muted);
  border-top: 1px dashed var(--border-color);
  padding-top: 4px;
}

.news-tags {
  display: flex;
  gap: 4px;
}

.news-tag {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
}

.news-stats {
  display: flex;
  gap: 6px;
  align-items: center;
}

.news-stat-item {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* ==================== 2. WATCHLIST BLOCK ==================== */
.watchlist-block-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  height: 100%;
}

.watchlist-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-right: 8px;
  flex-shrink: 0;
}

.watchlist-search-inline input {
  padding: 3px 6px;
  font-size: 11px;
  width: 90px;
}

.watchlist-table-wrapper {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
}

.watchlist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  text-align: left;
}

.watchlist-table th {
  position: sticky;
  top: 0;
  background-color: #10141e;
  color: var(--text-muted);
  font-weight: 600;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border-color);
  z-index: 2;
}

.watchlist-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.watchlist-table tr {
  cursor: pointer;
}

.watchlist-table tr:hover {
  background-color: var(--bg-card-hover);
}

.watchlist-table tr.selected {
  background-color: rgba(59, 130, 246, 0.12);
}

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

.ticker-name {
  font-size: 9.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

.sparkline-svg {
  width: 55px;
  height: 18px;
  vertical-align: middle;
}

/* ==================== 3. CHART BLOCK ==================== */
.chart-block-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  height: 100%;
}

.chart-top-summary {
  padding: 8px 10px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.symbol-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.symbol-title {
  font-size: 16px;
  font-weight: 800;
  font-family: var(--font-mono);
}

.symbol-desc {
  font-size: 10px;
  color: var(--text-muted);
}

.symbol-price-group {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.current-price {
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-mono);
}

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

.chart-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background: #10141e;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.timeframe-selector {
  display: flex;
  gap: 2px;
}

.tf-btn {
  padding: 2px 6px;
  font-size: 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.tf-btn.active {
  background: var(--accent-blue);
  color: #fff;
  font-weight: 600;
}

.chart-container-wrapper {
  flex: 1 1 0;
  min-height: 120px;
  position: relative;
  background-color: #0b0e14;
}

canvas[id^="canvas_"] {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.stat-card {
  background: var(--bg-card);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.stat-label {
  font-size: 9px;
  color: var(--text-muted);
}

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

/* ==================== 4. CHAT BLOCK ==================== */
.chat-block-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  height: 100%;
}

.chat-stream-container {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msg-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.chat-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #232a3d;
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.chat-msg-content {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 10px;
}

.chat-msg-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.chat-username {
  font-weight: 700;
  font-size: 11px;
  color: var(--text-primary);
}

.chat-role-badge {
  font-size: 9px;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.role-vip { background: rgba(234, 179, 8, 0.15); color: #eab308; }
.role-expert { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.role-member { background: rgba(255, 255, 255, 0.08); color: var(--text-muted); }

.chat-time {
  font-size: 9px;
  color: var(--text-muted);
  margin-left: auto;
}

.chat-text {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.chat-input-bar {
  display: flex;
  padding: 6px 8px;
  background: #10141e;
  border-top: 1px solid var(--border-color);
  gap: 6px;
  flex-shrink: 0;
}

.chat-input-bar input {
  flex: 1;
  padding: 6px 10px;
}

.btn-send-chat {
  background: var(--accent-blue);
  color: #fff;
  padding: 0 10px;
  border-radius: var(--radius-sm);
}

.btn-send-chat:hover {
  background: var(--accent-blue-hover);
}

/* ==================== 5. MEDIA BLOCK ==================== */
.media-block-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  height: 100%;
}

.media-content-scroll {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.media-item-card {
  display: flex;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px;
  cursor: pointer;
}

.media-item-card:hover {
  border-color: #3b4560;
  background: var(--bg-card-hover);
}

.media-thumb-box {
  width: 90px;
  height: 55px;
  background: #0d1017;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.play-icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
  color: rgba(255, 255, 255, 0.7);
}

.media-duration {
  position: absolute;
  bottom: 3px;
  right: 4px;
  font-size: 9px;
  background: rgba(0, 0, 0, 0.8);
  padding: 1px 3px;
  border-radius: 2px;
  font-family: var(--font-mono);
}

.media-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.media-item-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.media-item-meta {
  font-size: 9.5px;
  color: var(--text-muted);
}

/* Livestream & Podcast Items */
.live-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px;
}

.live-screen-mock {
  height: 110px;
  background: #090c12;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 6px;
}

.live-pill {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.live-viewers-count {
  position: absolute;
  bottom: 6px;
  right: 6px;
  font-size: 9px;
  color: var(--text-muted);
}

.podcast-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 10px;
}

.podcast-icon-box {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(59, 130, 246, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.podcast-info {
  flex: 1;
}

.btn-play-podcast {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}

.btn-play-podcast:hover {
  background: var(--accent-blue);
  color: #fff;
}

/* ==================== MODAL ARTICLE VIEW (ROBUST DISPLAY NONE/FLEX) ==================== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal-overlay.active {
  display: flex !important;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 620px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  position: relative;
  display: flex;
  flex-direction: column;
}

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

.modal-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 700;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-close-btn:hover {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

.modal-footer {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

.btn-modal-close-action {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn-modal-close-action:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}
