/* ==========================================================================
   manual_pipeline.css — /manual_pipeline (dataset mode)
   Loaded AFTER new_preuploader.css; the page shares the /workspace header and
   theme tokens by putting both classes on body
   (class="new_preuploader manual_pipeline"). Every rule here is scoped under
   body.new_preuploader.manual_pipeline so specificity beats both single.css
   and the shared file regardless of load order.
   Light theme: no visual change from the single.css look.
   Dark theme (body.theme-dark): the --np tokens from new_preuploader.css.
   CSP: style-src 'self' — keep all styles in this file, no inline styles.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Page tokens. new_preuploader.css sets body color to --np-text (#fff in
   light) which would turn this page's default black text white, so the body
   colour is re-pinned here and switched only in dark.
   -------------------------------------------------------------------------- */
body.new_preuploader.manual_pipeline {
    --mp-text: #000000;
    --mp-text-soft: #021235;
    --mp-panel-border: #95b1df3b;
    --mp-button-bg: #22222211;
    --mp-button-active-bg: #ffffff30;
    --mp-error: red;
    --mp-warn: #9a3412;
    /* 価格の金額 (ライトは --np-accent #1764ff より少し濃い青で視認性を上げる) */
    --mp-price: #173cff;
    /* High Quality 表示 (青系統。金額の青とは色相をずらす) */
    --mp-quality-high: #0400cf;
    /* 実行中スロットの進捗表示 (点灯色は --np-accent: light #1764ff / dark #22d3ee) */
    --mp-progress-fill: var(--np-accent);
    --mp-progress-track: rgba(2, 18, 53, 0.14);
    --mp-progress-spinner-track: rgba(2, 18, 53, 0.18);
    color: var(--mp-text);
}
body.new_preuploader.manual_pipeline.theme-dark {
    --mp-text: var(--np-text);
    --mp-text-soft: var(--np-text-soft);
    --mp-panel-border: var(--np-border-color);
    --mp-button-bg: rgba(255, 255, 255, 0.06);
    --mp-button-active-bg: rgba(255, 255, 255, 0.14);
    --mp-error: #ff6b6b;
    --mp-warn: #fbbf24;
    --mp-price: var(--np-accent);
    --mp-quality-high: #00c75b;
    --mp-progress-track: rgba(255, 255, 255, 0.12);
    --mp-progress-spinner-track: rgba(255, 255, 255, 0.18);
}

/* ルート要素の背景 (single.css の --main-background を np トークンに置換。
   new_preuploader.css は #new_preuploader_root にのみ効く) */
body.new_preuploader.manual_pipeline #sfm_root {
    /* 背景は new_preuploader.css の body::before (固定レイヤー) が描く */
    background-image: none;
}
/* single.css は縦持ちスマホでグラデーションの上端色を #1764ff に変える。
   ライトの見た目を現状維持するため同じ切替を再現する (ダークは共通) */
