/* ========== 全体共通 ========== */
:root {
  --red: #b71c1c;
  --red-dark: #8e1414;
  --bg: #fff1ec;
  --card: #ffffff;
  --text: #222222;
  --text-sub: #666666;
  --line: #e0e0e0;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* hidden 属性が付いた要素は必ず隠す
   (.btn などの display 指定が hidden より優先されて出てしまうのを防ぐ) */
[hidden] { display: none !important; }

body {
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}

a { color: var(--red); }
img { max-width: 100%; }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px;
}

/* ========== ヘッダー ========== */
.site-header {
  background: var(--red);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.site-header .title {
  color: #fff;
  text-decoration: none;
  font-size: 18px;
  font-weight: bold;
  white-space: nowrap;
}

.site-header nav {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.site-header nav a {
  color: #fff;
  text-decoration: none;
  font-size: 14px;
}

.site-header nav a:hover { text-decoration: underline; }

/* 新規登録の完了案内(確認メールを送った旨) */
.register-done {
  margin-top: 14px;
  padding: 16px;
  border: 2px solid #2e7d32;
  border-radius: var(--radius);
  background: #eef7ee;
  text-align: left;
  line-height: 1.7;
}

.register-done-title {
  font-weight: bold;
  font-size: 16px;
  color: #2e7d32;
  margin-bottom: 8px;
}

.register-done p { margin: 4px 0; }

/* ログイン欄の区切り(Google と メール+パスワード の間) */
.login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 10px;
  color: var(--text-sub);
  font-size: 13px;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line);
}

/* ヘッダーのハンバーガーメニュー(スマホ幅のみ) */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
}

@media (max-width: 640px) {
  .site-header .inner { position: relative; }
  .nav-toggle { display: block; }
  #header-nav { display: none; }
  /* 未ログイン(リンク1つ)はボタンにせずそのまま表示 */
  #header-nav.always-open { display: flex; }
  #header-nav.open {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--red);
    padding: 4px 20px 12px;
    box-shadow: 0 6px 12px rgba(0, 0, 0, .2);
  }
  #header-nav.open a {
    padding: 12px 0;
    font-size: 16px;
    border-top: 1px solid rgba(255, 255, 255, .25);
  }
}

