/* 右パネルのタブスタイル */

/* タブバー */
.right-panel-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    border-bottom: 2px solid rgba(14, 165, 233, 0.3);
    background: rgba(255, 255, 255, 0.8);
    border-radius: 12px 12px 0 0;
    margin-bottom: 0;
    flex-shrink: 0;
    /* タブバーは縮小しない */
    min-height: 40px;
    align-items: center;
}

.right-panel-tab-btn {
    flex: 1;
    padding: 6px;
    border: none;
    background: transparent;
    color: #64748b;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    min-height: 32px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.1;
}

.right-panel-tab-btn:hover {
    color: #0ea5e9;
    background: rgba(14, 165, 233, 0.05);
}

.right-panel-tab-btn.active {
    color: #0ea5e9;
    border-bottom-color: #0ea5e9;
}

.right-panel-tab-content {
    display: none;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 0 0 12px 12px;
    flex: 1;
    /* 残りの高さを埋める */
    overflow: hidden;
    /* 内部スクロールのため */
    flex-direction: column;
    /* grid/flexの子として縮められるように（はみ出し防止の要） */
    min-height: 0;
}

.right-panel-tab-content.active {
    display: flex;
    /* blockではなくflexにして高さを広げる */
    animation: fadeIn 0.2s ease-out;
}

/* 大目標タブ: タブ全体を埋めるようにflexで拡張 */
#tab-breakdown.right-panel-tab-content.active {
    display: flex !important;
    flex-direction: column;
    padding: 4px;
    gap: 4px;
    overflow: hidden;
    min-height: 0;
}

/* 大目標サブセクションがタブ全体を埋める */
#tab-breakdown.right-panel-tab-content.active > .progress-subsection {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 強制表示/非表示クラス（!important で確実に適用） */
.force-hide {
    display: none !important;
}

.force-show {
    display: flex !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ヘッダー部分 */
.right-panel-tab-content .pie-header,
.right-panel-tab-content .log-header {
    flex-shrink: 0;
    padding: 6px 4px; /* 左右を詰める */
}

/* 作業内訳タブのヘッダーはグラフ用として青系の背景色 */
.right-panel-tab-content .pie-header {
    /* 背景がチープに見えやすい青グラデはやめて、To World寄せのニュートラルに */
    background: transparent;
    border-bottom: 1px solid #e5e7eb;
    padding: 4px 4px !important; /* 縦幅圧縮 */
    gap: 6px;
}

/* pie-controls をヘッダー行内で右寄せ固定（インラインstyleを上書き） */
#tab-breakdown .progress-section-header-compact .pie-controls {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important; /* space-between を潰す */
    gap: 6px;
    width: auto !important; /* width:100% を潰す */
    min-width: 0;
    flex: 0 0 auto;
}

#tab-breakdown #pieDurationSummary {
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.1;
    /* 時間は「今月」の右隣へ */
    order: 2;
    flex: 0 0 auto;
    margin-left: 2px;
}

#tab-breakdown .progress-section-header-compact .pie-controls > div {
    /* 右側の操作群 */
    flex-wrap: nowrap;
    white-space: nowrap;
    order: 1;
}

/* 操作群（Prj/Ctg/時間帯/期間）自体も右寄せ・折り返し禁止 */
#tab-breakdown .progress-section-header-compact .pie-controls > div {
    justify-content: flex-end;
}

/* インライン指定があるので !important で密度を合わせる */
#tab-breakdown .breakdown-segment-btn {
    padding: 2px 6px !important;
    font-size: 10px !important;
}

#tab-breakdown #pieRangePreset {
    font-size: 10px;
    padding: 1px 4px;
    height: 22px;
}

/* 作業ログタブのヘッダーは一覧用として落ち着いたグレー系 */
.right-panel-tab-content .log-header {
    background: linear-gradient(to right, rgba(148, 163, 184, 0.12), rgba(148, 163, 184, 0.03));
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

/* パイチャートのラッパー調整 */
.right-panel-tab-content .pieWrap {
    flex: 1;
    position: relative;
    min-height: 0;
    /* Flexboxの子要素でスクロールさせるためのハック */
    padding: 4px 2px; /* 左右をさらに詰める */
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 8px;
}

.right-panel-tab-content #pieCanvas {
    flex: 0 0 auto;
    max-height: 150px; /* To Worldの密度に合わせて縦を詰める */
    max-width: 100%;
}

