/* ── YouTube Export Tool ──────────────────────────────────────── */
.ytex {
  background: radial-gradient(1200px 600px at 12% 0%, rgba(255,0,0,0.08), transparent 55%),
              radial-gradient(900px 520px at 85% 12%, rgba(34,211,238,0.10), transparent 55%),
              #070707;
  color: #d7d8dc;
  min-height: 100vh;
  padding: 30px 0 80px;
}
.ytex *, .ytex *::before, .ytex *::after { box-sizing: border-box; }

.ytex-container {
  width: min(94vw, 1200px);
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Header ──────────────────────────────────────────────────── */
.ytex-header {
  text-align: center;
  margin-bottom: 40px;
}
.ytex-header h1 {
  margin-top: 20px;
  font-size: 2.2em;
  color: #ff4444;
  font-weight: 750;
  letter-spacing: -0.01em;
}
.ytex-subtitle {
  font-size: 1.15em;
  color: #b8bcc4;
  margin: 14px 0 8px;
  font-weight: 600;
}
.ytex-description {
  font-size: 1.02em;
  color: #9aa0a8;
  max-width: 720px;
  margin: 0 auto 28px;
  line-height: 1.6;
}

/* ── Form ────────────────────────────────────────────────────── */
.ytex-form { max-width: 700px; margin: 0 auto; }
.ytex-input-row {
  display: flex;
  gap: 10px;
}
.ytex-input-row input[type="text"],
.ytex-input-row input[type="url"] {
  flex: 1;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255,68,68,0.3);
  background: rgba(255,255,255,0.05);
  color: #e8e9ec;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
.ytex-input-row input:focus {
  border-color: #ff4444;
}
.ytex-input-row input::placeholder { color: #6b7280; }

.ytex-input-row button {
  padding: 12px 24px;
  border-radius: 12px;
  border: 1px solid #ff4444;
  background: rgba(255,68,68,0.12);
  color: #ff4444;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  white-space: nowrap;
}
.ytex-input-row button:hover {
  background: rgba(255,68,68,0.22);
  transform: translateY(-1px);
}
.ytex-input-row button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ── Options row ─────────────────────────────────────────────── */
.ytex-options {
  display: flex;
  gap: 14px;
  margin-top: 14px;
  flex-wrap: wrap;
  align-items: center;
}
.ytex-field {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ytex-field label {
  font-size: 0.9em;
  color: #b8bcc4;
  font-weight: 600;
  white-space: nowrap;
}
.ytex-field input[type="number"] {
  width: 90px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
  color: #e8e9ec;
  font-size: 0.9rem;
  outline: none;
}
.ytex-field input[type="number"]:focus {
  border-color: #ff4444;
}

/* ── API Key fallback ────────────────────────────────────────── */
.ytex-apikey-section {
  margin-top: 16px;
  padding: 16px;
  background: rgba(255,68,68,0.06);
  border: 1px solid rgba(255,68,68,0.2);
  border-radius: 12px;
  display: none;
}
.ytex-apikey-section.visible {
  display: block;
}
.ytex-apikey-section p {
  margin: 0 0 10px;
  font-size: 0.92em;
  color: #fca5a5;
  line-height: 1.5;
}
.ytex-apikey-section input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,68,68,0.3);
  background: rgba(255,255,255,0.05);
  color: #e8e9ec;
  font-size: 0.95rem;
  outline: none;
}
.ytex-apikey-section input:focus {
  border-color: #ff4444;
}

.ytex-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,68,68,0.3);
  border-top-color: #ff4444;
  border-radius: 50%;
  animation: ytex-spin 0.6s linear infinite;
  vertical-align: middle;
}
@keyframes ytex-spin { to { transform: rotate(360deg); } }

.ytex-error {
  color: #f87171;
  margin-top: 10px;
  font-size: 0.92em;
}

/* ── Section ─────────────────────────────────────────────────── */
.ytex-section {
  background: rgba(10,10,10,0.62);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 28px 24px;
  margin-bottom: 24px;
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
}
.ytex-section h2 {
  color: #ff4444;
  font-size: 1.35em;
  margin: 0 0 10px;
}
.ytex-section-desc {
  color: #9aa0a8;
  font-size: 0.95em;
  margin-bottom: 16px;
}

