/*
 * Depends on:
 * - index.html inline app shell tokens: --bg-page, --bg-white, --border, --text-*, --accent, --radius
 * - Channel analysis DOM ids/classes rendered by index.html: #tab-channel, #channelDashboard, .ch-*
 */

#tab-channel .channel-workspace {
  padding: 0;
  overflow: hidden;
  border-color: rgba(24, 24, 27, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 1) 36%),
    radial-gradient(circle at 0 0, rgba(255, 0, 0, 0.08), transparent 34%);
}

.channel-hero {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-light);
  background:
    linear-gradient(135deg, rgba(255, 0, 0, 0.06), rgba(255, 255, 255, 0) 42%),
    #fff;
}

.channel-hero h1 {
  margin: 0;
  color: var(--accent);
  font-size: clamp(0.86rem, 1.05vw, 1rem);
  line-height: 1.2;
  letter-spacing: 0;
  text-transform: uppercase;
}

.channel-hero p {
  max-width: 640px;
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  line-height: 1.5;
}

#btnChannelReport {
  white-space: nowrap;
}

.channel-dashboard {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.channel-loading-card {
  margin: 24px;
  padding: 52px 20px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: #fff;
}

.channel-overview,
.channel-section {
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 34px rgba(17, 24, 39, 0.05);
}

.channel-overview {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  overflow: hidden;
}

.channel-overview #channelProfile,
.channel-overview #channelStats {
  min-width: 0;
}

.ch-profile {
  min-height: 104px;
  margin: 0;
  padding: 18px 24px;
  align-items: center;
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 16px;
  background:
    linear-gradient(135deg, rgba(255, 0, 0, 0.055), rgba(255, 255, 255, 0) 46%),
    #fff;
  border: 0;
  border-bottom: 1px solid var(--border-light);
  border-radius: 0;
}

.ch-profile img {
  width: 68px;
  height: 68px;
  border: 3px solid #fff;
  box-shadow: 0 7px 18px rgba(17, 24, 39, 0.1);
}

.ch-profile-info {
  min-width: 0;
  max-width: 1180px;
}

.ch-profile-info span {
  display: inline-flex;
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.ch-profile-info h3 {
  margin-bottom: 0;
  font-size: clamp(1.08rem, 1.55vw, 1.34rem);
  line-height: 1.25;
  letter-spacing: 0;
}

.ch-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  background: #fff;
}

.ch-stat-card {
  display: flex;
  min-height: 92px;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  padding: 18px 24px;
  border: 0;
  border-right: 1px solid var(--border-light);
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(250, 250, 250, 0.96), #fff);
  text-align: left;
}

.ch-stat-card:last-child {
  border-right: 0;
}

.ch-stat-label {
  order: 0;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.ch-stat-value {
  order: 1;
  margin: 0;
  color: var(--text-primary);
  font-size: clamp(1.35rem, 2.35vw, 1.8rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.channel-section {
  padding: 22px;
}

.channel-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.channel-section-head p {
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.ch-section-title {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.02rem;
  line-height: 1.25;
  letter-spacing: 0;
}

.ch-filter-tabs {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: #f7f8fa;
}

.ch-filter-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.ch-filter-tab:hover {
  color: var(--text-primary);
}

.ch-filter-tab.active {
  background: #fff;
  color: var(--accent);
  border-color: transparent;
  box-shadow: 0 2px 10px rgba(17, 24, 39, 0.08);
}

.ch-avg-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 0, 0, 0.11);
  border-radius: var(--radius-sm);
  background: rgba(255, 0, 0, 0.035);
}

.ch-avg-row span {
  color: #b91c1c;
  font-size: 0.76rem;
  font-weight: 800;
}

.ch-avg-row strong {
  color: var(--text-primary);
  font-size: 0.96rem;
}

.ch-avg-row small {
  min-width: 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-align: right;
}

.ch-video-grid {
  display: grid;
  gap: 10px;
}

.channel-load-more {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.channel-more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid rgba(255, 0, 0, 0.16);
  border-radius: 999px;
  background: rgba(255, 0, 0, 0.045);
  color: var(--accent);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 850;
  line-height: 1;
  transition: all 0.18s ease;
}

.channel-more-btn:hover {
  border-color: rgba(255, 0, 0, 0.28);
  background: rgba(255, 0, 0, 0.08);
  box-shadow: 0 8px 18px rgba(255, 0, 0, 0.08);
  transform: translateY(-1px);
}

.channel-more-btn span {
  color: inherit;
  font-size: 0.7rem;
  line-height: 1;
}

.ch-video-wrapper {
  margin: 0;
}

.ch-video-item {
  grid-template-columns: 132px minmax(0, 1fr) minmax(152px, auto);
  gap: 16px;
  min-height: 102px;
  padding: 12px;
  border-color: var(--border-light);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 0 rgba(17, 24, 39, 0.02);
}

.ch-video-item:hover {
  border-color: rgba(255, 0, 0, 0.22);
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.07);
  transform: translateY(-1px);
}

.ch-video-item.expanded {
  border-color: rgba(255, 0, 0, 0.2);
}

.ch-video-thumb {
  width: 132px;
  height: 74px;
  border-radius: 8px;
  background: #f1f3f5;
}

.ch-video-info {
  min-width: 0;
}

.ch-video-info h4 {
  display: -webkit-box;
  margin-bottom: 8px;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 0.92rem;
  font-weight: 750;
  line-height: 1.42;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ch-video-info span {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.76rem;
}

.ch-video-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  text-align: right;
}

.ch-video-stats .views {
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 800;
}

.ch-video-stats .sub-stats {
  color: var(--text-muted);
  font-size: 0.74rem;
}

.ch-video-performance {
  margin-top: 3px;
}

.ch-perf-tag {
  margin: 0;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
}

.ch-perf-up {
  border: 1px solid var(--green-border);
}

.ch-perf-down {
  border: 1px solid var(--red-border);
}

.ch-detail-tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  font-size: 0.7rem;
  font-weight: 800;
}

