/* ========================================
   便利店系统 - 主样式文件
   简洁大气 · 响应式设计
   ======================================== */

/* CSS 变量 */
:root {
    --primary: #2ECC71;
    --primary-dark: #27ae60;
    --primary-light: #a8e6c1;
    --accent: #F39C12;
    --accent-dark: #e67e22;
    --danger: #e74c3c;
    --text: #2C3E50;
    --text-light: #7f8c8d;
    --text-lighter: #bdc3c7;
    --bg: #f5f7fa;
    --bg-card: #ffffff;
    --border: #e8ecf1;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-hover: 0 6px 20px rgba(0,0,0,0.1);
    --radius: 10px;
    --radius-sm: 6px;
    --transition: all 0.3s ease;
    --max-width: 1200px;
    --header-height: 70px;
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; }
table { width: 100%; border-collapse: collapse; }

/* ======== Header ======== */
.site-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height);
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
}

.logo span { color: var(--primary); }

.header-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-nav a {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.header-nav a:hover,
.header-nav a.active {
    background: var(--primary);
    color: #fff;
}

.cart-btn {
    position: relative;
    padding: 8px 16px !important;
    background: var(--bg) !important;
}

.cart-btn:hover { background: var(--primary-light) !important; color: var(--primary-dark) !important; }

.cart-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}
.cart-count.show { display: flex; }

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    color: var(--text);
}

/* ======== Hero 横幅 ======== */
.hero {
    background: linear-gradient(135deg, #2ECC71 0%, #27ae60 50%, #1a8a4a 100%);
    padding: 50px 20px;
    text-align: center;
    color: #fff;
}

.hero h1 {
    font-size: 32px;
    margin-bottom: 10px;
    font-weight: 700;
}

.hero p {
    font-size: 16px;
    opacity: 0.9;
    max-width: 500px;
    margin: 0 auto;
}

/* ======== 搜索栏 ======== */
.search-bar {
    max-width: 600px;
    margin: -24px auto 20px;
    padding: 0 20px;
    position: relative;
    z-index: 10;
}

.search-bar form {
    display: flex;
    gap: 0;
    background: #fff;
    border-radius: 30px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
}

.search-bar input {
    flex: 1;
    border: none;
    padding: 14px 24px;
    font-size: 15px;
    outline: none;
}

.search-bar button {
    padding: 14px 28px;
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: var(--transition);
}

.search-bar button:hover { background: var(--primary-dark); }

/* ======== 分类导航 ======== */
.categories {
    max-width: var(--max-width);
    margin: 0 auto 20px;
    padding: 0 20px;
}

.category-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 5px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.category-list::-webkit-scrollbar { display: none; }

.category-list a {
    padding: 8px 20px;
    border-radius: 20px;
    background: #fff;
    color: var(--text);
    font-size: 14px;
    white-space: nowrap;
    border: 1px solid var(--border);
    transition: var(--transition);
    flex-shrink: 0;
}

.category-list a:hover,
.category-list a.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ======== 商品网格 ======== */
.main-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px 40px;
    flex: 1;
    width: 100%;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-title span { color: var(--primary); }

.product-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* 商品卡片 */
.product-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-3px);
}

.product-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: #f0f0f0;
}

.product-img-placeholder {
    width: 100%;
    aspect-ratio: 1;
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: var(--primary);
}

.product-info {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
    line-height: 1.4;
}

.product-desc {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 12px;
    line-height: 1.5;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.product-price {
    font-size: 22px;
    font-weight: 700;
    color: var(--danger);
}

.product-price .symbol {
    font-size: 14px;
}

.product-stock {
    font-size: 12px;
    color: var(--text-light);
}

.add-cart-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.add-cart-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

/* ======== 购物车侧栏 ======== */
.cart-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    animation: fadeIn 0.2s ease;
}

.cart-overlay.open { display: block; }

