/* ==========================================================================
   スーパー底値・単価比較 アプリ用スタイル
   ========================================================================== */

:root {
  --primary: #10B981;
  --primary-dark: #059669;
  --primary-light: #D1FAE5;
  --primary-glow: rgba(16, 185, 129, 0.25);
  
  --gold: #F59E0B;
  --gold-bg: #FEF3C7;
  --gold-border: #FCD34D;
  --gold-text: #92400E;
  
  --bg-page: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-input: #F1F5F9;
  
  --text-main: #0F172A;
  --text-sub: #64748B;
  --text-muted: #94A3B8;
  
  --border-card: #E2E8F0;
  --border-input: #CBD5E1;
  --border-focus: #10B981;
  
  --danger: #EF4444;
  --danger-light: #FEE2E2;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-best: 0 8px 20px -3px rgba(16, 185, 129, 0.25), 0 4px 10px -2px rgba(245, 158, 11, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-page: #0F172A;
    --bg-card: #1E293B;
    --bg-input: #334155;
    
    --text-main: #F8FAFC;
    --text-sub: #94A3B8;
    --text-muted: #64748B;
    
    --border-card: #334155;
    --border-input: #475569;
    
    --gold-bg: #78350F;
    --gold-border: #B45309;
    --gold-text: #FDE68A;

    --primary-light: rgba(16, 185, 129, 0.2);
    --danger-light: rgba(239, 68, 68, 0.2);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 90px;
}

.app-container {
  max-width: 580px;
  margin: 0 auto;
  padding: 12px 16px;
}

/* ヘッダー */
.app-header {
  margin-bottom: 12px;
}

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

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.app-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

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

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-sub);
  padding: 6px 10px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.btn-icon:active {
  transform: scale(0.96);
  background: var(--bg-input);
}

/* カテゴリタブ */
.categories-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.categories-nav::-webkit-scrollbar {
  display: none;
}

.cat-tab {
  flex: 0 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-full);
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.cat-tab:active {
  transform: scale(0.96);
}

.cat-tab.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* 最安値ハイライトサマリーバナー */
.best-summary-banner {
  background: linear-gradient(135deg, #10B981, #059669);
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-best);
  animation: slideDown 0.25s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.summary-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.summary-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.summary-title {
  font-size: 0.98rem;
  font-weight: 700;
}

.summary-desc {
  font-size: 0.82rem;
  opacity: 0.95;
  margin-top: 2px;
}

/* 商品カードリスト */
.items-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.item-card {
  background: var(--bg-card);
  border: 2px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  position: relative;
}

/* 最安値商品の強調カード */
.item-card.best-deal {
  border-color: var(--primary);
  background: linear-gradient(to bottom, var(--primary-light), var(--bg-card) 25%);
  box-shadow: var(--shadow-best);
  transform: scale(1.01);
}

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

.title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.best-badge {
  background: var(--gold-bg);
  border: 1px solid var(--gold-border);
  color: var(--gold-text);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.item-name-input {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  background: transparent;
  border: 1px dashed transparent;
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  max-width: 140px;
  transition: all 0.15s;
}

.item-name-input:focus {
  outline: none;
  border-color: var(--border-focus);
  background: var(--bg-input);
}

.btn-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.btn-delete:hover, .btn-delete:active {
  color: var(--danger);
  background: var(--danger-light);
}

/* 入力フィールドグリッド */
.fields-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

@media (max-width: 380px) {
  .fields-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.input-with-unit {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  background: var(--bg-input);
  border: 1.5px solid var(--border-input);
  border-radius: var(--radius-md);
  padding: 8px 6px 8px 8px;
  min-height: 46px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.input-with-unit:focus-within {
  border-color: var(--border-focus);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.field-input {
  width: 100%;
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  text-align: right;
  outline: none;
}

.field-input:focus {
  outline: none;
  border: none;
  box-shadow: none;
}

/* 数値入力スピンボタンを非表示にしてスマホで押しやすく */
.field-input::-webkit-outer-spin-button,
.field-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.field-input[type=number] {
  -moz-appearance: textfield;
}

.field-unit {
  flex-shrink: 0;
  margin-left: 2px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  pointer-events: none;
  white-space: nowrap;
}

/* カードの計算結果表示エリア */
.card-result {
  border-top: 1px dashed var(--border-card);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.result-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.unit-price-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-sub);
}

.unit-price-val {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.unit-price-val.best-text {
  color: var(--primary);
}

.result-diff {
  font-size: 0.82rem;
  font-weight: 700;
  text-align: right;
}

.result-diff.best-diff {
  color: var(--primary);
}

.result-diff.worse-diff {
  color: var(--text-sub);
}

.result-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
}

.result-placeholder {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  padding: 4px 0;
}

/* ボトムアクションバー (固定 / 片手操作フレンドリー) */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border-card);
  padding: 10px 16px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: center;
  z-index: 100;
}

.bottom-bar-inner {
  width: 100%;
  max-width: 580px;
  display: flex;
  gap: 10px;
}

.btn-add {
  flex: 1;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: 1.02rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--primary-glow);
  transition: all 0.15s ease;
}

.btn-add:active {
  transform: scale(0.98);
  background: var(--primary-dark);
}

.btn-clear {
  background: var(--bg-input);
  border: 1px solid var(--border-card);
  color: var(--text-sub);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-clear:active {
  background: var(--border-card);
}

/* PWAインストール案内バナー */
.install-banner {
  background: var(--bg-card);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  animation: slideDown 0.3s ease;
}

.install-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.install-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-install {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-dismiss {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 4px;
  cursor: pointer;
}

/* iOSガイドモーダル */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
  backdrop-filter: blur(2px);
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow-best);
  position: relative;
}

.modal-header {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
  text-align: center;
}

.modal-body ol {
  padding-left: 20px;
  font-size: 0.9rem;
  color: var(--text-sub);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-close-btn {
  margin-top: 18px;
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px;
  font-weight: 700;
  cursor: pointer;
}

.hidden {
  display: none !important;
}