.ch-video-expand {
  border-color: rgba(255, 0, 0, 0.16);
  background:
    linear-gradient(180deg, rgba(255, 0, 0, 0.025), rgba(255, 255, 255, 0) 32%),
    #fff;
}

.ch-video-detail {
  padding: 20px;
}

.ch-detail-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.ch-detail-stat {
  display: flex;
  min-height: 96px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 12px;
  border: 1px solid rgba(17, 24, 39, 0.06);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 249, 250, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.ch-detail-stat .val {
  margin: 0;
  color: var(--text-primary);
  font-size: clamp(1.2rem, 2vw, 1.55rem);
  line-height: 1.06;
  letter-spacing: 0;
}

.ch-detail-stat .lbl {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
}

.ch-analytics-section {
  margin-top: 20px;
  padding: 24px;
  border: 1px solid rgba(17, 24, 39, 0.07);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 249, 250, 0.96)),
    radial-gradient(circle at 0 0, rgba(255, 0, 0, 0.06), transparent 30%);
  box-shadow: 0 14px 34px rgba(17, 24, 39, 0.06);
}

.ch-analytics-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(17, 24, 39, 0.07);
  color: var(--text-primary);
  font-size: 1.02rem;
  font-weight: 850;
  letter-spacing: 0;
}

.ch-analytics-title .badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border: 1px solid rgba(79, 70, 229, 0.14);
  border-radius: 999px;
  background: #eef2ff;
  color: #4f46e5;
  font-size: 0.7rem;
  font-weight: 800;
}

.ch-analytics-section .ch-detail-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  gap: 12px;
  margin-bottom: 20px !important;
}

.ch-analytics-section .ch-detail-stat {
  min-height: 92px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(250, 250, 250, 0.98));
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.035);
}

.ch-analytics-cols {
  gap: 14px !important;
}

.ch-analytics-cols > div {
  min-width: 0;
  padding: 18px;
  border: 1px solid rgba(17, 24, 39, 0.07);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.ch-analytics-cols h5 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(17, 24, 39, 0.07);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 850;
  line-height: 1.25;
}

.ch-analytics-cols h5[style] {
  margin-top: 18px !important;
}

.ch-analytics-bar-list {
  display: grid;
  gap: 11px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ch-analytics-bar-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 12px;
  align-items: center;
  margin: 0;
}

.ch-analytics-bar-label {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ch-analytics-bar-track {
  grid-column: 1 / -1;
  grid-row: 2;
  height: 9px;
  overflow: hidden;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 999px;
  background: #f2f4f7;
  box-shadow: inset 0 1px 2px rgba(17, 24, 39, 0.05);
}

.ch-analytics-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff0000, #ff4d4f);
  transition: width 0.4s ease;
}

