/* ===========================================
 * User Page Styles - ユーザー解析ページ
 * =========================================== */

.user-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px clamp(12px, 2vw, 24px);
}

/* ===== プロフィールヘッダー ===== */
.user-profile-header {
  position: relative;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  margin-bottom: 0;
}

/* カバー画像がある場合 */
.user-profile-header[style*="--cover-url"]::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--cover-url) center/cover no-repeat;
  opacity: 0.12;
  pointer-events: none;
}

.user-profile-inner {
  position: relative;
  padding: 16px 18px;
}

.user-profile-main {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.user-profile-icon {
  flex: 0 0 auto;
}

.user-profile-icon img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: #f1f5f9;
}

.user-icon-placeholder {
  display: block;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e5e7eb, #cbd5e1);
}

.user-profile-info {
  flex: 1;
  min-width: 0;
}

.user-profile-name {
  margin: 0 0 2px;
  font-size: 1.15rem;
  font-weight: 800;
  color: #1f2937;
  line-height: 1.35;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.user-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.4;
  vertical-align: middle;
}

.user-badge-premium {
  background: #fff4d6;
  color: #805900;
}

.user-profile-id {
  font-size: 0.78rem;
  color: #64748b;
  margin-bottom: 6px;
}

.user-profile-stats {
  display: flex;
  gap: 10px 14px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: #4b5563;
}

.user-profile-stats strong {
  font-weight: 700;
  color: #1f2937;
}

.user-profile-version {
  font-size: 0.75rem;
  color: #94a3b8;
}

/* ---- 説明文 ---- */
.user-profile-desc {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #edf0f3;
}

.user-profile-desc-text {
  margin: 0;
  font-size: 0.85rem;
  color: #4b5563;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.user-profile-desc.is-collapsible .user-profile-desc-text {
  max-height: 4.8em;
  overflow: hidden;
}

.user-profile-desc.is-collapsible.is-expanded .user-profile-desc-text {
  max-height: none;
}

.user-desc-toggle {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 0;
  border: none;
  background: none;
  color: var(--link-color);
  font-size: 0.8rem;
  cursor: pointer;
}

.user-desc-toggle:hover {
  text-decoration: underline;
}

.user-desc-toggle-less {
  display: none;
}

.user-profile-desc.is-expanded .user-desc-toggle-more {
  display: none;
}

.user-profile-desc.is-expanded .user-desc-toggle-less {
  display: inline;
}

