/* ====================================================================
   graph-core.css — 建築家ネットワーク 共通スタイル
   ==================================================================== */

:root {
  --bg:        #16213e;
  --sidebar:   #0f3460;
  --block:     #1a2a4a;
  --border:    #2a4a7a;
  --text:      #e8eaf6;
  --text-sub:  #90a4ae;
  --accent:    #4fc3f7;
  --accent-h:  #81d4fa;
  --danger:    #e94560;
  --danger-h:  #ff6b6b;
  --success:   #4dd0e1;
  --graph-bg:  #0d1117;
  --input-bg:  #0f3460;
  --radius:    8px;
}

/* ===== リセット・全体 ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans JP", sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}
#app { display: flex; height: 100%; width: 100%; }

/* ===== 左サイドバー ===== */
#sidebar {
  width: 320px; min-width: 240px; max-width: 480px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  box-shadow: 2px 0 10px rgba(0,0,0,.03);
  display: flex; flex-direction: column;
  transition: transform .2s ease, width .2s ease, min-width .2s ease,
              border-color .2s ease, box-shadow .2s ease;
  overflow: hidden;
  z-index: 10;
}
#sidebarHeader {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #eaeaea;
  background: var(--bg);
  flex-shrink: 0;
}
#title {
  margin: 0; font-size: 13px; color: var(--text-sub);
  letter-spacing: .02em; line-height: 1.3; flex: 1;
}
#toggleBtn {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer; font-size: 16px; line-height: 1;
  flex-shrink: 0;
  transition: background .15s;
}
#toggleBtn:hover { background: #f0f0f0; }
#sideScroll { overflow-y: auto; overflow-x: hidden; padding: 10px 10px 100px; flex: 1; }

/* ===== ブロック ===== */
.block {
  background: var(--block);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
}
.block h4 {
  margin: 0 0 8px 0; font-size: 13px; font-weight: 600;
  color: var(--text);
}

/* ===== フォーム要素 ===== */
.row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.row:last-child { margin-bottom: 0; }
.row > * { flex: 1 1 auto; min-width: 0; }

input, select, textarea {
  width: 100%;
  padding: 7px 9px;
  background: var(--input-bg);
  border: 1px solid #ccc;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: #aaa; }
select { cursor: pointer; }
select:disabled { background: #f3f3f3; color: #999; }
textarea { resize: vertical; min-height: 56px; line-height: 1.5; }

button.btn {
  width: 100%; padding: 7px 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
button.btn:hover { background: var(--accent-h); }
button.btn.secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
button.btn.secondary:hover { background: #1e3a5f; }
button.btn.danger { background: var(--danger); }
button.btn.danger:hover { background: var(--danger-h); }

small.help { color: var(--text-sub); font-size: 11px; line-height: 1.5; }

/* ===== フィルタボタン ===== */
#filter-buttons { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.filter-button {
  padding: 4px 10px;
  border: 1px solid #bbb;
  background: var(--bg);
  color: #555;
  border-radius: 999px;
  cursor: pointer; font-size: 12px;
  transition: background .15s, color .15s;
}
.filter-button:hover { background: #f0f0f0; }
.filter-button.is-active { background: #333; color: #fff; border-color: #333; }

/* ===== サイドバー折りたたみ ===== */
.is-collapsed #sidebar {
  transform: translateX(-100%); width: 0 !important;
  min-width: 0 !important; border-right: 0; box-shadow: none;
}

/* ===== グラフ領域 ===== */
#graphArea { flex: 1; min-width: 0; position: relative; background: var(--graph-bg); }
#cy { position: absolute; inset: 0; }
#floatingToggle {
  position: absolute; top: 12px; left: 12px; z-index: 50;
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer; font-size: 18px;
  display: none;
  transition: background .15s;
}
#floatingToggle:hover { background: #f0f0f0; }
.is-collapsed #floatingToggle { display: inline-flex; align-items: center; justify-content: center; }

/* ===== 詳細パネル ===== */
#detail-panel {
  border: 1px solid var(--accent);
}
#panel-badge {
  display: inline-block;
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
}
#panel-badge.node { background: #dbeafe; color: #1d4ed8; }
#panel-badge.edge { background: #d1fae5; color: #065f46; }
#panel-title { margin: 0 0 8px 0; font-size: 15px; font-weight: 600; color: var(--text); }
#panel-body { font-size: 12px; color: var(--text-sub); line-height: 1.8; }
#panel-body strong { color: var(--text); font-weight: 500; }
#panel-actions { display: flex; gap: 6px; margin-top: 10px; }
#panel-actions button { flex: 1; }

/* パネル編集フォーム */
#panel-edit-form { font-size: 13px; }
#panel-edit-form label {
  display: block; margin-bottom: 6px; color: var(--text-sub); font-size: 11px;
}
#panel-edit-form input,
#panel-edit-form select,
#panel-edit-form textarea { margin-top: 2px; margin-bottom: 0; }

