/* style.css - 内蒙古草原牛羊肉主题 (UI美化与移动端优化版) */

/* --- 主题色 & 字体 --- */
:root {
    --brand-green: #2d5016;      /* 草原深绿 (主色) - 加深 */
    --brand-green-light: #4a7c2a; /* 浅绿色 */
    --brand-brown: #8A5A44;      /* 大地棕 (辅色) */
    --brand-gold: #ECB365;       /* 尊贵金 (点缀/价格) */
    --brand-gold-light: #f4c97a; /* 浅金色 */
    --bg-light: #f8f9fa;         /* 米白背景 - 更现代 */
    --bg-white: #ffffff;         /* 纯白 */
    --text-dark: #2c3e50;        /* 深灰文字 - 更现代 */
    --text-muted: #6c757d;       /* 淡化文字 */
    --price-up: #e74c3c;         /* 涨价红 - 更鲜艳 */
    --price-down: #27ae60;       /* 降价绿 - 更鲜艳 */
    --border-light: #dee2e6;     /* 淡边框 */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 25px rgba(0,0,0,0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 全局重置与基础样式 */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, 'Hiragino Sans GB', 'WenQuanYi Micro Hei', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    margin: 0;
    background: linear-gradient(135deg, var(--bg-light) 0%, #e8f5e8 100%);
    color: var(--text-dark);
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- 头部英雄区 (现代化升级) --- */
.hero-header {
    background: linear-gradient(135deg, rgba(45, 80, 22, 0.8) 0%, rgba(138, 90, 68, 0.6) 100%), url('./bg.jpeg');
    background-size: cover;
    background-position: center 60%;
    background-attachment: fixed;
    text-align: center;
    padding: 100px 20px 80px;
    position: relative;
    overflow: hidden;
}

.hero-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at center, transparent 0%, rgba(0,0,0,0.1) 70%);
}

.hero-header h1,
.hero-header p {
    position: relative;
    z-index: 2;
    color: #ffffff;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.3);
}

.hero-header h1 {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 800;
    margin: 0 0 20px;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #fff 0%, var(--brand-gold-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-header p {
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    margin: 0;
    opacity: 0.95;
    font-weight: 300;
}

/* --- 容器与布局 (现代化卡片设计) --- */
.container {
    max-width: 1600px;
    margin: 40px auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.main-content-card {
    background: var(--bg-white);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.card-header {
    background: linear-gradient(135deg, var(--brand-green) 0%, var(--brand-green-light) 100%);
    color: white;
    padding: 25px 30px;
    border-bottom: none;
}

.card-body {
    padding: 30px;
}

h2 {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
}

.main-layout { 
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 30px;
    align-items: start;
}

.product-list-wrapper { 
    min-width: 0;
}

.wholesale-list-container {
    background: var(--bg-white);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    position: sticky;
    top: 30px;
    overflow: hidden;
}

/* --- 现代化表格样式 --- */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.table-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 30px;
    height: 100%;
    background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.9) 70%);
    pointer-events: none;
    transition: opacity var(--transition);
    opacity: 0;
    z-index: 5;
}

.table-styled {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
    font-size: 15px;
    min-width: 800px;
    background: var(--bg-white);
}

.table-styled th, 
.table-styled td {
    padding: 16px 20px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
    word-break: break-word;
    transition: var(--transition);
}

.table-styled thead th {
    background: linear-gradient(135deg, var(--brand-green) 0%, var(--brand-green-light) 100%);
    color: #fff;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 1px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.table-styled thead th:first-child {
    border-top-left-radius: 12px;
}

.table-styled thead th:last-child {
    border-top-right-radius: 12px;
}

.table-styled tbody tr {
    transition: var(--transition);
}

.table-styled tbody tr:nth-child(even) { 
    background-color: #f8f9fa; 
}

.table-styled tbody tr:hover { 
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.table-styled tbody tr:last-child td:first-child {
    border-bottom-left-radius: 12px;
}

.table-styled tbody tr:last-child td:last-child {
    border-bottom-right-radius: 12px;
}

/* --- 现代化按钮样式 --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
    min-height: 44px; /* 提升触摸友好性 */
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: var(--transition);
}

.btn:hover::before {
    left: 100%;
}

