/* style.css */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 基础变量定义 */
:root {
    --primary-color: #ff4d4f;
    --secondary-color: #1890ff;
    --text-color: #333;
    --text-light: #666;
    --border-color: #e8e8e8;
    --bg-light: #f5f5f5;
    --header-height: 64px;
    --container-width: 1200px;
    --border-radius: 4px;
    --transition-speed: 0.3s;
    --nav-active-bg: #fff2f0;
    --nav-hover-bg: #fff7f6;
}

/* 基础样式 */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
    color: var(--text-color);
    background-color: #fff;
}

img {
    max-width: 100%;
    height: auto;
    vertical-align: middle;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color var(--transition-speed);
}

/* 布局容器 */
.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 15px;
}

/* Header 样式 */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    z-index: 1000;
}

/* 头部容器布局 */
.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 0;
    gap: 20px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: 15px;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
}

.selected-city {
    font-size: 14px;
    color: var(--text-light);
    background-color: var(--bg-light);
    padding: 4px 12px;
    border-radius: 15px;
}

/* 城市选择弹窗样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 500px;
    width: 90%;
    text-align: center;
}

.modal-content h3 {
    margin-bottom: 20px;
    color: var(--text-color);
}

.city-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.city-option {
    padding: 10px;
    background-color: var(--bg-light);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.city-option:hover {
    background-color: var(--primary-color);
    color: white;
}

/* 导航菜单 */
.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-item {
    margin: 0 15px;
    border-radius: var(--border-radius); /* 添加圆角 */
    overflow: hidden; /* 确保圆角效果显示 */
}

.nav-link {
    color: var(--text-color);
    font-size: 16px;
    padding: 12px 24px;
    position: relative;
    display: block;
    transition: all var(--transition-speed);
    width: 100%; /* 确保链接填满整个导航项 */
    height: 100%;
}


/* 悬停效果 */
.nav-link:hover {
    color: var(--primary-color);
    background-color: var(--nav-hover-bg);
}
.nav-item .nav-link.active {
    color: var(--primary-color);
    background-color: var(--nav-active-bg);
    font-weight: 500;
}

.nav-link::after {
    display: none;
}

.nav-link:hover::after {
    transform: scaleX(1);
}

/* 搜索框容器 */
.search-box {
    flex: 1;
    max-width: 300px;
    margin: 0 20px;
    position: relative;
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: #fff;
    height: 34px;
    padding: 0;
}

.search-box:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(255, 77, 79, 0.2);
}

.search-box:focus-within .search-input,
.search-box:focus-within .search-type-select {
    outline: none;
    box-shadow: none;
}

/* 搜索类型容器 */
.search-type-container {
    height: 100%;
    display: flex;
    align-items: center;
}

/* 搜索类型选择器 */
.search-type-select {
    height: 100%;
    border: none;
    border-right: 1px solid var(--border-color);
    background-color: transparent;
    padding: 0 8px;
    font-size: 14px;
    color: var(--text-color);
    outline: none;
    cursor: pointer;
    border-radius: var(--border-radius) 0 0 var(--border-radius);
    appearance: auto;
    -webkit-appearance: auto;
    -moz-appearance: auto;
}

.search-type-select:focus {
    outline: none;
    box-shadow: none;
}

/* 搜索输入框 */
.search-input {
    width: 100%;
    padding: 8px 12px;
    padding-right: 30px; /* 为搜索按钮留出空间 */
    border: none;
    border-width: 0;
    font-size: 14px;
    outline: none;
    background-color: transparent;
    height: 100%;
    box-shadow: none;
    border-radius: 0;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.search-input:focus {
    outline: none;
    box-shadow: none;
    border: none;
}

.search-input:hover,
.search-input:active,
.search-input:not(:focus) {
    outline: none;
    box-shadow: none;
    border: none;
}

/* 搜索按钮 */
.search-button {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s;
    z-index: 2;
}

.search-button:hover {
    color: var(--primary-color);
}

/* 搜索图标 */
.search-icon {
    width: 16px;
    height: 16px;
}

/* 清除按钮样式 */
.search-clear {
    position: absolute;
    right: 30px; /* 位于搜索图标左侧 */
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s;
    font-size: 16px;
    line-height: 1;
    z-index: 2;
}

.search-clear:hover {
    color: var(--primary-color);
}

/* 用户操作区 */
.user-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn {
    padding: 8px 16px;
    border-radius: var(--border-radius);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-speed);
    border: none;
}

.btn-primary {
    background: var(--primary-color);
    color: #fff;
}

.btn-primary:hover {
    background: #ff7875;
}