@media (max-width: 680px) and (orientation: portrait) {
    body.new_preuploader.manual_pipeline:not(.theme-dark) {
        --np-page-bg: linear-gradient(#1764ff, #99c2bc);
    }
}

/* ヘッダー直下の 使い方 / User Log 領域。両方非表示のときは高さ 0 で
   本文位置を変えない */
body.new_preuploader.manual_pipeline .np_main.mp_top {
    padding-bottom: 0;
}
body.new_preuploader.manual_pipeline .np_page_explanation {
    margin-bottom: 1.4rem;
}

/* --------------------------------------------------------------------------
   Corner radius — /workspace と同じ使い分け (両テーマ共通)。
   パネル / キャンバス / ダイアログ = --np-radius (np_row, np_dialog と同じ)、
   テキストボタン = 7px (np_dialog_button と同じ)、select = 7px
   -------------------------------------------------------------------------- */
body.new_preuploader.manual_pipeline .execute_button_layout,
body.new_preuploader.manual_pipeline .progress_area,
body.new_preuploader.manual_pipeline .empty_three_canvas,
body.new_preuploader.manual_pipeline #three_canvas,
body.new_preuploader.manual_pipeline .advanced_option_area,
body.new_preuploader.manual_pipeline dialog.option_dialog,
body.new_preuploader.manual_pipeline dialog.mesh_option_dialog {
    border-radius: var(--np-radius);
}
body.new_preuploader.manual_pipeline .common_button,
body.new_preuploader.manual_pipeline .option_close_button,
body.new_preuploader.manual_pipeline .model_load_button,
body.new_preuploader.manual_pipeline .reset_button_layout,
body.new_preuploader.manual_pipeline .pointcloud_download_button,
body.new_preuploader.manual_pipeline .preuploaded_select,
body.new_preuploader.manual_pipeline .dataset_stage_option_row select {
    border-radius: 7px;
}

/* --------------------------------------------------------------------------
   Dark theme — body text / notices
   -------------------------------------------------------------------------- */
body.new_preuploader.manual_pipeline.theme-dark .page_explanation {
    color: var(--mp-text-soft);
}
body.new_preuploader.manual_pipeline.theme-dark .page_explanation a,
body.new_preuploader.manual_pipeline.theme-dark .dataset_sfm_notice a {
    color: var(--np-accent);
}
body.new_preuploader.manual_pipeline.theme-dark .dataset_stage_error {
    color: var(--mp-error);
}
body.new_preuploader.manual_pipeline.theme-dark .tsdf_memory_exceeded {
    color: var(--mp-error);
}
body.new_preuploader.manual_pipeline.theme-dark .model_load_too_large {
    color: var(--mp-warn);
}
body.new_preuploader.manual_pipeline.theme-dark .credit_number {
    color: var(--np-accent);
}
body.new_preuploader.manual_pipeline.theme-dark .pipeline_branch_switch {
    color: var(--np-accent);
}
body.new_preuploader.manual_pipeline.theme-dark .dataset_slot_rerun_toggle {
    color: var(--np-accent);
}
body.new_preuploader.manual_pipeline.theme-dark .inner_load_circle {
    border-top-color: var(--np-accent);
}
body.new_preuploader.manual_pipeline.theme-dark summary,
body.new_preuploader.manual_pipeline.theme-dark .expand_summary {
    color: var(--mp-text);
}

/* --------------------------------------------------------------------------
   Dark theme — controls (right panel)
   -------------------------------------------------------------------------- */
body.new_preuploader.manual_pipeline.theme-dark .common_button {
    color: var(--mp-text);
    background-color: var(--mp-button-bg);
    border-color: var(--mp-panel-border);
}
body.new_preuploader.manual_pipeline.theme-dark .common_button:active {
    background: var(--mp-button-active-bg);
}
body.new_preuploader.manual_pipeline.theme-dark .common_button:disabled {
    opacity: var(--np-disabled-opacity);
}
body.new_preuploader.manual_pipeline.theme-dark .execute_button_layout,
body.new_preuploader.manual_pipeline.theme-dark .progress_area {
    border-color: var(--mp-panel-border);
}
body.new_preuploader.manual_pipeline.theme-dark .preuploaded_select {
    background-color: var(--np-row-bg);
    border-color: var(--mp-panel-border);
    color: var(--mp-text);
}
body.new_preuploader.manual_pipeline.theme-dark .dataset_stage_option_row select {
    background: transparent;
    border: var(--np-control-border);
    color: var(--mp-text);
}
/* download.png は暗いグレーなので、ダークでも明るめの下地を残す */
body.new_preuploader.manual_pipeline.theme-dark .pointcloud_download_button {
    background-color: rgba(255, 255, 255, 0.78);
    border-color: var(--mp-panel-border);
}
body.new_preuploader.manual_pipeline.theme-dark .empty_three_canvas,
body.new_preuploader.manual_pipeline.theme-dark #three_canvas {
    border-color: var(--mp-panel-border);
}

/* --------------------------------------------------------------------------
   Dark theme — settings dialogs (<dialog> は body 配下なのでスコープが効く)
   -------------------------------------------------------------------------- */
