/* ページ全体。日本語は端末の標準フォントで表示する(外部フォントは読み込まない) */
html, body {
    margin: 0;
    font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* MudBlazor の文字も、端末の日本語フォントにそろえる(Roboto を読み込まないので、先頭の指定が効かないため) */
.mud-typography, .mud-input, .mud-button-root, .mud-table, .mud-chip, .mud-tab {
    font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, -apple-system, "Segoe UI", sans-serif !important;
}

/* 起動中の表示 */
.app-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 100vh;
    color: #555;
    font-size: 1rem;
}

/* 待っている間、キャラクターが小さくはねる(動きを減らす設定のときは止める) */
.app-loading img {
    animation: mascot-hop 1.2s ease-in-out infinite;
}

@keyframes mascot-hop {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@media (prefers-reduced-motion: reduce) {
    .app-loading img { animation: none; }
}

/* 明細の表: 列の種類ごとの色分け(見出しとセル)。濃い方が合計の列、薄い方が内訳の列。
   収入=緑、支出=橙、ローン返済・積立・取り崩し=青。残高(現預金・資産・負債・純資産)と収支は無色。
   固定した見出しが透けないよう、不透明な色にする(MudBlazor の見出しの背景より優先するため !important)。 */
.detail-table .cat-income { background-color: #d7ecde !important; }
.detail-table .cat-income-detail { background-color: #edf7f0 !important; }
.detail-table .cat-expense { background-color: #fde1cb !important; }
.detail-table .cat-expense-detail { background-color: #fef0e5 !important; }
.detail-table .cat-flow { background-color: #d9e5fa !important; }
.detail-table .cat-flow-detail { background-color: #edf2fc !important; }

/* 見出しは折り返さない(「取り崩し」が縦に割れないように) */
.detail-table th { white-space: nowrap; }

/* 色の凡例(表の上) */
.detail-legend {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
    margin: 4px 0;
}

.detail-legend .swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin: 0 4px 0 10px;
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 2px;
    vertical-align: -2px;
}

.detail-legend .swatch:first-of-type { margin-left: 4px; }
.swatch-income { background-color: #d7ecde; }
.swatch-expense { background-color: #fde1cb; }
.swatch-flow { background-color: #d9e5fa; }

/* 行にカーソルを乗せたときは、色付きのセルも少し暗くして、どの行かを分かるようにする */
.detail-table .mud-table-body .mud-table-row:hover > td[class*="cat-"] { filter: brightness(0.95); }

/* ヘッダーのロゴ(キャラクター) */
.app-logo {
    margin-right: 8px;
    flex-shrink: 0;
}

/* 「まだありません」のような案内に添える絵 */
.empty-state {
    display: flex;
    align-items: center;
    gap: 12px;
}

.empty-state .mascot {
    flex-shrink: 0;
}

/* エラー表示(Blazor が必要なときだけ表示する) */
#blazor-error-ui {
    background: #fff3cd;
    color: #664d03;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 2000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* 表を載せる Expansion Panel は、表の幅を確保するため内側の左右余白を詰める */
.mud-expand-panel.table-panel .mud-expand-panel-content {
    padding-left: 8px;
    padding-right: 8px;
}

/* ---- 印刷(ブラウザの「印刷」→「PDFに保存」)。操作の部品を隠し、表を全部出す ---- */
.print-only {
    display: none;
}

@media print {
    @page {
        size: A4 landscape;
        margin: 10mm;
    }

    body {
        background: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .mud-appbar,
    .no-print,
    .mud-table-pagination,
    .mud-snackbar-provider,
    #blazor-error-ui {
        display: none !important;
    }

    .print-only {
        display: block !important;
        margin-bottom: 8px;
    }

    .mud-main-content {
        padding-top: 0 !important;
    }

    .mud-container {
        max-width: none !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* 表: 高さの固定とスクロールをやめ、全行を出す。見出し行の固定も外す */
    .mud-table-container {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .mud-table-root th,
    .mud-table-root td {
        position: static !important;
        font-size: 9px !important;
        padding: 2px 4px !important;
    }

    .mud-table-root tr {
        break-inside: avoid;
    }

    .mud-paper,
    .mud-expand-panel {
        box-shadow: none !important;
    }

    .mud-expand-panel {
        break-inside: auto;
    }
}

/* 日付ピッカーのポップアップ: 入力欄が狭くても、カレンダーが潰れない幅を確保する(幅220pxの対象月など) */
.mud-picker-popover {
    min-width: 300px;
}

/* 入力画面の、画面の下に付いてくる収支の目安 */
.balance-bar { position: sticky; bottom: 0; z-index: 4; margin-top: 16px; }
@media print { .balance-bar { display: none !important; } }

/* ダークモード(画面の右上のボタンで切り替える。MudBlazor の色は自動で変わるので、ここは自前の色だけ) */
.app-dark .detail-table .cat-income { background-color: #1f3a2a !important; }
.app-dark .detail-table .cat-income-detail { background-color: #19301f !important; }
.app-dark .detail-table .cat-expense { background-color: #4a3220 !important; }
.app-dark .detail-table .cat-expense-detail { background-color: #3a281a !important; }
.app-dark .detail-table .cat-flow { background-color: #22344f !important; }
.app-dark .detail-table .cat-flow-detail { background-color: #1b2a40 !important; }
.app-dark .swatch-income { background-color: #1f3a2a; }
.app-dark .swatch-expense { background-color: #4a3220; }
.app-dark .swatch-flow { background-color: #22344f; }

/* ファイルバー: 未保存の変更があるとき、左に黄色の線を付けて目立たせる */
.file-bar-dirty { border-left: 4px solid var(--mud-palette-warning) !important; }

/* ファイルをドラッグしている間、画面全体に「ここにドロップして開く」を出す(.file-dragging は shortcuts.js が付け外しする) */
body.file-dragging::after {
    content: "ここにファイルをドロップして開く(.lifeplan.json)";
    position: fixed;
    inset: 12px;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px dashed var(--mud-palette-primary);
    border-radius: 12px;
    background: color-mix(in srgb, var(--mud-palette-surface) 88%, transparent);
    color: var(--mud-palette-primary);
    font-size: 1.25rem;
    font-weight: 500;
    pointer-events: none;
}
@media print { body.file-dragging::after { display: none; } }

/* スマホ幅の下部ナビ(MainLayout の nav.bottom-nav。広い画面では d-sm-none で隠れる) */
.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1050;
    display: flex;
    background: var(--mud-palette-surface);
    border-top: 1px solid var(--mud-palette-lines-default);
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 0 6px;
    font-size: 0.75rem;
    text-decoration: none;
    color: var(--mud-palette-text-secondary);
}
.bottom-nav-item.active { color: var(--mud-palette-primary); font-weight: 600; }
@media (max-width: 599.98px) {
    .mud-main-content { padding-bottom: 72px; }      /* 下部ナビに、本文の末尾が隠れないように */
    .balance-bar { bottom: 58px; }                   /* 入力画面の収支の目安は、下部ナビの上に */
}
