/* 通用样式 - 模拟微信小程序风格 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    /* 品牌色 - 更加沉稳的绿色 */
    --primary-color: #07c160;
    --primary-dark: #06ad56;
    --primary-light: #e8f8f0;
    
    /* 辅助色 */
    --vip-color: #d4a366;
    --vip-bg: #fff8ed;
    --danger-color: #fa5151;
    --warning-color: #ffc300;
    --info-color: #1989fa;
    
    /* 文字颜色 */
    --text-main: #333333;
    --text-regular: #666666;
    --text-secondary: #999999;
    --text-placeholder: #cccccc;
    
    /* 背景颜色 */
    --bg-color: #f7f8fa;
    --card-bg: #ffffff;
    --border-color: #ebedf0;
    
    /* 字体大小 */
    --font-xs: 10px;
    --font-sm: 12px;
    --font-md: 14px;
    --font-lg: 16px;
    --font-xl: 18px;
    --font-xxl: 24px;
    
    /* 阴影 */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Segoe UI, Arial, Roboto, 'PingFang SC', 'miui', 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    font-size: var(--font-md);
    line-height: 1.5;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--bg-color);
}

/* 顶部标题栏 */
.header {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: 44px;
    background-color: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    /* 移除底部边框，使用阴影代替，更现代 */
    box-shadow: 0 1px 0 rgba(0,0,0,0.05);
}

.header-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-main);
}

.user-level-switcher {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
}

.user-level-switcher select {
    appearance: none;
    -webkit-appearance: none;
    padding: 4px 24px 4px 12px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    font-size: 12px;
    background-color: var(--bg-color);
    color: var(--text-main);
    outline: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='16' height='16'%3E%3Cpath fill='none' d='M0 0h24v24H0z'/%3E%3Cpath d='M12 15l-4.243-4.243 1.415-1.414L12 12.172l2.828-2.829 1.415 1.414z' fill='%23999999'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 4px center;
}

/* 内容区域 */
.content {
    flex: 1;
    margin-top: 44px;
    margin-bottom: 50px;
    padding-bottom: 20px;
    /* 增加平滑滚动 */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* 底部 TabBar */
.tabbar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: 50px;
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -1px 4px rgba(0,0,0,0.02);
}

.tabbar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    height: 100%;
}

.tabbar-icon {
    font-size: 24px;
    margin-bottom: 0;
    line-height: 1;
    transition: transform 0.2s;
}

.tabbar-label {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 2px;
    font-weight: 500;
}

.tabbar-item.active .tabbar-icon {
    transform: scale(1.1);
}

.tabbar-item.active .tabbar-label {
    color: var(--primary-color);
}

.cart-badge {
    position: absolute;
    top: 4px;
    right: 25%;
    background-color: var(--danger-color);
    color: white;
    font-size: 10px;
    padding: 0 5px;
    height: 16px;
    line-height: 16px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
    display: none;
    border: 1px solid #fff;
}

.cart-badge.show {
    display: block;
}

/* Toast 提示 */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    max-width: 80%;
    text-align: center;
    line-height: 1.4;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.toast.show {
    opacity: 1;
}

/* 通用按钮 */
.btn {
    padding: 0 20px;
    height: 40px;
    line-height: 40px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:active {
    transform: scale(0.96);
    opacity: 0.9;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 2px 8px rgba(7, 193, 96, 0.3);
}

.btn-secondary {
    background-color: white;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

/* 卡片样式 */
.card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
}

/* 搜索框 */
.search-bar {
    padding: 8px 16px;
    background-color: var(--card-bg);
    position: sticky;
    top: 44px;
    z-index: 100;
}

.search-input {
    width: 100%;
    height: 36px;
    padding: 0 16px 0 36px;
    border: none;
    border-radius: 18px;
    font-size: 14px;
    background-color: var(--bg-color);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='16' height='16'%3E%3Cpath fill='none' d='M0 0h24v24H0z'/%3E%3Cpath d='M18.031 16.617l4.283 4.282-1.415 1.415-4.282-4.283A8.96 8.96 0 0 1 11 20c-4.968 0-9-4.032-9-9s4.032-9 9-9 9 4.032 9 9a8.96 8.96 0 0 1-1.969 5.617zm-2.006-.742A6.977 6.977 0 0 0 18 11c0-3.868-3.133-7-7-7-3.868 0-7 3.132-7 7 0 3.867 3.132 7 7 7a6.977 6.977 0 0 0 4.875-1.975l.15-.15z' fill='%23999999'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
}

.search-input:focus {
    outline: none;
    background-color: #fff;
    box-shadow: 0 0 0 1px var(--primary-color) inset;
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.modal.show {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background-color: var(--card-bg);
    border-radius: 16px;
    width: 85%;
    max-width: 360px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-md);
    animation: zoomIn 0.2s ease-out;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
    border: none;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s;
}

.modal-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

/* 价格标签 */
.price {
    color: var(--danger-color);
    font-weight: 600;
    font-family: 'DIN Alternate', 'Roboto', sans-serif;
}

.price::before {
    content: '¥';
    font-size: 0.8em;
    margin-right: 1px;
}

.price-vip {
    color: var(--vip-color);
}

.vip-badge {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #fce3ba 0%, #f3d098 100%);
    color: #8a6026;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
    font-weight: 600;
    line-height: 1.4;
}

/* 动画 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* 加载中 */
.loading {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 12px;
}

/* 空状态 */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* 子页面通用样式 (模拟页面跳转) */
.sub-page {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-color);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 16px rgba(0,0,0,0.1);
}

.sub-page.show {
    transform: translateX(0);
}

.sub-header {
    height: 44px;
    background-color: var(--card-bg);
    display: flex;
    align-items: center;
    padding: 0 16px;
    box-shadow: 0 1px 0 rgba(0,0,0,0.05);
    font-size: 16px;
    font-weight: 600;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.sub-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
}

.back-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 8px;
    margin-right: 4px;
    margin-left: -8px;
    color: var(--text-main);
    display: flex;
    align-items: center;
}

.back-btn::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    margin-right: 4px;
}

/* 隐藏类 */
.hidden {
    display: none !important;
}