/* ========== ボタン・フォーム部品 ========== */
.btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-outline {
  background: #fff;
  color: var(--red);
  border: 1px solid var(--red);
}
.btn-gray { background: #eee; color: var(--text); }
.btn-block { display: block; width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

input[type="text"], input[type="tel"], input[type="url"],
select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
}

textarea { resize: vertical; }

label.field-label {
  display: block;
  font-size: 13px;
  color: var(--text-sub);
  margin: 14px 0 4px;
}

.required::after {
  content: "必須";
  color: #fff;
  background: var(--red);
  font-size: 10px;
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
}

.note { font-size: 12px; color: var(--text-sub); }

/* 管理ページから編集できる文言(改行をそのまま表示) */
.editable-text { white-space: pre-line; }

/* お問い合わせ一覧(管理者ページ) */
.inquiry-item {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

/* 年次更新: 期限切れ会員の表示枠 */
.renew-result-box {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafafa;
}

.renew-result-title {
  font-weight: bold;
  margin-bottom: 10px;
  color: var(--red-dark);
}

.renew-expired-item {
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.renew-expired-item:first-of-type { border-top: none; }

/* 顔写真の切り抜きエディタ(位置調整+拡大) */
.photo-editor {
  margin: 12px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafafa;
}

.crop-box {
  position: relative;
  width: 240px;
  height: 240px;
  max-width: 100%;
  margin: 10px 0;
  overflow: hidden;
  border: 2px solid var(--red);
  border-radius: 8px;
  background: #eee;
  touch-action: none; /* 枠内のドラッグを画面スクロールと区別する */
  cursor: grab;
}

.crop-box img {
  position: absolute;
  max-width: none; /* 全体CSSの縮小指定を打ち消し、原寸ベースで動かす */
  user-select: none;
  pointer-events: none;
}

.crop-zoom-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.crop-zoom-row input[type="range"] { flex: 1; max-width: 240px; }

/* 保存完了などの通知(画面下の中央に数秒だけ表示) */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  background: #2e7d32;
  color: #fff;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 15px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
  z-index: 1000;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
  max-width: 90vw;
}

.toast.show { opacity: 1; }

/* 読み取り専用の入力欄(住所の自動入力部分など) */
input[readonly] { background: #ececec; color: var(--text-sub); }

/* 文字数カウンター(マイページの入力欄) */
.char-counter { float: right; font-size: 12px; color: var(--text-sub); }
.char-counter-max { color: var(--red); font-weight: bold; }

/* ========== カード ========== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.section-title {
  font-size: 16px;
  font-weight: bold;
  border-left: 4px solid var(--red);
  padding-left: 8px;
  margin-bottom: 12px;
}

/* ========== 会の案内(index) ========== */
.hero {
  background: var(--red);
  color: #fff;
  text-align: center;
  padding: 48px 16px;
}

/* 見出し・サブタイトル内の改行をそのまま表示する(スマホでの行の折り返し位置の調整用) */
.hero h1 { font-size: 26px; margin-bottom: 8px; white-space: pre-line; }
.hero p { opacity: 0.95; white-space: pre-line; }

.login-box { text-align: center; }
.login-box .btn { margin-top: 8px; }

.alert {
  background: #fdecea;
  border: 1px solid #f5c6c2;
  color: #a94442;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
  font-size: 14px;
}

/* ========== 会員一覧 ========== */
.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar .search { flex: 1 1 240px; }
.toolbar select { flex: 0 1 200px; width: auto; }

.member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.member-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 14px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.1s;
}

/* 一覧カードの写真は少し大きめ。切り取らず全体を表示(横長ロゴ等に対応) */
.member-card .avatar {
  width: 160px;
  height: 160px;
  object-fit: contain;
  background: #fff;
}

.member-card:hover { transform: translateY(-2px); }

.avatar {
  width: 96px;
  height: 96px;
  border-radius: 8px;
  object-fit: cover;
  background: #ddd;
  display: inline-block;
}

.avatar-lg { width: 160px; height: 160px; }

/* 会員詳細の写真は切り取らず全体を表示(横長のロゴ・店舗写真などに対応) */
.profile-box .avatar { height: auto; }

/* 事業所・商品写真(会員詳細の表示欄) */
.biz-photos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}
.biz-photos img { width: 100%; border-radius: 8px; }

/* 事業所・商品写真(マイページのアップロード欄) */
.biz-photo-edit { display: flex; gap: 16px; flex-wrap: wrap; }
.biz-photo-preview {
  width: 160px;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  background: #ddd;
  display: block;
  margin-bottom: 6px;
}

.member-card .name { font-size: 17px; font-weight: bold; margin-top: 8px; }
.member-card .company { font-size: 13px; color: var(--text-sub); }

.tag {
  display: inline-block;
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 999px;
  font-size: 11px;
  padding: 1px 10px;
  margin: 6px 0;
}

.member-card .catch {
  font-size: 13px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;      /* 2行まで表示、あふれた分は省略 */
  min-height: 3.4em;          /* 2行分の高さを常に確保し、カードの高さを揃える */
}

.member-card .distance { font-size: 12px; color: var(--text-sub); }

.empty-message {
  text-align: center;
  color: var(--text-sub);
  padding: 40px 0;
}

/* ========== 会員詳細 ========== */
.detail-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 760px) {
  .detail-layout { grid-template-columns: 1fr; }
}

.profile-box { text-align: center; }
.profile-box .name { font-size: 22px; font-weight: bold; margin-top: 10px; }
.profile-box .company { color: var(--text-sub); }
.profile-box .catch { color: var(--text); font-weight: bold; margin: 8px 0; }

.contact-list { margin-top: 14px; text-align: left; }

.contact-list .row {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 10px 4px;
  font-size: 14px;
  text-decoration: none;
  color: var(--text);
}

.contact-list .row .icon { width: 20px; text-align: center; }

.badge {
  background: #eee;
  border-radius: 6px;
  font-size: 11px;
  padding: 1px 6px;
  color: var(--text-sub);
  white-space: nowrap;
}

.video-frame {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
  background: #000;
}

.video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.media-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.media-photos img { border-radius: 8px; width: 100%; }

.description { white-space: pre-wrap; }

/* ========== マイページ編集 ========== */
.photo-edit {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.publish-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.publish-row .value { flex: 1; }

.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }

.form-error { color: var(--red); font-size: 13px; margin-top: 10px; white-space: pre-wrap; }
.form-ok { color: #2e7d32; font-size: 14px; margin-top: 10px; }

/* ========== 管理者 ========== */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
}

.admin-table th, .admin-table td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  text-align: left;
  vertical-align: middle;
}

.admin-table th { background: #fafafa; white-space: nowrap; }

.admin-table .actions { white-space: nowrap; }

.admin-table .btn { padding: 4px 10px; font-size: 12px; }

.table-wrap { overflow-x: auto; }

/* ========== フッター ========== */
.site-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-sub);
  padding: 24px 0 40px;
}

/* ========== デモモード表示 ========== */
.demo-banner {
  background: #fff3cd;
  border-bottom: 1px solid #ffe08a;
  color: #7a5b00;
  text-align: center;
  font-size: 12px;
  padding: 4px 8px;
}
