<template>
    <div class="platform-container">
        <!-- 使用导航栏组件 -->
        <NavBar />

        <div class="main-content">
            <!-- 主体内容 -->
            <router-view />
        </div>
    </div>
</template>

<script>
// 引入导航栏组件
import NavBar from './components/navBar.vue'

export default {
    name: 'PublicService',
    components: {
        NavBar,
    },
}
</script>

<style scoped lang="scss">
.platform-container {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;

    .main-content {
        flex: 1;
        width: 100%;
        overflow: auto;
    }
}

/* 顶部导航栏 */
.header {
    background-image: url('/img/psp/productCenter/topbg.png');
    color: white;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 100vw;
    margin: 0 auto;
    padding: 12px 20px;
}

.header-left {
    display: flex;
    align-items: center;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    width: 32px;
    height: 32px;
    border-radius: 6px;
}

.platform-title {
    font-size: 18px;
    font-weight: 600;
    color: white;
}

.header-nav {
    display: flex;
    gap: 32px;
    justify-content: space-between;
}

.nav-item {
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 14px;
    display: flex;
    align-items: center;
}

.nav-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    margin-right: 10px;
    flex-shrink: 0;
}

.nav-text {
    white-space: nowrap;
}

.nav-item:hover,
.nav-item.active {
    background-color: rgba(255, 255, 255, 0.15);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-box {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 6px 12px;
}

.search-input {
    background: transparent;
    border: none;
    outline: none;
    color: white;
    font-size: 14px;
    width: 200px;
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.search-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
}

.user-avatar img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

/* 主体内容 */
.main-content {
    display: flex;
    max-width: 95%;
    margin: 0 auto;
    padding: 24px 20px;
    gap: 24px;
}

/* 左侧分类菜单 */
.sidebar {
    width: 160px;
    flex-shrink: 0;
}

.category-item {
    padding: 12px 16px;
    margin-bottom: 8px;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: #666;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.category-item:hover {
    background-color: #f0f7ff;
    color: #4a90e2;
}

.category-item.active {
    background-color: #4a90e2;
    color: white;
}

/* 服务卡片区域 */
.content-area {
    flex: 1;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.service-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    height: 100%; /* 让卡片高度撑满 grid 单元格 */
}

.service-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.card-image {
    height: 180px; /* 固定高度，可根据设计调整 */
    overflow: hidden;
    background-color: #f8f9fa; /* 图片加载前的占位背景 */
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* 关键：完整显示图片，不裁剪，保持比例 */
    transition: transform 0.3s ease;
}

.service-card:hover .card-image img {
    transform: scale(1.05);
}

.card-content {
    padding: 16px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0 0 16px 0;
    line-height: 1.4;
    text-align: center;
}

.card-actions {
    display: flex;
    gap: 8px;
}

.btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    flex: 1;
    text-align: center;
}

.btn-primary {
    background-color: #4a90e2;
    color: white;
    border-color: #4a90e2;
}

.btn-primary:hover {
    background-color: #357abd;
    border-color: #357abd;
}

.btn-outline {
    background-color: transparent;
    color: #4a90e2;
    border-color: #4a90e2;
}

.btn-outline:hover {
    background-color: #4a90e2;
    color: white;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 12px;
        padding: 16px;
    }

    .header-nav {
        gap: 16px;
    }

    .main-content {
        flex-direction: column;
        padding: 16px;
    }

    .sidebar {
        width: 100%;
    }

    .services-grid {
        grid-template-columns: 1fr;
    }

    .search-input {
        width: 150px;
    }
}
</style>
