/* ============================================
   算账系统样式表 / Calculator System Stylesheet
   遵循UI设计规范文档 / Following UI Design System
   ============================================ */

/* CSS变量定义 / CSS Variables Definition */
:root {
  /* 背景色 / Backgrounds */
  --bg-primary: linear-gradient(135deg, #ffeef8 0%, #e8f4ff 50%, #ffeef8 100%);
  --bg-card: #ffffff;
  --bg-input: #fafafa;

  /* 文字色 / Text Colors */
  --text-primary: #ff6bb3;
  --text-secondary: #999999;
  --text-title: #ff6bb3;
  --text-body: #666666;
  --text-inverse: #ffffff;

  /* 强调色 / Accent Colors */
  --accent-pink: #ff9ed2;
  --accent-blue: #9ed2ff;
  --accent-gradient: linear-gradient(135deg, #ff9ed2 0%, #9ed2ff 100%);

  /* 数字显示统一颜色 / Number Display Unified Colors */
  --number-integer: #ff6bb3;
  --number-decimal-major: #ff6bb3;
  --number-decimal-minor: #ff9ed2;
  --number-negative: #ff6b6b;

  /* 边框与阴影 / Borders & Shadows */
  --border-color: #ff9ed2;
  --input-border: #ffeef8;
  --shadow-color: rgba(255, 158, 210, 0.3);
  --shadow-hover: rgba(255, 158, 210, 0.4);

  /* 组件特定 / Component Specific */
  --card-bg: linear-gradient(135deg, #ffeef8 0%, #e8f4ff 100%);

  /* 间距 / Spacing */
  --spacing-xs: 6px;
  --spacing-sm: 10px;
  --spacing-md: 14px;
  --spacing-lg: 18px;
  --spacing-xl: 22px;

  /* 圆角 / Border Radius - 更大的圆角 */
  --radius-sm: 16px;
  --radius-md: 24px;
  --radius-lg: 32px;
  --radius-xl: 40px;
}

/* 深色模式 / Dark Mode */
[data-theme="dark"] {
  --bg-primary: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #1a1a2e 100%);
  --bg-card: #242438;
  --bg-input: #1a1a2e;
  --text-primary: #ff9ed2;
  --text-secondary: #888899;
  --text-title: #ff9ed2;
  --text-body: #aaaabc;
  --accent-blue: #6bb3ff;
  --accent-gradient: linear-gradient(135deg, #ff9ed2 0%, #6bb3ff 100%);
  --number-integer: #ff9ed2;
  --number-decimal-major: #ff9ed2;
  --number-decimal-minor: #ff6bb3;
  --number-negative: #ff8080;
  --shadow-color: rgba(255, 158, 210, 0.15);
  --shadow-hover: rgba(255, 158, 210, 0.25);
  --card-bg: linear-gradient(135deg, #2d2d4a 0%, #1e2a4a 100%);
  --input-border: #3d3d5c;
}

/* 基础重置 / Base Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 页面主体 / Page Body */
html {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Segoe UI", "Microsoft YaHei", Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-primary);
  background-size: 200% 200%;
  animation: gradientShift 15s ease infinite;
  color: var(--text-body);
  height: 100%;
  overflow: hidden;
  line-height: 1.4;
}

/* 渐变动画 / Gradient Animation */
@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* 主容器 / Main Container */
.container {
  max-width: 100%;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: var(--spacing-md);
  overflow: hidden;
}

/* ============================================
   头部区域 / Header Section
   ============================================ */
.header {
  text-align: center;
  padding: var(--spacing-lg);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px var(--shadow-color);
  flex-shrink: 0;
  margin-bottom: var(--spacing-md);
}

.title {
  font-size: 1.8em;
  font-weight: bold;
  color: var(--text-title);
  text-shadow: 2px 2px 0 rgba(255, 107, 179, 0.2);
}

/* ============================================
   输入区域 / Input Section
   ============================================ */
.input-section {
  flex-shrink: 0;
  margin-bottom: var(--spacing-md);
}

.input-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-md);
}

.input-group {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  box-shadow: 0 4px 20px var(--shadow-color);
  transition: all 0.3s ease;
}

.input-group:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px var(--shadow-hover);
}

.input-group label {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-size: 1em;
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: var(--spacing-sm);
}

.label-icon {
  font-size: 1.2em;
}

.number-input {
  width: 100%;
  padding: var(--spacing-md);
  border: 2px solid var(--input-border);
  border-radius: var(--radius-sm);
  font-size: 1.3em;
  font-weight: bold;
  background: var(--bg-input);
  color: var(--text-body);
  transition: all 0.3s ease;
  text-align: center;
}

.number-input:focus {
  outline: none;
  border-color: var(--accent-pink);
  box-shadow: 0 0 15px var(--shadow-hover);
}

.number-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.5;
  font-size: 0.9em;
}

/* ============================================
   工资卡片 - 双层设计 / Salary Card - Dual Layer
   ============================================ */
.salary-card {
  position: relative;
  background: linear-gradient(135deg, #fff5f8 0%, #f0f8ff 100%);
  border: 2px solid var(--accent-pink);
  overflow: hidden;
}

/* 标签行 / Label Row */
.salary-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
}

.salary-label-row label {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-size: 1em;
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 0;
  flex: 1;
}

/* 切换按钮 / Toggle Button */
.salary-toggle-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--accent-gradient);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px var(--shadow-color);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  margin-left: var(--spacing-xs);
  padding: 0;
}

