/**
 * CATBAR TABS STYLE - Lấy nguyên style từ mixproxy.html
 * Wrap xuống dòng, không card container
 * Hỗ trợ cả Light Mode và Dark Mode
 */

/* ============================================
   TABS & TAB (from mixproxy.html)
   ============================================ */
.tabs {
    display: flex;
    gap: 10px;
    padding: 18px 0 18px;
    overflow-x: auto;
    scrollbar-width: none;
    flex-wrap: wrap;
    justify-content: stretch;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: fit-content;
    height: 46px;
    padding: 0 18px;
    background: #fff;
    border-radius: 11px;
    border: 1px solid #e9f0fa;
    box-shadow: 0 1px 3px rgba(21, 58, 110, .05);
    font-size: 13.5px;
    font-weight: 600;
    color: #33445e;
    transition: transform .12s, box-shadow .15s;
    cursor: pointer;
    outline: none;
}

.tab:hover {
    box-shadow: 0 4px 12px rgba(21, 58, 110, .1);
}

.tab:active {
    transform: translateY(1px);
}

.tab.is-active {
    background: linear-gradient(135deg, #2f8ef0, #0f62d6);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 16px rgba(17, 95, 214, .32);
}

.tab.is-hot {
    border: 1.5px solid #ffc9d6;
    color: #e8194c;
    background: #fff;
}

.tab.is-hot:hover {
    background: #fff6f8;
}

.tab-logo {
    height: 15px;
    width: auto;
}

/* Icon in tab */
.tab i {
    font-size: 14px;
}

/* Dark mode for tabs */
body.dark-mode .tabs {
    background: transparent;
}

body.dark-mode .tab {
    background: #1f2937;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

body.dark-mode .tab:hover {
    background: #273344;
    border-color: rgba(96, 165, 250, 0.4);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

body.dark-mode .tab.is-active {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

body.dark-mode .tab.is-hot {
    border: 1.5px solid #4a1e2a;
    color: #f87171;
    background: #1f2937;
}

body.dark-mode .tab.is-hot:hover {
    background: #2a1a1f;
}

/* Skeleton loading cho tab */
.tab--skeleton {
    height: 46px;
    min-width: 120px;
    background: linear-gradient(90deg, #f0f4f8 25%, #e4ecf2 50%, #f0f4f8 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border: 1px solid #e9f0fa;
    border-radius: 11px;
    pointer-events: none;
}

body.dark-mode .tab--skeleton {
    background: linear-gradient(90deg, rgba(51, 65, 85, 0.4) 25%, rgba(71, 85, 105, 0.6) 50%, rgba(51, 65, 85, 0.4) 75%);
    background-size: 200% 100%;
    border-color: rgba(255, 255, 255, 0.1);
}

/* Tab icon/initial/caret */
.tab-icon {
    width: 35px;
    height: 35px;
    object-fit: contain;
    border-radius: 4px;
}

.tab-initial {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e5e7eb;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    color: #1f2937;
}

body.dark-mode .tab-initial {
    background: #374151;
    color: #e2e8f0;
}

.tab-caret {
    font-size: 10px;
    opacity: 0.7;
    margin-left: 2px;
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.tab.is-anchor .tab-caret {
    transform: rotate(180deg);
}

/* Responsive mobile */
@media (max-width: 768px) {
    .tabs {
        padding: 14px 0 4px;
        gap: 8px;
    }

    .tab {
        height: 42px;
        padding: 0 16px;
        font-size: 13px;
    }

    .tab--skeleton {
        height: 42px;
        min-width: 100px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .tab,
    .tab-caret {
        transition: opacity 0.16s linear;
        transform: none !important;
    }

    .tab.is-anchor .tab-caret {
        transform: none;
    }

    .tab--skeleton {
        animation: none;
    }
}

/* Focus visible */
.tab:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

body.dark-mode .tab:focus-visible {
    outline-color: #60a5fa;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   CATBAR WRAPPER - NEO POPOVER
   ============================================ */
.catbar-wrapper {
    position: relative;  /* ← Neo popover ở đây */
    margin: 0;
    padding: 0;
}

/* Tabs container */
.tabs {
    /* KHÔNG CẦN position relative vì popover neo vào wrapper */
}

.catbar::before {
    display: none;
}

/* ============================================
   CATBAR RAIL (TABS CONTAINER) - FLEX WRAP
   ============================================ */
.catbar-rail {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 18px 0 4px;
    align-items: center;
}

/* ============================================
   CATBAR CHIP (TAB BUTTON) - LIGHT MODE
   Lấy nguyên style từ mixproxy.html
   ============================================ */
.catbar-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    height: 46px;
    padding: 0 18px;
    background: #fff;
    border-radius: 11px;
    border: 1px solid #e9f0fa;
    box-shadow: 0 1px 3px rgba(21, 58, 110, .05);
    font-size: 13.5px;
    font-weight: 600;
    color: #33445e;
    transition: transform .12s, box-shadow .15s, background-color .15s, border-color .15s;
    cursor: pointer;
    outline: none;
}

.catbar-chip:hover {
    box-shadow: 0 4px 12px rgba(21, 58, 110, .1);
    border-color: #d8e5f5;
}

.catbar-chip:active {
    transform: translateY(1px);
}

/* Active State - Blue Gradient */
.catbar-chip.is-active {
    background: linear-gradient(135deg, #2f8ef0, #0f62d6);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 16px rgba(17, 95, 214, .32);
}

/* Anchor State (when popover is open) */
.catbar-chip.is-anchor {
    background: linear-gradient(135deg, #2f8ef0, #0f62d6);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 16px rgba(17, 95, 214, .32);
}

/* Hot tab - đặc biệt */
.catbar-chip.is-hot {
    border: 1.5px solid #ffc9d6;
    color: #e8194c;
    background: #fff;
}

.catbar-chip.is-hot:hover {
    background: #fff6f8;
}

.catbar-chip.is-hot.is-active {
    background: linear-gradient(135deg, #ff4760, #e8194c);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 16px rgba(232, 25, 76, .32);
}

/* "Tất cả sản phẩm" chip */
.catbar-chip--all {
    background: #fff;
    border-color: #e9f0fa;
    font-weight: 700;
}

.catbar-chip--all.is-active {
    background: linear-gradient(135deg, #2f8ef0, #0f62d6);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 16px rgba(17, 95, 214, .32);
}

/* Icon trong chip */
.catbar-chip i {
    font-size: 14px;
}

.catbar-chip-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    border-radius: 4px;
}

.catbar-chip-initial {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e5e7eb;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    color: #1f2937;
}

/* Caret icon */
.catbar-chip-caret {
    font-size: 10px;
    opacity: 0.7;
    margin-left: 2px;
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.catbar-chip.is-anchor .catbar-chip-caret {
    transform: rotate(180deg);
}

/* Logo SVG trong chip (giống mixproxy) */
.catbar-chip-logo {
    height: 15px;
    width: auto;
}

/* ============================================
   SKELETON LOADING
   ============================================ */
.catbar-chip--skeleton {
    height: 46px;
    min-width: 120px;
    background: linear-gradient(90deg, #f0f4f8 25%, #e4ecf2 50%, #f0f4f8 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border: 1px solid #e9f0fa;
    border-radius: 11px;
    pointer-events: none;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   DARK MODE STYLES
   ============================================ */
body.dark-mode .catbar-chip {
    background: #1f2937;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

body.dark-mode .catbar-chip:hover {
    background: #273344;
    border-color: rgba(96, 165, 250, 0.4);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

body.dark-mode .catbar-chip.is-active {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

body.dark-mode .catbar-chip.is-anchor {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

body.dark-mode .catbar-chip--all {
    background: #1f2937;
    border-color: rgba(255, 255, 255, 0.12);
}

body.dark-mode .catbar-chip--all.is-active {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

body.dark-mode .catbar-chip.is-hot {
    border: 1.5px solid #4a1e2a;
    color: #f87171;
    background: #1f2937;
}

body.dark-mode .catbar-chip.is-hot:hover {
    background: #2a1a1f;
}

body.dark-mode .catbar-chip.is-hot.is-active {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}

body.dark-mode .catbar-chip-initial {
    background: #374151;
    color: #e2e8f0;
}

/* Dark mode skeleton */
body.dark-mode .catbar-chip--skeleton {
    background: linear-gradient(90deg, rgba(51, 65, 85, 0.4) 25%, rgba(71, 85, 105, 0.6) 50%, rgba(51, 65, 85, 0.4) 75%);
    background-size: 200% 100%;
    border-color: rgba(255, 255, 255, 0.1);
}

/* ============================================
   POPOVER (giữ nguyên style)
   ============================================ */
.catbar-popover {
    /* Giữ nguyên style popover hiện tại */
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */
@media (max-width: 768px) {
    .catbar-rail {
        padding: 14px 0 4px;
        gap: 8px;
    }

    .catbar-chip {
        height: 42px;
        padding: 0 16px;
        font-size: 13px;
    }

    .catbar-chip--skeleton {
        height: 42px;
        min-width: 100px;
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .catbar-chip,
    .catbar-chip-caret {
        transition: opacity 0.16s linear;
        transform: none !important;
    }

    .catbar-chip.is-anchor .catbar-chip-caret {
        transform: none;
    }

    .catbar-chip--skeleton {
        animation: none;
    }
}

/* ============================================
   FOCUS VISIBLE (Accessibility)
   ============================================ */
.catbar-chip:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

body.dark-mode .catbar-chip:focus-visible {
    outline-color: #60a5fa;
}
