/* ===== Base ===== */
@import url("common/ress.css");
@import url("common/typography.css");

/* ===== Components ===== */
@import url("components/buttons.css");
@import url("components/forms.css");
@import url("components/cards.css");
@import url("components/tables.css");
@import url("components/badges.css");
@import url("components/modals.css");
@import url("components/toast.css");
@import url("components/pagination.css");
@import url("components/upload_zone.css");
@import url("components/sortable.css");
@import url("components/tom-select.css");

/* ===== Layout ===== */
@import url("layout/sidebar.css");
@import url("layout/header.css");
@import url("layout/page.css");

/* ===== Utilities ===== */
@import url("common/utilities.css");

/* ===== Global defaults ===== */
html {
  color-scheme: dark;
}

body {
  color: #f3f4f6;
}

a {
  text-decoration: none;
}

/* ===================================
   Page-specific styles
   ページ固有のスタイル
   =================================== */

/* --- Login --- */

.bl_login {
  .bl_container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100dvh;

    .bl_login_ttl {
      font-size: 1.25rem;
      font-weight: 700;
      text-align: center;
      color: #f3f4f6;
      margin-bottom: 1.5rem;
    }

    .bl_login_form {
      background-color: #111827;
      border: 1px solid #1f2937;
      border-radius: 0.5rem;
      padding: 2rem;
      width: 100%;
      max-width: 22.5rem;
      box-sizing: border-box;
    }
  }
}

/* --- Video --- */

/* ページヘッダー */
.bl_video_page_header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.bl_video_header_actions {
  display: flex;
  gap: 0.5rem;
}

/* フィルターラベル */
.el_filterLabel {
  font-size: 0.875rem;
  color: #9ca3af;
  white-space: nowrap;
  padding: 0.5rem 0;
}

/* サムネイル（テーブル内） */
.bl_video_thumbnail {
  width: 6rem;
  height: 3.5rem;
  background-color: #1f2937;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;

  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  svg {
    width: 1.5rem;
    height: 1.5rem;
    color: #4b5563;
  }
}

/* タイトルセル */
.bl_table_name {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  max-width: 32rem;
}

.bl_table_name span {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

/* 数値セル */
.el_tableNumeric.el_text_gray_400 {
  font-variant-numeric: tabular-nums;
}

/* 戻るボタン内アイコン */
.el_btnBack {
  svg {
    width: 1rem;
    height: 1rem;
  }
}

/* 動画フォーム */
.bl_video_form_id_row {
  display: flex;
  gap: 0.5rem;

  > .el_formInput {
    width: 24rem;
  }
}

.bl_video_thumbnailPreview {
  width: 24rem;
  height: 14rem;
  background-color: #1f2937;
  border: 1px solid #374151;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;

  .el_video_thumbnailPreview_img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .el_video_thumbnailPreview_icon {
    width: 3rem;
    height: 3rem;
    color: #4b5563;
  }
}

/* フォームフッター */
.bl_formFooter {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #1f2937;
}

/* CSV一括登録 */
.bl_uploadZone_csv {
  cursor: pointer;
  transition:
    background-color 0.2s,
    border-color 0.2s;
}

.bl_uploadZone_csv:hover {
  background-color: #ffffff0d;
  border-color: #4b5563;
}

.bl_uploadZone_csv .bl_uploadZone_icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1rem;
}

.el_uploadZoneText {
  color: #f3f4f6;
  margin-bottom: 0.25rem;
}

.el_uploadZoneSub {
  color: #6b7280;
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}

.el_csvNote {
  color: #4ade80;
  font-size: 0.75rem;
}

.el_csvFileName {
  font-size: 0.875rem;
  color: #f3f4f6;
}

.bl_csv_error {
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background-color: #ef44441a;
  border: 1px solid #ef44444d;
  color: #f87171;
  font-size: 0.875rem;
}

.bl_csv_errorHeader {
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.bl_csv_errorList {
  max-height: 40vh;
  overflow-y: auto;
  scrollbar-width: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
}

.bl_csv_errorList::-webkit-scrollbar {
  display: none;
}

.bl_csv_errorRow {
  display: flex;
  gap: 0.5rem;
}

.el_csv_errorLine {
  color: #fca5a5;
  white-space: nowrap;
  font-family: monospace;
}

/* CSVプレビューテーブル */
.bl_csv_previewWrapper {
  background-color: #1f293780;
  border-radius: 0.75rem;
  border: 1px solid #374151;
  overflow: auto;
  max-height: 70vh;

  &::-webkit-scrollbar {
    height: 8px;
  }
  &::-webkit-scrollbar-track {
    background: transparent;
  }
  &::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 9999px;
  }
  &::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
  }
  scrollbar-color: #4b5563 transparent;
  scrollbar-width: thin;

  .bl_csv_previewTable {
    width: 100%;
    min-width: 75rem;
    border-collapse: collapse;
  }

  /* スクロール時もヘッダ行を上部固定 */
  .bl_table_header {
    position: sticky;
    top: 0;
    z-index: 1;
    background-color: #1f2937;
  }

  .bl_csv_th {
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 500;
    color: #9ca3af;
    white-space: nowrap;
  }

  .bl_csv_thMd {
    min-width: 12.5rem;
  }

  .bl_csv_thLg {
    min-width: 18.75rem;
  }

  .bl_csv_name {
    max-width: 18.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
  }

  .bl_csv_program {
    max-width: 12.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
  }

  .bl_csv_episode {
    max-width: 8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
  }

  .bl_csv_desc {
    max-width: 25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
  }

  .bl_csv_tagCell {
    cursor: pointer;
  }

  .js_thumbPreview {
    cursor: pointer;
    border-radius: 0.375rem;
  }
}

