/**
 * 产品溯源系统 - 全局样式
 */

/* 基础样式 */
:root {
    --primary-color: #1a365d;
    --primary-light: #2d5a87;
    --accent-color: #d69e2e;
    --text-color: #2d3748;
    --text-muted: #718096;
    --bg-color: #f7fafc;
    --border-color: #e2e8f0;
    --card-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* 布局 */
.wrapper {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 25px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h4 {
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-nav {
    list-style: none;
    padding: 20px 0;
    flex: 1;
}

.sidebar-nav li {
    margin: 5px 15px;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s;
}

.sidebar-nav li a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-nav li.active a {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 14px;
}

.logout-link {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: color 0.3s;
}

.logout-link:hover {
    color: white;
}

/* 主内容区 */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 30px;
    background: var(--bg-color);
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.content-header h1 {
    font-size: 28px;
    color: var(--primary-color);
    font-weight: 600;
}

/* 产品网格 */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.product-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: all 0.3s;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.product-image {
    aspect-ratio: 1;
    overflow: hidden;
    background: #edf2f7;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #a0aec0;
    font-size: 48px;
}

.product-info {
    padding: 15px;
}

.product-info h5 {
    font-size: 16px;
    color: var(--text-color);
    margin-bottom: 8px;
}

.batch-no, .production-date {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.product-actions {
    padding: 10px;
    display: flex;
    gap: 6px;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.product-actions .btn {
    padding: 4px 10px !important;
    font-size: 12px !important;
    border-radius: 6px !important;
    line-height: 1.4;
}

.product-actions .btn i {
    font-size: 12px;
    margin-right: 3px;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 64px;
    margin-bottom: 20px;
}

.empty-state p {
    font-size: 18px;
    margin-bottom: 20px;
}

/* 表单容器 */
.form-container {
    max-width: 900px;
}

.form-actions {
    margin-top: 30px;
    display: flex;
    gap: 15px;
}

/* 卡片样式 */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
}

.card-header {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 15px 20px;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 图片上传 */
.image-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.image-upload-area:hover, .image-upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(26, 54, 93, 0.05);
}

.upload-placeholder {
    color: var(--text-muted);
}

.upload-placeholder i {
    font-size: 48px;
    margin-bottom: 15px;
    color: #a0aec0;
}

.upload-placeholder p {
    margin-bottom: 5px;
}

.upload-placeholder small {
    font-size: 12px;
}

.image-preview {
    position: relative;
}

.image-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
}

.remove-image {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #e53e3e;
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.current-image {
    text-align: center;
}

.current-image img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
}

.no-image-placeholder {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.no-image-placeholder i {
    font-size: 48px;
    margin-bottom: 15px;
}

/* 按钮样式 */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(26, 54, 93, 0.3);
}

.btn-secondary {
    background: #718096;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: 500;
    transition: all 0.3s;
    color: white;
}

.btn-secondary:hover {
    background: #4a5568;
    color: white;
}

.btn-outline-primary {
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #38a169 0%, #48bb78 100%);
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(56, 161, 105, 0.3);
}

.btn-outline-secondary {
    border: 2px solid var(--border-color);
    color: var(--text-muted);
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-outline-secondary:hover {
    background: #edf2f7;
    color: var(--text-color);
}

.btn-outline-danger {
    border: 2px solid #e53e3e;
    color: #e53e3e;
    border-radius: 8px;
    padding: 6px 12px;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-outline-danger:hover {
    background: #e53e3e;
    color: white;
}

.btn-outline-success {
    border: 2px solid #38a169;
    color: #38a169;
    border-radius: 8px;
    padding: 6px 12px;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-outline-success:hover {
    background: #38a169;
    color: white;
}

.btn-outline-info {
    border: 2px solid #3182ce;
    color: #3182ce;
    border-radius: 8px;
    padding: 6px 12px;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-outline-info:hover {
    background: #3182ce;
    color: white;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
}

/* 表单样式 */
.form-label {
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 8px;
}

/* 输入框与下拉框统一外观（下拉框必须一起写，否则会比输入框矮一截） */
.form-control,
.form-select {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.3s;
}

.form-control {
    padding: 10px 15px;
}

/* 内边距与 .form-control 保持一致，右侧额外留出下拉箭头的位置 */
.form-select {
    padding: 10px 2.25rem 10px 15px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 54, 93, 0.1);
}

/* 搜索栏 */
.search-bar .input-group {
    max-width: 400px;
}

.search-bar .form-control {
    border-right: none;
}

.search-bar .btn-outline-secondary {
    border: 2px solid var(--border-color);
    border-left: none;
}

/* 响应式 */
@media (max-width: 992px) {
    .sidebar {
        width: 200px;
    }

    .main-content {
        margin-left: 200px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }

    .main-content {
        margin-left: 0;
    }

    .wrapper {
        flex-direction: column;
    }

    .product-grid {
        grid-template-columns: 1fr;
    }

    .content-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .form-actions {
        flex-direction: column;
    }
}