/**
 * 多多客导购站主题样式
 * 支持PC端和H5移动端自动识别
 */

/* ===== CSS Variables ===== */
:root {
    --primary: #E24E26;
    --primary-dark: #C43D1A;
    --primary-light: #FF6B35;
    --success: #4CAF50;
    --warning: #FF9800;
    --danger: #F44336;
    --text: #333;
    --text-light: #666;
    --text-muted: #999;
    --bg: #f5f5f5;
    --white: #fff;
    --border: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --radius: 8px;
    --radius-sm: 4px;
}

/* ===== Reset ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    padding-bottom: 60px;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }

/* ===== Container ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* ===== Header ===== */
.site-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    gap: 10px;
}

.logo a { color: #fff; text-decoration: none; }
.logo-text { font-size: 20px; font-weight: bold; }
.logo img { height: 30px; }

/* ===== Desktop Header ===== */
.desktop-header {
    background: var(--white);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.desktop-header .header-inner {
    height: 60px;
    padding: 0;
}

.desktop-header .logo { flex: 0 0 150px; }

.desktop-header .main-nav ul {
    display: flex;
    list-style: none;
    gap: 30px;
}

.desktop-header .main-nav a {
    color: var(--text);
    font-size: 15px;
    padding: 5px 0;
    position: relative;
}

.desktop-header .main-nav a.active,
.desktop-header .main-nav a:hover {
    color: var(--primary);
}

.desktop-header .header-search {
    flex: 1;
    max-width: 400px;
    margin: 0 20px;
}

.desktop-header .header-search form {
    display: flex;
}

.desktop-header .header-search input {
    flex: 1;
    padding: 8px 15px;
    border: 1px solid var(--border);
    border-radius: 20px 0 0 20px;
    outline: none;
}

.desktop-header .header-search button {
    padding: 8px 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 0 20px 20px 0;
    cursor: pointer;
}

.desktop-header .header-user .login-link {
    color: var(--text);
    font-size: 14px;
}

/* ===== Search Section ===== */
.search-section { background: var(--primary); padding: 15px; }
.search-form { display: flex; gap: 10px; }
.search-input { 
    flex: 1; padding: 10px 15px; border: none; border-radius: 20px; 
    font-size: 14px; outline: none; 
}
.search-btn { 
    padding: 10px 20px; background: var(--primary-dark); color: #fff; 
    border: none; border-radius: 20px; cursor: pointer; 
}

/* ===== Banner ===== */
.banner-section { margin: 10px; }
.banner-slider { border-radius: var(--radius); overflow: hidden; }
.banner-slider img { width: 100%; display: block; }

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

.banner-sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-item {
    background: var(--white);
    padding: 15px;
    border-radius: var(--radius);
    text-align: center;
}

.sidebar-item h3 { font-size: 16px; margin-bottom: 5px; }
.sidebar-item p { font-size: 12px; color: var(--text-muted); }

/* ===== Quick Entry ===== */
.quick-entry { margin: 10px; background: var(--white); border-radius: var(--radius); padding: 15px; }
.entry-grid { display: grid; gap: 10px; }

.desktop-entry .entry-grid { grid-template-columns: repeat(8, 1fr); }

.mobile-entry .entry-grid { grid-template-columns: repeat(5, 1fr); }

.entry-item { 
    display: flex; flex-direction: column; align-items: center; 
    text-decoration: none; color: var(--text); padding: 10px;
}
.entry-icon { 
    width: 40px; height: 40px; 
    background: linear-gradient(135deg, #FFF3E0, #FFECB3); 
    border-radius: 10px; 
    display: flex; align-items: center; justify-content: center; 
    font-size: 14px; font-weight: bold; color: var(--primary); 
    margin-bottom: 5px;
}
.entry-label { font-size: 12px; }

/* ===== Section ===== */
.section { margin: 15px 10px; background: var(--white); border-radius: var(--radius); }
.section-header { 
    padding: 15px; border-bottom: 1px solid var(--border); 
    display: flex; justify-content: space-between; align-items: center; 
}
.section-title { font-size: 16px; font-weight: bold; }
.section-more { font-size: 12px; color: var(--text-muted); }

/* ===== Goods List ===== */
.goods-list { padding: 10px; display: grid; gap: 10px; }

/* 移动端双列 */
.goods-list {
    grid-template-columns: repeat(2, 1fr);
}

/* PC端四列 */
.goods-list-pc {
    grid-template-columns: repeat(4, 1fr);
}

.goods-card { 
    background: var(--white); border-radius: var(--radius); 
    overflow: hidden; box-shadow: var(--shadow); 
    cursor: pointer; transition: transform 0.2s;
}
.goods-card:hover { transform: translateY(-3px); }

.goods-img { 
    position: relative; aspect-ratio: 1; background: #f0f0f0; 
}
.goods-img img { width: 100%; height: 100%; object-fit: cover; }

.coupon-tag { 
    position: absolute; bottom: 0; left: 0; 
    background: var(--primary); color: #fff; 
    font-size: 10px; padding: 2px 6px; 
    border-radius: 0 var(--radius-sm) 0 0; 
}

.goods-info { padding: 10px; }

.goods-title { 
    font-size: 13px; line-height: 1.4; height: 36px; overflow: hidden; 
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; 
}

.goods-tags { margin: 5px 0; }
.tag-commission { 
    background: #E8F5E9; color: var(--success); 
    font-size: 10px; padding: 2px 5px; border-radius: 3px; 
}

.goods-price { margin-top: 8px; display: flex; align-items: baseline; gap: 5px; }
.price-current { color: var(--primary); font-size: 18px; font-weight: bold; }
.price-original { color: var(--text-muted); font-size: 12px; text-decoration: line-through; }

.goods-bottom { 
    margin-top: 8px; display: flex; justify-content: space-between; 
    font-size: 11px; 
}
.commission { color: var(--primary); font-weight: 500; }
.sales { color: var(--text-muted); }

.btn-buy {
    width: 100%; margin-top: 10px; padding: 8px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff; border: none; border-radius: var(--radius-sm);
    font-size: 13px; cursor: pointer;
}

.btn-buy-mobile {
    width: 100%; margin-top: 8px; padding: 8px;
    background: var(--primary); color: #fff; border: none;
    border-radius: 15px; font-size: 12px; cursor: pointer;
}

/* ===== Category Tabs ===== */
.category-tabs {
    display: flex; gap: 8px; padding: 12px 10px; background: var(--white);
    overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.category-tabs::-webkit-scrollbar { display: none; }

.category-tabs a {
    flex-shrink: 0; padding: 8px 16px; background: var(--bg);
    border-radius: 20px; font-size: 13px; white-space: nowrap;
    transition: all 0.2s;
}
.category-tabs a.active { background: var(--primary); color: #fff; }

/* ===== Category Grid ===== */
.category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 15px;
}
.category-item {
    display: flex; flex-direction: column; align-items: center;
    padding: 15px; background: var(--bg); border-radius: var(--radius);
    text-decoration: none;
}
.cat-icon { font-size: 24px; margin-bottom: 8px; }
.cat-name { font-size: 13px; }

/* ===== Ranking ===== */
.ranking-list { padding: 10px; }
.ranking-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px; border-bottom: 1px solid var(--border);
}
.ranking-item:last-child { border-bottom: none; }

.ranking-num {
    width: 24px; height: 24px; background: var(--bg);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: bold; color: var(--text-muted);
}
.ranking-num.top { background: #FFD700; color: #B8860B; }

.ranking-img { width: 50px; height: 50px; border-radius: var(--radius-sm); object-fit: cover; }
.ranking-info { flex: 1; min-width: 0; }
.ranking-title { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-price { font-size: 14px; font-weight: bold; color: var(--primary); }
.ranking-sales { font-size: 11px; color: var(--text-muted); }

/* ===== Tab Bar (Mobile) ===== */
.tab-bar {
    position: fixed; bottom: 0; left: 0; right: 0; background: var(--white);
    display: flex; border-top: 1px solid var(--border); z-index: 100;
}
.tab-item { 
    flex: 1; display: flex; flex-direction: column; align-items: center; 
    padding: 8px 0; color: var(--text-light); text-decoration: none; font-size: 11px; 
}
.tab-item.active { color: var(--primary); }
.tab-icon { font-size: 20px; }

/* ===== Modal ===== */
.modal-overlay { 
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); 
    z-index: 1000; align-items: center; justify-content: center; padding: 20px; 
}
.modal-overlay.active { display: flex; }
.modal { background: var(--white); border-radius: var(--radius); width: 100%; max-width: 400px; }

.modal-header { 
    padding: 15px; border-bottom: 1px solid var(--border); 
    display: flex; justify-content: space-between; align-items: center; 
}
.modal-header h3 { font-size: 16px; }
.modal-header button { background: none; border: none; font-size: 24px; cursor: pointer; }

.modal-body { padding: 20px; }

.promo-link-box input { 
    width: 100%; padding: 12px; border: 1px solid var(--border); 
    border-radius: var(--radius-sm); font-size: 13px; 
}

.copy-btn {
    width: 100%; margin-top: 15px; padding: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff; border: none; border-radius: var(--radius-sm);
    font-size: 15px; font-weight: 600; cursor: pointer;
}

.copy-btn-success { background: var(--success); }

.promo-tips { 
    margin-top: 15px; padding: 12px; background: #FFF3E0; 
    border-radius: var(--radius-sm); font-size: 12px; color: #E65100; 
}

/* ===== Toast ===== */
.toast { 
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); 
    background: rgba(0,0,0,0.8); color: #fff; padding: 12px 24px; 
    border-radius: 20px; font-size: 14px; z-index: 9999; 
}

/* ===== Empty ===== */
.empty-state { 
    text-align: center; padding: 50px 20px; color: var(--text-muted); 
    grid-column: 1 / -1;
}

/* ===== Responsive ===== */
@media (max-width: 767px) {
    /* 移动端样式 */
    body { padding-bottom: 60px; }
    
    .desktop-header { display: none; }
    
    .tab-bar { display: flex; }
    
    .banner-grid { grid-template-columns: 1fr; }
    
    .goods-list { grid-template-columns: repeat(2, 1fr); }
    
    .category-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 768px) {
    /* PC端样式 */
    body { padding-bottom: 0; }
    
    .tab-bar { display: none; }
    
    .site-header:not(.desktop-header) { display: none; }
    
    .section { margin: 20px 0; }
    
    .goods-list { grid-template-columns: repeat(4, 1fr); }
    
    .category-grid { grid-template-columns: repeat(8, 1fr); }
    
    .ranking-item { padding: 15px; }
    
    .ranking-img { width: 80px; height: 80px; }
}

/* ===== PC端独有样式 ===== */
.ddk-home-desktop .site-header.desktop-header { display: block; }
.ddk-home-desktop .search-section { display: none; }
.ddk-home-desktop .tab-bar { display: none; }

/* ===== 移动端独有 ===== */
body:not(.ddk-home-desktop) .desktop-header { display: none; }