/* 移动优先的CSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #007AFF;
    --background-color: #F5F5F7;
    --card-background: #FFFFFF;
    --text-primary: #000000;
    --text-secondary: #6C6C70;
    --border-color: #E5E5EA;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

.app-container {
    max-width: 500px;
    margin: 0 auto;
    background-color: var(--background-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) 0;
}

/* 头部 */
.app-header {
    background-color: var(--card-background);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.9);
}

.app-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.add-button {
    width: 44px;
    height: 44px;
    border-radius: 22px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
    transition: transform 0.2s;
}

.add-button:active {
    transform: scale(0.95);
}

/* 主要内容 */
.main-content {
    flex: 1;
    padding: 16px;
}

/* 预测卡片 */
.prediction-card {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 20px;
    color: white;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
    animation: slideDown 0.3s ease;
}

.prediction-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.prediction-label {
    font-size: 16px;
    font-weight: 500;
    opacity: 0.9;
}

.prediction-badge {
    background-color: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    backdrop-filter: blur(5px);
}

.prediction-content {
    display: flex;
    gap: 24px;
}

.prediction-item {
    flex: 1;
}

.prediction-item-label {
    display: block;
    font-size: 14px;
    opacity: 0.8;
    margin-bottom: 4px;
}

.prediction-item-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
}

.prediction-footer {
    margin-top: 12px;
    font-size: 14px;
    opacity: 0.9;
    text-align: center;
}

/* 视图标签 */
.view-tabs {
    display: flex;
    background-color: var(--card-background);
    border-radius: 30px;
    padding: 4px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    border-radius: 26px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

/* 记录列表 */
.records-list {
    margin-bottom: 24px;
}

.record-item {
    background-color: var(--card-background);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    animation: fadeIn 0.3s ease;
}

.record-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.record-time {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.record-amount {
    font-size: 14px;
    color: var(--text-secondary);
}

.delete-record {
    width: 36px;
    height: 36px;
    border-radius: 18px;
    background-color: #FF3B30;
    color: white;
    border: none;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.7;
    transition: all 0.2s;
}

.delete-record:active {
    opacity: 1;
    transform: scale(1.1);
}

/* 统计部分 */
.stats-section {
    margin-bottom: 20px;
}

.stats-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 20px;
    padding: 18px 16px;
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.25);
    color: white;
    transition: transform 0.2s ease;
    animation: fadeIn 0.3s ease;
}

.stat-card:active {
    transform: scale(0.98);
}

.stat-title {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 8px;
    display: block;
}

.stat-main {
    font-size: 24px;
    font-weight: 700;
    color: white;
    margin-bottom: 4px;
    line-height: 1.2;
}

.stat-unit {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    margin-left: 2px;
    font-weight: 400;
}

.stat-detail {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

/* 底部操作栏 */
.bottom-actions {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    background-color: var(--card-background);
    border-top: 1px solid var(--border-color);
    position: sticky;
    bottom: 0;
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.9);
}

.action-btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background-color: var(--background-color);
    color: var(--text-primary);
}

.action-btn:active {
    background-color: var(--border-color);
    transform: scale(0.98);
}

#voiceBtn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

#voiceBtn.listening {
    animation: pulse 1.5s infinite;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
}

/* 语音状态提示 */
.voice-status {
    position: fixed;
    bottom: 80px;
    left: 16px;
    right: 16px;
    max-width: 400px;
    margin: 0 auto;
    z-index: 2000;
    animation: slideUp 0.3s ease;
}

.voice-status-content {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 40px;
    padding: 16px 24px;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}

.voice-icon {
    font-size: 24px;
    animation: pulse 1s infinite;
}

.voice-text {
    font-size: 16px;
    font-weight: 500;
}

.voice-hint {
    font-size: 12px;
    opacity: 0.8;
}

.voice-timer {
    font-size: 14px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
}

/* 模态框 */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.3s;
}

.modal {
    background-color: var(--card-background);
    border-radius: 28px;
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 18px;
    border: none;
    background-color: var(--background-color);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
}

#feedingForm {
    padding: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 14px;
    border: 1.5px solid var(--border-color);
    border-radius: 14px;
    font-size: 16px;
    transition: all 0.2s;
    background-color: var(--background-color);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn {
    flex: 1;
    padding: 16px;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-secondary {
    background-color: var(--background-color);
    color: var(--text-primary);
}

/* 提示消息 */
.toast {
    position: fixed;
    bottom: 30px;
    left: 20px;
    right: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 16px;
    border-radius: 14px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    z-index: 2000;
    display: none;
    animation: slideUp 0.3s;
    max-width: 400px;
    margin: 0 auto;
}

.toast.show {
    display: block;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    background-color: var(--card-background);
    border-radius: 20px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.empty-state-emoji {
    font-size: 48px;
    margin-bottom: 12px;
    display: block;
}

/* 动画 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* 语音状态框增强样式 */
.voice-status {
    position: fixed;
    bottom: 80px;
    left: 16px;
    right: 16px;
    max-width: 400px;
    margin: 0 auto;
    z-index: 2000;
    animation: slideUp 0.3s ease;
}

.voice-status-content {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 40px;
    padding: 16px 24px;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}

/* 不同状态的颜色 */
.status-recording .voice-status-content {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    animation: pulse 1.5s infinite;
}

.status-waiting .voice-status-content {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.status-processing .voice-status-content {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

.status-success .voice-status-content {
    background: linear-gradient(135deg, #00b09b, #96c93d);
}

.status-error .voice-status-content {
    background: linear-gradient(135deg, #d66d75, #e29587);
}

.voice-icon {
    font-size: 24px;
    animation: pulse 1s infinite;
}

.voice-text {
    flex: 1;
    font-size: 16px;
    font-weight: 500;
}

.voice-timer {
    font-size: 18px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
    min-width: 50px;
    text-align: center;
    transition: color 0.3s ease;
}

.voice-stop-btn {
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid white;
    color: white;
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
}

.voice-stop-btn:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.voice-stop-btn:active {
    transform: scale(0.95);
}

/* 闪烁动画 */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}