.salary-toggle-btn:hover {
  transform: scale(1.1) rotate(180deg);
  box-shadow: 0 4px 12px var(--shadow-hover);
}

.salary-toggle-btn:active {
  transform: scale(0.95);
}

.toggle-icon-svg {
  width: 18px;
  height: 18px;
  filter: brightness(0) invert(1);
  transition: transform 0.3s ease;
}

/* 模式标签 / Mode Badge */
.mode-badge {
  margin-left: auto;
  font-size: 0.7em;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent-pink);
  color: white;
  font-weight: normal;
  transition: all 0.3s ease;
}

/* 双层容器 / Dual Layer Container */
.salary-layers {
  position: relative;
  width: 100%;
  height: 70px;
  perspective: 1000px;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 工资层 - 通用样式 / Salary Layer - Common Styles */
.salary-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  border-radius: var(--radius-sm);
}

/* 查表层 - 正面 / Lookup Layer - Front */
.lookup-layer {
  background: var(--bg-card);
  transform: rotateY(0deg);
  opacity: 1;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 手动输入层 - 背面 / Manual Layer - Back */
.manual-layer {
  background: var(--bg-card);
  transform: rotateY(180deg);
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 手动模式 - 翻转显示手动层 / Manual Mode - Show Manual Layer */
.salary-layers.manual-mode {
  transform: rotateY(180deg);
}

.salary-layers.manual-mode .lookup-layer {
  opacity: 0;
}

.salary-layers.manual-mode .manual-layer {
  opacity: 1;
}

/* 工资显示值 / Salary Value Display */
.salary-value-display {
  font-size: 1.6em;
  font-weight: bold;
  color: var(--text-primary);
  text-align: center;
}

/* 工资输入框 / Salary Input */
.salary-input {
  width: 90%;
  padding: var(--spacing-sm);
  border: 2px solid var(--accent-pink);
  border-radius: 12px;
  font-size: 1.3em;
  font-weight: bold;
  background: var(--bg-input);
  color: var(--text-body);
  text-align: center;
  transition: all 0.3s ease;
}

.salary-input:focus {
  outline: none;
  box-shadow: 0 0 15px var(--shadow-hover);
}

.salary-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
  font-size: 0.85em;
}

/* 层提示文字 / Layer Hint */
.layer-hint {
  font-size: 0.7em;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ============================================
   算式区域 / Formula Section
   ============================================ */
.formula-section {
  flex-shrink: 0;
  margin-bottom: var(--spacing-md);
}

.formula-box {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  box-shadow: 0 4px 20px var(--shadow-color);
  border: 2px solid var(--border-color);
}

.formula-line {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

.formula-text {
  font-size: 1em;
  color: var(--text-body);
  font-weight: 600;
}

.formula-divider {
  font-size: 1.2em;
  color: var(--text-primary);
  font-weight: bold;
}

/* ============================================
   结果区域 / Result Section
   ============================================ */
.result-section {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: stretch;
  gap: var(--spacing-md);
  flex: 1;
  min-height: 0;
  margin-bottom: var(--spacing-md);
}

.result-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: 0 4px 20px var(--shadow-color);
  text-align: center;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  flex: 1;
  min-width: 0;
  border: 2px solid transparent;
}

.result-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px var(--shadow-hover);
  border-color: var(--accent-pink);
}

.result-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  font-size: 1.1em;
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
}

.result-icon {
  font-size: 1.3em;
}

/* 特殊数字显示 / Special Number Display */
.result-value {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  font-family: "Segoe UI", "Microsoft YaHei", Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1;
}

/* 整数部分 / Integer Part */
.integer-part {
  font-size: 1.5em;
  font-weight: bold;
  color: var(--number-integer);
}

/* 小数点 / Decimal Separator */
.decimal-separator {
  font-size: 1.5em;
  font-weight: bold;
  color: var(--number-integer);
}

/* 小数主要位（前两位）/ Decimal Major */
.decimal-major {
  font-size: 1em;
  font-weight: bold;
  color: var(--number-decimal-major);
  margin-bottom: 0.15em;
}

/* 小数次要位（第三位）/ Decimal Minor */
.decimal-minor {
  font-size: 0.5em;
  font-weight: 500;
  color: var(--number-decimal-minor);
  margin-bottom: 0.3em;
}

