/* ============================================================
   M・Kシステム 共通スタイル
   ライトテーマ / 全ページ共通。ページ側の <style> は持たせない
   ============================================================ */

:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --border: #e3e6ea;
    --text: #16181d;
    --muted: #6b7280;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.07);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0 0 56px;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP',
        'Yu Gothic UI', Meiryo, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
}

/* ---- ヘッダー ---- */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 56px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.navbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text);
    text-decoration: none;
}
.navbar-brand img { width: 24px; height: 24px; }

/* ---- 見出し ---- */
h1 {
    width: min(420px, 92%);
    margin: 28px auto -8px;
    font-size: 1.3rem;
    font-weight: 700;
}
/* 一覧系のページは本文が広いので見出しも合わせる */
body:has(#result) h1 { width: min(900px, 92%); }

/* ---- ボタン ---- */
.btn-custom,
.btn-custom-red,
#label1,
#folderForm button,
#folderForm .btn-custom,
button[type="submit"] {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 56px;
    padding: 14px 20px;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    text-align: center;
    text-decoration: none;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: background 0.15s ease, transform 0.05s ease;
}
.btn-custom:hover,
#label1:hover,
#folderForm button:hover,
button[type="submit"]:hover { background: var(--accent-hover); }
.btn-custom:active,
.btn-custom-red:active,
#label1:active,
button[type="submit"]:active { transform: translateY(1px); }
.btn-custom-red { background: var(--danger); }
.btn-custom-red:hover { background: var(--danger-hover); }

/* トップページのボタン一覧 */
.btn-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: min(420px, 92%);
    margin: 32px auto 0;
    padding: 0;
    border: none;
    background: none;
}

/* ---- フォーム ---- */
#form,
#folderForm {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: min(420px, 92%);
    margin: 32px auto 0;
    padding: 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}
#form label:not(.btn-custom):not(#label1),
#folderForm label {
    margin-bottom: -6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
    text-align: left;
}
#form #label3 {
    margin: 4px 0 0;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--muted);
    text-align: right;
}

/* カメラ起動用のファイル入力は隠して、ラベルをボタンとして見せる */
#input1, #input3, #input5 { display: none; }

input[type="text"],
input[type="tel"],
select {
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 1.05rem;
    color: var(--text);
    background: #fff;
    border: 1px solid #d3d8de;
    border-radius: 10px;
    appearance: none;
}
select {
    padding-right: 38px;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
input[type="text"]:focus,
input[type="tel"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ---- 撮影プレビュー ---- */
#previews {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    width: min(720px, 92%);
    margin: 20px auto 0;
}
.preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.preview img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 8px;
}
.status {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}

/* ---- 検索結果・一覧 ---- */
#result {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
    width: min(900px, 92%);
    margin: 20px auto 0;
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
}
#result > .link-pair,
#result > div { flex: 1 1 100%; }
.link-pair {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.link-pair a {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
}
.link-pair a:hover { text-decoration: underline; }
.pdf-link {
    margin-left: auto;
    font-size: 0.9rem;
    white-space: nowrap;
}
#result h4 {
    margin: 14px 0 6px;
    font-size: 1rem;
    font-weight: 700;
}
.file-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 8px;
    padding: 0;
    margin: 8px 0 0;
    list-style: none;
}
.file-list-item img {
    display: block;
    width: 100%;
    border-radius: 8px;
}
/* スクラップ閲覧のサムネイル（#resultへ直接置かれる） */
#result > a img { border-radius: 8px; }