.ch-analytics-bar-fill.blue {
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
}

.ch-analytics-bar-fill.green {
  background: linear-gradient(90deg, #22c55e, #34d399);
}

.ch-analytics-bar-fill.orange {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.ch-analytics-bar-pct {
  grid-column: 2;
  grid-row: 1;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 850;
  line-height: 1.2;
  text-align: right;
  white-space: nowrap;
}

.ch-detail-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(17, 24, 39, 0.08);
}

.ch-detail-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 850;
  line-height: 1;
  text-decoration: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.ch-detail-action-btn:hover {
  transform: translateY(-1px);
}

.ch-detail-action-secondary {
  border: 1px solid rgba(17, 24, 39, 0.12);
  background: #fff;
  color: var(--text-secondary);
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.05);
}

.ch-detail-action-secondary:hover {
  border-color: rgba(17, 24, 39, 0.2);
  color: var(--text-primary);
  box-shadow: 0 12px 24px rgba(17, 24, 39, 0.08);
}

.ch-detail-action-primary {
  border: 1px solid rgba(255, 0, 0, 0.88);
  background: linear-gradient(135deg, #ff0000, #d91414);
  color: #fff;
  box-shadow: 0 12px 24px rgba(255, 0, 0, 0.22);
}

.ch-detail-action-primary:hover {
  box-shadow: 0 16px 30px rgba(255, 0, 0, 0.28);
}

.channel-report-section {
  margin-bottom: 2px;
}

.ch-report {
  min-height: 88px;
  border-color: var(--border-light);
  background:
    linear-gradient(180deg, rgba(17, 24, 39, 0.025), transparent),
    #fff;
}

.channel-report-empty {
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 30px 16px;
  color: var(--text-muted);
  text-align: center;
}

.channel-report-empty strong {
  color: var(--text-primary);
  font-size: 0.96rem;
}

.channel-report-empty p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.55;
}

.channel-report-empty span {
  color: var(--text-muted);
  font-size: 0.72rem;
}

@media (max-width: 900px) {
  .channel-hero,
  .channel-overview {
    grid-template-columns: 1fr;
  }

  .ch-profile {
    min-height: 0;
    padding: 18px;
    grid-template-columns: 62px minmax(0, 1fr);
    gap: 14px;
  }

  .ch-profile img {
    width: 62px;
    height: 62px;
  }

  .ch-stat-card {
    min-height: 86px;
    padding: 16px 18px;
  }

  .ch-video-item {
    grid-template-columns: 112px minmax(0, 1fr);
  }

  .ch-video-thumb {
    width: 112px;
    height: 63px;
  }

  .ch-video-stats {
    grid-column: 1 / -1;
    align-items: flex-start;
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
    text-align: left;
  }

  .ch-detail-grid,
  .ch-analytics-section .ch-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .ch-analytics-cols {
    grid-template-columns: 1fr !important;
    gap: 18px;
  }

  .ch-analytics-bar-item {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

@media (max-width: 640px) {
  #tab-channel .channel-workspace {
    border-radius: 0;
  }

  .channel-hero,
  .channel-dashboard,
  .channel-section {
    padding: 18px;
  }

  .channel-hero h1 {
    font-size: 0.9rem;
  }

  .channel-section-head {
    flex-direction: column;
    align-items: stretch;
  }

  .ch-filter-tabs {
    width: 100%;
    justify-content: stretch;
  }

  .ch-filter-tab {
    flex: 1;
  }

  .ch-stats {
    grid-template-columns: 1fr;
  }

  .ch-stat-card {
    min-height: 92px;
    border-right: 0;
    border-bottom: 1px solid var(--border-light);
  }

  .ch-stat-card:last-child {
    border-bottom: 0;
  }

  .ch-profile {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .ch-profile img {
    width: 62px;
    height: 62px;
  }

  .ch-avg-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .ch-avg-row small {
    text-align: left;
  }

  .ch-video-item {
    grid-template-columns: 1fr;
  }

  .ch-video-thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .ch-detail-grid,
  .ch-analytics-section .ch-detail-grid {
    grid-template-columns: 1fr !important;
  }

  .ch-analytics-section {
    padding: 18px;
  }

  .ch-analytics-cols > div {
    padding: 15px;
  }

  .ch-detail-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .ch-detail-action-btn {
    width: 100%;
  }
}
