/* Layout Tabs Styles */
/* Category tab navigation, drag handles, update indicators */

/* Tab 导航 - 默认隐藏，防止刷新时闪烁 */
.category-tabs {
    background: white;
    border-radius: 10px;
    padding: 6px;
    margin-bottom: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: none;
    /* 默认隐藏，由 JS 添加 .categories-ready 后显示 */
    gap: 4px;
    overflow-x: hidden;
    flex-wrap: nowrap;
    justify-content: flex-start;
}

/* 栏目准备就绪后显示（使用 body.categories-ready 提高优先级） */
body.categories-ready .category-tabs {
    display: flex;
}

body.categories-ready .tab-content-area {
    display: block;
}

.tr-footer-top-toggle {
    margin-left: 10px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.tr-footer-top-toggle:hover,
.tr-footer-top-toggle:focus-visible {
    color: #ffffff;
    text-decoration: underline;
    outline: none;
}

/* Desktop-only tip - hide on mobile */
.tr-footer-tip-desktop {
    cursor: default;
}

.tr-footer-tip-desktop:hover {
    text-decoration: none;
}

.category-tab {
    flex: 1 1 0;
    min-width: 0;
    padding: 6px 8px;
    background: #f3f4f6;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
}

.category-tab-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.8rem;
    font-weight: 600;
}

.category-drag-handle {
    position: absolute;
    top: 4px;
    left: 6px;
    color: #9ca3af;
    cursor: grab;
    user-select: none;
    padding: 2px 6px;
    border-radius: 6px;
    display: none;
}

body.categories-ready .category-tab:hover .category-drag-handle {
    display: inline-block;
}

body.categories-ready.category-tabs-drag-mode .category-drag-handle {
    display: inline-block;
}

.category-drag-handle:hover {
    background: rgba(0, 0, 0, 0.04);
}

.category-tab.dragging {
    opacity: 0.7;
}

.category-tabs.compact {
    gap: 4px;
    padding: 4px;
    overflow-x: hidden;
    flex-wrap: nowrap;
}

.category-tabs.compact .category-tab {
    flex: 1 1 0;
    min-width: 0;
    padding: 4px 6px;
}

.category-tabs.compact .category-tab-icon {
    font-size: 0.9rem;
}

.category-tabs.compact .category-tab-name {
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-tabs.compact .category-tab-count {
    font-size: 0.6rem;
}

.category-tab:hover {
    background: #e5e7eb;
}

.category-tab.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.category-tab-icon {
    font-size: 1rem;
}

.category-tab-count {
    font-size: 0.65rem;
    opacity: 0.8;
}

/* Update indicator red dot */
.update-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    display: none;
    box-shadow: 0 0 0 2px white;
}

.update-dot.show {
    display: block;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 2px white;
    }

    50% {
        transform: scale(1.2);
        box-shadow: 0 0 0 2px white, 0 0 8px rgba(239, 68, 68, 0.5);
    }
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* Long press visual feedback */
.category-tab.long-pressing {
    transform: scale(0.95);
    opacity: 0.8;
}

/* Category tab context menu */
.tr-category-context-menu {
    animation: categoryMenuFadeIn 0.15s ease-out;
}

@keyframes categoryMenuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ── Tag-driven Columns: Hover Dropdown Megamenu ── */

/* 允许 dropdown 溢出 sub-tabs 容器 */
#homeSubTabs {
    overflow: visible;
}

/* Wrapper for tabs that have sub-columns */
.sub-tab-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    /* Bridge gap between tab and dropdown so hover doesn't break */
    padding-bottom: 8px;
    margin-bottom: -8px;
}

.sub-tab-wrapper .sub-tab {
    /* Inherit existing sub-tab styles */
}

/* Dropdown panel */
.sub-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 16px;
    min-width: 200px;
    max-width: 900px;
    width: max-content;
}

.sub-tab-wrapper:hover .sub-dropdown {
    display: block;
}

/* Grid of columns inside dropdown */
.dropdown-grid {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 20px;
    align-items: flex-start;
}

/* Each column in the dropdown */
.dropdown-col {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 80px;
    flex-shrink: 0;
}

/* Column title (L2 label) — 统一样式，全部可点击 */
.dropdown-col-title {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    padding: 2px 6px 6px;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 4px;
    white-space: nowrap;
}

/* Clickable column title */
.dropdown-col-title--link {
    cursor: pointer;
    transition: color 0.15s;
}

.dropdown-col-title--link:hover {
    color: var(--primary-color, #07c160);
}

/* L3 items — 与二级标题左对齐 */
.dd-item {
    font-size: 13px;
    color: #6b7280;
    padding: 3px 6px;
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.dd-item:hover {
    background: #f3f4f6;
    color: var(--primary-color, #07c160);
}

/* Active state for wrapper */
.sub-tab-wrapper.active > .sub-tab {
    /* active styles already applied by .sub-tab.active */
}
