/**
 * calendar.css
 * 現場・予定カレンダー(社員画面 screen-calendar / calendar.js)の見た目。
 * 色は既存の style.css の変数(--primary など)を使い、ダークモードにもそのまま合わせる。
 * iPhoneで押しやすいよう、押す部品は高さ44px以上・入力欄は16px(拡大されないため)にしてある。
 */

/* カレンダーを開いているときだけ、PCでは横幅を広げる(月表示が窮屈にならないように) */
main:has(#screen-calendar:not(.hidden)) { max-width: 1100px; }

.cal-banner {
  border: 1px solid #f59e0b; background: #fff7e6; color: #7a4a00;
  border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 14px;
}
html[data-theme="dark"] .cal-banner { background: #3a2a0a; color: #ffd48a; }
.cal-banner a { color: inherit; font-weight: bold; }

.cal-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin: 8px 0; }
.cal-views, .cal-nav { display: flex; gap: 6px; align-items: center; }
.cal-btn {
  min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--secondary); color: var(--secondary-text); font-size: 15px; cursor: pointer;
}
.cal-btn.is-active { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.cal-title { font-weight: bold; font-size: 17px; margin: 4px 0; }
.cal-filter { display: flex; gap: 8px; align-items: center; margin: 4px 0 8px; }
.cal-filter select { margin-top: 0; }

.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 10px; margin: 4px 0 10px; font-size: 13px; color: var(--text-sub); }
.cal-legend span { display: inline-flex; align-items: center; gap: 4px; }
.cal-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

