/* css/app.css - 洗練されたダークモード基調のiOS/PWA最適化スタイル */
:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-card-hover: #273549;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-green: #10b981;
  --accent-green-bg: rgba(16, 185, 129, 0.15);
  --accent-blue: #38bdf8;
  --accent-orange: #f59e0b;
  --accent-purple: #a855f7;
  --accent-rose: #f43f5e;
  --border-color: rgba(255, 255, 255, 0.08);
  --safe-bottom: env(safe-area-inset-bottom, 16px);
  --safe-top: env(safe-area-inset-top, 0px);
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--font-family);
}

body {
  background-color: #0b1120;
  color: var(--text-main);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  overflow-x: hidden;
}

.app-frame {
  width: 100%;
  max-width: 460px;
  min-height: 100vh;
  background-color: var(--bg-primary);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  padding-bottom: calc(75px + var(--safe-bottom));
}

/* ヘッダー */
header {
  position: sticky;
  top: 0;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 40;
  padding: calc(14px + var(--safe-top)) 20px 12px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-title-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-title {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-date-badge {
  font-size: 0.78rem;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-blue);
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 600;
}

.header-lock-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.header-lock-btn:active {
  transform: scale(0.92);
}

/* 画面ビュー */
.view-content {
  display: none;
  padding: 16px;
  animation: fadeIn 0.2s ease-in-out;
}

.view-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 共通カード */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
}

.card-heading {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ヒーローカード: 使えるお金 */
.hero-cash-card {
  background: linear-gradient(135deg, #1e293b 0%, #0f2b48 100%);
  border: 1px solid rgba(56, 189, 248, 0.25);
  position: relative;
  overflow: hidden;
}

.hero-cash-card::after {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 110px;
  height: 110px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.22) 0%, transparent 70%);
  pointer-events: none;
}

.hero-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.hero-amount {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin: 8px 0;
  color: #38bdf8;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.hero-amount span.unit {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.hero-subcalc {
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px dashed var(--border-color);
  padding-top: 8px;
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
}

/* 2列ミニステータス */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.mini-stat {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 12px 14px;
}

.mini-stat-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.mini-stat-value {
  font-size: 1.25rem;
  font-weight: 700;
}

.mini-stat-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* 資産構成バー */
.breakdown-bar {
  display: flex;
  height: 10px;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 10px;
  background: #0f172a;
}

.bar-cash { background: var(--accent-blue); transition: width 0.3s; }
.bar-stock { background: var(--accent-orange); transition: width 0.3s; }
.bar-wait { background: var(--accent-green); transition: width 0.3s; }

.breakdown-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* カード引落リスト */
.card-schedule-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.card-schedule-item:last-child {
  border-bottom: none;
  padding-bottom: 2px;
}

.card-sch-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
}

.badge-card-b {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-card-a {
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.badge-cash {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.card-sch-date {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
}

.card-sch-amount {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f8fafc;
}

/* バナーアラート */
.notice-banner {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fde68a;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

/* フォームパーツ */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.form-label .req {
  color: var(--accent-rose);
  margin-left: 4px;
}

.form-input {
  width: 100%;
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text-main);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--accent-blue);
}

.btn-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.btn-chip {
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 10px 4px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-chip:active {
  transform: scale(0.97);
}

.btn-chip.selected {
  background: var(--accent-blue);
  color: #0f172a;
  border-color: var(--accent-blue);
  font-weight: 700;
}

/* メインボタン */
.btn-submit-main {
  width: 100%;
  background: #0284c7;
  color: #ffffff;
  border: none;
  padding: 15px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
  margin-top: 10px;
  transition: all 0.15s ease;
}

.btn-submit-main:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.btn-submit-continuous {
  width: 100%;
  background: transparent;
  color: var(--accent-blue);
  border: 1px solid var(--accent-blue);
  padding: 13px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 10px;
  transition: all 0.15s ease;
}

.btn-submit-continuous:active {
  background: rgba(56, 189, 248, 0.1);
}

/* 商品カード */
.item-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.item-info {
  flex: 1;
  padding-right: 12px;
}

.item-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.item-badge {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.status-stock { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }
.status-sold { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.status-done { background: rgba(16, 185, 129, 0.15); color: #34d399; }

.btn-sell-trigger {
  background: #10b981;
  color: #0f172a;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn-sell-trigger:active {
  transform: scale(0.95);
}

.btn-done-trigger {
  background: #38bdf8;
  color: #0f172a;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

/* 下部固定ナビ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  width: 100%;
  max-width: 460px;
  height: calc(64px + var(--safe-bottom));
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding-top: 8px;
  z-index: 50;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  width: 20%;
}

.nav-btn svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
}

.nav-btn.active {
  color: var(--accent-blue);
}

.nav-btn.active svg {
  stroke: var(--accent-blue);
}

.nav-plus-btn {
  margin-top: -12px;
}

.nav-plus-circle {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.5);
  transition: transform 0.15s;
}

.nav-plus-circle:active {
  transform: scale(0.92);
}

/* モーダル */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 100;
  justify-content: center;
  align-items: flex-end;
}

.modal-backdrop.open {
  display: flex;
}

.modal-sheet {
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-secondary);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  padding: 20px 20px calc(24px + var(--safe-bottom));
  border-top: 1px solid var(--border-color);
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px;
}

.calc-preview {
  background: #0f172a;
  border-radius: 12px;
  padding: 12px;
  margin-top: 12px;
  font-size: 0.85rem;
}

.calc-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.calc-row.profit {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-green);
  border-top: 1px dashed var(--border-color);
  padding-top: 8px;
  margin-top: 6px;
  margin-bottom: 0;
}

/* フィルターチップ */
.tag-container {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 12px;
  scrollbar-width: none;
}

.tag-container::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.filter-chip.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

/* トースト通知 */
.toast {
  position: fixed;
  bottom: calc(78px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--accent-blue);
  color: #fff;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ロック画面 */
.lock-screen {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.98);
  z-index: 300;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.lock-screen.open {
  display: flex;
}

.faceid-icon {
  width: 68px;
  height: 68px;
  margin-bottom: 16px;
  color: var(--accent-blue);
}
