/**
 * style.css — 钱的等价物 PWA 样式
 * 深色主题，移动端优先
 */

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #1a1a2e;
  --card: #16213e;
  --card-hover: #1a2744;
  --gold: #e2b714;
  --amber: #f0a500;
  --text: #e8e8e8;
  --text-dim: #8892a4;
  --text-muted: #5a6478;
  --danger: #e74c3c;
  --success: #2ecc71;
  --radius: 12px;
  --nav-height: 64px;
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* ===== Utility ===== */
.hidden { display: none !important; }

/* ===== Overlay (Onboarding / Confirm) ===== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(8px);
}

/* ===== Onboarding ===== */
.onboarding-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px 24px;
  max-width: 400px;
  width: 100%;
  animation: slideUp 0.3s ease;
}

.onboarding-card h2 {
  font-size: 1.4rem;
  margin-bottom: 8px;
  color: var(--gold);
  text-align: center;
}

.onboarding-card .subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
  text-align: center;
  margin-bottom: 24px;
}

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

/* ===== Form Elements ===== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-group.half {
  flex: 1;
}

.input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.input-wrap:focus-within {
  border-color: var(--gold);
}

.input-wrap .prefix,
.input-wrap .suffix {
  padding: 0 10px;
  color: var(--text-dim);
  font-size: 0.95rem;
  white-space: nowrap;
}

input, select {
  width: 100%;
  padding: 12px;
  background: var(--bg);
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

input:focus, select:focus {
  border-color: var(--gold);
}

.input-wrap input {
  border: none;
  background: transparent;
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238892a4' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ===== Buttons ===== */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--gold), var(--amber));
  color: #1a1a2e;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  padding: 10px 24px;
  background: var(--card);
  color: var(--text);
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn-danger {
  padding: 10px 24px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn-small {
  padding: 8px 16px;
  background: var(--gold);
  color: #1a1a2e;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* ===== App Layout ===== */
#app {
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: calc(var(--nav-height) + 16px);
  min-height: 100dvh;
}

.app-header {
  padding: 16px 20px 8px;
  text-align: center;
}

.app-header h1 {
  font-size: 1.3rem;
  color: var(--gold);
  font-weight: 700;
}

/* ===== Tab Content ===== */
.tab-content {
  display: none;
  padding: 0 16px;
  animation: fadeIn 0.2s ease;
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== Input Card (Home) ===== */
.input-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.amount-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.yen-sign {
  font-size: 2rem;
  color: var(--gold);
  font-weight: 700;
  font-family: 'Courier New', monospace;
}

#amount-input {
  font-size: 2rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  color: var(--text);
  background: transparent;
  border: none;
  padding: 8px 0;
  width: 100%;
}

#amount-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 1.2rem;
}

/* ===== Section ===== */
.section {
  margin-bottom: 16px;
}

.section-title {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 16px 0 12px;
  letter-spacing: 2px;
}

/* ===== Conversion List ===== */
.conversion-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.conversion-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: 10px;
  padding: 14px 16px;
  transition: background 0.2s;
}

.conversion-item:active {
  background: var(--card-hover);
}

.conv-icon {
  font-size: 1.5rem;
  width: 36px;
  text-align: center;
  flex-shrink: 0;
}

.conv-info {
  flex: 1;
  min-width: 0;
}

.conv-name {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.conv-result {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gold);
  font-family: 'Courier New', monospace;
}

/* ===== Today Card ===== */
.today-card {
  background: linear-gradient(135deg, #16213e, #1a2744);
  border: 1px solid #2a3a5e;
  border-radius: var(--radius);
  padding: 20px;
}

.today-income {
  font-size: 1.1rem;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 12px;
  font-family: 'Courier New', monospace;
}

.today-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.today-tag {
  background: rgba(226, 183, 20, 0.12);
  color: var(--amber);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-family: 'Courier New', monospace;
}

/* ===== Search & Sort Bar ===== */
.search-sort-bar {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  align-items: center;
}

.search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--card);
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  padding: 0 10px;
  transition: border-color 0.2s;
}

.search-wrap:focus-within {
  border-color: var(--gold);
}

.search-icon {
  font-size: 0.9rem;
  margin-right: 6px;
}

#search-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 0;
  font-size: 0.9rem;
  color: var(--text);
  outline: none;
}

#sort-select {
  width: auto;
  min-width: 90px;
  padding: 10px 8px;
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* ===== Category Tabs ===== */
.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.cat-tab {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid #2a2a4a;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.cat-tab.active {
  background: var(--gold);
  color: #1a1a2e;
  border-color: var(--gold);
  font-weight: 600;
}