body.new_preuploader.manual_pipeline.theme-dark dialog.option_dialog,
body.new_preuploader.manual_pipeline.theme-dark dialog.mesh_option_dialog {
    background-color: var(--np-dialog-bg);
    color: var(--np-dialog-text);
    border: var(--np-dialog-border);
}
body.new_preuploader.manual_pipeline.theme-dark .option_close_button {
    background-color: var(--mp-button-bg);
    color: var(--np-dialog-text);
    border-color: var(--mp-panel-border);
}
body.new_preuploader.manual_pipeline.theme-dark .advanced_option_area {
    background: rgba(255, 255, 255, 0.04);
}
body.new_preuploader.manual_pipeline.theme-dark .tooltip-icon {
    background-color: rgba(148, 163, 184, 0.5);
}

/* --------------------------------------------------------------------------
   Dark theme — bevel borders. single.css の border は幅が vh 依存で、
   outset / inset の暗い側の色はブラウザが自動生成する (暗色はほぼ黒に
   落ちる)。ダークでは px 幅の solid + 明示色の 4 辺 (new_preuploader.css
   の --np-bevel-colors / --np-bevel-colors-inset) に置き換え、PC / スマホ
   で同じ見え方にする。ライトは single.css の見た目を現状維持
   -------------------------------------------------------------------------- */
body.new_preuploader.manual_pipeline.theme-dark .empty_three_canvas,
body.new_preuploader.manual_pipeline.theme-dark #three_canvas {
    border: 3px solid var(--np-border-color);   /* 0.4vh outset */
    border-color: var(--np-bevel-colors);
}
body.new_preuploader.manual_pipeline.theme-dark .common_button,
body.new_preuploader.manual_pipeline.theme-dark .option_close_button {
    border: 2px solid var(--np-border-color);   /* 0.3vh / 0.2rem outset */
    border-color: var(--np-bevel-colors);
}
body.new_preuploader.manual_pipeline.theme-dark .pointcloud_download_button {
    border: 4px solid var(--np-border-color);   /* 0.5vh outset */
    border-color: var(--np-bevel-colors);
}
body.new_preuploader.manual_pipeline.theme-dark .execute_button_layout,
body.new_preuploader.manual_pipeline.theme-dark .progress_area,
body.new_preuploader.manual_pipeline.theme-dark .preuploaded_select {
    border: 3px solid var(--np-border-color);   /* 3px / 0.4vh inset */
    border-color: var(--np-bevel-colors-inset);
}

/* --------------------------------------------------------------------------
   実行中スロットの進捗表示 (dataset_sfm.js DatasetProgressDisplay)
   上段: スピナー + 工程名 + Running...   下段: % + セグメントバー
   バーは縦長の小さな角丸セグメント (PROGRESS_SEGMENT_COUNT = 100 個) を横に
   並べたもの。幅はセグメント寸法から決まる: 100 × 2px + 99 × 1px gap = 299px
   (スマホ幅でも収まる)。1 目盛りの横幅は画面幅によらず 2px で統一
   -------------------------------------------------------------------------- */
