/* ================================================================
   足場材料拾いツール — Professional Light UI
   ================================================================ */

*, *::before, *::after { box-sizing: border-box; }

/* ── Base ─────────────────────────────────────────────────────── */
body {
  font-family: 'Segoe UI', 'Noto Sans JP', 'Yu Gothic UI', sans-serif;
  /* 足場立面図スタイル：Xブレース＋ジョイント丸＋グリッド */
  background-color: #e4eef8;
  background-image:
    url("data:image/svg+xml,%3Csvg width='120' height='80' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='0' y='0' width='120' height='80' fill='none' stroke='%231a4a9a' stroke-width='1.2' opacity='0.18'/%3E%3Cline x1='0' y1='0' x2='120' y2='80' stroke='%231a4a9a' stroke-width='0.9' opacity='0.12'/%3E%3Cline x1='120' y1='0' x2='0' y2='80' stroke='%231a4a9a' stroke-width='0.9' opacity='0.12'/%3E%3Ccircle cx='0' cy='0' r='3' fill='%231a4a9a' opacity='0.22'/%3E%3Ccircle cx='120' cy='0' r='3' fill='%231a4a9a' opacity='0.22'/%3E%3Ccircle cx='0' cy='80' r='3' fill='%231a4a9a' opacity='0.22'/%3E%3Ccircle cx='120' cy='80' r='3' fill='%231a4a9a' opacity='0.22'/%3E%3Ccircle cx='60' cy='40' r='2' fill='%231a4a9a' opacity='0.12'/%3E%3C/svg%3E"),
    linear-gradient(160deg, #d8e8f5 0%, #e4eef8 50%, #dce8f4 100%);
  background-size: 120px 80px, cover;
  color: #1a2e45;
  display: flex;
  gap: 20px;
  padding: 20px;
  min-height: 100vh;
  font-size: 13px;
  line-height: 1.4;
}

/* ── Main panel ──────────────────────────────────────────────── */
body > div:first-child {
  flex: 1;
  min-width: 0;
  background: rgba(248,252,255,0.92);
  border: 1px solid rgba(255,255,255,0.75);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(15,40,80,0.22), 0 1px 4px rgba(15,40,80,0.1);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* ── App header ──────────────────────────────────────────────── */
body > div:first-child > h2 {
  /* 足場Xブレース＋ジョイント丸パターン（立面図タイトルブロック風） */
  background-color: #0e2240;
  background-image:
    url("data:image/svg+xml,%3Csvg width='120' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='0' y='0' width='120' height='60' fill='none' stroke='%234a88e0' stroke-width='1' opacity='0.28'/%3E%3Cline x1='0' y1='0' x2='120' y2='60' stroke='%234a88e0' stroke-width='0.9' opacity='0.2'/%3E%3Cline x1='120' y1='0' x2='0' y2='60' stroke='%234a88e0' stroke-width='0.9' opacity='0.2'/%3E%3Ccircle cx='0' cy='0' r='3.5' fill='%234a88e0' opacity='0.35'/%3E%3Ccircle cx='120' cy='0' r='3.5' fill='%234a88e0' opacity='0.35'/%3E%3Ccircle cx='0' cy='60' r='3.5' fill='%234a88e0' opacity='0.35'/%3E%3Ccircle cx='120' cy='60' r='3.5' fill='%234a88e0' opacity='0.35'/%3E%3Ccircle cx='60' cy='30' r='2.5' fill='%234a88e0' opacity='0.22'/%3E%3C/svg%3E"),
    linear-gradient(135deg, #122852 0%, #0e2040 100%);
  background-size: 120px 60px, cover;
  color: #e8f4ff;
  margin: 0;
  padding: 16px 24px;
  font-size: 1.25em;
  font-weight: 700;
  letter-spacing: 0.08em;
  border-bottom: 3px solid #e67e22;
  text-shadow: 0 1px 6px rgba(0,0,0,0.6);
  position: relative;
  overflow: hidden;
}

/* 左端に図面の縦ボーダーライン風アクセント */
body > div:first-child > h2::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: linear-gradient(to bottom, #4a88e0, #2a60c0);
  opacity: 0.7;
}

body > div:first-child > h2::before {
  content: "🏗 ";
  letter-spacing: 0;
  position: relative;
  z-index: 1;
}

/* ── Settings block ──────────────────────────────────────────── */
.block {
  padding: 12px 20px;
  background: #edf3fa;
  border-bottom: 1px solid #c5d8e8;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
}

.block label {
  color: #2a5070;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

/* ── Form inputs / selects ────────────────────────────────────── */
input[type="text"],
select {
  background: #ffffff !important;
  color: #1a2e45 !important;
  border: 1px solid #98bcd4 !important;
  border-radius: 5px !important;
  padding: 3px 8px !important;
  font-size: 12px !important;
  font-family: inherit !important;
  outline: none !important;
  height: 27px !important;
  transition: border-color 0.15s, box-shadow 0.15s !important;
  cursor: pointer;
  box-shadow: inset 0 1px 3px rgba(15,40,80,0.07) !important;
}

input[type="text"]:focus,
select:focus {
  border-color: #2a88d8 !important;
  box-shadow: 0 0 0 2px rgba(42,136,216,0.2), inset 0 1px 3px rgba(15,40,80,0.05) !important;
}

/* ── Lists ───────────────────────────────────────────────────── */
#scaffold-list,
#other-material-list {
  padding: 10px 16px 4px;
}

/* ── Scaffold entry row ───────────────────────────────────────── */
.scaffold-entry {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-bottom: 7px;
  align-items: center;
  background: #ffffff;
  border: 1px solid #c0d8ea;
  border-left: 3px solid #2a78c8;
  border-radius: 0 6px 6px 0;
  padding: 7px 10px;
  transition: border-left-color 0.15s, background 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 4px rgba(15,40,80,0.06);
}

.scaffold-entry:hover {
  background: #eef6ff;
  border-left-color: #1a60b8;
  box-shadow: 0 2px 10px rgba(15,40,80,0.1);
}

.scaffold-entry label {
  white-space: nowrap;
  font-weight: 600;
  color: #2a5878;
  font-size: 12px;
}

/* Other material row — green tint */
.other-entry {
  background: #f2fbf5 !important;
  border-color: #aad8bc !important;
  border-left-color: #28a060 !important;
}

.other-entry:hover {
  background: #e6f7ec !important;
  border-left-color: #1a8050 !important;
}

/* Warning row */
.warning {
  background: #fff4f4 !important;
  border-left-color: #d44030 !important;
}

/* ── H-container ──────────────────────────────────────────────── */
.h-container {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  border-radius: 4px;
  transition: 0.15s;
}

.h-container.is-multi {
  background: #e4f0f8;
  padding: 3px 8px;
  border: 1px solid #98bcd4;
  border-radius: 4px;
}

/* ── Buttons — base ───────────────────────────────────────────── */
button[type="button"] {
  background: #dceaf6;
  color: #1a4870;
  border: 1px solid #98bcd4;
  border-radius: 5px;
  padding: 6px 14px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

button[type="button"]:hover {
  background: #c4d8ee;
  color: #0d2e52;
  border-color: #2a78c8;
  box-shadow: 0 2px 8px rgba(15,40,80,0.12);
}

button[type="button"]:active {
  transform: translateY(1px);
}

/* Calculate button — primary CTA */
button[type="button"][onclick="calculate()"] {
  background: linear-gradient(135deg, #1e75d8, #1458b0) !important;
  color: #fff !important;
  border: none !important;
  padding: 8px 22px !important;
  font-size: 1.05em !important;
  font-weight: 700 !important;
  border-radius: 6px !important;
  box-shadow: 0 3px 12px rgba(21,101,192,0.45) !important;
  letter-spacing: 0.04em;
}

button[type="button"][onclick="calculate()"]:hover {
  background: linear-gradient(135deg, #2a88e8, #1e75d8) !important;
  box-shadow: 0 4px 18px rgba(21,101,192,0.65) !important;
  transform: translateY(-1px);
}

/* Canvas toggle button */
button[type="button"][onclick*="toggleCanvas"] {
  background: #ddf4f4;
  color: #186868;
  border-color: #78c8c8;
  font-weight: 700 !important;
}

button[type="button"][onclick*="toggleCanvas"]:hover {
  background: #c2eaea;
  border-color: #289898;
  color: #0a4848;
}

/* Save button */
button[type="button"][onclick="saveData(false)"] {
  background: #e6f6e8;
  color: #186030;
  border-color: #78c888;
}

button[type="button"][onclick="saveData(false)"]:hover {
  background: #ceecd4;
  border-color: #289848;
  color: #0a4020;
}

/* Test data button */
#testDataBtn {
  background: linear-gradient(135deg, #d89010, #b07010) !important;
  color: #fff !important;
  border: none !important;
  font-weight: 700 !important;
  margin-left: 16px !important;
  box-shadow: 0 2px 10px rgba(200,128,0,0.35) !important;
}

#testDataBtn:hover {
  background: linear-gradient(135deg, #f0a820, #d89010) !important;
  box-shadow: 0 3px 14px rgba(200,128,0,0.55) !important;
}

/* Remove button */
.remove-btn {
  background: #fff0f0;
  color: #c03030;
  border: 1px solid #e8a0a0;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 4px;
  font-weight: bold;
  font-size: 11px;
  transition: all 0.15s;
}

.remove-btn:hover {
  background: #fdd8d8;
  color: #901010;
  border-color: #d04040;
}

/* Insert button */
.insert-btn {
  background: #f0faf3;
  color: #1a7840;
  border: 1px solid #78c890;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 4px;
  font-weight: bold;
  font-size: 11px;
  margin-left: auto;
  transition: all 0.15s;
}

.insert-btn:hover {
  background: #d8f0e0;
  color: #0d5028;
  border-color: #2a9848;
}

/* ── Add buttons row ──────────────────────────────────────────── */
button[type="button"][onclick="addScaffold()"] {
  background: #dceaf6;
  color: #1a4878;
  border-color: #78aad0;
}

button[type="button"][onclick="addScaffold()"]:hover {
  background: #c4d8ee;
  color: #0d2e58;
}

button[type="button"][onclick="addOtherMaterial()"] {
  background: #e6f5e8;
  color: #1a5830;
  border-color: #78c080;
}

button[type="button"][onclick="addOtherMaterial()"]:hover {
  background: #d0ecd8;
  color: #0d3c20;
}

/* ── Result area ──────────────────────────────────────────────── */
#result {
  white-space: pre-wrap;
  font-weight: bold;
  line-height: 1.75;
  font-size: 1.05em;
  color: #0d2038;
  background: #f0f7ff;
  padding: 16px 20px;
  border-radius: 8px;
  border: 1px solid #b0cce4;
  border-left: 3px solid #2a78c8;
  margin-top: 12px;
  font-family: 'Consolas', 'Courier New', 'Noto Sans JP', monospace;
  box-shadow: inset 0 2px 8px rgba(15,40,80,0.06);
  flex-basis: 100%;
}

.result-category {
  color: #c86010;
  margin-top: 12px;
  font-size: 1.05em;
  border-bottom: 1px solid #b0cce4;
  padding-bottom: 4px;
  letter-spacing: 0.04em;
}

/* ── Canvas container ─────────────────────────────────────────── */
.canvas-container {
  position: relative;
  flex-shrink: 0;
}

#scaffoldCanvas {
  border: 1px solid #b0cce4;
  background-color: #f4f9ff;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(15,40,80,0.15);
  cursor: pointer;
}

.canvas-hint {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(240,247,255,0.96);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #2a78c8;
  font-size: 12px;
  font-weight: bold;
  color: #1a4878;
  pointer-events: none;
  display: none;
  box-shadow: 0 2px 12px rgba(15,40,80,0.12);
}