/* ジャンルCSVプレビューテーブル */
.bl_genreCsv_previewWrapper {
  overflow-y: auto;
  max-height: calc(100vh - 22rem);
  scrollbar-color: #4b5563 transparent;
  scrollbar-width: thin;
}

.bl_genreCsv_previewWrapper::-webkit-scrollbar {
  width: 8px;
}

.bl_genreCsv_previewWrapper::-webkit-scrollbar-track {
  background: transparent;
}

.bl_genreCsv_previewWrapper::-webkit-scrollbar-thumb {
  background: #4b5563;
  border-radius: 9999px;
}

.bl_genreCsv_previewWrapper::-webkit-scrollbar-thumb:hover {
  background: #6b7280;
}

.bl_genreCsv_previewList {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.bl_genreCsv_previewRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #1f2937;
  border: 1px solid #374151;
  border-radius: 0.5rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  color: #f3f4f6;
}

.bl_genreCsv_previewRow.is_error {
  border-color: #f87171;
}

.bl_genreCsv_previewRow_error {
  font-size: 0.75rem;
  color: #f87171;
}

/* CSVプレビューフッター：戻るを左・登録するを右に配置 */
#genre-csv-preview .bl_formFooter {
  justify-content: space-between;
}

/* CSVステップ（プログレス・完了） */
.bl_csv_step {
  padding: 2rem 0;
  text-align: center;

  .bl_csv_stepInner {
    margin-bottom: 1rem;
  }

  .bl_csv_stepIcon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 9999px;
    background-color: #f59e0b1a;
    margin-bottom: 0.75rem;
  }

  .bl_csv_stepIconSuccess {
    background-color: #22c55e1a;
  }

  .el_csvSpinner {
    width: 1.5rem;
    height: 1.5rem;
    color: #f59e0b;
    animation: spin 1s linear infinite;
  }

  .el_csvStepText {
    color: #f3f4f6;
    font-size: 0.875rem;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* CSVプログレスバー */
.bl_csv_progress {
  width: 100%;
  background-color: #1f2937;
  border-radius: 9999px;
  height: 0.5rem;
  overflow: hidden;

  .bl_csv_progressFill {
    background-color: #f59e0b;
    height: 0.5rem;
    border-radius: 9999px;
    transition: width 0.3s ease;
    width: 0%;
  }
}

.el_csvProgressText {
  font-size: 0.75rem;
  color: #6b7280;
}

.el_csvDoneIcon {
  width: 1.5rem;
  height: 1.5rem;
  color: #22c55e;
}

/* --- Genre --- */

.bl_program_actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* --- Machine keyword --- */

/* 8行上限 or ビューポート追従の小さい方でスクロール */
#machine-keyword-list {
  max-height: min(calc(2.475rem * 8 + 0.5rem * 7), calc(100vh - 24rem));
  overflow-y: auto;
  &::-webkit-scrollbar {
    width: 6px;
  }
  &::-webkit-scrollbar-track {
    background: transparent;
  }
  &::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 9999px;
  }
  &::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
  }
  scrollbar-color: #4b5563 transparent;
  scrollbar-width: thin;
}

/* アラート表示時はその分だけ高さを縮小 */
.bl_formAlert:not(.el_hidden) ~ .bl_card #machine-keyword-list {
  max-height: min(calc(2.475rem * 8 + 0.5rem * 7), calc(100vh - 30rem));
}

.bl_keywordRow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- Talent --- */

/* 演者名の検索入力の最大幅を制限 */
.bl_talent .el_formInput_keyword {
  max-width: 24rem;
}

/* --- Tag --- */

/* タグ編集フォームのタグタイプ表示行 */
.bl_tag_form_typeRow {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

/* 表示制御 */
/* bl_formFooter より後に定義することで display: flex を上書き */
.hidden {
  display: none;
}

/* --- Feature --- */

/* アイテム一覧コンテナ */
.bl_featureItems {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* 3件超でスクロール */
#feature-items-list {
  max-height: min(calc(5.625rem * 3 + 0.75rem * 2), calc(100vh - 27rem));
  overflow-y: auto;
  &::-webkit-scrollbar {
    width: 6px;
  }
  &::-webkit-scrollbar-track {
    background: transparent;
  }
  &::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 9999px;
  }
  &::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
  }
  scrollbar-color: #4b5563 transparent;
  scrollbar-width: thin;
}

/* アラート表示時は高さを縮小 */
.bl_formAlert:not(.el_hidden) ~ form #feature-items-list {
  max-height: min(calc(5.625rem * 3 + 0.75rem * 2), calc(100vh - 31rem));
}

/* アイテム1行 */
.bl_featureItem {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background-color: #111827;
  border: 1px solid #1f2937;
  border-radius: 0.5rem;
}

/* ドラッグハンドル */
.bl_featureItem_handle {
  cursor: grab;
  color: #6b7280;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.25rem;
  flex-shrink: 0;
  &:active {
    cursor: grabbing;
  }
}

/* 行番号 */
.bl_featureItem_number {
  width: 1.5rem;
  text-align: center;
  font-size: 0.875rem;
  color: #9ca3af;
  flex-shrink: 0;
}

/* 画像・URL入力フィールド群 */
.bl_featureItem_fields {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

/* 画像アップロード */
.bl_featureItem_imageWrap {
  flex-shrink: 0;
}


/* URL入力欄 */
.bl_featureItem_urlWrap {
  flex: 1;
  min-width: 0;
}

/* ドラッグ中の行（Sortable ghost） */
.bl_featureItem_dragging {
  opacity: 0.5;
}
