/* 智邮视界 - 公共样式 */
:root {
  --primary: #00664E;
  --primary-light: #00A870;
  --primary-gradient: linear-gradient(135deg, #00664E 0%, #00A870 100%);
  --ai-color: #7C3AED;
  --ai-gradient: linear-gradient(135deg, #7C3AED 0%, #B87DF8 100%);
  --blue: #3B82F6;
  --amber: #F59E0B;
  --pink: #EC4899;
  --bg: #FAFAFA;
  --card-border: #E8ECF0;
  --text: #1A1F36;
  --text-secondary: #6B7280;
  --text-tertiary: #9CA3AF;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text);
  max-width: 420px; margin: 0 auto; padding-bottom: 20px;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
  background: var(--primary-gradient); color: #fff;
  padding: 40px 16px 16px; border-radius: 0 0 16px 16px; box-shadow: 0 4px 12px rgba(0,0,0,.1); margin-bottom: 12px;
}
.status-bar { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.header-title-row { display: flex; justify-content: space-between; align-items: center; }
.header-title { font-size: 20px; font-weight: 600; }
.header-sub { font-size: 12px; opacity: 0.85; margin-top: 2px; }
.header-btn { background: rgba(255,255,255,0.92); color: var(--primary); padding: 6px 12px; border-radius: 14px; font-size: 11px; font-weight: 600; cursor: pointer; }
.header-chip { background: rgba(255,255,255,0.22); padding: 6px 12px; border-radius: 14px; font-size: 11px; display: flex; align-items: center; gap: 4px; cursor: pointer; }

/* Section */
.section { padding: 16px; }
.section-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.section-title .more { font-size: 11px; color: var(--primary-light); font-weight: 500; cursor: pointer; }

/* Grid */
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.grid-item-wrap { position: relative; }
.grid-item { background: #fff; border-radius: 12px; padding: 12px 4px; text-align: center; border: 1px solid var(--card-border); cursor: pointer; transition: transform 0.2s; }
.grid-item:active { transform: scale(0.95); }
.grid-icon { font-size: 22px; }
.grid-label { font-size: 10px; font-weight: 600; margin-top: 4px; color: var(--text); }
.grid-badge { position: absolute; top: -4px; right: -4px; background: #EF4444; color: #fff; font-size: 8px; width: 14px; height: 14px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }

/* List Card */
.list-card { background: #fff; border: 1px solid var(--card-border); border-radius: 12px; margin-bottom: 8px; overflow: hidden; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid #F3F4F6; cursor: pointer; }
.list-item:last-child { border-bottom: none; }
.list-item:active { background: #F9FAFB; }
.list-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.list-info { flex: 1; min-width: 0; }
.list-name { font-size: 13px; font-weight: 600; color: var(--text); }
.list-desc { font-size: 10px; color: var(--text-secondary); margin-top: 2px; }
.list-arrow { color: var(--text-tertiary); font-size: 16px; }

/* Data Card */
.data-card { border-radius: 14px; padding: 14px; color: #fff; margin: 0 16px 12px; }
.data-card.green { background: var(--primary-gradient); }
.data-card.blue { background: linear-gradient(135deg, #3B82F6 0%, #60A5FA 100%); }
.data-card.purple { background: var(--ai-gradient); }
.data-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.data-title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.live-tag { background: rgba(255,255,255,0.25); padding: 2px 6px; border-radius: 4px; font-size: 9px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.pulse-dot { width: 5px; height: 5px; background: #FFD700; border-radius: 50%; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.data-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 10px; }
.data-stat { background: rgba(255,255,255,0.18); border-radius: 8px; padding: 10px 6px; text-align: center; }
.data-stat-num { font-size: 20px; font-weight: 700; }
.data-stat-label { font-size: 10px; opacity: 0.9; margin-top: 2px; }
.data-stat-delta { font-size: 9px; margin-top: 2px; opacity: 0.95; }
.mini-bars { display: grid; grid-template-columns: repeat(24,1fr); gap: 2px; height: 28px; align-items: end; margin-top: 6px; }
.mini-bar { background: rgba(255,255,255,0.4); border-radius: 2px; min-height: 3px; }
.mini-bar.peak { background: #FFD700; }
.mini-bar.high { background: rgba(255,215,0,0.7); }

/* Tab Bar */
.tab-bar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 420px; background: #fff; border-top: 1px solid var(--card-border); display: flex; padding: 8px 16px 16px; gap: 4px; z-index: 50; }
.tab { flex: 1; text-align: center; padding: 8px 0; border-radius: 26px; cursor: pointer; }
.tab.active { background: var(--primary-light); }
.tab-icon { font-size: 18px; }
.tab-label { font-size: 10px; color: var(--text-tertiary); font-weight: 500; margin-top: 2px; }
.tab.active .tab-label { color: #fff; font-weight: 600; }

/* FAB AI */
.fab-ai { position: fixed; right: 20px; bottom: 100px; width: 60px; height: 60px; background: var(--ai-gradient); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 28px; box-shadow: 0 4px 20px rgba(124,58,237,0.5); cursor: pointer; z-index: 100; border: 3px solid #fff; animation: fab-glow 2s ease-in-out infinite; }
@keyframes fab-glow { 0%,100% { box-shadow: 0 4px 20px rgba(124,58,237,0.5); transform: scale(1); } 50% { box-shadow: 0 4px 30px rgba(124,58,237,0.8); transform: scale(1.05); } }
.fab-badge { position: absolute; top: -4px; right: -4px; background: #EF4444; color: #fff; font-size: 10px; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; border: 2px solid #fff; }

.overlay-mask { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 150; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.overlay-mask.show { opacity: 1; pointer-events: auto; }

/* AI Panel */
.ai-panel { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%) translateY(100%); width: 100%; max-width: 420px; height: 92vh; background: #FAFAFA; border-radius: 20px 20px 0 0; box-shadow: 0 -8px 40px rgba(0,0,0,0.18); z-index: 200; display: flex; flex-direction: column; transition: transform 0.35s cubic-bezier(0.32,0.72,0,1); }
.ai-panel.show { transform: translateX(-50%) translateY(0); }
.ai-panel-header { background: #fff; border-bottom: 1px solid #F3F4F6; padding: 14px 16px; display: flex; align-items: center; gap: 10px; }
.ai-avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, #00A870 0%, #00664E 100%); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.ai-header-info { flex: 1; min-width: 0; }
.ai-panel-title { font-size: 16px; font-weight: 600; color: #1A1F36; }
.ai-panel-sub { font-size: 11px; color: #9CA3AF; margin-top: 2px; }
.ai-panel-close { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; color: #6B7280; cursor: pointer; }
.ai-panel-close:active { background: #F3F4F6; }

.ai-panel-body { flex: 1; overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; scroll-behavior: smooth; }

.ai-welcome { text-align: center; padding: 24px 10px 18px; }
.ai-welcome-title { font-size: 16px; font-weight: 600; color: #1A1F36; margin-bottom: 8px; }
.ai-welcome-desc { font-size: 12px; color: #6B7280; line-height: 1.6; }

.ai-quick-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 0 4px 8px; }
.ai-chip { padding: 8px 12px; background: #fff; border: 1px solid #E8ECF0; border-radius: 16px; font-size: 12px; color: #1A1F36; cursor: pointer; transition: all 0.15s; }
.ai-chip:active { background: #E6F7F0; border-color: #00A870; transform: scale(0.96); }

.chat-msg { display: flex; margin-bottom: 14px; animation: msg-in 0.25s ease-out; }
@keyframes msg-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.chat-msg-user { justify-content: flex-end; }
.chat-msg-ai { justify-content: flex-start; align-items: flex-start; gap: 8px; }

.chat-avatar-ai { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, #00A870 0%, #00664E 100%); display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; margin-top: 2px; }
.chat-bubble-user { background: #00664E; color: #fff; padding: 10px 14px; border-radius: 18px 18px 4px 18px; font-size: 14px; line-height: 1.5; max-width: 80%; word-break: break-word; }
.chat-bubble-ai { background: #fff; border: 1px solid #E8ECF0; padding: 12px 14px; border-radius: 16px 16px 16px 4px; font-size: 14px; line-height: 1.6; color: #1A1F36; max-width: 85%; word-break: break-word; box-shadow: 0 1px 2px rgba(0,0,0,0.03); }
.chat-bubble-ai a { color: #00A870; }

.ai-panel-input { background: #fff; border-top: 1px solid #F3F4F6; padding: 10px 14px 14px; display: flex; align-items: center; gap: 10px; }
.ai-input-wrap { flex: 1; display: flex; align-items: center; background: #F3F4F6; border-radius: 24px; padding: 4px 4px 4px 16px; }
.ai-input-wrap input { flex: 1; border: none; background: transparent; font-size: 14px; outline: none; padding: 8px 0; color: #1A1F36; }
.ai-input-wrap input::placeholder { color: #9CA3AF; }
.ai-mic-btn { width: 36px; height: 36px; border-radius: 50%; border: none; background: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,0.08); user-select: none; -webkit-user-select: none; }
.ai-mic-btn:active { background: #E6F7F0; transform: scale(0.95); }
.ai-send-btn { background: #00664E; color: #fff; border: none; border-radius: 22px; padding: 10px 18px; font-size: 14px; font-weight: 600; cursor: pointer; }
.ai-send-btn:active { background: #005240; }
.ai-input-tip { text-align: center; font-size: 10px; color: #9CA3AF; padding-bottom: 8px; background: #fff; }

/* Voice Overlay */
.voice-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 1000; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.voice-overlay.show { opacity: 1; pointer-events: auto; }
.voice-overlay-box { background: #1A1F36; color: #fff; border-radius: 20px; padding: 32px 40px; text-align: center; min-width: 220px; }
.voice-wave { display: flex; align-items: center; justify-content: center; gap: 5px; height: 50px; margin-bottom: 16px; }
.voice-wave span { width: 5px; height: 12px; background: #00A870; border-radius: 3px; animation: voice-bar 1s ease-in-out infinite; }
.voice-wave span:nth-child(1) { animation-delay: 0s; }
.voice-wave span:nth-child(2) { animation-delay: 0.1s; }
.voice-wave span:nth-child(3) { animation-delay: 0.2s; }
.voice-wave span:nth-child(4) { animation-delay: 0.3s; }
.voice-wave span:nth-child(5) { animation-delay: 0.4s; }
.voice-wave.active span { animation-play-state: running; }
.voice-wave:not(.active) span { animation-play-state: paused; }
@keyframes voice-bar { 0%,100% { height: 12px; } 50% { height: 36px; } }
.voice-overlay-text { font-size: 16px; font-weight: 600; margin-bottom: 8px; min-height: 24px; }
.voice-overlay-hint { font-size: 12px; color: #9CA3AF; }

/* Loading */
.loading { text-align: center; padding: 20px; color: var(--text-tertiary); font-size: 12px; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid #E8ECF0; border-top-color: var(--primary-light); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); background: rgba(26,31,54,0.9); color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 13px; z-index: 9999; opacity: 0; transition: opacity 0.3s; }
.toast.show { opacity: 1; }