.btn-outline {
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    background: transparent;
}

.btn-outline:hover {
    background: var(--primary-color);
    color: #fff;
}

/* 汉堡菜单按钮 */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 24px;
    height: 18px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-right: 15px; /* 添加右侧间距 */
}

.hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text-color);
    transition: all var(--transition-speed);
}

/* 主内容区域 */
.main-content {
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
    padding: 24px 0;
}

/* Footer 样式 */
.footer {
    background: #f7f7f7;
    padding: 40px 0;
    margin-top: auto;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 32px;
}

.footer-section h3 {
    font-size: 18px;
    margin-bottom: 16px;
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: 8px;
}

.footer-bottom {
    margin-top: 32px;
    text-align: center;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

/* 通用组件样式 */
/* 卡片组件 */
.card {
    background: #fff;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform var(--transition-speed);
}

.card:hover {
    transform: translateY(-4px);
}

/* 标签组件 */
.tag {
    display: inline-block;
    padding: 4px 8px;
    border-radius: var(--border-radius);
    font-size: 12px;
    background: var(--bg-light);
    color: var(--text-light);
    margin-right: 8px;
}

/* 响应式布局 */
@media (max-width: 1024px) {
    :root {
        --container-width: 960px;
    }
}

@media (max-width: 768px) {
    .header-container {
        position: relative;
        padding: 15px;
    }

    /* 调整布局顺序和位置 */
    .logo {
        order: 0;
    }

    .hamburger {
        order: 2;
        display: flex;
        margin-left: 0;
        margin-right: 0;
    }

    .nav-menu {
        position: fixed;
        top: var(--header-height);
        left: -100%;
        width: 100%;
        height: calc(100vh - var(--header-height));
        background: #fff;
        flex-direction: column;
        padding: 20px;
        transition: left var(--transition-speed);
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-item {
        margin: 10px 0;
        padding: 12px 24px;
    }

    .nav-link {
        padding: 12px 16px; /* 移动端增加垂直内边距 */
        border-radius: var(--border-radius);
    }

    .nav-link.active {
        background-color: var(--nav-active-bg);
    }

    .search-box {
        order: 1;
        flex: 1;
        margin: 0 10px;  /* 减小边距 */
        max-width: none;  /* 移除最大宽度限制 */
    }

    .user-actions {
        order: 2;
        gap: 8px;
    }

    /* 确保汉堡菜单不会被其他元素遮挡 */
    .hamburger {
        position: relative;
        z-index: 1002;
    }

    /* 调整按钮大小，使其更紧凑 */
    .btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    /* 确保用户操作区不会挤压汉堡菜单 */
    .user-actions {
        flex-shrink: 0;
    }

    .footer-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .header-container {
        padding: 10px;
    }

    .search-box {
        max-width: 240px;
    }

    .logo {
        font-size: 22px;
    }

    .search-input {
        font-size: 13px;
        padding: 6px 30px 6px 10px;
    }

    .search-button {
        right: 2px;
    }

    .search-icon {
        width: 14px;
        height: 14px;
    }

    .user-actions {
        gap: 8px;
    }

    .btn {
        padding: 6px 12px;
    }

    .footer-content {
        grid-template-columns: 1fr;
    }
}

/* 图片懒加载占位 */
.lazy-image {
    background: var(--bg-light);
    position: relative;
    overflow: hidden;
}

.lazy-image::before {
    content: '';
    display: block;
    padding-top: 56.25%; /* 16:9 比例 */
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn var(--transition-speed);
}




/* 汉堡菜单样式 */
.hamburger {
    display: none; /* 默认隐藏 */
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 20px;
    cursor: pointer;
    padding: 0;
    background: none;
    border: none;
}

.hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--text-color);
    transition: all 0.3s ease;
}

/* 汉堡菜单激活状态 */
.hamburger.active span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

/* 移动端导航菜单样式 */
@media (max-width: 768px) {
    .hamburger {
        display: flex; /* 在移动端显示汉堡菜单 */
    }

    .nav-menu {
        display: none; /* 默认隐藏导航菜单 */
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: #fff;
        padding: 20px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        z-index: 1000;
    }

    .nav-menu.active {
        display: block; /* 显示导航菜单 */
    }

    .nav-menu li {
        display: block;
        margin: 10px 0;
    }

    .nav-link {
        display: block;
        padding: 10px 0;
    }

    /* 调整 header 布局 */
    .header-container {
        position: relative;
    }



    /* 当导航菜单激活时显示用户操作区 */
    .nav-menu.active + .user-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 10px 20px;
        background-color: #fff;
    }
}