.cart-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    height: 100%;
    background: #fff;
    z-index: 201;
    box-shadow: -4px 0 20px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.cart-sidebar.open { right: 0; }

.cart-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-header h3 { font-size: 18px; }

.cart-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 15px 20px;
}

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

.cart-empty-icon { font-size: 48px; margin-bottom: 10px; opacity: 0.5; }

.cart-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.cart-item-img {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    object-fit: cover;
    background: #f0f0f0;
}

.cart-item-info { flex: 1; }

.cart-item-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
}

.cart-item-price { font-size: 14px; color: var(--danger); font-weight: 600; }

.cart-item-qty {
    display: flex;
    align-items: center;
    gap: 6px;
}

.qty-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.qty-btn:hover { border-color: var(--primary); color: var(--primary); }

.qty-num { font-size: 14px; font-weight: 600; min-width: 20px; text-align: center; }

.cart-item-remove {
    color: var(--text-lighter);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
    transition: var(--transition);
}

.cart-item-remove:hover { color: var(--danger); }

.cart-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
    background: #fafafa;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.cart-total-label { font-size: 14px; color: var(--text-light); }

.cart-total-price {
    font-size: 24px;
    font-weight: 700;
    color: var(--danger);
}

.checkout-btn {
    display: block;
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.checkout-btn:hover { background: var(--primary-dark); }

.checkout-btn:disabled {
    background: var(--text-lighter);
    cursor: not-allowed;
}

/* ======== 下单页面 ======== */
.order-page {
    max-width: 800px;
    margin: 30px auto;
    padding: 0 20px;
}

.order-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 30px;
    margin-bottom: 20px;
}

.order-card h2 {
    font-size: 20px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.order-items-summary {
    margin-bottom: 25px;
}

.order-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5;
    font-size: 14px;
}

.order-item-row:last-child { border-bottom: none; }

.order-total-row {
    display: flex;
    justify-content: space-between;
    padding: 15px 0 0;
    font-size: 18px;
    font-weight: 700;
    border-top: 2px solid var(--border);
    margin-top: 5px;
}

.order-total-row .price { color: var(--danger); }

.form-section { margin-bottom: 22px; }

.form-section label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-section label .required { color: var(--danger); margin-left: 2px; }

.form-section input,
.form-section textarea,
.form-section select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
    outline: none;
    font-family: inherit;
}

.form-section input:focus,
.form-section textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(46,204,113,0.1);
}

.form-section textarea {
    min-height: 80px;
    resize: vertical;
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.submit-order-btn {
    display: block;
    width: 100%;
    padding: 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.submit-order-btn:hover { background: var(--primary-dark); }

.submit-order-btn:disabled {
    background: var(--text-lighter);
    cursor: not-allowed;
}

/* ======== 订单查询 ======== */
.query-page {
    max-width: 800px;
    margin: 50px auto;
    padding: 0 20px;
}

.query-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px;
    text-align: center;
}

.query-card h2 { margin-bottom: 10px; }

.query-card p { color: var(--text-light); margin-bottom: 25px; }

.query-form {
    display: flex;
    gap: 10px;
    max-width: 450px;
    margin: 0 auto;
}

.query-form input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    outline: none;
    transition: var(--transition);
}

.query-form input:focus { border-color: var(--primary); }