body.new_preuploader.manual_pipeline .progress_area.mp_progress_area {
    box-sizing: border-box;
    padding: 0.5rem 0.7rem;
}
body.new_preuploader.manual_pipeline .mp_progress {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 0;
}
body.new_preuploader.manual_pipeline .mp_progress_head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}
body.new_preuploader.manual_pipeline .mp_progress_spinner {
    box-sizing: border-box;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 2px solid var(--mp-progress-spinner-track);
    border-top-color: var(--mp-progress-fill);
    animation: mp_spin 0.9s linear infinite;
}
@keyframes mp_spin {
    to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    body.new_preuploader.manual_pipeline .mp_progress_spinner {
        animation: none;
    }
}
body.new_preuploader.manual_pipeline .mp_progress_step {
    font-weight: 600;
    color: var(--mp-text);
}
body.new_preuploader.manual_pipeline .mp_progress_running {
    color: var(--mp-text-soft);
    font-size: 0.9em;
}
body.new_preuploader.manual_pipeline .mp_progress_body {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
body.new_preuploader.manual_pipeline .mp_progress_percent {
    min-width: 3.2em;
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    color: var(--mp-text);
}
body.new_preuploader.manual_pipeline .mp_progress_bar {
    display: flex;
    align-items: stretch;
    gap: 1px;
    width: fit-content;
    height: 12px;
}
body.new_preuploader.manual_pipeline .mp_progress_segment {
    flex: 0 0 auto;
    width: 2px;
    border-radius: 1px;
    background: var(--mp-progress-track);
    transition: background-color 200ms linear;
}
body.new_preuploader.manual_pipeline .mp_progress_segment_filled {
    background: var(--mp-progress-fill);
}
/* 警告 (旧 ProgressDisplay の inline style 相当を両テーマ対応でクラス化) */
body.new_preuploader.manual_pipeline .mp_progress_warnings {
    max-width: 299px;
    margin: 0.2rem 0 0;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--mp-warn);
    border-radius: 4px;
}
body.new_preuploader.manual_pipeline .mp_progress_warnings p {
    margin: 0.1rem 0;
    font-size: 0.85em;
    color: var(--mp-warn);
    overflow-wrap: anywhere;
}
@media (max-width: 880px) {
    body.new_preuploader.manual_pipeline .progress_area.mp_progress_area {
        margin: 0.8rem auto;
    }
}
/* 狭いスマホ (≤480px): % を横に置くと箱が 388px になり 390px 幅で端に
   張り付くため、% をバーの上に積む (箱 ≈ 327px) */
@media (max-width: 480px) {
    body.new_preuploader.manual_pipeline .mp_progress_body {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    body.new_preuploader.manual_pipeline .mp_progress_percent {
        min-width: 0;
        text-align: left;
    }
}

/* --------------------------------------------------------------------------
   ステップ run の価格 (実行ボタン上の行と確認ダイアログ)。OpenMVG の SfM は
   サーバー見積の内訳 (従量上限 / 成功時残額 / 合計) を添える
   -------------------------------------------------------------------------- */
body.new_preuploader.manual_pipeline .stage_price_row {
    flex-wrap: wrap;
    white-space: normal;
    max-width: 320px;
}
body.new_preuploader.manual_pipeline .stage_price_dialog_row {
    flex-wrap: wrap;
}
body.new_preuploader.manual_pipeline .stage_price_breakdown {
    flex-basis: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 0.8rem;
    font-size: 0.8rem;
    color: var(--mp-text-soft);
}
/* 価格〜画質〜切替ボタンの 1 行目。狭い幅でも折り返さない */
body.new_preuploader.manual_pipeline .stage_price_main {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
    gap: 0.6rem;
    max-width: none;
}
/* 画質の表示 (":" 区切り) と切替ボタン。High Quality は色を変えて目立たせる */
body.new_preuploader.manual_pipeline .stage_price_sep {
    color: var(--mp-text-soft);
}
body.new_preuploader.manual_pipeline .stage_price_quality {
    font-weight: 600;
    white-space: nowrap;
}
body.new_preuploader.manual_pipeline .stage_price_quality_high {
    color: var(--mp-quality-high);
}
/* 切替ボタンは 3 文字分程度の小さなもの (⇄ 1 文字) */
body.new_preuploader.manual_pipeline .stage_price_quality_button {
    white-space: nowrap;
    min-width: 3ch;
    width: 3ch;
    padding: 0 0.2rem;
    font-size: 0.85rem;
    line-height: 1.4;
    text-align: center;
    /* 共通の np_run_switch_button (--np-dialog-dim) は青い背景で薄いため本文色に */
    color: var(--mp-text);
    border-color: var(--mp-text-soft);
}
body.new_preuploader.manual_pipeline .np_run_price_value {
    color: var(--mp-price);
}
body.new_preuploader.manual_pipeline .stage_price_quality_button:disabled {
    opacity: 0.5;
    cursor: default;
}
/* staff 限定の見積根拠 (予測時間 / 単価 / 積)。内訳より一段薄く */
body.new_preuploader.manual_pipeline .stage_price_staff_detail {
    font-size: 0.75rem;
    opacity: 0.8;
}
body.new_preuploader.manual_pipeline .stage_price_over_limit {
    color: var(--mp-error);
    font-size: 0.85rem;
    white-space: normal;
}
