/* PARMEL Gear — style.css
   軽量・ダーク基調。PC/スマホ両対応（レスポンシブ）。 */

:root {
  --bg: #0a0c0b;
  --bg-elev: #121613;
  --bg-elev2: #1a201c;
  --line: #29332c;
  --text: #e9efe9;
  --text-dim: #90a096;
  --accent: #22c55e;
  --accent-2: #4ade80;
  --accent-dim: #14532d;
  --danger: #ff5b6a;
  --ok: #34d399;
  --warn: #ffcf5b;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  /* 英字=Helvetica / 日本語=Noto Sans JP */
  font-family: "Helvetica Neue", Helvetica, Arial, "Noto Sans JP",
    "Hiragino Kaku Gothic ProN", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- ヘッダー / ナビ ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 20px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.topbar .brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
}
.topbar .brand span { color: var(--accent); }
.topbar nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.topbar nav a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-dim);
}
.topbar nav a.active,
.topbar nav a:hover {
  background: var(--bg-elev2);
  color: var(--text);
  text-decoration: none;
}
.topbar .spacer { flex: 1; }
.topbar .user {
  color: var(--text-dim);
  font-size: 13px;
}

/* ---- レイアウト ---- */
.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
h1 { font-size: 23px; margin: 0; font-weight: 800; letter-spacing: -0.01em; }
h2 {
  font-size: 15px;
  margin: 26px 0 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding-left: 11px;
  border-left: 4px solid var(--accent);
  line-height: 1.2;
}
.muted { color: var(--text-dim); }
.small { font-size: 13px; }

/* ---- カード ---- */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}

/* ---- ボタン ---- */
button, .btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--bg-elev2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  transition: background 0.15s, border-color 0.15s;
}
button:hover, .btn:hover { border-color: var(--accent-dim); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #052012;
  font-weight: 700;
}
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger { color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- フォーム ---- */
label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 64px; }
.field { margin-bottom: 12px; }
.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.checkline { display: flex; align-items: center; gap: 10px; }
.checkline label { margin: 0; color: var(--text); cursor: pointer; user-select: none; }
/* スライド式トグル（アーカイブON/OFF・通知トグル共通）— 添付イメージ準拠 */
.checkline input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  padding: 0;
  border-radius: 999px;
  background: var(--bg-elev2);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.checkline input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s ease;
}
.checkline input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.checkline input[type="checkbox"]:checked::after { transform: translateX(18px); }
.checkline input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* ---- テーブル ---- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th { color: var(--text-dim); font-weight: 600; white-space: nowrap; }
tr:hover td { background: var(--bg-elev2); }

/* ---- バッジ ---- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
  color: var(--text-dim);
}
.badge.on { color: var(--ok); border-color: var(--ok); }
.badge.off { color: var(--text-dim); }
.badge.today { color: var(--warn); border-color: var(--warn); }
.badge.cat { color: var(--accent); border-color: var(--accent-dim); }

/* ---- 複数日ウィジェット ---- */
.md-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.md-row .md-input { width: auto; flex: 1; min-width: 130px; }
.md-row .md-sep { color: var(--text-dim); flex: 0 0 auto; }
.md-row .md-add { white-space: nowrap; }
.md-cal-toggle { margin-top: 8px; }