/* ===== 月表示 ===== */
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.cal-wd { text-align: center; font-size: 12px; font-weight: bold; padding: 6px 0; background: var(--secondary); color: var(--text-sub); }
.cal-wd.sun, .cal-day.sun .cal-daynum, .cal-day.is-holiday .cal-daynum { color: #d93025; }
.cal-wd.sat, .cal-day.sat .cal-daynum { color: #1a73e8; }
/* 日曜・祝日・休日は薄い赤、土曜は薄い青(2026-09-30)。ダークモードでも見えるよう半透明にしている */
.cal-day.sun, .cal-day.is-holiday, .cal-listday.sun, .cal-listday.is-holiday { background: rgba(217, 48, 37, .07); }
.cal-day.sat, .cal-listday.sat { background: rgba(26, 115, 232, .07); }
.cal-holiday-name {
  display: block; font-size: 10px; line-height: 1.2; color: #d93025; font-weight: normal;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-listhead .cal-holiday-name { display: inline; font-size: 12px; margin-left: 4px; }
.cal-listhead .is-holiday { color: #d93025; }
/* 資格試験日(全員向け。予定とは別の紫系で見分ける) */
.cal-exam {
  display: block; font-size: 11px; line-height: 1.3; padding: 1px 4px; margin-top: 2px; border-radius: 4px;
  background: rgba(147, 52, 230, .12); color: #7b2cbf; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-exam-row {
  margin-top: 8px; padding: 6px 8px; border-radius: 8px; font-size: 14px; font-weight: bold;
  background: rgba(147, 52, 230, .12); color: #7b2cbf;
}
html[data-theme="dark"] .cal-exam, html[data-theme="dark"] .cal-exam-row { color: #d0a8ff; }
.cal-day {
  min-height: 92px; border-top: 1px solid var(--border); border-left: 1px solid var(--border);
  padding: 3px; cursor: pointer; position: relative; min-width: 0;
}
.cal-day:nth-child(7n+1) { border-left: none; }
.cal-day.is-other { background: var(--bg); opacity: .6; }
.cal-day.is-today { background: rgba(26, 115, 232, .08); }
.cal-day.is-today .cal-daynum { background: var(--primary); color: var(--primary-text); border-radius: 50%; }
.cal-day.is-drop { outline: 2px dashed var(--primary); outline-offset: -2px; }
.cal-daynum { font-size: 13px; font-weight: bold; display: inline-block; min-width: 22px; height: 22px; line-height: 22px; text-align: center; }
.cal-chip {
  display: block; font-size: 12px; line-height: 1.3; padding: 2px 4px; margin-top: 2px; border-radius: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; cursor: pointer;
}
.cal-chip[draggable="true"] { cursor: grab; }
.cal-more { font-size: 12px; color: var(--primary); padding: 2px 4px; cursor: pointer; }

/* ===== 週表示・日表示(縦に並べる。スマホで読みやすいように) ===== */
.cal-list { display: flex; flex-direction: column; gap: 8px; }
.cal-listday { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.cal-listday.is-today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.cal-listday.is-drop { outline: 2px dashed var(--primary); }
.cal-listhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-listhead b { font-size: 15px; }
.cal-listhead .sun { color: #d93025; }
.cal-listhead .sat { color: #1a73e8; }
.cal-add-day { min-height: 40px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--secondary); color: var(--secondary-text); font-size: 14px; cursor: pointer; }
.cal-empty { color: var(--text-sub); font-size: 13px; padding: 6px 0 2px; }
.cal-item {
  display: flex; gap: 10px; align-items: stretch; margin-top: 8px; padding: 8px; border-radius: 8px;
  background: var(--bg); cursor: pointer; border-left: 6px solid var(--border); min-height: 44px;
}
.cal-item[draggable="true"] { cursor: grab; }
.cal-item-time { flex: none; width: 58px; font-size: 13px; font-weight: bold; color: var(--text-sub); }
.cal-item-main { flex: 1; min-width: 0; }
.cal-item-title { font-weight: bold; font-size: 15px; word-break: break-all; }
.cal-item-sub { font-size: 13px; color: var(--text-sub); margin-top: 2px; word-break: break-all; }
.cal-kind { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--secondary); color: var(--text-sub); margin-right: 4px; font-weight: normal; }
.cal-sync { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: #fff0e0; color: #9a4b00; margin-left: 4px; font-weight: normal; }
.cal-dots { display: inline-flex; gap: 3px; margin-left: 4px; vertical-align: middle; }

/* 予定を追加ボタン(画面下に固定。親指で押しやすい位置) */
.cal-fab {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 50;
  min-height: 52px; padding: 0 20px; border-radius: 26px; border: none; background: var(--primary); color: var(--primary-text);
  font-size: 16px; font-weight: bold; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); cursor: pointer;
}

/* ===== 入力・詳細のシート ===== */
.cal-sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 1000;
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 700px) { .cal-sheet-backdrop { align-items: center; padding: 16px; } }
.cal-sheet {
  background: var(--surface); color: var(--text); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: 16px 16px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 30px rgba(0, 0, 0, .25); -webkit-overflow-scrolling: touch;
}
@media (min-width: 700px) { .cal-sheet { border-radius: 14px; } }
.cal-sheet h3 { margin: 0 0 6px; }
.cal-sheet label { margin: 12px 0 2px; }
.cal-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cal-check { display: flex; align-items: center; gap: 8px; font-weight: normal; margin: 12px 0 0; min-height: 44px; }
.cal-check input { width: 22px; height: 22px; margin: 0; }
.cal-staff-checks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.cal-staff-checks label { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 0 10px; min-height: 44px; border: 1px solid var(--border); border-radius: 8px; font-weight: normal; cursor: pointer; }
.cal-staff-checks input { width: 20px; height: 20px; margin: 0; }
.cal-sheet-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.cal-sheet-actions .btn { flex: 1 1 140px; margin: 0; min-height: 50px; font-size: 16px; }
.btn-danger { background: var(--danger); color: #fff; }
.cal-site-results { border: 1px solid var(--border); border-radius: 8px; margin-top: 4px; max-height: 220px; overflow: auto; }
.cal-site-results div { padding: 10px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 14px; }
.cal-site-results div:last-child { border-bottom: none; }
.cal-site-results small { color: var(--text-sub); display: block; }
.cal-detail dt { font-size: 12px; color: var(--text-sub); margin-top: 10px; }
.cal-detail dd { margin: 2px 0 0; white-space: pre-wrap; word-break: break-all; }
.cal-err { color: var(--danger); font-size: 14px; margin-top: 10px; min-height: 1em; }
.cal-move { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; }
.cal-move input { margin-top: 0; }
.cal-move .cal-btn { flex: none; }

@media (max-width: 480px) {
  .cal-exam { font-size: 9px; padding: 0 2px; }
  .cal-day { min-height: 64px; padding: 2px; }
  .cal-chip { font-size: 10px; padding: 1px 2px; }
  .cal-daynum { font-size: 12px; }
  .cal-title { width: 100%; }
}

/* =====================================================================
 * 見た目の作り直し(2026-09-30 狩野さん指定: iPhone標準カレンダー風)
 * 上の指定を上書きする。動き(日付を押す・予定を押す・ドラッグ)は変えていない。
 * ===================================================================== */
:root { --cal-accent: #e5242b; --cal-line: #e6e6ea; --cal-weekend: #f6f6f8; }
html[data-theme="dark"] { --cal-line: #333; --cal-weekend: #1a1a1c; }

.cal-toolbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 6px 0 10px; }
.cal-title { font-size: 22px; font-weight: normal; margin: 0; white-space: nowrap; }
.cal-title-year { color: var(--text-sub); }
.cal-title b { font-weight: 800; }
/* 日/週/月 の切り替え(つながった灰色の枠) */
.cal-views { display: inline-flex; gap: 0; background: #eeeef0; border-radius: 9px; padding: 2px; justify-self: center; }
html[data-theme="dark"] .cal-views { background: #2a2a2c; }
.cal-views .cal-btn {
  min-height: 36px; min-width: 76px; border: none; background: transparent; border-radius: 7px;
  font-size: 14px; font-weight: 600; color: var(--text); padding: 0 16px;
}
.cal-views .cal-btn.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
/* 右側の ‹ 今日 › ＋(赤い文字だけのボタン) */
.cal-nav { justify-self: end; display: flex; align-items: center; gap: 2px; }
.cal-navbtn {
  min-width: 44px; min-height: 44px; border: none; background: transparent; color: var(--cal-accent);
  font-size: 26px; line-height: 1; cursor: pointer; border-radius: 8px; padding: 0 8px;
}
.cal-navbtn:hover { background: rgba(229, 36, 43, .08); }
.cal-today-btn { font-size: 17px; font-weight: 600; }
.cal-add-btn { font-size: 28px; }

/* 月表示: 罫線は横の細い線だけ。土日の列は淡い灰色 */
.cal-month { border: none; border-radius: 0; background: var(--surface); }
.cal-wd { background: transparent; color: var(--text-sub); font-weight: normal; font-size: 15px; text-align: left; padding: 6px 8px 8px; }
.cal-wd.sun, .cal-wd.sat { color: var(--text-sub); }
.cal-wd.is-today-wd { color: var(--cal-accent); font-weight: 700; }
.cal-day {
  min-height: 118px; border-left: none; border-top: 1px solid var(--cal-line); padding: 6px 6px 4px;
  background: var(--surface);
}
.cal-day.sat, .cal-day.sun { background: var(--cal-weekend); }
/* 祝日・休日は、以前の指定どおり淡い赤で区別する(土日の灰色より少し色を付ける) */
.cal-day.is-holiday { background: rgba(229, 36, 43, .05); }
.cal-daynum {
  font-size: 15px; font-weight: 600; color: var(--text); display: inline-block; min-width: 0; height: auto;
  line-height: 1.6; padding: 0 6px; margin-left: -6px; text-align: left; border-radius: 14px;
}
.cal-wd.sun, .cal-day.sun .cal-daynum, .cal-day.sat .cal-daynum { color: var(--text); }
.cal-day.is-holiday .cal-daynum { color: var(--cal-accent); }
.cal-day.is-other { background: var(--surface); opacity: 1; }
.cal-day.is-other.sat, .cal-day.is-other.sun { background: var(--cal-weekend); }
.cal-day.is-other .cal-daynum { color: #c7c7cc; }
.cal-day.is-other .cal-chip, .cal-day.is-other .cal-exam { opacity: .45; }
.cal-day.is-today { background: inherit; }
.cal-day.is-today.sat, .cal-day.is-today.sun { background: var(--cal-weekend); }
.cal-day.is-today .cal-daynum { background: var(--cal-accent); color: #fff; }
.cal-holiday-name { color: var(--cal-accent); font-size: 11px; margin-top: 1px; }
/* 予定: 色の「●」+ 現場名(帯は付けない) */
.cal-chip {
  display: flex; align-items: center; gap: 5px; background: transparent !important; color: var(--text);
  font-size: 13px; line-height: 1.35; padding: 1px 0; margin-top: 3px; border-radius: 4px;
}
.cal-chip:hover { background: rgba(0, 0, 0, .05) !important; }
.cal-chip .cal-dot { width: 8px; height: 8px; }
.cal-exam { background: transparent; padding: 1px 0; font-size: 12px; margin-top: 3px; }
.cal-more { color: var(--text-sub); font-size: 12px; padding: 1px 0; }

/* 週・日表示もカードの枠を弱めて、同じ雰囲気にそろえる */
.cal-listday { border: none; border-top: 1px solid var(--cal-line); border-radius: 0; padding: 10px 4px; }
.cal-listday.sat, .cal-listday.sun { background: var(--cal-weekend); }
.cal-listday.is-holiday { background: rgba(229, 36, 43, .05); }
.cal-listday.is-today { box-shadow: none; border-color: var(--cal-line); }
.cal-listday.is-today .cal-listhead b { color: var(--cal-accent); }
.cal-listhead .sun, .cal-listhead .sat { color: var(--text); }
.cal-listhead .is-holiday { color: var(--cal-accent); }
.cal-add-day { border: none; background: transparent; color: var(--cal-accent); font-weight: 600; }
.cal-item { background: transparent; border-left-width: 4px; }

@media (max-width: 640px) {
  .cal-toolbar { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title nav" "views views"; }
  .cal-title { grid-area: title; font-size: 20px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .cal-nav { grid-area: nav; }
  .cal-views { grid-area: views; justify-self: stretch; }
  .cal-views .cal-btn { flex: 1; min-width: 0; min-height: 34px; }
}
@media (max-width: 480px) {
  .cal-day { min-height: 76px; padding: 4px 2px 2px; }
  .cal-daynum { font-size: 13px; padding: 0 4px; margin-left: -2px; }
  .cal-chip { font-size: 10px; gap: 2px; margin-top: 1px; }
  .cal-chip .cal-dot { width: 6px; height: 6px; }
  .cal-wd { font-size: 12px; padding: 4px 3px; }
  .cal-navbtn { min-width: 40px; font-size: 24px; padding: 0 4px; }
  .cal-today-btn { font-size: 15px; }
  .cal-title { font-size: 17px; }
}

/* 資格試験日(月表示): 紫の「●」+名前 */
.cal-exam { display: flex; align-items: center; gap: 5px; }
.cal-exam-dot { width: 8px; height: 8px; background: #9334e6; }
@media (max-width: 480px) { .cal-exam { font-size: 10px; gap: 2px; } .cal-exam-dot { width: 6px; height: 6px; } }
.cal-exam, .cal-chip { overflow: hidden; white-space: nowrap; min-width: 0; }
.cal-exam .cal-dot, .cal-chip .cal-dot { flex: none; }