/* ── Summary cards ───────────────────────────────────────────── */
.ytex-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}
.ytex-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 20px 16px;
  text-align: center;
  transition: transform 0.2s;
}
.ytex-card:hover { transform: translateY(-2px); }
.ytex-card-value {
  font-size: 1.8em;
  font-weight: 750;
  color: #ff4444;
  display: block;
  margin-bottom: 4px;
}
.ytex-card-value.cyan { color: #22d3ee; }
.ytex-card-value.green { color: #22c55e; }
.ytex-card-value.gold { color: #d4af37; }
.ytex-card-label {
  font-size: 0.88em;
  color: #b8bcc4;
  font-weight: 600;
}

/* ── Channel info ────────────────────────────────────────────── */
.ytex-channel-info {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding: 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
}
.ytex-channel-name {
  font-size: 1.2em;
  font-weight: 700;
  color: #ffffff;
}
.ytex-channel-id {
  font-size: 0.85em;
  color: #6b7280;
  margin-top: 2px;
}

/* ── Video table ─────────────────────────────────────────────── */
.ytex-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.ytex .ytex-table,
.ytex .ytex-table thead,
.ytex .ytex-table tbody,
.ytex .ytex-table tr {
  background: transparent !important;
}
.ytex .ytex-table {
  width: 100% !important;
  border-collapse: collapse !important;
  font-size: 0.92em;
  border: none !important;
}
.ytex .ytex-table th,
.ytex .ytex-table td {
  padding: 10px 12px !important;
  text-align: left !important;
  border: none !important;
  border-bottom: 1px solid rgba(255,255,255,0.08) !important;
  color: #e0e2e8 !important;
  background: transparent !important;
}
.ytex .ytex-table th {
  color: #ff4444 !important;
  font-weight: 700;
  font-size: 0.82em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.ytex .ytex-table th:hover {
  color: #ff6b6b !important;
}
.ytex .ytex-table th .sort-icon {
  margin-left: 4px;
  font-size: 0.9em;
  opacity: 0.5;
}
.ytex .ytex-table th .sort-icon.active {
  opacity: 1;
}
.ytex .ytex-table td strong {
  color: #ffffff !important;
}
.ytex .ytex-table tbody tr:hover {
  background: rgba(255,68,68,0.05) !important;
}
.ytex .ytex-table td a {
  color: #22d3ee;
  text-decoration: none;
}
.ytex .ytex-table td a:hover {
  text-decoration: underline;
}
.ytex .ytex-table .ytex-thumb {
  width: 80px;
  height: 45px;
  object-fit: cover;
  border-radius: 6px;
  vertical-align: middle;
}
.ytex .ytex-table .ytex-title-cell {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Search & filter bar ─────────────────────────────────────── */
.ytex-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.ytex-search {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
  color: #e8e9ec;
  font-size: 0.92em;
  outline: none;
}
.ytex-search:focus {
  border-color: #ff4444;
}
.ytex-search::placeholder { color: #6b7280; }

/* ── Export buttons ──────────────────────────────────────────── */
.ytex-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.ytex-btn {
  padding: 8px 18px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
  color: #b8bcc4;
  font-weight: 600;
  font-size: 0.9em;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.ytex-btn:hover {
  background: rgba(255,255,255,0.10);
  color: #e8e9ec;
}
.ytex-btn-primary {
  border-color: #ff4444;
  background: rgba(255,68,68,0.12);
  color: #ff4444;
}
.ytex-btn-primary:hover {
  background: rgba(255,68,68,0.22);
}

/* ── Pagination ──────────────────────────────────────────────── */
.ytex-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}
.ytex-pagination button {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: #b8bcc4;
  font-size: 0.88em;
  cursor: pointer;
  transition: background 0.2s;
}
.ytex-pagination button:hover {
  background: rgba(255,255,255,0.10);
}
.ytex-pagination button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.ytex-pagination .ytex-page-info {
  font-size: 0.88em;
  color: #9aa0a8;
}

/* ── Top video card ──────────────────────────────────────────── */
.ytex-top-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
a.ytex-top-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, transform 0.15s, background 0.2s;
}
a.ytex-top-card:hover {
  border-color: rgba(255,68,68,0.35);
  background: rgba(255,255,255,0.06);
  transform: translateY(-2px);
}
.ytex-top-card img {
  width: 120px;
  height: 68px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}
.ytex-top-card-body h3 {
  font-size: 0.95em;
  color: #ffffff;
  margin: 0 0 6px;
  line-height: 1.3;
}
.ytex-top-card-body .meta {
  font-size: 0.82em;
  color: #9aa0a8;
  line-height: 1.5;
}
.ytex-top-card-body .meta strong {
  color: #22d3ee;
}

/* ── Expandable rows (description + tags) ────────────────────── */
.ytex .ytex-row-main.ytex-expandable {
  cursor: pointer;
}
.ytex .ytex-row-main.ytex-expandable:hover {
  background: rgba(255,68,68,0.05) !important;
}
.ytex-expand-icon {
  font-size: 0.7em;
  color: #6b7280;
  margin-left: 6px;
  vertical-align: middle;
  transition: transform 0.2s;
}
.ytex .ytex-row-detail td {
  padding: 0 12px 14px !important;
  border-bottom: 1px solid rgba(255,255,255,0.06) !important;
}
.ytex-detail-content {
  padding: 12px 16px;
  background: rgba(255,255,255,0.02);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.06);
}
.ytex-tags {
  margin-bottom: 10px;
  line-height: 1.8;
}
.ytex-tags strong {
  color: #b8bcc4;
  font-size: 0.88em;
}
.ytex-tag {
  display: inline-block;
  padding: 2px 8px;
  margin: 2px 4px 2px 0;
  border-radius: 6px;
  font-size: 0.82em;
  font-weight: 600;
  background: rgba(255,68,68,0.12);
  color: #ff6b6b;
}
.ytex-desc {
  font-size: 0.9em;
  color: #c0c4cc;
  line-height: 1.6;
}
.ytex-desc strong {
  color: #b8bcc4;
  font-size: 0.92em;
}
.ytex-desc-text {
  white-space: pre-line;
}
.ytex-desc-more {
  background: none;
  border: none;
  color: #22d3ee;
  font-size: 0.88em;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
}
.ytex-desc-more:hover {
  text-decoration: underline;
}

/* ── Word cloud ──────────────────────────────────────────────── */
.ytex-wordcloud {
  padding: 28px 24px;
  background: rgba(0,0,0,0.3);
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.06);
  min-height: 120px;
  text-align: center;
  line-height: 1.3;
  word-spacing: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 2px 6px;
}
.ytex-wc-word {
  display: inline-block;
  padding: 1px 3px;
  cursor: default;
  font-weight: 600;
  transition: transform 0.15s, background 0.15s;
  border-radius: 4px;
  white-space: nowrap;
}
.ytex-wc-word:hover {
  transform: scale(1.12);
  background: rgba(255,255,255,0.08);
}

/* ── Badge ───────────────────────────────────────────────────── */
.ytex .badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.82em;
}
.ytex .badge-red { background: rgba(255,68,68,0.18); color: #ff6b6b; }
.ytex .badge-cyan { background: rgba(34,211,238,0.18); color: #22d3ee; }

/* ── Chart containers ────────────────────────────────────────── */
.ytex-chart-container {
  background: rgba(0,0,0,0.3);
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.06);
  padding: 20px;
  position: relative;
}
.ytex-chart-container canvas {
  max-height: 400px;
}

/* ── Filter group (Shorts / Longues / Toutes) ────────────────── */
.ytex-filter-group {
  display: flex;
  gap: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.15);
}
.ytex-filter-btn {
  padding: 7px 16px;
  border: none;
  background: rgba(255,255,255,0.04);
  color: #9aa0a8;
  font-size: 0.88em;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.ytex-filter-btn:not(:last-child) {
  border-right: 1px solid rgba(255,255,255,0.10);
}
.ytex-filter-btn:hover {
  background: rgba(255,255,255,0.08);
  color: #e8e9ec;
}
.ytex-filter-btn.active {
  background: rgba(255,68,68,0.15);
  color: #ff4444;
}

/* ── Engagement column ──────────────────────────────────────── */
.ytex-engagement {
  font-weight: 700;
  white-space: nowrap;
}
.ytex-engagement.high { color: #22c55e; }
.ytex-engagement.medium { color: #d4af37; }
.ytex-engagement.low { color: #6b7280; }

/* ── Outlier badges ─────────────────────────────────────────── */
.ytex-outlier {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 0.72em;
  font-weight: 700;
  margin-left: 6px;
  vertical-align: middle;
}
.ytex-outlier.viral {
  background: rgba(34,197,94,0.18);
  color: #22c55e;
}
.ytex-outlier.flop {
  background: rgba(239,68,68,0.18);
  color: #f87171;
}

/* ── Heatmap ────────────────────────────────────────────────── */
.ytex-heatmap {
  overflow-x: auto;
}
.ytex-heatmap-grid {
  display: grid;
  grid-template-columns: 60px repeat(24, 1fr);
  gap: 3px;
  min-width: 700px;
}
.ytex-hm-header {
  font-size: 0.72em;
  color: #9aa0a8;
  text-align: center;
  padding: 4px 0;
  font-weight: 600;
}
.ytex-hm-day {
  font-size: 0.82em;
  color: #b8bcc4;
  font-weight: 600;
  display: flex;
  align-items: center;
  padding-right: 6px;
}
.ytex-hm-cell {
  aspect-ratio: 1;
  border-radius: 4px;
  cursor: default;
  transition: transform 0.15s;
  min-height: 20px;
  position: relative;
}
.ytex-hm-cell:hover {
  transform: scale(1.2);
  z-index: 2;
}

/* ── Chart filter bar ───────────────────────────────────────── */
.ytex-chart-filter-bar {
  display: flex;
  gap: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.15);
  margin-bottom: 16px;
  width: fit-content;
}
.ytex-chart-filter {
  padding: 7px 18px;
  border: none;
  background: rgba(255,255,255,0.04);
  color: #9aa0a8;
  font-size: 0.88em;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.ytex-chart-filter:not(:last-child) {
  border-right: 1px solid rgba(255,255,255,0.10);
}
.ytex-chart-filter:hover {
  background: rgba(255,255,255,0.08);
  color: #e8e9ec;
}
.ytex-chart-filter.active {
  background: rgba(255,68,68,0.15);
  color: #ff4444;
}

/* ── Recommendation box ────────────────────────────────────── */
.ytex-recommendation {
  padding: 14px 18px;
  background: rgba(34,211,238,0.06);
  border: 1px solid rgba(34,211,238,0.2);
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 0.95em;
  color: #d7d8dc;
  line-height: 1.5;
  display: none;
}
.ytex-recommendation.visible {
  display: block;
}
.ytex-recommendation strong {
  color: #22d3ee;
}
.ytex-recommendation .ytex-reco-icon {
  margin-right: 8px;
}

/* ── PDF export button ──────────────────────────────────────── */
.ytex-btn-pdf {
  border-color: #d4af37;
  background: rgba(212,175,55,0.12);
  color: #d4af37;
}
.ytex-btn-pdf:hover {
  background: rgba(212,175,55,0.22);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  .ytex-header h1 { font-size: 1.6em; }
  .ytex-input-row { flex-direction: column; }
  .ytex-input-row button { width: 100%; }
  .ytex-options { flex-direction: column; gap: 10px; }
  .ytex-summary-grid { grid-template-columns: repeat(2, 1fr); }
  .ytex-section { padding: 20px 14px; }
  .ytex-toolbar { flex-direction: column; }
  .ytex-top-card { flex-direction: column; }
  .ytex-top-card img { width: 100%; height: auto; }
  .ytex .ytex-table { font-size: 0.8em; }
  .ytex .ytex-table th, .ytex .ytex-table td { padding: 8px 6px !important; }
  .ytex-chart-container canvas { max-height: 300px; }
  .ytex-heatmap-grid { min-width: 600px; }
  .ytex-filter-btn { padding: 6px 10px; font-size: 0.82em; }
}