/* ===== Items List ===== */
.items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-card {
  background: var(--card);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.item-card:active {
  background: var(--card-hover);
}

.item-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.item-icon {
  font-size: 1.5rem;
  width: 36px;
  text-align: center;
  flex-shrink: 0;
}

.item-info {
  flex: 1;
  min-width: 0;
}

.item-name {
  font-size: 0.95rem;
  font-weight: 500;
}

.item-price {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-family: 'Courier New', monospace;
}

.item-quick {
  font-size: 0.8rem;
  color: var(--amber);
  font-family: 'Courier New', monospace;
  text-align: right;
  flex-shrink: 0;
}

.item-detail {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #2a2a4a;
}

.item-card.expanded .item-detail {
  display: block;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.detail-row .detail-val {
  color: var(--gold);
  font-family: 'Courier New', monospace;
  font-weight: 600;
}

.item-delete-btn {
  margin-top: 8px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
}

/* ===== Add Form ===== */
.add-form-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin-bottom: 16px;
}

.add-form-card h3 {
  font-size: 1.1rem;
  color: var(--gold);
  margin-bottom: 16px;
}

/* ===== Settings ===== */
.settings-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin-bottom: 16px;
}

.settings-card h3 {
  font-size: 1.1rem;
  color: var(--gold);
  margin-bottom: 16px;
}

.preview-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
}

.preview-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 0.9rem;
}

.preview-val {
  color: var(--gold);
  font-family: 'Courier New', monospace;
  font-weight: 700;
}

.inline-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.inline-form input {
  flex: 1;
  min-width: 60px;
  padding: 8px 10px;
  font-size: 0.85rem;
}

.units-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.unit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 0.85rem;
}

.unit-row .unit-info {
  color: var(--text-dim);
}

.unit-row .unit-info span {
  color: var(--gold);
  font-family: 'Courier New', monospace;
}

.unit-del {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
}

.danger-zone {
  text-align: center;
  padding: 20px 0;
}

/* ===== Bottom Nav ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-height);
  background: var(--card);
  border-top: 1px solid #2a2a4a;
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
  padding: 6px 12px;
  transition: color 0.2s;
}

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

.nav-icon {
  font-size: 1.3rem;
}

.nav-label {
  font-size: 0.7rem;
}

/* ===== Confirm Dialog ===== */
.confirm-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  animation: slideUp 0.2s ease;
}

.confirm-card p {
  margin-bottom: 20px;
  font-size: 1rem;
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 20px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 200;
  animation: toastIn 0.2s ease;
  border: 1px solid #2a3a5e;
  white-space: nowrap;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== Responsive ===== */
@media (max-width: 360px) {
  .yen-sign, #amount-input {
    font-size: 1.6rem;
  }
  .conv-result {
    font-size: 1rem;
  }
}

/* ===== Wishlist ===== */
.wishlist-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.wishlist-empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.wishlist-hint {
  font-size: 0.85rem;
  margin-top: 8px;
}

.wishlist-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 0;
}

.wishlist-item {
  background: var(--card);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.wishlist-item:active {
  background: var(--card-hover);
}

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

.wishlist-item-name {
  font-size: 0.95rem;
  font-weight: 500;
}

.wishlist-item-price {
  font-size: 0.9rem;
  color: var(--gold);
  font-family: 'Courier New', monospace;
  font-weight: 600;
}

.wishlist-item-days {
  font-size: 0.8rem;
  color: var(--amber);
  margin-bottom: 8px;
}

.wishlist-progress-bar {
  height: 6px;
  background: #2a2a4a;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.wishlist-progress-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.wishlist-item-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.wishlist-action-btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  border: 1px solid #2a2a4a;
  background: transparent;
  color: var(--text-dim);
  transition: all 0.2s;
}

.wishlist-action-btn:hover,
.wishlist-action-btn:active {
  border-color: var(--gold);
  color: var(--gold);
}

.wishlist-action-btn.delete {
  border-color: var(--danger);
  color: var(--danger);
}

/* ===== Wishlist Modal ===== */
.wishlist-modal-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 340px;
  width: 100%;
  animation: slideUp 0.2s ease;
}

.wishlist-modal-card h3 {
  font-size: 1.1rem;
  color: var(--gold);
  margin-bottom: 4px;
  text-align: center;
}

.wishlist-modal-price {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 16px;
  font-family: 'Courier New', monospace;
}

/* ===== Worth It Calculator ===== */
.btn-worthit {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #2a2a4a, #1a2744);
  border: 1px solid #3a3a5a;
  border-radius: 10px;
  color: var(--gold);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 16px;
  transition: all 0.2s;
}

.btn-worthit:active {
  background: linear-gradient(135deg, #3a3a5a, #2a3744);
  transform: scale(0.98);
}

.worthit-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 380px;
  width: 100%;
  animation: slideUp 0.2s ease;
  max-height: 85vh;
  overflow-y: auto;
}

.worthit-card h3 {
  font-size: 1.2rem;
  color: var(--gold);
  margin-bottom: 16px;
  text-align: center;
}

.worthit-result {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg);
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--text);
}

.worthit-result .wi-title {
  font-size: 1rem;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 8px;
}

.worthit-result .wi-main {
  font-size: 1.2rem;
  color: var(--text);
  font-weight: 700;
  font-family: 'Courier New', monospace;
  margin-bottom: 12px;
}

.worthit-result .wi-equiv {
  color: var(--text-dim);
  margin-bottom: 4px;
}

.worthit-result .wi-equiv span {
  color: var(--amber);
  font-family: 'Courier New', monospace;
}

.worthit-result .wi-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #2a2a4a;
}

.worthit-result .wi-tip {
  color: var(--success);
  font-weight: 500;
}

/* ===== Checkbox ===== */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
  cursor: pointer;
}