.query-form button {
    padding: 12px 24px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.query-form button:hover { background: var(--primary-dark); }

/* 订单列表查询结果 */
.order-list {
    margin-top: 30px;
    text-align: left;
}

.order-card-item {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 15px;
    transition: var(--transition);
}

.order-card-item:hover { box-shadow: var(--shadow-hover); }

.order-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.order-no { font-weight: 700; font-size: 15px; }

.order-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-pending { background: #fff3cd; color: #856404; }
.status-paid { background: #d4edda; color: #155724; }
.status-shipped { background: #cce5ff; color: #004085; }
.status-completed { background: #d1e7dd; color: #0f5132; }
.status-cancelled { background: #fdf0ef; color: #e74c3c; }

.order-card-body { font-size: 14px; color: var(--text-light); }
.order-card-body .info-row { display: flex; gap: 20px; margin-bottom: 4px; }

.order-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.order-amount { font-size: 18px; font-weight: 700; color: var(--danger); }

.order-detail-link {
    padding: 6px 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text);
    transition: var(--transition);
}

.order-detail-link:hover { background: var(--primary); color: #fff; }

/* ======== 订单详情 ======== */
.order-detail {
    max-width: 700px;
    margin: 30px auto;
    padding: 0 20px;
}

.order-detail-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 30px;
}

.order-detail-card h2 { margin-bottom: 20px; }

.order-info-table { width: 100%; }

.order-info-table td {
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5;
    font-size: 14px;
}

.order-info-table td:first-child {
    color: var(--text-light);
    width: 100px;
}

/* ======== 页脚 ======== */
.site-footer {
    background: #2C3E50;
    color: rgba(255,255,255,0.7);
    padding: 30px 20px;
    text-align: center;
    margin-top: auto;
}

.site-footer .footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
}

.site-footer p { font-size: 13px; margin: 3px 0; }
.site-footer .store-name { font-size: 16px; font-weight: 600; color: #fff; margin-bottom: 8px; }

/* ======== 分页 ======== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 30px;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text);
    font-size: 14px;
    transition: var(--transition);
}

.page-btn:hover,
.page-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.page-dots {
    display: inline-flex;
    align-items: center;
    padding: 0 6px;
    color: var(--text-light);
}

/* ======== Toast 通知 ======== */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.toast-success { background: #2ECC71; }
.toast-error { background: #e74c3c; }
.toast-info { background: #3498db; }

/* ======== Loading ======== */
.loading {
    display: none;
    text-align: center;
    padding: 40px;
}

.loading.show { display: block; }

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ======== Animations ======== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ======== 响应式设计 ======== */

/* 平板 */
@media (max-width: 992px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 手机 */
@media (max-width: 768px) {
    :root {
        --header-height: 60px;
    }

    .header-inner { padding: 0 15px; }
    .logo { font-size: 18px; }
    .logo-icon { width: 30px; height: 30px; font-size: 14px; }
    .header-nav a { padding: 6px 12px; font-size: 13px; }
    .header-nav a span { display: none; }

    .mobile-menu-btn { display: block; }

    .hero { padding: 30px 15px; }
    .hero h1 { font-size: 24px; }
    .hero p { font-size: 14px; }

    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .product-info { padding: 12px; }
    .product-name { font-size: 14px; }
    .product-price { font-size: 18px; }
    .product-desc { display: none; }
    .product-bottom { padding-top: 8px; }
    .add-cart-btn { width: 30px; height: 30px; font-size: 14px; }

    .cart-sidebar {
        width: 100%;
        right: -100%;
    }

    .order-page { margin: 15px auto; }
    .order-card { padding: 20px; }
    .form-row-2 { grid-template-columns: 1fr; }

    .query-card { padding: 25px; }
    .query-form { flex-direction: column; }

    .order-card-header { flex-direction: column; gap: 8px; align-items: flex-start; }
    .order-card-body .info-row { flex-direction: column; gap: 4px; }

    .search-bar { margin-top: -20px; }
    .search-bar input { padding: 12px 16px; font-size: 14px; }
    .search-bar button { padding: 12px 18px; font-size: 14px; }

    .main-content { padding: 0 12px 30px; }
    .section-title { font-size: 17px; }
}

/* 小手机 */
@media (max-width: 380px) {
    .product-grid { gap: 8px; }
    .product-info { padding: 8px; }
    .product-name { font-size: 12px; }
    .product-price { font-size: 15px; }
    .add-cart-btn { width: 26px; height: 26px; font-size: 12px; }
    .product-stock { font-size: 10px; }
}
