/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a90d9;
    --primary-dark: #357abd;
    --secondary-color: #f5f5f5;
    --text-color: #333;
    --text-light: #666;
    --text-lighter: #999;
    --border-color: #e0e0e0;
    --bg-color: #f8f9fa;
    --white: #fff;
    --danger: #e74c3c;
    --success: #2ecc71;
    --warning: #f39c12;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --radius: 8px;
    --radius-lg: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* 应用容器 */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    padding-bottom: 70px;
}

/* 页面切换 */
.page {
    display: none;
    min-height: calc(100vh - 70px);
}

.page.active {
    display: block;
}

/* 页面头部 */
.page-header {
    background: var(--white);
    padding: 16px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-header h2 {
    font-size: 18px;
    font-weight: 600;
}

/* 底部导航 */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 6px 0;
    z-index: 1000;
    max-width: 1200px;
    margin: 0 auto;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-lighter);
    font-size: 11px;
    transition: color 0.3s;
    position: relative;
    padding: 4px 12px;
}

.nav-item svg {
    width: 22px;
    height: 22px;
    margin-bottom: 2px;
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-publish .publish-icon {
    background: var(--primary-color);
    color: var(--white);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2px;
    box-shadow: var(--shadow);
}

.nav-publish .publish-icon svg {
    width: 24px;
    height: 24px;
    margin: 0;
}

.nav-publish span {
    color: var(--text-lighter);
}

.badge {
    position: absolute;
    top: 0;
    right: 4px;
    background: var(--danger);
    color: var(--white);
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

/* 表单样式 */
.form-group {
    margin-bottom: 16px;
}

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

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--white);
    transition: border-color 0.3s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

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

/* 按钮样式 */
button {
    cursor: pointer;
    border: none;
    font-family: inherit;
}

.publish-btn,
.login-btn,
.submit-btn {
    width: 100%;
    padding: 14px;
    background: var(--primary-color);
    color: var(--white);
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 500;
    transition: background 0.3s;
}

.publish-btn:hover,
.login-btn:hover,
.submit-btn:hover {
    background: var(--primary-dark);
}

/* 图片上传 */
.image-upload-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.image-upload-btn {
    width: 80px;
    height: 80px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-lighter);
    transition: border-color 0.3s;
}

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

.image-upload-btn svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
}

.image-upload-btn span {
    font-size: 12px;
}

.image-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.image-preview-item {
    width: 80px;
    height: 80px;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-item .remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: rgba(0,0,0,0.5);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
}

.image-preview {
    width: 120px;
    height: 120px;
    border-radius: var(--radius);
    overflow: hidden;
    display: none;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview.show {
    display: block;
}

/* 弹窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideUp 0.3s ease;
}

@keyframes modalSlideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    font-size: 24px;
    color: var(--text-lighter);
    line-height: 1;
}

.modal-body {
    padding: 16px;
}

/* 区服选择器 */
.server-type-selector {
    display: flex;
    gap: 12px;
}

.server-type-option {
    flex: 1;
    padding: 12px;
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s;
}

.server-type-option.active {
    border-color: var(--primary-color);
    background: rgba(74, 144, 217, 0.1);
    color: var(--primary-color);
}

/* 词条选择器 */
.attributes-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.attribute-tag {
    padding: 6px 14px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--white);
}

.attribute-tag.selected {
    border-color: var(--primary-color);
    background: rgba(74, 144, 217, 0.1);
    color: var(--primary-color);
}

/* 商品卡片 */
.goods-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.3s;
    cursor: pointer;
}

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

.goods-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.goods-info {
    padding: 10px;
}

.goods-title {
    font-size: 14px;
    color: var(--text-color);
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.goods-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.goods-price {
    font-size: 16px;
    font-weight: 600;
    color: var(--danger);
}

.goods-server {
    font-size: 12px;
    color: var(--text-lighter);
    background: var(--secondary-color);
    padding: 2px 8px;
    border-radius: 10px;
}

/* 聊天列表 */
.chat-room-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.3s;
}

.chat-room-item:hover {
    background: var(--secondary-color);
}

.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-name {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 4px;
}

.chat-last-msg {
    font-size: 13px;
    color: var(--text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-meta {
    text-align: right;
}

.chat-time {
    font-size: 12px;
    color: var(--text-lighter);
    margin-bottom: 4px;
}

.chat-unread {
    display: inline-block;
    background: var(--danger);
    color: var(--white);
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* 消息列表 */
.message-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.message-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    margin-right: 12px;
}

.message-content {
    flex: 1;
}

.message-title {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 4px;
}

.message-text {
    font-size: 13px;
    color: var(--text-light);
}

.message-time {
    font-size: 12px;
    color: var(--text-lighter);
}

/* 个人中心 */
.profile-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    padding: 40px 16px 24px;
    color: var(--white);
}

.user-info {
    display: flex;
    align-items: center;
}

.user-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    margin-right: 16px;
    border: 3px solid rgba(255,255,255,0.3);
}

.user-meta h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.user-meta p {
    font-size: 13px;
    opacity: 0.8;
}

.orders-section {
    background: var(--white);
    margin: 12px;
    border-radius: var(--radius);
    padding: 16px;
}

.orders-section .section-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
}

.order-tabs {
    display: flex;
    justify-content: space-around;
}

.order-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: 8px;
}

.tab-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
    color: var(--primary-color);
}

.tab-icon svg {
    width: 24px;
    height: 24px;
}

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

.balance-section {
    margin: 12px;
}

.balance-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.balance-info {
    display: flex;
    flex-direction: column;
}

.balance-label {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 4px;
}

.balance-amount {
    font-size: 24px;
    font-weight: 600;
    color: var(--danger);
}

.withdraw-btn {
    padding: 10px 20px;
    background: var(--primary-color);
    color: var(--white);
    border-radius: var(--radius);
    font-size: 14px;
}

.profile-menu {
    background: var(--white);
    margin: 12px;
    border-radius: var(--radius);
    overflow: hidden;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.3s;
}

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

.menu-item:hover {
    background: var(--secondary-color);
}

.menu-icon {
    width: 24px;
    height: 24px;
    margin-right: 12px;
    color: var(--primary-color);
}

.menu-icon svg {
    width: 20px;
    height: 20px;
}

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

/* 加载更多 */
.loading-more {
    text-align: center;
    padding: 16px;
    color: var(--text-lighter);
    font-size: 13px;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-lighter);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 14px;
}

/* 响应式布局 */
@media (min-width: 768px) {
    .app-container {
        padding-bottom: 0;
    }

    .bottom-nav {
        position: relative;
        border-top: none;
        border-bottom: 1px solid var(--border-color);
        padding: 12px 0;
    }

    .page {
        min-height: calc(100vh - 60px);
    }
}

@media (min-width: 1024px) {
    .goods-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}
