/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

:root {
  --color-text: #1f2328;
  --color-muted: #59636e;
  --color-border: #d1d9e0;
  --color-bg: #f6f8fa;
  --color-surface: #ffffff;
  --color-primary: #0969da;
  --color-error: #cf222e;
  --color-error-bg: #ffebe9;
  --color-notice-bg: #ddf4ff;
  --color-highlight-bg: #fff8c5;
  /* ホバー・押下時の色（クリックできる部品の反応を分かるようにする） */
  --color-hover-bg: #eef1f4;
  --color-active-bg: #e1e6eb;
  --color-hover-border: #afb8c1;
  --color-primary-hover: #0757b8;
  --color-primary-active: #064a9c;
  --color-row-hover-bg: #eaeef2;
}

* { box-sizing: border-box; }

.body {
  margin: 0;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
}

.body--centered {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

a { color: var(--color-primary); }

/* ヘッダ */
.header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 52px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}
.header__brand a { font-weight: bold; color: var(--color-text); text-decoration: none; }
.header__nav { display: flex; gap: 16px; flex: 1; }
.header__user { display: flex; align-items: center; gap: 8px; }
.header__department {
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  font-size: 12px;
}
.header__logout { margin: 0; }

.main { padding: 24px; }

/* お知らせ・エラー */
.alert {
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: 6px;
  border: 1px solid;
}
.alert ul { margin: 4px 0 0; padding-left: 20px; }
.alert p { margin: 0; }
.alert--error { color: var(--color-error); background: var(--color-error-bg); border-color: var(--color-error); }
.alert--notice { background: var(--color-notice-bg); border-color: var(--color-primary); }

/* フォーム */
.form__field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.form__field input,
.form__field select,
.form__field textarea {
  padding: 6px 8px;
  font: inherit;
  border: 1px solid var(--color-border);
  border-radius: 6px;
}
.form__actions { display: flex; justify-content: flex-end; gap: 8px; }

/* 入力エラーのある欄（Rails が field_with_errors で囲む） */
.field_with_errors { display: contents; }
.field_with_errors label { color: var(--color-error); }
.field_with_errors input,
.field_with_errors select,
.field_with_errors textarea { border-color: var(--color-error); background: var(--color-error-bg); }

/* ボタン */
.button {
  padding: 6px 16px;
  font: inherit;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  cursor: pointer;
}
.button--primary { color: #fff; background: var(--color-primary); border-color: var(--color-primary); }
.button--link { padding: 0; border: none; background: none; color: var(--color-primary); }

/* ログイン */
.login {
  width: 360px;
  padding: 32px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
}
.login__title { margin: 0 0 24px; font-size: 20px; text-align: center; }

/* ページ見出し */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.page-header h1 { margin: 0; font-size: 20px; }
.page-header__sub { margin-left: 8px; font-size: 16px; font-weight: normal; color: var(--color-muted); }

/* パネル */
.panel {
  margin-bottom: 16px;
  padding: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
}
.panel--row { display: flex; align-items: center; gap: 16px; }
.panel__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel__title { margin: 0; font-size: 16px; }

/* 詳細の項目一覧 */
.details { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 24px; margin: 0; }
.details dt { font-size: 12px; color: var(--color-muted); }
.details dd { margin: 2px 0 0; }
.details dd p { margin: 0; }
.details__wide { grid-column: 1 / -1; }

/* 表 */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}
.table th,
.table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--color-border); }
.table th { font-size: 12px; color: var(--color-muted); background: var(--color-bg); white-space: nowrap; }
.table__number { text-align: right; }
.table th.table__number { text-align: right; }
/* 材質が部品マスタと違う部品明細の行（製作指図 04 の 3.3） */
.table tbody tr.is-material-changed td { background: var(--color-highlight-bg); }
/* 表の中の数値の入力欄（製作指図の No・数量など） */
.input--number { width: 5em; }

.empty { color: var(--color-muted); }