/* 開催日ミニカレンダー（タップでトグル選択） */
.md-cal {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  max-width: 360px;
}
.md-cal.hidden { display: none; }
.md-cal .cal-head { padding: 6px 10px; }
.md-cal .cal-head .title { font-size: 14px; }
.md-cal .cal-cell {
  min-height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.md-cal .cal-cell .daynum { font-size: 13px; }
.md-cal .cal-cell.sel {
  background: var(--accent);
  outline: none;
}
.md-cal .cal-cell.sel .daynum { color: #05140c; font-weight: 700; }
.md-list {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  background: var(--bg-elev2);
}
.chip button {
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  line-height: 1;
}
.chip button:hover { color: var(--danger); }
.chip.travel { border-color: var(--accent-dim); }
.chip.return { border-color: var(--warn); }

/* ---- 機材：カテゴリ別グリッド + 使用中表示 ---- */
.cat-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 22px 0 10px;
}
.cat-head h3 { margin: 0; font-size: 15px; }
.cat-head .count { color: var(--text-dim); font-size: 12px; }
.gear-grid {
  display: grid;
  gap: 10px;
  /* PCは横長(360px)、狭い画面(スマホ)では自動で1カラム全幅=はみ出し防止 */
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
}
.gear-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--bg-elev);
  position: relative;
  /* 一定の最小サイズ。機材名が長い場合はカードが縦に伸びる */
  min-height: 150px;
  display: flex;
  flex-direction: column;
}
.gear-card .gname {
  font-weight: 700;
  padding-right: 52px; /* 「使用中」バッジと重ならない余白 */
  white-space: normal; /* 省略せず全文表示（折り返し可） */
  overflow-wrap: anywhere;
}
.gear-card .gserial { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.gear-card .gmeta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gear-card > .row:last-child { margin-top: auto; } /* 操作ボタンを下端に固定 */
.gear-card.in-use {
  opacity: 0.45;
  filter: grayscale(0.5);
  background: var(--bg);
}
.gear-card.in-use::after {
  content: "使用中";
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 11px;
  color: var(--warn);
  border: 1px solid var(--warn);
  border-radius: 999px;
  padding: 1px 8px;
  opacity: 1;
}
.gear-card .use-where {
  font-size: 11px;
  color: var(--warn);
  margin-top: 6px;
}
.inline-date { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-date input { width: auto; }

/* ---- カレンダー ---- */
.cal {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
}
.cal-head .title { font-weight: 700; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.cal-dow {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  padding: 6px 0;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
}
.cal-cell {
  min-height: 84px;
  min-width: 0; /* 予定名で列が広がってはみ出すのを防ぐ */
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 4px 6px;
  cursor: pointer;
  vertical-align: top;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.other { background: var(--bg); opacity: 0.5; }
.cal-cell.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-cell .daynum { font-size: 12px; color: var(--text-dim); }
.cal-cell.sun .daynum { color: #ff8a8a; }
.cal-cell.sat .daynum { color: #8ab4ff; }
.cal-pill {
  display: block;
  font-size: 11px;
  border-radius: 5px;
  padding: 1px 5px;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-pill.event { background: var(--accent-dim); color: #d6f5e2; }
.cal-pill.travel { background: #3a2f14; color: var(--warn); }
.cal-pill.car { background: #0f3a28; color: var(--ok); }

/* ---- ダッシュボード カレンダー配置 ---- */
.cal-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  align-items: start;
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 760px) {
  .cal-layout { grid-template-columns: 1fr; }
}
.cal-layout > * { min-width: 0; } /* グリッド項目が内容で広がらないように */
.cal { max-width: 100%; }

/* ---- 統計タイル（インフォグラフィック調） ---- */
#stat-events, #stat-equipment, #stat-today {
  color: var(--accent);
  font-weight: 800 !important;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* ---- リンク集 ---- */
.linkrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.linkrow input { width: auto; flex: 1; min-width: 120px; }

/* ---- 通知 / 空状態 ---- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev2);
  border: 1px solid var(--line);
  padding: 10px 16px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 100;
}
.toast.show { opacity: 1; }
.toast.err { border-color: var(--danger); color: var(--danger); }
.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 20px;
}

/* ---- ログイン ---- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { margin-bottom: 4px; }
.login-card .note {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 14px;
}

/* ---- 会場名セル（省略せず全文表示・小さめフォント） ---- */
.venue-cell {
  font-size: 13px;
  line-height: 1.35;
  word-break: break-word;
  min-width: 140px; /* 極端な縦積みを防ぎ、全文を読みやすく折り返す */
}

@media (max-width: 560px) {
  .topbar { padding: 10px 10px; gap: 8px; }
  /* メニュータブを横一列（はみ出す場合は横スクロール） */
  .topbar nav {
    order: 3;
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 1px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar nav a { padding: 4px 6px; font-size: 12px; white-space: nowrap; }
  .topbar .brand { order: 1; }
  .topbar .spacer { display: none; }
  .topbar .user { order: 2; font-size: 12px; }
  .topbar #nav-signout { order: 2; }
  .wrap { padding: 18px 14px 80px; }
  h1 { font-size: 19px; }
  .venue-cell { font-size: 12px; }

  /* ---- ダッシュボードのカレンダー：予定の有無で高さを変えない（Google風・ドット表示） ---- */
  .cal-head { padding: 8px 10px; }
  .cal-dow { font-size: 11px; padding: 4px 0; }
  .cal-cell {
    height: 74px;      /* 全セル固定高さ（予定があっても伸びない） */
    min-height: 0;
    padding: 3px 3px;
    overflow: hidden;  /* 収まらない予定はクリップ（省略表示） */
  }
  .cal-cell .daynum { font-size: 11px; }
  /* 予定はセル内に名称を省略して表示（幅も高さも増やさない） */
  .cal-pill {
    display: block;
    font-size: 10px;
    line-height: 1.3;
    padding: 0 3px;
    margin-top: 2px;
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ---- 一覧テーブル：文字は必ず1行。最終列（開く/操作）は横スワイプしても常時表示 ---- */
  .table-scroll td { white-space: nowrap; }
  .venue-cell { white-space: nowrap; word-break: normal; min-width: 0; }
  .table-scroll table th:last-child,
  .table-scroll table td:last-child {
    position: sticky;
    right: 0;
    z-index: 1;
    background: var(--bg-elev);
    box-shadow: -6px 0 6px -4px rgba(0, 0, 0, 0.45);
  }
  .table-scroll table tr:hover td:last-child { background: var(--bg-elev2); }
}
