* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4CAF50;
    --secondary-color: #2196F3;
    --danger-color: #f44336;
    --warning-color: #ff9800;
    --text-dark: #333;
    --text-light: #666;
    --bg-light: #f5f5f5;
    --white: #ffffff;
    --border-color: #ddd;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-dark);
}

.container {
    max-width: 1000px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: var(--white);
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

.add-form {
    background: var(--white);
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.add-form h2 {
    margin-bottom: 20px;
    color: var(--text-dark);
    font-size: 1.5rem;
}

.form-group {
    margin-bottom: 15px;
    flex: 1;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-dark);
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

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

.btn-primary:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* 表单中的提交按钮占满宽度 */
form .btn-primary {
    width: 100%;
}

.btn-secondary {
    background: var(--secondary-color);
    color: var(--white);
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-secondary:hover {
    background: #1976D2;
}

.btn-danger {
    background: var(--danger-color);
    color: var(--white);
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-danger:hover {
    background: #da190b;
}

.filter-bar {
    background: var(--white);
    padding: 15px 25px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-group label {
    font-weight: 500;
    color: var(--text-dark);
}

.filter-group select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--white);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
    border-left: 4px solid var(--primary-color);
}

.stat-card.warning {
    border-left-color: var(--warning-color);
}

.stat-card.danger {
    border-left-color: var(--danger-color);
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-dark);
    margin-bottom: 5px;
}

.stat-label {
    color: var(--text-light);
    font-size: 0.9rem;
}

.food-list {
    background: var(--white);
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.food-list h2 {
    margin-bottom: 20px;
    color: var(--text-dark);
    font-size: 1.5rem;
}

.items-container {
    display: grid;
    gap: 20px;
}

/* 新的卡片样式 */
.food-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.food-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    transform: translateY(-2px);
}

.food-card.expired {
    border-color: #f44336;
    background: #fff5f5;
}

.food-card.expiring-soon {
    border-color: #ff9800;
    background: #fffbf5;
}

.food-card.fresh {
    border-color: #4CAF50;
}

.food-card-header {
    padding: 20px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.food-card.expired .food-card-header {
    background: linear-gradient(135deg, #fee 0%, #fcc 100%);
}

.food-card.expiring-soon .food-card-header {
    background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%);
}

.food-card.fresh .food-card-header {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
}

.food-title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.food-icon {
    font-size: 2rem;
    line-height: 1;
}

.food-name {
    font-size: 1.3rem;
    font-weight: 600;
    color: #333;
}

.food-category-tag {
    font-size: 0.85rem;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    color: #666;
    font-weight: 500;
}

.food-total {
    display: flex;
    align-items: center;
    gap: 12px;
}

.total-quantity {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 14px;
    border-radius: 20px;
}

.status-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.fresh {
    background: #4CAF50;
    color: white;
}

.status-badge.expiring {
    background: #ff9800;
    color: white;
}

.status-badge.expired {
    background: #f44336;
    color: white;
}

.food-batches {
    padding: 15px 20px 20px;
}

.batch-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid #ddd;
    transition: all 0.2s ease;
}

.batch-item:hover {
    background: #e9ecef;
    border-left-color: #667eea;
}

.batch-item:last-child {
    margin-bottom: 0;
}

.batch-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    flex-wrap: wrap;
}

.batch-expiry {
    font-size: 0.95rem;
    color: #555;
    display: flex;
    align-items: center;
    gap: 8px;
}

.batch-quantity {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    background: white;
    padding: 4px 12px;
    border-radius: 15px;
}

.expiry-date {
    color: #666;
    font-weight: 500;
}

.expiry-warning {
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}

.expiry-warning.expiring {
    background: #fff3cd;
    color: #856404;
}

.expiry-warning.expired {
    background: #f8d7da;
    color: #721c24;
}

.batch-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border: none;
    background: white;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}

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

.btn-icon.btn-delete:hover {
    background: #fee;
}

/* 旧样式保留（可能view-app还在用） */
.food-item {
    background: var(--bg-light);
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    transition: all 0.3s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.food-item:hover {
    box-shadow: var(--shadow-hover);
    transform: translateX(5px);
}

.food-item.expiring-soon {
    border-left-color: var(--warning-color);
    background: #fff3cd;
}

.food-item.expired {
    border-left-color: var(--danger-color);
    background: #f8d7da;
}

.food-info {
    flex: 1;
}

.food-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.food-category {
    font-size: 0.85rem;
    padding: 3px 8px;
    background: var(--white);
    border-radius: 12px;
    color: var(--text-light);
}

.food-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-light);
}

.food-detail {
    display: flex;
    align-items: center;
    gap: 5px;
}

.food-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.food-actions .btn {
    padding: 8px 16px;
    font-size: 0.9rem;
    white-space: nowrap;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
    font-size: 1.1rem;
}

.empty-state p {
    margin: 0;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

.loading::after {
    content: '加载中...';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: '加载中'; }
    40% { content: '加载中.'; }
    60% { content: '加载中..'; }
    80%, 100% { content: '加载中...'; }
}

/* 响应式设计 */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 2rem;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .filter-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .food-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .food-actions {
        width: 100%;
    }

    .btn-danger {
        width: 100%;
    }
}

/* 动画 */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.food-item {
    animation: slideIn 0.3s ease-out;
}