/* ページ分割 */
.pagination { display: flex; justify-content: center; gap: 4px; margin-top: 16px; }
.pagination__link,
.pagination__current { min-width: 32px; padding: 4px 8px; text-align: center; border-radius: 6px; }
.pagination__link { text-decoration: none; border: 1px solid var(--color-border); background: var(--color-surface); }
.pagination__current { font-weight: bold; color: #fff; background: var(--color-primary); }

/* フォーム（パネル型） */
.form--panel {
  max-width: 640px;
  padding: 24px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
}
.form__label { font-weight: bold; }
.form__radios { display: flex; gap: 16px; }
.form__readonly { padding: 6px 0; }
.form__inline { display: flex; align-items: center; gap: 8px; }
.form__short { width: 96px; }
.form--panel .form__actions { justify-content: space-between; }
.required { margin-left: 2px; color: var(--color-error); }
.is-invalid { border-color: var(--color-error) !important; background: var(--color-error-bg); }

/* ボタン（追加） */
a.button { display: inline-block; color: var(--color-text); text-decoration: none; }
a.button--primary { color: #fff; }
.button--small { padding: 2px 10px; font-size: 12px; }
.button--disabled,
.button:disabled { color: var(--color-muted); background: var(--color-bg); cursor: not-allowed; }

/* ボタン・リンクのホバーと押下。押せないボタンは見た目を変えない */
.button,
.pagination__link { transition: background-color 0.1s, border-color 0.1s; }
.button:not(:disabled, .button--disabled, .button--primary, .button--link):hover { background: var(--color-hover-bg); border-color: var(--color-hover-border); }
.button:not(:disabled, .button--disabled, .button--primary, .button--link):active { background: var(--color-active-bg); }
.button--primary:not(:disabled, .button--disabled):hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
.button--primary:not(:disabled, .button--disabled):active { background: var(--color-primary-active); border-color: var(--color-primary-active); }
.button--link:not(:disabled, .button--disabled):hover { text-decoration: underline; }
.pagination__link:hover { background: var(--color-hover-bg); border-color: var(--color-hover-border); }
.pagination__link:active { background: var(--color-active-bg); }

/* メニュー */
.menu {
  width: 360px;
  margin: 40px auto;
  padding: 32px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
}
.menu__title { margin: 0 0 24px; font-size: 20px; text-align: center; }
.menu__items { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; list-style: none; }
.menu__items form { margin: 0; }
.menu__button { width: 100%; padding: 12px 16px; text-align: center; }

/* 検索条件 */
.search { display: flex; align-items: flex-end; gap: 16px; }
.search__fields { display: flex; flex-wrap: wrap; gap: 12px 16px; flex: 1; }
.search__field { display: flex; align-items: center; gap: 6px; }
.search__field label { font-size: 12px; color: var(--color-muted); white-space: nowrap; }
.search__field input,
.search__field select { padding: 4px 6px; font: inherit; border: 1px solid var(--color-border); border-radius: 6px; }
.search__field--wide input { width: 240px; }
.search__short { width: 120px; }

/* 行を選べる表 */
.table--selectable tbody tr { cursor: pointer; }
.table--selectable tbody tr:hover { background: var(--color-row-hover-bg); }
.table--selectable tbody tr.is-selected { background: var(--color-notice-bg); }

/* ボタンの並び */
.toolbar { display: flex; gap: 8px; margin: 16px 0; }
.toolbar--end { justify-content: flex-end; }
.button--icon { padding: 4px 8px; line-height: 1; }
.form--narrow { max-width: 480px; }
.form__actions--split { justify-content: space-between; margin-top: 16px; }

/* モーダル */
.modal {
  width: 560px;
  padding: 24px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
}
.modal::backdrop { background: rgb(0 0 0 / 30%); }
.modal__title { margin: 0 0 16px; font-size: 16px; }
.modal__list { max-height: 280px; margin-top: 16px; overflow-y: auto; }
.modal--wide { width: 800px; }

/* 製作情報（02） */
.form__group { margin: 0 0 16px; padding: 12px 16px; border: 1px solid var(--color-border); border-radius: 6px; }
.form__group legend { padding: 0 4px; font-weight: bold; }
/* 製作情報は案件情報とフォームを同じ幅にそろえ、画面の中央に置く。
   フォームは表（付属品・特注品・必要書類）を持つので、通常のパネルの幅の上限を外して枠いっぱいに広げる */
.page--centered { max-width: 1120px; margin: 0 auto; }
.page--centered .details { margin-bottom: 16px; }
.form--wide { max-width: none; }
/* ⑤ 付属品情報の「編集」ボタンと一覧の間を空ける */
.accessories { margin-top: 8px; }
/* 表の中の入力欄は他の入力欄と同じ見た目にし、セルの幅に合わせる（maxlength から決まる size で表が広がらないように） */
.form__group .table input[type="text"],
.form__group .table input[type="date"] {
  padding: 4px 8px;
  font: inherit;
  border: 1px solid var(--color-border);
  border-radius: 6px;
}
.form__group .table input[type="text"] { width: 100%; }
.form__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 16px; }
/* 見積明細（03 の 3.3）。諸経費行は灰色、小計行は区切り線 */
.table tbody tr.estimate-line--expense td { background: var(--color-bg); color: var(--color-muted); }
.table tbody tr.estimate-line--subtotal td { border-top: 2px solid var(--color-border); font-weight: bold; }
/* 品名仕様は「部品名【規格】」が切れない幅を取り、行の種類は選択肢の文字が切れないようにする */
.estimate-lines__description { min-width: 16em; }
.estimate-lines .estimate-lines__line-type { min-width: 6em; padding: 4px 6px; font: inherit; border: 1px solid var(--color-border); border-radius: 6px; }
/* 仕様変更（06 の 6-1）。新規ボタンは右端に置き、一覧と入力欄の間を空ける */
.spec-changes__header { justify-content: space-between; }
.spec-changes { margin-bottom: 16px; }
/* 確認内容の 3 枠（06 の 3.4）。各枠は左に確認の状態、右に確認内容 */
.confirmations { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.confirmation { display: flex; border: 1px solid var(--color-border); border-radius: 6px; }
.confirmation__status { flex: 0 0 8em; padding: 8px; font-size: 12px; border-right: 1px solid var(--color-border); }
.confirmation__department { margin-bottom: 4px; font-weight: bold; }
.confirmation__note { display: flex; flex: 1; flex-direction: column; align-items: flex-end; gap: 8px; padding: 8px; }
.confirmation__note textarea { width: 100%; padding: 4px 8px; font: inherit; border: 1px solid var(--color-border); border-radius: 6px; }
/* 製作進捗（05 の 3.2）。横に長い一覧は横スクロールし、製番・御需要家・納期の 3 列は左に固定する */
.progress-table { overflow-x: auto; border: 1px solid var(--color-border); border-radius: 6px; }
.progress-table .table { width: max-content; min-width: 100%; }
.progress-table td { white-space: nowrap; background: var(--color-surface); }
.progress-table input[type="text"],
.progress-table input[type="date"],
.progress-table select { padding: 4px 6px; font: inherit; border: 1px solid var(--color-border); border-radius: 6px; }
.progress-table input[type="text"] { width: 10em; }
.progress-table__fixed { position: sticky; z-index: 1; box-sizing: border-box; }
.progress-table__fixed--1 { left: 0; width: 8em; min-width: 8em; }
.progress-table__fixed--2 { left: 8em; width: 14em; min-width: 14em; white-space: normal; }
.progress-table__fixed--3 { left: 22em; width: 7em; min-width: 7em; border-right: 2px solid var(--color-border); }
/* 見出しの色はマニュアルどおり（納期はオレンジ、最終検査は緑、出荷日は水色） */
.progress-table th.progress-table__head--due { color: #000; background: #ffc078; }
.progress-table th.progress-table__head--inspected { color: #000; background: #b2f2bb; }
.progress-table th.progress-table__head--shipped { color: #000; background: #a5d8ff; }