.btn:hover { 
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary { 
    background: linear-gradient(135deg, var(--brand-brown) 0%, #9d6951 100%);
}

.btn-primary:hover { 
    background: linear-gradient(135deg, #6d4532 0%, var(--brand-brown) 100%);
}

.btn-primary:disabled { 
    background: linear-gradient(135deg, #a7a7a7 0%, #999 100%);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#copy-order-btn {
    width: 100%;
    margin-top: 25px;
    padding: 16px;
    font-size: 16px;
    background: linear-gradient(135deg, var(--brand-gold) 0%, var(--brand-gold-light) 100%);
    color: var(--text-dark);
    border-radius: 12px;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
}

#copy-order-btn:hover { 
    background: linear-gradient(135deg, #d4a25a 0%, var(--brand-gold) 100%);
    color: #fff;
}

/* --- 增强的数据显示样式 --- */
.sku-cell { 
    font-family: 'SF Mono', 'Monaco', 'Consolas', 'Roboto Mono', monospace;
    font-weight: 600;
    background: rgba(45, 80, 22, 0.05);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.9em;
}

.price-cell { 
    font-weight: 700;
    font-size: 1.1em;
    color: var(--brand-brown);
}

.price-up { 
    color: var(--price-up);
    position: relative;
}

.price-up::before {
    content: '↗';
    font-size: 0.8em;
    margin-right: 4px;
}

.price-down { 
    color: var(--price-down);
    position: relative;
}

.price-down::before {
    content: '↘';
    font-size: 0.8em;
    margin-right: 4px;
}

.price-flat { 
    color: var(--text-muted);
    position: relative;
}

.price-flat::before {
    content: '→';
    font-size: 0.8em;
    margin-right: 4px;
}

.price-change-percent { 
    font-size: 0.85em;
    margin-left: 8px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255,255,255,0.8);
}

/* 库存状态标签 */
.stock-status { 
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 600;
    border: 2px solid;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stock-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 6px;
}

.stock-sufficient { 
    border-color: var(--price-down);
    background: linear-gradient(135deg, #eaf6ec 0%, #d4edda 100%);
    color: #155724;
}

.stock-sufficient::before {
    background: var(--price-down);
}

.stock-low { 
    border-color: #f0ad4e;
    background: linear-gradient(135deg, #fff4e5 0%, #ffeaa7 100%);
    color: #856404;
}

.stock-low::before {
    background: #f0ad4e;
}

.stock-out { 
    border-color: var(--price-up);
    background: linear-gradient(135deg, #fdecea 0%, #f8d7da 100%);
    color: #721c24;
}

.stock-out::before {
    background: var(--price-up);
}

.sales-volume { 
    color: var(--brand-green);
    font-weight: 600;
    padding: 4px 8px;
    background: rgba(45, 80, 22, 0.1);
    border-radius: 6px;
}

/* 表单控件优化 */
.quantity-input { 
    width: 80px;
    text-align: center;
    padding: 10px 8px;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition);
}

.quantity-input:focus {
    outline: none;
    border-color: var(--brand-green);
    box-shadow: 0 0 0 3px rgba(45, 80, 22, 0.1);
}

#wholesale-list-body .quantity-input-list { 
    width: 70px;
    padding: 8px;
    text-align: center;
    font-size: 13px;
}

.remove-item-btn { 
    color: var(--price-up);
    text-decoration: none;
    font-size: 1.4em;
    font-weight: bold;
    opacity: 0.7;
    transition: var(--transition);
    padding: 4px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
}

.remove-item-btn:hover { 
    opacity: 1;
    background: rgba(231, 76, 60, 0.1);
    transform: scale(1.1);
}

#total-price { 
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 800;
    color: var(--brand-brown);
    text-align: right;
    margin-top: 25px;
    padding: 20px 0;
    border-top: 3px solid var(--brand-gold);
    background: linear-gradient(135deg, rgba(236, 179, 101, 0.1) 0%, rgba(236, 179, 101, 0.05) 100%);
    border-radius: 8px;
    padding: 20px;
}

#order-details-for-copy { 
    position: absolute;
    left: -9999px;
    opacity: 0;
}

.footer { 
    text-align: center;
    padding: 40px 20px;
    margin-top: 60px;
    color: var(--text-muted);
    font-size: 0.9em;
    background: var(--bg-white);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(45, 80, 22, 0.3);
    border-radius: 50%;
    border-top-color: var(--brand-green);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 工具提示 */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: rgba(0,0,0,0.9);
    color: white;
    border-radius: 6px;
    font-size: 0.8em;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
    z-index: 1000;
}

.tooltip:hover::after {
    opacity: 1;
}

/**************************************
 * --- 响应式设计 (移动优先) ---
 **************************************/

/* 大屏幕优化 */
@media (min-width: 1400px) {
    .container {
        padding: 0 40px;
    }
}

/* 中等屏幕 */
@media (max-width: 1200px) {
    .main-layout { 
        grid-template-columns: 1fr;
        gap: 25px;
    }
    
    .wholesale-list-container {
        position: static;
        order: -1; /* 移动端优先显示采购清单 */
    }
    
    .hero-header {
        background-attachment: scroll;
    }
}

/* 平板优化 */
@media (max-width: 992px) {
    .container {
        margin: 20px auto;
        padding: 0 15px;
    }
    
    .card-body {
        padding: 20px;
    }
    
    .table-styled {
        min-width: 700px;
    }
}

/* 手机端全面优化 */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    
    .container {
        margin: 0;
        padding: 0 12px;
        gap: 20px;
    }
    
    .main-content-card {
        border-radius: 12px;
        margin: 0 8px;
    }
    
    .card-header,
    .card-body {
        padding: 20px 16px;
    }
    
    .hero-header { 
        padding: 60px 16px 50px;
        background-attachment: scroll;
    }
    
    /* 产品列表表格 - 保持水平滚动 */
    .product-list-wrapper .table-wrapper {
        border-radius: 8px;
        box-shadow: var(--shadow-sm);
    }
    
    .product-list-wrapper .table-wrapper::after {
        opacity: 1;
        width: 20px;
    }
    
    #product-quote-table {
        font-size: 13px;
        min-width: 600px;
    }
    
    #product-quote-table th,
    #product-quote-table td {
        padding: 12px 8px;
        font-size: 12px;
    }
    
    /* 采购清单表格 - 完全响应式 */
    .wholesale-list-container {
        border-radius: 12px;
        margin: 0 8px;
    }
    
    .wholesale-list-container .table-wrapper {
        overflow-x: visible;
        border-radius: 8px;
    }
    
    .wholesale-list-container .table-styled {
        min-width: 100%;
        font-size: 13px;
    }
    
    .wholesale-list-container .table-wrapper::after {
        display: none;
    }
    
    .wholesale-list-container th,
    .wholesale-list-container td {
        padding: 10px 6px;
    }
    
    /* 移动端按钮优化 */
    .btn {
        padding: 14px 20px;
        font-size: 14px;
        min-height: 48px; /* 更大的触摸目标 */
        border-radius: 12px;
    }
    
    #copy-order-btn {
        padding: 18px;
        font-size: 16px;
        margin-top: 20px;
    }
    
    /* 移动端表单优化 */
    .quantity-input {
        width: 60px;
        padding: 8px 4px;
        font-size: 13px;
        border-radius: 6px;
    }
    
    .quantity-input-list {
        width: 50px !important;
        padding: 6px 4px !important;
    }
    
    /* 数据标签移动端优化 */
    .sku-cell {
        font-size: 0.8em;
        padding: 4px 6px;
    }
    
    .stock-status {
        font-size: 0.7em;
        padding: 4px 8px;
    }
    
    .price-change-percent {
        font-size: 0.75em;
        padding: 1px 4px;
    }
    
    /* 总价显示优化 */
    #total-price {
        margin-top: 20px;
        padding: 16px;
        text-align: center;
    }
    
    .footer {
        margin-top: 30px;
        padding: 25px 16px;
        border-radius: 12px;
        margin-left: 8px;
        margin-right: 8px;
    }
}