/* ===== FABボタン (members) ===== */
#fab-btn {
  position: absolute; bottom: 24px; right: 24px; z-index: 50;
  width: 52px; height: 52px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 26px; line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(59,130,246,.4);
  transition: background .15s, transform .15s, box-shadow .15s;
  display: flex; align-items: center; justify-content: center;
}
#fab-btn:hover {
  background: var(--accent-h);
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(59,130,246,.55);
}

/* ===== FABモーダル ===== */
#fab-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.3); z-index: 98;
}
#fab-overlay.open { display: block; }
#fab-modal {
  display: none; position: fixed;
  bottom: 90px; right: 24px;
  width: 360px; max-width: calc(100vw - 48px);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.15);
  z-index: 99;
  overflow: hidden;
}
#fab-modal.open { display: block; }
#fab-modal-header {
  display: flex; align-items: center;
  padding: 12px 14px 0;
  gap: 6px;
}
.tab-btn {
  flex: 1; padding: 6px 10px;
  background: #f0f0f0;
  border: 1px solid var(--border);
  color: var(--text-sub);
  border-radius: var(--radius);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
#fab-close-btn {
  width: 28px; height: 28px;
  background: #f0f0f0; border: 1px solid var(--border); color: var(--text-sub);
  border-radius: var(--radius); cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
#fab-close-btn:hover { color: var(--text); background: #e0e0e0; }
#fab-modal-body { padding: 10px 14px 14px; }
#fab-modal-body input,
#fab-modal-body select,
#fab-modal-body textarea { margin-bottom: 6px; }
#tab-add-node, #tab-add-edge { display: none; }
#tab-add-node.active, #tab-add-edge.active { display: block; }

/* ===== モバイル対応 (≤640px) ===== */
@media (max-width: 640px) {
  /* サイドバーをグラフに重なるオーバーレイ方式に */
  #sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100%; height: 100dvh;
    width: min(88vw, 340px) !important;
    min-width: 0 !important;
    z-index: 100;
    transform: translateX(0);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    box-shadow: 4px 0 32px rgba(0,0,0,.22);
  }
  .is-collapsed #sidebar {
    transform: translateX(-110%);
    box-shadow: none;
    border-right: 0;
  }

  /* 背景オーバーレイ */
  #sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.42);
    z-index: 99;
    display: none;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }

  /* floatingToggle は常に表示 */
  #floatingToggle {
    display: inline-flex !important;
    align-items: center; justify-content: center;
    width: 44px; height: 44px;
    font-size: 20px;
  }

  /* グラフ全画面 */
  #graphArea { width: 100%; }

  /* 詳細パネルを読みやすく */
  #panel-title { font-size: 16px; }
  #panel-body  { font-size: 13px; line-height: 2; }
  #panel-actions { gap: 8px; }
  #panel-actions button { min-height: 44px; font-size: 14px; }

  /* タップしやすいボタン */
  button.btn     { min-height: 44px; font-size: 14px; }
  .filter-button { padding: 7px 14px; font-size: 13px; }
  input, select, textarea { font-size: 16px; } /* iOS zoom防止 */

  /* FABボタン */
  #fab-btn { width: 58px; height: 58px; font-size: 28px; bottom: 20px; right: 16px; }

  /* FABモーダルをボトムシートに */
  #fab-modal {
    right: 0; left: 0; bottom: 0;
    width: 100%; max-width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 82dvh;
    overflow-y: auto;
  }
  #fab-modal-body { padding: 12px 16px 32px; }
}
