/**
 * @file style.css
 * @description 拟态（Neumorphism）风格样式表
 * @created 2026-07-04
 * @updated 2026-07-04
 */

/* ===== CSS 变量定义 ===== */
:root {
  --bg: #e0e5ec;            /* 主背景色 */
  --light: #ffffff;          /* 亮投影 */
  --shadow: #a3b1c6;         /* 暗投影 */
  --mint: #7fdbb6;           /* 薄荷绿强调色 */
  --sky: #7ab8e0;            /* 天蓝强调色 */
  --text: #4a5568;           /* 主文字色 */
  --radius: 16px;            /* 通用圆角 */
  --radius-lg: 20px;         /* 大圆角 */
}

/* ===== 全局重置 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  /* 防止模态打开时底层滚动 */
  overflow-x: hidden;
}

body.modal-open {
  overflow: hidden;
}

/* ===== 拟态工具类 ===== */
.neu-raised {
  background: var(--bg);
  border: none;
  border-radius: var(--radius);
  box-shadow: 8px 8px 16px var(--shadow), -8px -8px 16px var(--light);
}

.neu-inset {
  background: var(--bg);
  border: none;
  border-radius: var(--radius);
  box-shadow: inset 8px 8px 16px var(--shadow), inset -8px -8px 16px var(--light);
}

/* ===== 顶部栏 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  background: var(--bg);
  /* 顶部栏底部柔和投影分隔 */
  box-shadow: 0 6px 12px rgba(163, 177, 198, 0.25);
}

.topbar-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
}

/* ===== 加号按钮 ===== */
.add-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 26px;
  font-weight: 300;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.18s ease, transform 0.18s ease, color 0.18s ease;
}

.add-btn:hover {
  color: var(--mint);
  transform: translateY(-1px);
}

.add-btn:active,
.add-btn.pressed {
  box-shadow: inset 8px 8px 16px var(--shadow), inset -8px -8px 16px var(--light);
  transform: translateY(0);
  color: var(--sky);
}

.add-btn:focus-visible {
  outline: 2px solid var(--sky);
  outline-offset: 3px;
}

/* ===== 存款滚动容器（纵向布局） ===== */
.deposits-scroll {
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
  overflow-x: auto;
  padding: 32px 24px;
  align-items: stretch;
  min-height: 200px;
  scrollbar-width: thin;
}

/* ===== 空状态 ===== */
.empty-state {
  display: none;
  margin: 40px auto;
  padding: 40px 28px;
  max-width: 420px;
  text-align: center;
  color: var(--text);
  font-size: 15px;
}

.empty-state.show {
  display: block;
}

/* ===== 存款卡片 ===== */
.deposit-card {
  position: relative;
  flex-shrink: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start; /* 进度条无论长度如何始终居左排布 */
  padding: 18px 16px 14px;
  /* 卡片本身拟态外凸 */
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: 8px 8px 16px var(--shadow), -8px -8px 16px var(--light);
}

/* 已到期角标 */
.expired-badge {
  position: absolute;
  top: -10px;
  right: -8px;
  background: var(--shadow);
  color: #fff;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 10px;
  box-shadow: 2px 2px 6px var(--shadow);
  letter-spacing: 0.5px;
}

/* ===== 进度条 ===== */
.bar {
  /* 内嵌背景轨道 */
  position: relative;
  height: 64px;
  border-radius: 14px;
  background: var(--bg);
  box-shadow: inset 6px 6px 12px var(--shadow), inset -6px -6px 12px var(--light);
  overflow: hidden;
  display: flex;
  align-items: center;
}

.bar-fill {
  /* 拟态外凸填充 */
  height: 100%;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--mint), var(--sky));
  box-shadow: 4px 4px 10px var(--shadow), -4px -4px 10px var(--light);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  color: #2d3748;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.4;
  min-width: 120px;
  transition: width 0.4s ease;
}

/* 左列：本金 + 利息，垂直排列 */
.bar-fill .money-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  min-width: 0;
}

.bar-fill .money-line {
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* 右列：剩余天数，靠右对齐 */
.bar-fill .days-remaining {
  flex-shrink: 0;
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
  font-weight: 700;
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.45);
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* 到期日期：换行显示，字号略小、字重稍轻 */
.bar-fill .maturity-date {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.85;
  margin-top: 2px;
}

/* ===== 卡片信息区 ===== */
.bar-info {
  margin-top: 12px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bank-name {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== 删除按钮 ===== */
.delete-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 4px 4px 8px var(--shadow), -4px -4px 8px var(--light);
  transition: box-shadow 0.18s ease, color 0.18s ease;
}

.delete-btn:hover {
  color: #e53e3e;
}

.delete-btn:active {
  box-shadow: inset 4px 4px 8px var(--shadow), inset -4px -4px 8px var(--light);
}

/* ===== 模态窗 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.18s ease;
}

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

.modal-card {
  width: 360px;
  max-width: 92vw;
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: 12px 12px 24px var(--shadow), -12px -12px 24px var(--light);
  padding: 28px 24px 24px;
  animation: popIn 0.22s ease;
}

@keyframes popIn {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
  text-align: center;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.field label {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  padding-left: 4px;
}

.field input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: none;
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  box-shadow: inset 4px 4px 8px var(--shadow), inset -4px -4px 8px var(--light);
  outline: none;
  transition: box-shadow 0.18s ease;
}

.field input:focus {
  box-shadow: inset 4px 4px 8px var(--shadow), inset -4px -4px 8px var(--light),
    0 0 0 2px var(--sky);
}

.field select {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: none;
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  box-shadow: inset 4px 4px 8px var(--shadow), inset -4px -4px 8px var(--light);
  outline: none;
  appearance: none;
  cursor: pointer;
}

.field select:focus {
  box-shadow: inset 4px 4px 8px var(--shadow), inset -4px -4px 8px var(--light), 0 0 0 2px var(--sky);
}

.field input.hidden {
  display: none;
}

.field-error {
  font-size: 12px;
  color: #e53e3e;
  padding-left: 4px;
  min-height: 14px;
  line-height: 14px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.btn {
  flex: 1;
  height: 42px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  transition: box-shadow 0.18s ease, color 0.18s ease;
}

.btn-primary {
  box-shadow: 6px 6px 12px var(--shadow), -6px -6px 12px var(--light);
  color: #2d3748;
}

.btn-primary:hover {
  color: var(--mint);
}

.btn-primary:active {
  box-shadow: inset 6px 6px 12px var(--shadow), inset -6px -6px 12px var(--light);
}

.btn-secondary {
  box-shadow: 6px 6px 12px var(--shadow), -6px -6px 12px var(--light);
}

.btn-secondary:hover {
  color: var(--sky);
}

.btn-secondary:active {
  box-shadow: inset 6px 6px 12px var(--shadow), inset -6px -6px 12px var(--light);
}

/* ===== 响应式 ===== */
@media (max-width: 600px) {
  .topbar {
    padding: 14px 18px;
  }

  .topbar-title {
    font-size: 17px;
  }

  .add-btn {
    width: 40px;
    height: 40px;
    font-size: 22px;
  }

  .deposits-scroll {
    padding: 24px 16px;
    gap: 18px;
  }

  /* 进度条最小宽度通过 JS 常量控制，移动端 CSS 辅助 */
  .bar-fill {
    min-width: 90px;
  }

  .modal-card {
    width: 90vw;
    padding: 22px 18px 18px;
  }
}
