/* style.css */

/* 基本リセット */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary-color: #6ACC4B;
  --primary-hover: #5bb542;
  --text-color: #333333;
  --bg-color: #f9fafb;
  --white: #ffffff;
  --gray-border: #e5e7eb;
  --gray-text: #6b7280;
  --error-red: #ef4444;
  --income-green: #10b981;
  --payment-red: #ef4444;
}

html, body {
  height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: 480px;
  background: var(--white);
  min-height: 100vh;
  padding: 80px 20px 120px;
  position: relative;
  box-shadow: 0 0 20px rgba(0,0,0,0.05);
  overflow-x: hidden;
}

/* 固定ヘッダー */
.fixed-header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: 60px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border-bottom: 1px solid var(--gray-border);
  display: flex;
  align-items: center;
  justify-content: space-between; /* 左右の要素を配置 */
  padding: 0 20px;
  z-index: 100;
  /* position: relative;  <-- これがあると絶対配置の基準になってしまうため削除してもよいが、念のため残す場合は注意 */
}

.header-left {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary-color);
  text-decoration: none;
  letter-spacing: -0.5px;
  z-index: 10; /* 前面に */
  /* 幅を確保して、左端に固定 */
  flex: 0 0 auto;
}

.header-center {
  /* 絶対配置で画面中央に強制配置 */
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  
  font-size: 16px;
  font-weight: 700;
  color: var(--text-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50%; /* 左右ボタンと被らないように制限 */
  text-align: center;
  z-index: 1; /* 最背面ではないが、ボタンよりは下 */
}

.header-right {
  /* 右端に固定 */
  flex: 0 0 auto;
  z-index: 10;
}

.header-right button {
  background: none;
  border: none;
  font-size: 24px;
  padding: 4px;
  color: var(--text-color);
  box-shadow: none;
  cursor: pointer;
}

/* セクション */
section {
  margin-bottom: 32px;
}

h1, h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-color);
}

p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-color);
}

.muted {
  color: var(--gray-text);
  font-size: 13px;
}

/* フォーム要素 */
input[type="text"],
input[type="number"],
input[type="date"],
select {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: 12px;
  border: 1px solid var(--gray-border);
  font-size: 15px;
  outline: none;
  background: #fdfdfd;
  transition: border 0.2s;
  appearance: none;
  -webkit-appearance: none;

  color: var(--text-color) !important;
}

input:focus, select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(106, 204, 75, 0.2);

  color: var(--text-color) !important;
}

select option {
  color: var(--text-color);
}

/* 検索ボックス */
.search-input {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%239ca3af" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>');
  background-repeat: no-repeat;
  background-position: 12px center;
  padding-left: 40px !important;
}

/* 入力欄の中にボタンを入れるスタイル */
.input-group {
  position: relative;
  margin-bottom: 16px;
}
.input-group input {
  margin-bottom: 0;
  padding-right: 80px;
}
.input-group button {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 12px;
  font-size: 13px;
  margin: 0;
  border-radius: 8px;
}

/* ボタン */
button {
  cursor: pointer;
  border: none;
  border-radius: 50px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 700;
  background: var(--primary-color);
  color: #fff;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(106, 204, 75, 0.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

button:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

button:active {
  transform: translateY(0);
}

button.full {
  width: 100%;
}

button.secondary {
  background: #f3f4f6;
  color: #4b5563;
  box-shadow: none;
}
button.secondary:hover {
  background: #e5e7eb;
}

button.danger {
  background: #fee2e2;
  color: var(--error-red);
  box-shadow: none;
}
button.small {
  padding: 6px 12px;
  font-size: 12px;
  height: auto;
}

/* カード共通スタイル */
.card-list {
  list-style: none;
  padding: 0;
}

.card-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background: var(--white);
  border: 1px solid var(--gray-border);
  margin-bottom: 12px;
  transition: background 0.1s;
}

.card-item.clickable {
  cursor: pointer;
}
.card-item.clickable:active {
  background: #f9fafb;
}

/* ★修正: アイコンの背景色・丸みを削除 */
.card-icon {
  font-size: 24px;
  /* width, height の固定を解除しても良いが、レイアウト崩れ防止のため残す場合は background: transparent に */
  width: 40px; 
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  
  background: transparent; /* 背景透明 */
  border-radius: 0;        /* 角丸なし */
  
  flex-shrink: 0;
}

.card-main {
  flex: 1;
  min-width: 0;
}

.card-top {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  margin-bottom: 4px;
  font-size: 15px;
}

.card-meta {
  font-size: 12px;
  color: var(--gray-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 設定画面のメンバーリスト用 */
.member-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--gray-border);
  background: var(--white);
  margin-bottom: 8px;
}
.member-card input {
  margin: 0;
  border: none;
  background: transparent;
  font-weight: bold;
  font-size: 15px;
  padding: 0;
  width: 100%;
}
.member-card input:focus {
  box-shadow: none;
  outline: none;
  border-bottom: 1px solid var(--primary-color);
  border-radius: 0;
}
.member-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ボトムバー */
.bottom-actions {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 440px;
  display: flex;
  gap: 10px;
  z-index: 90;
  pointer-events: none;
}
.bottom-actions > * {
  pointer-events: auto;
}
.bottom-actions.single {
  justify-content: center;
}

/* 精算画面のタブ */
.tab-container {
  display: flex;
  background: #f3f4f6;
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 24px;
}
.tab-btn {
  flex: 1;
  text-align: center;
  padding: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-text);
  border-radius: 10px;
  cursor: pointer;
  background: transparent;
  box-shadow: none;
}
.tab-btn.active {
  background: var(--white);
  color: var(--primary-color);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* 参加者選択チップ */
.chip-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 20px;
}
.chip-label {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid var(--gray-border);
  background: var(--white);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.chip-label:has(input:checked) {
  background: #f0fdf4;
  border-color: var(--primary-color);
  color: var(--primary-color);
  font-weight: bold;
}
.chip-label input {
  display: none;
}

/* トップページ用 */
.hero {
  text-align: center;
  padding: 60px 0 40px;
  background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 100%);
  margin: -80px -20px 40px;
  border-bottom-left-radius: 30px;
  border-bottom-right-radius: 30px;
}
.hero-logo {
  font-size: 48px;
  font-weight: 900;
  color: var(--primary-color);
  margin-bottom: 10px;
  letter-spacing: -1px;
}
.hero-copy {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-color);
  margin-bottom: 24px;
  opacity: 0.8;
}

/* トースト通知 */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 41, 59, 0.95);
  color: #fff;
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 2000;
  width: max-content;
  max-width: 90%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(10px); }
.toast.error { background: rgba(239, 68, 68, 0.95); }

/* フッター */
footer {
  text-align: center;
  font-size: 12px;
  color: var(--gray-text);
  margin-top: 60px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-border);
}
footer a {
  color: var(--gray-text);
  text-decoration: none;
  margin: 0 8px;
  display: inline-block;
  padding: 4px;
}

/* ユーティリティ */
.text-green { color: var(--income-green) !important; font-weight: bold; }
.text-red { color: var(--payment-red) !important; font-weight: bold; }

.material-icons {
  font-size: 28px;
  color: #333;
}