/* src/public/css/calculator/recipe-cost.css … レシピ原価計算の見た目
   💡 入力欄・ボタン・結果のカード・表は、共通の money.css・calc-common.css を使います（ダークモードは theme-dark.css の末尾） */

/* 材料の行：広い画面は1行（番号・材料名・仕入れ価格・仕入れ量・単位・使う量・歩留まり・消す）。見出しは1度だけ */
.rc-head, .rc-row {
    display: grid;
    grid-template-columns: 1.4em minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 0.9fr) 4.6em minmax(0, 1.1fr) minmax(0, 0.9fr) 2.2em;
    grid-template-areas: "no name price qty unit use yield del";
    gap: 6px; align-items: center;
}
.rc-head { font-size: 0.82rem; font-weight: bold; color: #475569; margin: 12px 0 4px; align-items: end; }
.rc-head span { min-width: 0; overflow-wrap: anywhere; hyphens: auto; line-height: 1.25; }
.rc-rows { display: flex; flex-direction: column; gap: 6px; }
.rc-no { grid-area: no; font-size: 0.85rem; color: #64748b; text-align: center; }
.rc-f-name { grid-area: name; } .rc-f-price { grid-area: price; } .rc-f-qty { grid-area: qty; } .rc-f-unit { grid-area: unit; }
.rc-f-use { grid-area: use; } .rc-f-yield { grid-area: yield; } .rc-del { grid-area: del; }
.rc-f { display: block; min-width: 0; margin: 0; }
/* 広い画面では、欄ごとの名前は読み上げだけ（見出しがある） */
.rc-cap { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.rc-row input, .rc-row select { width: 100%; min-width: 0; box-sizing: border-box; padding: 8px; border: 1px solid #ccc; border-radius: 6px; font-size: 1rem; background: #fff; }
.rc-row select { padding: 7px 4px; }
.rc-row .rc-price, .rc-row .rc-qty, .rc-row .rc-use, .rc-row .rc-yield { text-align: right; }
.rc-with-unit { display: flex; align-items: center; gap: 3px; }
.rc-with-unit > span { font-size: 0.85rem; color: #475569; white-space: nowrap; }
.rc-row [aria-invalid="true"], .mc-form input[aria-invalid="true"] { border-color: #dc2626; background-color: #fef2f2; }
.rc-del { width: 2.2em; height: 2.2em; border: 1px solid #fca5a5; border-radius: 6px; background: #fff; color: #dc2626; cursor: pointer; }
.rc-del:disabled { opacity: 0.35; cursor: not-allowed; }
.rc-add-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 10px 0 14px; }
.rc-add { padding: 8px 14px; border: 1px dashed #94a3b8; border-radius: 6px; background: #fff; color: #2a5298; font-weight: bold; cursor: pointer; }
.rc-add:disabled { opacity: 0.5; cursor: not-allowed; }
.rc-add-note { font-size: 0.85rem; color: #64748b; }

/* 書き出し・読み込み */
.rc-file { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.rc-file-btn { padding: 8px 14px; border: 1px solid #94a3b8; border-radius: 6px; background: #fff; color: #1e3c72; font-weight: bold; cursor: pointer; }

/* 「クリア」「計算する」は、材料が多くても押せるように、画面の下に貼り付ける */
.rc-actions-sticky {
    position: sticky; bottom: 0; z-index: 5;
    margin-left: -8px; margin-right: -8px; padding: 10px 8px;
    background: #ffffff; border-top: 1px solid #e2e8f0;
}
.rc-actions-sticky .btn-group { margin: 0; }
.rc-sticky-message { margin: 0 0 8px; max-height: 7.5em; overflow-y: auto; white-space: pre-line; }
.rc-sticky-message:empty { display: none; }

/* 結果 */
.mc-cards.rc-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rc-cards #rc-current-card { grid-column: 1 / -1; }
.rc-cards .mc-card-val.is-loss { color: #b91c1c; }
.rc-table-title { margin: 16px 0 6px; font-size: 1rem; }
.mc-table.rc-table tbody th, .mc-table.rc-table tfoot th { white-space: normal; overflow-wrap: anywhere; font-weight: normal; }
.mc-table.rc-table tfoot th, .mc-table.rc-table tfoot td { font-weight: bold; border-top: 2px solid #cbd5e1; }
.mc-table.rc-table tr.is-top th { font-weight: bold; color: #9a3412; }
.mc-table.rc-quick-table thead th, .mc-table.rc-quick-table tbody th { white-space: normal; overflow-wrap: anywhere; hyphens: auto; }
.mc-table tr.is-current th, .mc-table tr.is-current td { font-weight: bold; }

/* 狭い画面：材料の行は3段（名前と消す／仕入れ価格・仕入れ量・単位／使う量・歩留まり）。欄ごとに名前を出す */
@media (max-width: 700px) {
    .rc-head { display: none; }
    .rc-row {
        grid-template-columns: 1.2em minmax(0, 1fr) minmax(0, 1fr) 4.8em;
        grid-template-areas:
            "no name name del"
            ". price qty unit"
            ". use use yield";
        gap: 4px 6px; padding: 8px 0; border-bottom: 1px dashed #e2e8f0; align-items: end;
    }
    .rc-cap { position: static; width: auto; height: auto; overflow: visible; clip: auto; display: block; font-size: 0.75rem; color: #475569; margin-bottom: 2px; white-space: normal; overflow-wrap: anywhere; line-height: 1.2; }
    .rc-f-name .rc-cap { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .rc-f-yield { grid-column: 4; }
    .rc-f-use { grid-column: 2 / 4; }
    .rc-del { justify-self: end; }
    .rc-no { align-self: center; }
    .mc-cards.rc-cards { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    /* 16px より小さいと、iPhone が入力のときに画面を拡大する */
    .rc-row input, .rc-row select { padding: 7px 5px; font-size: 16px; }
    .rc-del { width: 32px; height: 32px; }
    .mc-form .rc-opt-grid { grid-template-columns: 1fr; }
    .mc-table.rc-quick-table th, .mc-table.rc-quick-table td { padding-left: 3px; padding-right: 3px; font-size: 0.88rem; }
    /* 原価率の例のボタンは、欄の幅が狭いので折り返す（横に隠れない） */
    .mc-form .mc-chips.rc-chips { flex-wrap: wrap; overflow: visible; }
}