/* 超小屏幕优化 */
@media (max-width: 480px) {
    .hero-header {
        padding: 40px 12px 30px;
    }
    
    .container {
        padding: 0 8px;
    }
    
    .main-content-card {
        margin: 0 4px;
        border-radius: 8px;
    }
    
    .card-header,
    .card-body {
        padding: 16px 12px;
    }
    
    #product-quote-table {
        min-width: 500px;
        font-size: 12px;
    }
    
    #product-quote-table th,
    #product-quote-table td {
        padding: 8px 4px;
    }
    
    .wholesale-list-container {
        margin: 0 4px;
    }
    
    .btn {
        font-size: 13px;
        padding: 12px 16px;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-light: #1a1a1a;
        --bg-white: #2d2d2d;
        --text-dark: #f0f0f0;
        --text-muted: #a0a0a0;
        --border-light: #404040;
    }
    
    .table-styled tbody tr:nth-child(even) {
        background-color: #383838;
    }
    
    .table-styled tbody tr:hover {
        background: linear-gradient(135deg, #404040 0%, #4a4a4a 100%);
    }
}

/* 无障碍优化 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .hero-header {
        background-attachment: scroll;
    }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
    :root {
        --brand-green: #000000;
        --brand-brown: #000000;
        --text-dark: #000000;
        --border-light: #000000;
    }
    
    .btn {
        border: 2px solid #000000;
    }
}