/* ================================================
   头部「最近访问」下拉面板
   颜色全部取自父主题 CSS 变量，暗色模式自动适配
   ================================================ */

.nav-recent {
    position: relative;
    display: flex;
    align-items: center;
}

/* 触发按钮（加 .header-tools 前缀提高权重，压过父主题 .header-icon-btn > a 的 38px 尺寸） */
.header-tools .nav-recent > a {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin: 0;
    border-radius: 8px;
    color: var(--main-color, #4b5563);
    font-size: 17px;
    cursor: pointer;
    transition: background-color .2s, color .2s;
    text-decoration: none;
}

.header-tools .nav-recent > a:hover,
.header-tools .nav-recent.is-open > a {
    background: var(--muted-bg-a-color, rgba(136, 136, 136, .1));
    color: var(--theme-color, #f1404b);
}

.header-tools .nav-recent > a:focus-visible {
    outline: 2px solid var(--theme-color, #f1404b);
    outline-offset: 2px;
}

/* 未读徽标 */
.nav-recent .recent-badge {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--theme-color, #f1404b);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    border-radius: 8px;
    border: 2px solid var(--main-bg-color, #fff);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 下拉面板 */
.nav-recent .recent-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 300px;
    background: var(--main-bg-color, #fff);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .14);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .2s cubic-bezier(.3, 0, .3, 1), transform .2s cubic-bezier(.3, 0, .3, 1), visibility .2s;
    z-index: 300;
    overflow: hidden;
}

.nav-recent:hover .recent-dropdown,
.nav-recent.is-open .recent-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.io-black-mode .nav-recent .recent-dropdown {
    box-shadow: 0 8px 32px rgba(0, 0, 0, .45);
}

/* 标题栏 */
.nav-recent .recent-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--muted-bg-color, #f1f3f7);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-recent .recent-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--main-color, #1f2937);
}

.nav-recent .recent-title i {
    color: var(--theme-color, #f1404b);
    font-size: 14px;
}

.nav-recent .recent-header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    text-align: right;
}

.nav-recent .recent-clear {
    font-size: 12px;
    color: var(--muted-color, #9ca3af);
    cursor: pointer;
    transition: color .2s;
}

.nav-recent .recent-clear:hover {
    color: var(--theme-color, #f1404b);
}

.nav-recent .recent-storage-tip {
    margin-top: 3px;
    font-size: 10px;
    line-height: 1;
    color: var(--muted-color3, #c0c4cc);
    white-space: nowrap;
}

/* 分类筛选标签 */
.nav-recent .recent-filters {
    display: flex;
    gap: 6px;
    padding: 10px 16px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.nav-recent .recent-filters::-webkit-scrollbar {
    display: none;
}

.nav-recent .filter-tag {
    flex-shrink: 0;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid transparent;
    font-size: 11px;
    white-space: nowrap;
    color: var(--muted-color2, #6b7280);
    background: var(--muted-bg-color-l, #f3f4f6);
    cursor: pointer;
    transition: color .2s, background-color .2s, border-color .2s;
}

.nav-recent .filter-tag:hover {
    background: var(--muted-bg-color, #e5e7eb);
}

.nav-recent .filter-tag.active {
    background: var(--main-bg-color, #fff);
    border-color: var(--theme-color, #f1404b);
    color: var(--theme-color, #f1404b);
    font-weight: 500;
}

/* 列表 */
.nav-recent .recent-list {
    position: relative;
    max-height: 340px;
    padding: 4px 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--theme-color, #f1404b) var(--muted-bg-color-l, #f5f5f5);
}

.nav-recent .recent-list::-webkit-scrollbar {
    width: 8px;
}

.nav-recent .recent-list::-webkit-scrollbar-track {
    background: var(--muted-bg-color-l, #f8f8f8);
    border-radius: 4px;
    margin: 4px 0;
}

.nav-recent .recent-list::-webkit-scrollbar-thumb {
    min-height: 32px;
    background-color: var(--theme-color, #f1404b);
    border: 2px solid var(--muted-bg-color-l, #f8f8f8);
    border-radius: 4px;
}

/* 单条记录 */
.nav-recent .recent-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background-color .15s, opacity .28s, transform .28s, height .28s, padding .28s;
    text-decoration: none;
}

.nav-recent .recent-item:hover {
    background: var(--muted-bg-color-l, #f8f9fb);
}

.nav-recent .recent-item:focus-visible {
    outline: 2px solid var(--theme-color, #f1404b);
    outline-offset: -2px;
}

.nav-recent .recent-item.removing {
    height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    transform: translateX(20px);
    overflow: hidden;
}

.nav-recent .recent-favicon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 6px;
    background: var(--muted-bg-color-l, #f3f4f6);
    color: var(--muted-color2, #6b7280);
    font-size: 12px;
    font-weight: 600;
}

.nav-recent .recent-favicon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.nav-recent .recent-info {
    flex: 1;
    min-width: 0;
}

.nav-recent .recent-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--main-color, #1f2937);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-recent .recent-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.nav-recent .recent-type-tag {
    flex-shrink: 0;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    color: var(--muted-color, #9ca3af);
    background: var(--muted-bg-color-l, #f3f4f6);
}

.nav-recent .recent-time {
    margin-top: 0;
    font-size: 11px;
    color: var(--muted-color, #9ca3af);
}

/* 单条删除 */
.nav-recent .recent-delete {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--muted-color3, #d1d5db);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity .2s, background-color .2s, color .2s;
}

.nav-recent .recent-item:hover .recent-delete,
.nav-recent .recent-delete:focus-visible {
    opacity: 1;
}

.nav-recent .recent-delete:hover {
    background: var(--theme-color-bg, rgba(241, 64, 75, .12));
    color: var(--theme-color, #f1404b);
}

/* 底部「查看更多」 */
.nav-recent .recent-view-more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 12px 16px;
    border-top: 1px solid var(--muted-bg-color, #f5f6f8);
    font-size: 12px;
    color: var(--muted-color, #9ca3af);
    cursor: pointer;
    transition: color .2s, background-color .2s;
}

.nav-recent .recent-view-more:hover {
    color: var(--theme-color, #f1404b);
    background: var(--muted-bg-color-l, #f8f9fb);
}

.nav-recent .recent-view-more i {
    font-size: 14px;
    font-style: normal;
    font-weight: 700;
    transition: transform .2s;
}

.nav-recent .recent-view-more:hover i {
    transform: translateX(2px);
}

/* 空态 / 加载态 */
.nav-recent .recent-empty,
.nav-recent .recent-loading {
    padding: 32px 16px;
    text-align: center;
    font-size: 13px;
    color: var(--muted-color, #9ca3af);
}

.nav-recent .recent-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.nav-recent .recent-loading {
    padding: 24px 16px;
}

.nav-recent .recent-empty i {
    font-size: 32px;
    color: var(--muted-color3, #d1d5db);
}

/* 底部「还有更多」渐变箭头提示 */
.nav-recent .recent-more-hint {
    --io-rv-fade: rgba(255, 255, 255, 0);
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 44px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 8px;
    background: linear-gradient(180deg, var(--io-rv-fade) 0%, var(--main-bg-color, #fff) 92%);
    pointer-events: none;
    opacity: 0;
    transition: opacity .3s ease;
    z-index: 2;
}

.io-black-mode .nav-recent .recent-more-hint {
    --io-rv-fade: rgba(45, 46, 47, 0);
}

.nav-recent .recent-more-hint.visible {
    opacity: 1;
}

.nav-recent .recent-more-hint .arrow-down {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--main-bg-color, #fff);
    box-shadow: 0 2px 10px var(--theme-color-bg, rgba(241, 64, 75, .35));
    color: var(--theme-color, #f1404b);
    font-size: 12px;
    animation: io-recent-arrow-bounce 1.5s ease-in-out infinite;
}

@keyframes io-recent-arrow-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(3px); }
}

/* 移动端隐藏最近访问（与父主题头部图标策略一致） */
@media (max-width: 992px) {
    .nav-recent {
        display: none;
    }
}

/* 尊重「减少动效」系统偏好 */
@media (prefers-reduced-motion: reduce) {
    .nav-recent .recent-dropdown,
    .nav-recent .recent-item,
    .nav-recent .recent-more-hint,
    .nav-recent .recent-view-more i {
        transition: none;
    }

    .nav-recent .recent-more-hint .arrow-down {
        animation: none;
    }
}
