/* ==========================================================================
   活动聚合页样式 (events.css)
   完全兼容 common.css 全局变量与暗黑模式
   ========================================================================== */

.events-page {
    width: 100%;
    min-height: calc(100vh - 110px); /* 减去导航栏和底部的高度 */
    padding: 40px 0;
    background: var(--bg-body);
}

/* 严格限定宽度与居中 */
.events-container {
    width: 1570px;
    margin: 0 auto;
    max-width: 100%; /* 为移动端降级做准备 */
}

/* 网格布局：4列，每列 370px，间距 30px */
.events-grid {
    display: grid;
    grid-template-columns: repeat(4, 370px);
    gap: 30px;
    justify-content: center;
}

/* ================= 卡片主体结构 ================= */
.event-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
}

.event-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(35,35,55,.09)
}

/* ================= 封面图片与角标 ================= */
.event-cover {
    position: relative;
    width: 100%;
    height: 190px; /* 根据参考图比例大致设定 */
    overflow: hidden;
    background: var(--skeleton-bg);
}

.event-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}


/* 左上角状态标签 */
.event-status {
    position: absolute;
    left: 0;
    padding: 5px 15px;
    font-size: 12px;
    font-weight: 600;
    color: #FFFFFF;
    border-radius: 0 6px 6px 0; /* 右侧圆角 */
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* 不同状态的颜色搭配 (参考图片配色) */
.status-active { background: #3861fb; }   /* 进行中 - 主题蓝 */
.status-upcoming { background: #22bf7a; } /* 即将开始 - 绿色 */
.status-ended { background: #a1a7bb; }   /* 已结束 - 灰色 */

/* ================= 下方文本信息区 ================= */
.event-info {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
    background: var(--sidebar-bg);
}
/* 标题后缀小图标 */
.event-title .title-icon {
    display: inline-block;
    width: 30px;
    height: 16px;
    vertical-align: middle; /* 垂直居中对齐文字 */
    margin-left: 5px;       /* 和左侧文字保持一点间距 */
    margin-top: -3px;       /* 核心微调：抵消字体的默认基线偏差，让图标在视觉上绝对居中 */
}

.event-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-main);
    margin: 0 0 15px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s;
}

.event-card:hover .event-title {
    color: var(--btn-active);
}

/* 地址与时间描述 */
.event-meta {
    font-size: 13px;
    color: var(--text-sub);
    margin-bottom: 8px;
    display: flex;
    align-items: center; /* 关键修改：直接使用 center 垂直居中 */
    gap: 6px; /* 保持间距控制 */
    line-height: 1.6;
}

/* 专门针对新增的 SVG 图标 */
.event-meta svg {
    flex-shrink: 0; /* 防止文字换行压扁图标 */
    width: 15px;
    height: 15px;
    margin-top: 0; /* 清除所有外边距干扰 */
    display: block;
}

/* 兼容原有的 Emoji 或文本图标 */
.meta-icon {
    font-size: 13px;
    flex-shrink: 0;
    opacity: 0.6;
}

.time-meta {
    margin-bottom: 0;
}

/* 底部标签 (例如：#其他) */
.event-footer {
    margin-top: auto; /* 始终推到卡片最底部 */
    padding-top: 16px;
}

.event-tag {
    display: inline-block;
    font-size: 12px;
    color: var(--text-sub);
    background: var(--line-border);
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 500;
}

/* ================= 针对你系统现有的暗黑模式微调 ================= */
[data-theme="dark"] .event-card {
    background: var(--sidebar-bg); /* 暗色模式下使用你定义的侧边栏底色 */
}
[data-theme="dark"] .event-status.status-ended {
    background: #3B4252;
    color: #A1A7BB;
}


/* ================= 响应式降级处理 (适配平板和手机) ================= */
@media (max-width: 1600px) {
    .events-container {
        width: 100%;
        padding: 0 24px;
        box-sizing: border-box;
    }
    .events-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        gap: 24px;
    }
}

@media (max-width: 768px) {
    .events-grid {
        grid-template-columns: 1fr; /* 手机端单列 */
        gap: 20px;
    }
    .events-page {
        padding: 20px 0;
    }
    .event-cover {
        height: 180px;
    }
}

/* ==========================================================================
   全新丝滑头部模块样式 (events-header-section)
   ========================================================================== */

.events-header-section {
    display: flex;
    justify-content: space-between;
    align-items: flex-end; /* 底部对齐，让 Tab 和搜索框在同一水平线 */
    margin-bottom: 10px;
    padding-bottom: 10px;
}

/* 左侧标题与 Tab */
.eh-left {
    display: flex;
    flex-direction: column;
}

.eh-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 8px 0;
    line-height: 1.2;
}

.eh-subtitle {
    font-size: 14px;
    color: var(--text-sub);
    margin: 0 0 20px 0;
}

/* --- 丝滑滑动 Tab 容器设计 --- */
.eh-tabs {
    position: relative;
    display: inline-flex;
    background: var(--hover-bg); /* 浅灰背景 */
    padding: 4px;
    border-radius: 8px;
    /* 消除内联元素的间隙 */
    font-size: 0; 
}

