/**
 * チバリヨ モバイルシェル スタイル
 * Phase 2-B-1 / 段階1
 *
 * - 最大幅 414px (中央寄せ)
 * - PC で開いた時も中央表示
 * - セーフエリア対応
 * - 下部5タブナビ
 * - サブ画面 (S4作成等のフルスクリーン画面)
 * - トースト
 */

/* CSS変数 */
:root {
  --mobile-max-width: 414px;
  --mobile-header-height: 56px;
  --mobile-tabbar-height: 64px;

  --mobile-bg: #f9f9f7;
  --mobile-surface: #ffffff;
  --mobile-border: #e8e7e2;
  --mobile-text: #2c2c2a;
  --mobile-text-secondary: #5F5E5A;
  --mobile-text-tertiary: #888780;

  --mobile-accent: #1D9E75;
  --mobile-accent-dark: #0F6E56;
  --mobile-accent-light: #E1F5EE;
}

/* モバイルアプリビュー (全面) */
.mobile-app-view {
  position: fixed;
  inset: 0;
  background: #2c2c2a;
  display: flex;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  overflow: hidden;
}

@media (max-width: 414px) {
  .mobile-app-view {
    background: var(--mobile-bg);
  }
}

/* モバイルアプリ枠 (中央 414px) */
.mobile-app-frame {
  position: relative;
  width: 100%;
  max-width: var(--mobile-max-width);
  height: 100%;
  background: var(--mobile-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ヘッダー */
.mobile-header {
  flex: 0 0 auto;
  height: calc(var(--mobile-header-height) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: var(--mobile-surface);
  border-bottom: 1px solid var(--mobile-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 16px;
  padding-right: 16px;
  z-index: 10;
}

.mobile-header-brand {
  font-size: 18px;
  font-weight: 600;
  color: var(--mobile-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.env-badge-mobile {
  display: none;
  font-size: 10px;
  font-weight: 700;
  background: #f59e0b;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.env-badge-mobile.is-visible {
  display: inline-block;
}

.mobile-user-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mobile-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  background: #e8e7e2;
  color: #5F5E5A;
  user-select: none;
}

/* メイン領域 (スクロール) */
.mobile-main {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--mobile-tabbar-height) + env(safe-area-inset-bottom) + 16px);
}

.mobile-tab-content {
  padding: 16px;
}

/* プレースホルダー */
.mobile-placeholder {
  background: var(--mobile-surface);
  border-radius: 12px;
  padding: 24px 20px;
  margin-top: 16px;
}

.mobile-placeholder h2 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 600;
  color: var(--mobile-text);
}

.mobile-placeholder p {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--mobile-text-secondary);
}

.mobile-placeholder-greeting {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--mobile-accent-light);
  color: var(--mobile-accent-dark);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
}

/* 下部タブバー */
.mobile-tabbar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--mobile-tabbar-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--mobile-surface);
  border-top: 1px solid var(--mobile-border);
  display: flex;
  align-items: stretch;
  z-index: 10;
}

.mobile-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--mobile-text-tertiary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
  position: relative;
}

.mobile-tab-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.mobile-tab svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mobile-tab.is-active {
  color: var(--mobile-accent);
}

/* S2 未読バッジ */
.mobile-tab-badge {
  position: absolute;
  top: 4px;
  left: calc(50% + 4px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #DC2626;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  box-sizing: border-box;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.mobile-tab:not(.mobile-tab-fab):active {
  background: rgba(0, 0, 0, 0.04);
}

.mobile-tab-fab {
  color: #ffffff;
}

.mobile-tab-fab .mobile-fab-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--mobile-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -8px;
  box-shadow: 0 2px 8px rgba(29, 158, 117, 0.35);
  transition: transform 0.15s ease, background 0.15s ease;
}

.mobile-tab-fab:active .mobile-fab-circle {
  transform: scale(0.92);
  background: var(--mobile-accent-dark);
}

.mobile-tab-fab svg {
  width: 26px;
  height: 26px;
  stroke-width: 2;
}

/* ============================================================
 * サブ画面 (S4作成等、タブ外のフルスクリーン画面)
 * ============================================================ */

.mobile-subscreen {
  position: absolute;
  inset: 0;
  background: var(--mobile-bg);
  display: flex;
  flex-direction: column;
  z-index: 20;
  transform: translateX(100%);
  transition: transform 0.2s ease;
}

.mobile-subscreen.is-open {
  transform: translateX(0);
}

@media (prefers-reduced-motion: reduce) {
  .mobile-subscreen {
    transition: opacity 0.1s ease;
  }
}

.mobile-subscreen-header {
  flex: 0 0 auto;
  height: calc(var(--mobile-header-height) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: var(--mobile-surface);
  border-bottom: 1px solid var(--mobile-border);
  display: flex;
  align-items: center;
  padding-left: 8px;
  padding-right: 16px;
  gap: 8px;
}

.mobile-subscreen-back {
  background: none;
  border: none;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--mobile-text);
  padding: 0;
}

.mobile-subscreen-back svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mobile-subscreen-title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  color: var(--mobile-text);
  margin: 0;
}

.mobile-subscreen-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
 * トースト
 * ============================================================ */

.mobile-toast-wrap {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 380px;
}

.mobile-toast {
  background: rgba(28, 28, 26, 0.92);
  color: white;
  padding: 12px 18px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 100%;
  text-align: center;
}

.mobile-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.mobile-toast.is-success {
  background: rgba(15, 110, 86, 0.95);
}

.mobile-toast.is-error {
  background: rgba(122, 30, 30, 0.95);
}

/* ============================================================
 * Phase 2-B-2.1: admin 用 PC画面切替ボタン (mobile-shell.css の末尾に追記)
 * ============================================================ */

.mobile-pc-switch {
  border: 1px solid #D1D5DB;
  background: #FFFFFF;
  color: #374151;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.mobile-pc-switch:active {
  opacity: 0.7;
}

/* ============================================================
 * Phase 2-B-5.1: dev admin メンバープレビュー
 *   - ヘッダーのプレビューバッジ
 *   - メンバー選択ピッカー / エラー表示
 * ============================================================ */

.mobile-preview-badge {
  font-size: 10px;
  font-weight: 700;
  background: #7C3AED;
  color: #ffffff;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-picker {
  width: 100%;
  max-width: var(--mobile-max-width);
  height: 100%;
  background: var(--mobile-bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px calc(env(safe-area-inset-bottom) + 24px);
  box-sizing: border-box;
}

.preview-picker-title {
  margin: 8px 0 4px;
  font-size: 18px;
  font-weight: 600;
  color: var(--mobile-text);
}

.preview-picker-note {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--mobile-text-secondary);
}

.preview-picker-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preview-picker-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--mobile-surface);
  border: 1px solid var(--mobile-border);
  border-radius: 12px;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--mobile-text);
}

.preview-picker-item:active {
  background: rgba(0, 0, 0, 0.04);
}

.preview-picker-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--mobile-text);
}

.preview-picker-meta {
  font-size: 12px;
  font-weight: 500;
  color: var(--mobile-accent-dark);
}

.preview-picker-id {
  font-size: 11px;
  color: var(--mobile-text-tertiary);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
}