/* ---- SNS / チャンネルリンク ---- */
.user-profile-links {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.user-link-chip {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid #d1d5db;
  border-radius: 14px;
  background: #f9fafb;
  color: #374151;
  font-size: 0.76rem;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.4;
}

.user-link-chip:hover {
  background: #f3f4f6;
  text-decoration: none;
  border-color: #9ca3af;
}

/* ---- 公式で確認ボタン ---- */
.user-profile-actions {
  margin-top: 10px;
}

/* ===== ユーザー内ハブ ===== */
.user-hub-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.user-hub-card {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  color: inherit;
  text-decoration: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.user-hub-card:hover {
  border-color: #93c5fd;
  background: #f8fbff;
  text-decoration: none;
}

.user-hub-card.is-active {
  border-color: #93c5fd;
  background: #eff6ff;
}

.user-hub-card span,
.user-hub-card small {
  display: block;
  color: #64748b;
  font-size: 0.74rem;
  font-weight: 800;
}

.user-hub-card strong {
  display: block;
  margin: 2px 0;
  color: #1f2937;
  font-size: 1.05rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.user-hub-card-official strong {
  font-size: 0.92rem;
}

/* ===== タブナビゲーション ===== */
.user-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e5e7eb;
  margin-top: 0;
  background: #fff;
  border-radius: 0 0 0 0;
  overflow-x: auto;
  overflow-y: hidden; /* overflow-x:auto が overflow-y を auto に昇格させ、バッジの高さ超過で縦スクロールバーが出るのを抑制 */
}

.user-tab {
  display: inline-block;
  padding: 10px 18px;
  color: #64748b;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.user-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6em;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #eef2f7;
  color: #475569;
  font-size: 0.72rem;
  line-height: 1.35;
}

.user-tab:hover {
  color: #1f2937;
  text-decoration: none;
}

.user-tab.active {
  color: #0066cc;
  border-bottom-color: #0066cc;
}

/* ===== タブコンテンツ ===== */
.user-tab-content {
  background: #fff;
  border-radius: 0 0 10px 10px;
  padding: 16px 18px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

/* ---- ソート・件数 ---- */
.user-sort-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.user-total-count {
  font-size: 0.82rem;
  color: #64748b;
  font-weight: 600;
}

.user-video-analysis-summary {
  box-shadow: none;
  border: 1px solid #e5e7eb;
}

.user-analysis-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.entity-analysis-full {
  margin-top: 8px;
  padding: 8px 0;
}

.entity-analysis-full button {
  font-size: 0.82rem;
}

.entity-analysis-note {
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 4px;
}

.entity-analysis-progress {
  height: 4px;
  background: #e5e7eb;
  margin-top: 8px;
  border-radius: 2px;
  overflow: hidden;
}

.entity-analysis-progress .bar {
  height: 100%;
  background: #3b82f6;
  transition: width 0.3s;
}

.user-video-filter-form {
  flex: 1 1 720px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ---- フィルタ行（各段） ---- */
.user-filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

/* フィルタグループ（ラベル付きで分かりやすく） */
.user-filter-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.user-filter-label {
  font-size: 0.7rem;
  color: #64748b;
  font-weight: 600;
  padding-left: 2px;
}

/* タイトル段：全幅 */
.user-filter-full {
  flex: 1 1 0;
  min-width: 0;
}

/* 範囲段（下限〜上限）：入力欄を均等 */
.user-filter-row-range .user-filter-input {
  flex: 1 1 0;
  min-width: 0;
}

/* 〜 セパレーター */
.user-filter-sep {
  flex-shrink: 0;
  color: #94a3b8;
  font-size: 0.82rem;
}

/* アクション段（並び順＋ボタン）*/
.user-filter-row-actions {
  flex-wrap: wrap;
}

.user-filter-sort {
  flex: 1 1 140px;
  min-width: 0;
}

.user-filter-input {
  min-width: 0;
  height: 34px;
  padding: 6px 9px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #1f2937;
  font-size: 0.82rem;
}

.user-filter-input-duration {
  /* 範囲行の flex で均等分配されるため個別幅は不要 */
}

/* 長さ入力（分/秒分割） - 検索と同等 */
.duration-ms-group {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1 1 0;
  min-width: 0;
}

.duration-range-input.duration-ms-input {
  flex: 1 1 0;
  min-width: 42px;
  max-width: 70px;
  text-align: center;
  font-size: 0.82rem;
}

.duration-ms-unit {
  font-size: 0.68rem;
  color: #94a3b8;
  flex-shrink: 0;
  margin-right: 2px;
}

.user-tab-content .entity-body {
  padding-right: 104px;
}

/* ===== マイリストカード ===== */
.user-mylist-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.user-mylist-card {
  position: relative;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}

.user-mylist-card-link {
  display: block;
  min-height: 92px;
  padding: 12px 118px 12px 14px;
  color: inherit;
  text-decoration: none;
}

.user-mylist-card-link:hover {
  background: #f3f4f6;
  text-decoration: none;
}

.user-mylist-card-link:hover .user-mylist-card-title {
  text-decoration: underline;
}

.user-mylist-card-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.user-mylist-card-title {
  color: #1f2937;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ===== レスポンシブ ===== */
@media (max-width: 600px) {
  .user-page {
    padding: 10px 10px;
  }

  .user-profile-inner {
    padding: 12px 14px;
  }

  .user-profile-icon img,
  .user-icon-placeholder {
    width: 48px;
    height: 48px;
  }

  .user-profile-name {
    font-size: 1rem;
  }

  .user-profile-stats {
    font-size: 0.78rem;
    gap: 6px 10px;
  }

  .user-hub-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .user-hub-card {
    padding: 9px 10px;
  }

  .user-tab {
    padding: 9px 14px;
    font-size: 0.82rem;
  }

  .user-tab-content {
    padding: 12px 12px;
  }

  .user-analysis-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .user-video-filter-form {
    flex: 1 1 100%;
  }

  /* スマホ：フィルタをコンパクトに */
  .user-filter-group {
    gap: 2px;
  }

  .user-filter-label {
    font-size: 0.65rem;
  }

  .user-filter-row {
    gap: 4px;
  }

  .user-filter-input {
    font-size: 0.78rem;
    height: 30px;
    padding: 4px 6px;
  }

  .duration-ms-group {
    gap: 1px;
  }

  .duration-range-input.duration-ms-input {
    min-width: 36px;
    max-width: 56px;
    font-size: 0.78rem;
  }

  .duration-ms-unit {
    font-size: 0.6rem;
  }

  .user-filter-sep {
    font-size: 0.7rem;
  }

  /* スマホ：並び順は全幅 */
  .user-filter-row-actions .result-sort-select,
  .user-filter-sort {
    flex: 1 1 100%;
  }

  /* 右切れ防止 */
  .user-sort-controls,
  .user-video-filter-form {
    overflow-x: visible;
    max-width: 100%;
  }

  .user-mylist-list {
    grid-template-columns: 1fr;
  }

  /* 動画カード: 検索ページと同じスマホレイアウト */
  .user-tab-content .video-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .user-tab-content .video-card {
    flex-direction: row;
    align-items: flex-start;
    padding: 10px;
    gap: 10px;
  }

  .user-tab-content .video-thumb {
    flex: 0 0 120px;
    align-self: flex-start;
  }

  .user-tab-content .video-thumb img {
    width: 120px;
    height: 67.5px;
    aspect-ratio: 16 / 9;
    border-radius: 6px;
    flex-shrink: 0;
  }

  .user-tab-content .video-body {
    padding: 0;
  }

  /* エンティティ: 検索ページと同じスマホレイアウト */
  .user-tab-content .entity-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .user-tab-content .entity-card-link {
    grid-template-columns: 112px minmax(0, 1fr);
  }

  .user-tab-content .entity-body {
    padding-right: 92px;
  }

  .user-mylist-card-link {
    padding-right: 104px;
  }
}
