/* ============================================================
   工地记工天 - 手机端样式
   设计原则：大按钮、大字体、暖色调、单手操作友好
   ============================================================ */

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

:root {
  --primary: #f59e0b;        /* 主色：暖橙 */
  --primary-dark: #d97706;
  --primary-light: #fef3c7;
  --danger: #ef4444;
  --success: #10b981;
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --text: #1f2937;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --radius: 12px;
  --nav-height: 60px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

.page {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ==================== 登录 / 注册页 ==================== */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 50%, #fcd34d 100%);
  padding: 20px;
}

.auth-container {
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon {
  font-size: 64px;
  margin-bottom: 12px;
}

.auth-logo h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-light);
}

.auth-form {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.form-group {
  margin-bottom: 16px;
}

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

.form-group input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font-size: 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: #fafafa;
  transition: border-color 0.2s;
  outline: none;
}

.form-group input:focus {
  border-color: var(--primary);
  background: #fff;
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 18px;
}

.auth-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-light);
}

.auth-switch a {
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 600;
}

/* ==================== 按钮 ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 20px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  outline: none;
  user-select: none;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:active {
  background: var(--primary-dark);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: var(--primary-dark);
  border: 1.5px solid var(--primary);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  height: 36px;
  padding: 0 14px;
  font-size: 14px;
}

.btn-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border: none;
  border-radius: 50%;
  background: var(--primary-light);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}

.btn-icon:active {
  transform: scale(0.9);
}

.btn-send {
  background: var(--primary);
  color: #fff;
}

.btn-icon.recording {
  background: var(--danger);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ==================== 主应用页 ==================== */
.main-page {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.tab-page {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--nav-height) + 10px);
}

.page-header {
  background: var(--primary);
  color: #fff;
  padding: 16px 16px 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.page-header h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.header-summary {
  display: flex;
  gap: 20px;
  font-size: 14px;
}

.header-summary strong {
  font-size: 18px;
  font-weight: 700;
}

.month-filter {
  margin-top: 8px;
}

.month-filter input {
  height: 36px;
  padding: 0 10px;
  font-size: 14px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
}

/* ==================== 聊天记工区 ==================== */
.chat-messages {
  padding: 16px;
  min-height: calc(100vh - 280px);
}

.chat-msg {
  margin-bottom: 12px;
  display: flex;
}

.chat-msg.user-msg {
  justify-content: flex-end;
}

.chat-msg.system-msg {
  justify-content: flex-center;
}

.msg-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.6;
  word-break: break-word;
}

.user-msg .msg-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.system-msg .msg-bubble {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* 确认卡片 */
.confirm-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-top: 8px;
  border: 1.5px solid var(--primary);
}

.confirm-card h4 {
  font-size: 15px;
  color: var(--primary-dark);
  margin-bottom: 10px;
}

.confirm-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.confirm-row:last-child {
  border-bottom: none;
}

.confirm-row .label {
  color: var(--text-light);
}

.confirm-row .value {
  font-weight: 600;
  color: var(--text);
}

.confirm-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.confirm-actions .btn {
  flex: 1;
  height: 42px;
  font-size: 15px;
}

/* 聊天输入区 */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: var(--nav-height);
}

#chat-input {
  flex: 1;
  height: 44px;
  padding: 0 16px;
  font-size: 15px;
  border: 1.5px solid var(--border);
  border-radius: 22px;
  background: #fafafa;
  outline: none;
}

#chat-input:focus {
  border-color: var(--primary);
  background: #fff;
}

.quick-actions {
  padding: 8px 16px 12px;
  background: #fff;
  border-top: 1px solid var(--border);
  text-align: center;
  position: sticky;
  bottom: var(--nav-height);
}

/* ==================== 统计页 ==================== */
.stats-content {
  padding: 16px;
}

.stats-overview {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.stats-overview .stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
}

.stats-overview .stat-label {
  font-size: 15px;
  color: var(--text-light);
}

.stats-overview .stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary-dark);
}

.stats-group-title {
  font-size: 16px;
  font-weight: 700;
  margin: 20px 0 10px;
  padding-left: 4px;
  border-left: 4px solid var(--primary);
}

.boss-stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.boss-stat-card .boss-name {
  font-size: 16px;
  font-weight: 600;
}

.boss-stat-card .boss-detail {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 4px;
}

.boss-stat-card .boss-amount {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-dark);
}

/* ==================== 历史记录页 ==================== */
.history-list {
  padding: 16px;
}

.record-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.record-card .record-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.record-card .record-boss {
  font-size: 16px;
  font-weight: 600;
}

.record-card .record-date {
  font-size: 13px;
  color: var(--text-light);
}

.record-card .record-middle {
  display: flex;
  gap: 16px;
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 6px;
}

.record-card .record-wage {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-dark);
}

.record-card .record-note {
  font-size: 13px;
  color: var(--text-light);
  background: var(--primary-light);
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-top: 4px;
}

.record-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.record-actions .btn {
  flex: 1;
  height: 36px;
  font-size: 13px;
}

/* ==================== 我的页 ==================== */
.me-content {
  padding: 16px;
}

.user-info-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.user-email {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  word-break: break-all;
}

.user-plan {
  font-size: 13px;
  color: var(--primary-dark);
  background: var(--primary-light);
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
}

.menu-list {
  background: #fff;
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.menu-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item:active {
  background: #f9fafb;
}

.menu-arrow {
  color: var(--text-light);
  font-size: 20px;
}

/* ==================== 底部导航 ==================== */
.bottom-nav {
  display: flex;
  height: var(--nav-height);
  background: #fff;
  border-top: 1px solid var(--border);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  color: var(--text-light);
  transition: color 0.2s;
  user-select: none;
}

.nav-item.active {
  color: var(--primary-dark);
}

.nav-icon {
  font-size: 22px;
}

.nav-label {
  font-size: 11px;
  font-weight: 500;
}

/* ==================== 弹窗 ==================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-box {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  max-height: 85vh;
  overflow-y: auto;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.modal-body {
  padding: 16px 20px;
}

.modal-footer {
  display: flex;
  gap: 10px;
  padding: 12px 20px 18px;
}

.modal-footer .btn {
  flex: 1;
}

/* 手动填写表单 */
.manual-form .form-group {
  margin-bottom: 14px;
}

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

.manual-form .form-row .form-group {
  flex: 1;
}

/* ==================== Toast ==================== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  max-width: 80%;
  text-align: center;
}

.toast.show {
  opacity: 1;
}

/* ==================== 空状态 ==================== */
.empty-tip {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
  font-size: 14px;
}

/* ==================== 加载中 ==================== */
.loading {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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