/* ================= 全局重置与变量 ================= */
:root {
    --primary-color: #8b1515;
    --primary-hover: #6a0d0d;
    --bg-light: #f8f9fc;
    --surface-color: #ffffff;
    --text-dark: #2c3e50;
    --text-muted: #7f8c8d;
    --border-light: #eaeaea;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-light);
    color: var(--text-dark);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* 工具类：用于替代行内样式 */
.hidden { display: none !important; }

/* ================= 前台：Header & 购物车 ================= */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h1 { margin: 0; font-size: 1.5rem; letter-spacing: 1px;}

.cart-container { position: relative; }

.cart-trigger {
    background: rgba(255,255,255,0.1);
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s ease;
}

.cart-trigger:hover { background: rgba(255,255,255,0.2); }

.cart-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 320px;
    background: var(--surface-color);
    color: var(--text-dark);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    display: none;
    z-index: 1000;
}

.cart-container:hover .cart-dropdown { display: block; }

.cart-items-list { max-height: 300px; overflow-y: auto; padding: 15px; }

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    padding: 10px 0;
    font-size: 0.9rem;
}

.cart-item-name { flex: 1; padding-right: 10px; }
.cart-item-controls { display: flex; align-items: center; gap: 8px; }
.qty-input { width: 50px; padding: 4px; text-align: center; border: 1px solid #ccc; border-radius: 4px; }
.item-price { min-width: 50px; text-align: right; font-weight: bold;}

.cart-summary { padding: 15px; border-top: 2px solid var(--border-light); font-size: 1.1rem; }
.cart-actions { padding: 0 15px 15px 15px; display: flex; gap: 10px; }

/* ================= 按钮样式 ================= */
.action-btn, .checkout-btn, .clear-btn, .admin-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.action-btn, .admin-btn { background-color: var(--primary-color); color: white; }
.action-btn:hover, .admin-btn:hover { background-color: var(--primary-hover); }
.large-btn { padding: 12px 25px; font-size: 1.1rem; }

.checkout-btn { background-color: #27ae60; color: white; flex: 2; }
.checkout-btn:hover { background-color: #219653; }
.clear-btn { background-color: transparent; border: 1px solid #ccc; color: var(--text-muted); flex: 1; }
.clear-btn:hover { background-color: #fce4e4; color: var(--primary-color); border-color: var(--primary-color); }

/* ================= 前台：主体布局 ================= */
.layout-container { display: flex; flex: 1; margin-top: 20px; gap: 30px; }

aside.sidebar {
    width: 220px; background: var(--surface-color); padding: 20px;
    border-radius: 8px; border: 1px solid var(--border-light); align-self: flex-start;
}
aside h2 { font-size: 1.2rem; margin-top: 0; border-bottom: 2px solid var(--primary-color); padding-bottom: 10px;}
#categoryList { list-style: none; padding: 0; margin: 0; }
#categoryList li { margin-bottom: 5px; }
#categoryList a {
    text-decoration: none; color: var(--text-dark); display: block; padding: 10px; border-radius: 4px; cursor: pointer; transition: background 0.2s;
}
#categoryList a:hover { background-color: #fff0f0; color: var(--primary-color); }

main.main-content { flex: 1; padding-bottom: 40px; }

.breadcrumbs { list-style: none; padding: 0; margin: 0 0 20px 0; display: flex; align-items: center; font-size: 0.95rem; color: var(--text-muted); }
.breadcrumbs li a { color: var(--primary-color); cursor: pointer; text-decoration: none; }
.breadcrumbs li a:hover { text-decoration: underline; }
.breadcrumbs .separator { margin: 0 10px; color: #ccc; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 25px; }
.product-card {
    background: var(--surface-color); border: 1px solid var(--border-light); border-radius: 8px; padding: 15px; text-align: center; transition: transform 0.2s, box-shadow 0.2s; display: flex; flex-direction: column;
}
.product-card:hover { transform: translateY(-5px); box-shadow: 0 8px 15px rgba(0,0,0,0.08); }
.product-card img { width: 100%; height: auto; border-radius: 6px; margin-bottom: 15px; cursor: pointer; object-fit: cover;}
.clickable-title { font-size: 1.1rem; margin: 0 0 10px; cursor: pointer; }
.clickable-title:hover { color: var(--primary-color); }
.price { color: var(--primary-color); font-size: 1.2rem; font-weight: bold; margin: 0 0 15px; }

.product-detail-container { display: flex; gap: 40px; background: var(--surface-color); padding: 30px; border-radius: 8px; border: 1px solid var(--border-light); }
.product-image-large img { max-width: 400px; width: 100%; border-radius: 8px; border: 1px solid var(--border-light);}
.product-info h1 { margin-top: 0; font-size: 2rem;}
.price-large { color: var(--primary-color); font-size: 2rem; font-weight: bold; margin-bottom: 15px; }
.meta { color: var(--text-muted); margin-bottom: 20px; }
.description { line-height: 1.6; margin-bottom: 30px; }

footer { background-color: var(--text-dark); color: white; text-align: center; padding: 15px 0; margin-top: auto; }

/* ================= 后台 Admin 专属样式 ================= */
.admin-body { margin: 20px; background-color: var(--surface-color); display: block; }
.admin-table { border-collapse: collapse; width: 100%; margin-bottom: 20px; }
.admin-table th, .admin-table td { border: 1px solid #ddd; padding: 8px; text-align: left; }
.admin-table th { background-color: #f2f2f2; }
.form-section { border: 1px solid #ccc; padding: 20px; margin-bottom: 30px; background: #f9f9f9; border-radius: 8px;}
.admin-input { padding: 8px; border: 1px solid #ccc; border-radius: 4px; width: 100%; max-width: 300px;}
.admin-textarea { padding: 8px; border: 1px solid #ccc; border-radius: 4px; width: 100%; max-width: 500px;}
.form-group { margin-bottom: 15px; }