/* 背景滑块 (纯 CSS 动画核心) */
.eh-tab-slider {
    position: absolute;
    top: 4px;
    left: 0;
    height: calc(100% - 8px);
    background: var(--bg-body); /* 纯白背景 */
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); /* 柔和的物理阴影 */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

/* 按钮基础样式 */
.eh-tab-item {
    position: relative;
    z-index: 2; /* 确保文字在滑块上方 */
    background: transparent;
    border: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-sub);
    padding: 8px 20px;
    cursor: pointer;
    transition: color 0.3s ease;
    outline: none;
    font-family: inherit;
}

/* 激活状态 */
.eh-tab-item.active {
    color: var(--btn-active); /* 激活时变成主题蓝 */
    font-weight: 600;
}

.eh-tab-item:hover:not(.active) {
    color: var(--text-main);
}

/* --- 右侧搜索框 (复用优化) --- */
.eh-right {
    padding-bottom: 4px; /* 微调以视觉对齐左侧的 Tab */
}

.event-search-box {
    display: flex;
    align-items: center;
    background: var(--skeleton-bg);
    border-radius: 8px;
    padding: 4px 4px 4px 16px;
    width: 280px;
    border: 1px solid transparent;
    transition: all 0.3s ease;
}

.event-search-box:focus-within {
    border-color: var(--btn-active);
    background: var(--bg-body);
    box-shadow: 0 0 0 3px rgba(56, 97, 251, 0.1);
}

.search-icon {
    color: var(--text-sub);
    flex-shrink: 0;
    margin-right: 8px;
}

.event-search-box input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    color: var(--text-main);
    font-size: 14px;
    height: 32px;
}

.event-search-box input::placeholder {
    color: var(--text-sub);
    opacity: 0.7;
}

.search-btn {
    background: var(--btn-active);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0 16px;
    height: 32px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.search-btn:hover {
    background: #2a4bc8;
}

/* ================= 移动端适配 ================= */
@media (max-width: 768px) {
    .events-header-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }
    .eh-right {
        width: 100%;
        padding-bottom: 0;
    }
    .event-search-box {
        width: 100%;
    }
    /* 移动端如果 Tab 太多，允许横向滚动 */
    .eh-tabs {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .eh-tabs::-webkit-scrollbar {
        display: none;
    }
}


/* 瀑布流加载状态动画 */
.js-loading {
    margin: 30px auto;
    width: 100%;
    text-align: center;
}

.js-noData {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
}

.js-noData img {
    margin: 10px 0 20px;
    width: 120px;
    opacity: 0.8;
}

.js-noData span {
    font-size: 14px;
    color: var(--home-text-sub, #888);
}

.js-list-loading {
    display: none;
    justify-content: center;
    align-items: center;
    height: 48px;
}

.js-list-loading div {
    width: 10px;
    height: 10px;
    margin: 0 6px;
    background: var(--home-primary, #3861fb);
    border-radius: 100%;
    display: inline-block;
    animation: bouncedelay 1.4s ease-in-out infinite;
    animation-fill-mode: both;
}

.js-list-loading div:first-child {
    animation-delay: -0.32s;
}

.js-list-loading div:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bouncedelay {
    0%, 80%, to { transform: scale(0); }
    40% { transform: scale(1); }
}

.events-empty,
.events-load-error {
    padding: 28px 12px;
    text-align: center;
    color: var(--home-text-sub, #888);
    font-size: 14px;
}

.events-load-error {
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.events-load-error button {
    border: 0;
    background: transparent;
    color: var(--home-primary, #3861fb);
    cursor: pointer;
}

/* 页面使用链接或 article 作为活动卡片外壳，都保持相同外观。 */
.events-grid > .event-card {
    color: inherit;
    text-decoration: none;
}


/* 统一首屏和 AJAX 新加载卡片的标签间距 */
.events-page .event-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

/* 统一每一个标签的尺寸、字体和间距 */
.events-page .event-footer .event-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    box-sizing: border-box;
    flex: 0 0 auto;

    /* 统一标签的最小尺寸 */
    min-width: 48px;
    min-height: 26px;

    /* 禁止旧样式的外边距干扰 gap */
    margin: 0 !important;

    padding: 3px 8px;

    /* 所有标签使用相同的字号和行高 */
    font-family: inherit;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;

    white-space: nowrap;
    vertical-align: middle;
}

/* 搜索框清空按钮：有关键词时由 JavaScript 显示 */
.events-page .event-search-box {
    position: relative;
}

.events-page .event-search-box #eventSearchInput {
    box-sizing: border-box;
    padding-right: 40px;
}

.events-page .event-search-box .event-search-clear {
    position: absolute;
    top: 50%;
    right: 10px;
    z-index: 2;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #e9edf3;
    color: #687386;
    font-family: Arial, sans-serif;
    font-size: 18px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    transform: translateY(-50%);
}

.events-page .event-search-box .event-search-clear:hover {
    background: #dce2eb;
    color: #2f3b4d;
}

.events-page .event-search-box .event-search-clear:focus-visible {
    outline: 2px solid var(--home-primary, #3861fb);
    outline-offset: 2px;
}