/* ---- 当日の配車表 ---- */
#haisha {
    width: min(1100px, 92%);
    margin: 44px auto 0;
}
.haisha-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
#haisha-date {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}
.haisha-reload {
    padding: 7px 14px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
}
.haisha-reload:hover { background: #eef2ff; }
.haisha-reload:disabled { opacity: 0.5; cursor: default; }
.haisha-status {
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: var(--muted);
}
.haisha-status.error { color: var(--danger); }
/* 1日分のかたまり（当日 / 翌日）。翌日分は上に区切り線を入れて切り替わりを分かりやすくする */
.haisha-day + .haisha-day {
    margin-top: 34px;
    padding-top: 26px;
    border-top: 2px solid var(--border);
}
.haisha-day-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 14px;
    font-size: 1.15rem;
    font-weight: 700;
}
.haisha-day-badge {
    padding: 3px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 999px;
}
.haisha-day-badge.today { color: #1d4ed8; background: #e6edff; }
.haisha-day-badge.next  { color: #b45309; background: #fdf0dc; }
.haisha-day-error {
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: var(--muted);
}
.haisha-group { margin-bottom: 26px; }
.haisha-group-title {
    margin: 0 0 8px;
    padding-left: 10px;
    font-size: 1.05rem;
    font-weight: 700;
    border-left: 4px solid var(--accent);
}
.haisha-group.yuzumi .haisha-group-title { border-left-color: #047857; }
.haisha-group.henkyaku .haisha-group-title { border-left-color: #dc2626; }
.haisha-row {
    display: grid;
    /* 最後の列は「西福3694 岡崎 13TU」が1行に収まる幅にしてある */
    grid-template-columns: 4.5em 5em 6.5em minmax(0, 1fr) minmax(0, 1.3fr) 14em;
    gap: 10px;
    align-items: center;
    padding: 12px 14px;
    margin-bottom: 8px;
    font-size: 0.98rem;
    line-height: 1.45;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.haisha-row.head {
    padding: 0 14px;
    margin-bottom: 6px;
    font-size: 0.78rem;
    color: var(--muted);
    background: none;
    border: none;
}
.haisha-cell { overflow-wrap: anywhere; }
/* 客先名・現場名は長くても1行に収め、あふれた分は「…」で省略する（全文はツールチップ） */
.haisha-row .haisha-cell:nth-child(4),
.haisha-row .haisha-cell:nth-child(5) {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.haisha-kubun { font-weight: 700; color: var(--text); white-space: nowrap; }
/* 積卸は「中央ビルト・アBC」のような長い値も入る。
   隣の列に重ねないよう、はみ出す分は折り返す（省略はしない＝中身が消えない） */
.haisha-tsumioroshi {
    white-space: normal;
    overflow-wrap: anywhere;
    color: var(--muted);
}
.haisha-row .haisha-cell:last-child { white-space: nowrap; } /* 車両情報を折り返さない */

/* 区分ごとの色分け */
.k-shukko    { color: #1d4ed8; } /* 出庫 = 青 */
.k-nyuko     { color: #dc2626; } /* 入庫 = 赤 */
.k-yuzumi    { color: #047857; } /* 夕積 = 緑 */
.k-asaoroshi { color: #16181d; } /* 朝卸 = 黒 */
.k-asazumi   { color: #dc2626; } /* 朝積 = 赤 */
.k-hiruzumi  { color: #b45309; } /* 昼積 = 橙（指定が無かったので暫定） */
.k-denyuko   { color: #7c3aed; } /* 出・入庫 = 紫（青と赤の中間の意味合い） */
.haisha-chumon.pending { color: #b45309; font-weight: 600; }
.haisha-empty {
    padding: 4px 2px 8px;
    font-size: 0.9rem;
    color: var(--muted);
}

@media (max-width: 700px) {
    .haisha-row { grid-template-columns: 1fr; gap: 2px; }
    .haisha-row.head { display: none; }
    .haisha-cell::before {
        content: attr(data-label) " ";
        font-size: 0.75rem;
        color: var(--muted);
    }
    .haisha-cell.is-empty { display: none; }
    .haisha-row .haisha-cell:last-child { white-space: normal; }
    .haisha-row .haisha-cell:nth-child(4),
    .haisha-row .haisha-cell:nth-child(5) {
        overflow: visible;
        white-space: normal;
        text-overflow: clip;
    }
    .haisha-kubun { font-size: 1.05rem; }
}

/* スマホでは全体的に文字を大きく（屋外・老眼でも読めるように） */
@media (max-width: 700px) {
    .btn-custom,
    .btn-custom-red,
    #label1,
    #folderForm button,
    button[type="submit"] {
        min-height: 78px;
        font-size: 1.5rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        border-radius: 14px;
    }
    .btn-container { gap: 14px; }
    h1 { font-size: 1.5rem; }
    #form label:not(.btn-custom):not(#label1),
    #folderForm label { font-size: 1.05rem; }
    input[type="text"],
    input[type="tel"],
    select {
        min-height: 56px;
        font-size: 1.2rem;
    }
    .navbar-brand { font-size: 1.15rem; }
    .status { font-size: 0.95rem; }
    .link-pair a { font-size: 1.15rem; }
    .pdf-link { font-size: 1rem; }
}