/* 负数样式 / Negative Number Style */
.result-value.negative .integer-part,
.result-value.negative .decimal-separator,
.result-value.negative .decimal-major {
  color: var(--number-negative);
}

/* ============================================
   页脚 / Footer
   ============================================ */
.footer {
  text-align: center;
  padding: var(--spacing-md);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px var(--shadow-color);
  color: var(--text-secondary);
  font-size: 1em;
  flex-shrink: 0;
}

.footer strong {
  color: var(--text-primary);
}

/* ============================================
   响应式设计 - 9:16竖屏优化
   ============================================ */

/* 9:16竖屏手机 */
@media (max-aspect-ratio: 9/16) {
  .container {
    padding: var(--spacing-sm);
  }

  .header {
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    border-radius: var(--radius-md);
  }

  .title {
    font-size: 1.6em;
  }

  .input-section {
    margin-bottom: var(--spacing-sm);
  }

  .input-grid {
    gap: var(--spacing-sm);
  }

  .input-group {
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
  }

  .input-group label {
    font-size: 0.9em;
    margin-bottom: var(--spacing-xs);
  }

  .number-input {
    padding: var(--spacing-sm);
    font-size: 1.2em;
    border-radius: 12px;
  }

  /* 工资卡片响应式 / Salary Card Responsive */
  .salary-toggle-btn {
    width: 24px;
    height: 24px;
  }

  .toggle-icon-svg {
    width: 16px;
    height: 16px;
  }

  .salary-layers {
    height: 60px;
  }

  .salary-value-display {
    font-size: 1.4em;
  }

  .salary-input {
    font-size: 1.1em;
    padding: var(--spacing-xs);
  }

  .layer-hint {
    font-size: 0.65em;
  }

  .formula-section {
    margin-bottom: var(--spacing-sm);
  }

  .formula-box {
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
  }

  .formula-line {
    gap: var(--spacing-sm);
  }

  .formula-text {
    font-size: 0.85em;
  }

  .formula-divider {
    font-size: 1em;
  }

  .result-section {
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
  }

  .result-card {
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
  }

  .result-label {
    font-size: 0.9em;
    margin-bottom: var(--spacing-xs);
  }

  .integer-part,
  .decimal-separator {
    font-size: 2em;
  }

  .decimal-major {
    font-size: 1.5em;
    margin-bottom: 0.1em;
  }

  .decimal-minor {
    font-size: 1em;
    margin-bottom: 0.2em;
  }

  .footer {
    padding: var(--spacing-sm);
    font-size: 0.9em;
    border-radius: var(--radius-sm);
  }
}

/* 超小屏幕 */
@media (max-height: 700px) {
  .header {
    padding: var(--spacing-sm);
  }

  .title {
    font-size: 1.4em;
  }

  .input-group {
    padding: var(--spacing-xs);
  }

  .number-input {
    padding: var(--spacing-xs);
    font-size: 1.1em;
  }

  .salary-layers {
    height: 55px;
  }

  .salary-value-display {
    font-size: 1.3em;
  }

  .formula-text {
    font-size: 0.75em;
  }

  .result-card {
    padding: var(--spacing-xs);
  }

  .integer-part,
  .decimal-separator {
    font-size: 1.6em;
  }

  .decimal-major {
    font-size: 1.2em;
  }

  .decimal-minor {
    font-size: 0.8em;
  }
}

/* 键盘弹出时 */
@media (max-height: 500px) {
  .header {
    padding: var(--spacing-xs);
    margin-bottom: var(--spacing-xs);
  }

  .title {
    font-size: 1.2em;
  }

  .input-section {
    margin-bottom: var(--spacing-xs);
  }

  .formula-section {
    margin-bottom: var(--spacing-xs);
  }

  .result-section {
    margin-bottom: var(--spacing-xs);
  }

  .result-card {
    padding: var(--spacing-xs);
  }

  .salary-layers {
    height: 50px;
  }
}

/* ============================================
   动画效果 / Animation Effects
   ============================================ */

@keyframes inputPulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 158, 210, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(255, 158, 210, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 158, 210, 0); }
}

.number-input:focus {
  animation: inputPulse 0.6s ease;
}

@keyframes resultUpdate {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.result-value.updating {
  animation: resultUpdate 0.3s ease;
}

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

.container > * {
  animation: fadeIn 0.5s ease forwards;
}

.container > *:nth-child(1) { animation-delay: 0.1s; }
.container > *:nth-child(2) { animation-delay: 0.2s; }
.container > *:nth-child(3) { animation-delay: 0.3s; }
.container > *:nth-child(4) { animation-delay: 0.4s; }
.container > *:nth-child(5) { animation-delay: 0.5s; }

/* 切换按钮旋转动画 / Toggle Button Rotation */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.salary-toggle-btn.spinning .toggle-icon {
  animation: spin 0.5s ease;
}