/* 凡例のスタイル - 右パネルタブ内での表示 */
.right-panel-tab-content #legend {
    flex: 0 0 auto; /* コンテンツ分だけのサイズに（余白を詰める） */
    overflow-y: auto;
    overflow-x: hidden;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px;
    align-content: start;
}

/* ログリストの高さ調整 */
.right-panel-tab-content .logBox {
    flex: 1;
    height: auto;
    /* 固定高さを解除 */
    min-height: 0;
    /* Flexboxの子要素でスクロールさせるためのハック */
    display: flex;
    flex-direction: column;
    /* index.html の inline overflow:hidden を上書きして横スクロールを許可 */
    overflow-x: auto !important;
    overflow-y: hidden !important;
}

/* ==========================
   作業ログ（React移行ブリッジ）空表示の整形
   - ブリッジ側は LogRow を #loglist の直下に並べる（既存CSSに合わせる）
   - 空表示だけは 14列グリッド扱いになると崩れるので、ここで上書き
========================== */
#loglist.loglist > .log-empty {
    grid-column: 1 / -1;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 10px 6px;
}

.right-panel-tab-content .loglist {
    flex: 1;
    overflow-y: auto;
    /* 横スクロールは親(.logBox)に任せる */
    overflow-x: visible;
}

/* 期間プルダウン（今月など）の横幅を30%削減 */
#tab-breakdown #pieRangePreset {
    width: 38px !important;
}

/* カテゴリー/プロジェクト切り替えセグメントボタン */
.breakdown-segment-btn:hover {
    background: rgba(14, 165, 233, 0.1) !important;
}

.breakdown-segment-btn.active {
    background: #0ea5e9 !important;
    color: #fff !important;
}

/* -----------------------------
 * 時間帯（hourly）内訳: 枠内に収める
 * stats-display-service が legendEl に HTML を注入するため、ここで制約をかける
 * ----------------------------- */
.hourly-chart {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    padding: 12px;
}

.hourly-chart__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    min-width: 0;
}

.hourly-chart__title {
    font-size: 14px;
    font-weight: 900;
    /* 時間帯内の灰色テキストは黒に寄せる（ユーザー指示） */
    color: #0f172a;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hourly-chart__hint {
    font-size: 11px;
    color: #94a3b8;
    flex: 0 0 auto;
    white-space: nowrap;
}

.hourly-chart__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    padding: 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.10);
    margin-bottom: 10px;
}

.hourly-chart__legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.hourly-chart__legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: var(--swatch, #64748b);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
    flex: 0 0 auto;
}

.hourly-chart__legend-name {
    font-size: 12px;
    font-weight: 800;
    color: #0f172a;
    max-width: 18ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hourly-chart__empty {
    text-align: center;
    padding: 18px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px dashed rgba(255, 255, 255, 0.16);
}
.hourly-chart__empty-icon { font-size: 26px; margin-bottom: 8px; }
.hourly-chart__empty-title { color: #e2e8f0; font-size: 13px; font-weight: 800; margin-bottom: 6px; }
.hourly-chart__empty-sub { color: #94a3b8; font-size: 11px; line-height: 1.5; }

.hourly-chart__bars {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.10);
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.hourly-chart__col {
    /* 棒グラフの横幅を半分に */
    width: 22px;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.hourly-chart__val {
    font-size: 10px;
    color: #0f172a;
    font-weight: 800;
    text-align: center;
    min-height: 16px;
}

.hourly-chart__bar {
    width: 100%;
    height: 150px;
    display: flex;
    align-items: flex-end;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.hourly-chart__stack {
    width: 100%;
    background: rgba(148, 163, 184, 0.25);
    display: flex;
    flex-direction: column-reverse;
}

.hourly-chart__seg {
    width: 100%;
}

.hourly-chart__tick {
    font-size: 11px;
    color: #0f172a;
    font-weight: 800;
    text-align: center;
}