/**
 * CB Menu v3.1 — Premium Navigation Component
 * Design: Modern, Glassmorphism, Responsive
 * Prefix: cbm-
 */

:root {
    /* Design Tokens - Standard Colors */
    --cbm-primary: #3b82f6;
    --cbm-primary-hover: #2563eb;
    --cbm-text: #f8fafc;
    --cbm-text-muted: #94a3b8;
    --cbm-bg: rgba(15, 23, 42, 0.9);
    --cbm-glass-bg: rgba(255, 255, 255, 0.05);
    --cbm-glass-border: rgba(255, 255, 255, 0.1);
    --cbm-radius: 12px;
    --cbm-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & base ───────────────────────────────────────────── */
.cbm-nav, .cbm-nav * { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    -webkit-font-smoothing: antialiased;
}

.cbm-nav {
    font-family: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
    width: 100%;
    position: relative;
    z-index: 1050;
    line-height: 1.5;
    background: var(--cbm-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: var(--cbm-transition);
}

.cbm-wrap {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

/* ── Menu list ──────────────────────────────────────────────── */
.cbm-list {
    list-style: none;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    width: 100%;
}
.cbm-align-left   { justify-content: flex-start; }
.cbm-align-center { justify-content: center; }
.cbm-align-right  { justify-content: flex-end; }

/* ── Item ───────────────────────────────────────────────────── */
.cbm-item { 
    position: relative; 
}

.cbm-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 18px 20px;
    text-decoration: none;
    color: var(--cbm-text-muted);
    font-weight: 500;
    font-size: 15px;
    letter-spacing: 0.01em;
    white-space: nowrap;
    transition: var(--cbm-transition);
    border-radius: var(--cbm-radius);
    position: relative;
}

.cbm-link:hover {
    color: var(--cbm-text);
    background: var(--cbm-glass-bg);
}

.cbm-item.cbm-active > .cbm-link {
    color: var(--cbm-text);
    font-weight: 600;
}

/* Active indicator — dynamic bottom line */
.cbm-item.cbm-active > .cbm-link::after {
    content: '';
    position: absolute;
    bottom: 12px;
    left: 20px;
    right: 20px;
    height: 3px;
    background: var(--cbm-primary);
    border-radius: 4px;
    box-shadow: 0 0 12px var(--cbm-primary);
    animation: cbmSlideIn 0.4s ease-out;
}

@keyframes cbmSlideIn {
    from { transform: scaleX(0); opacity: 0; }
    to { transform: scaleX(1); opacity: 1; }
}

/* ── Submenu (Premium Dropdown) ─────────────────────────────── */
.cbm-sub {
    list-style: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 260px;
    background: #1e293b;
    border: 1px solid var(--cbm-glass-border);
    border-radius: 16px;
    padding: 12px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px) scale(0.98);
    transition: var(--cbm-transition);
    z-index: 1060;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.cbm-has-sub:hover > .cbm-sub,
.cbm-has-sub.cbm-open > .cbm-sub {
    opacity: 1;
    visibility: visible;
    transform: translateY(4px) scale(1);
}

.cbm-sub-item {
    margin-bottom: 2px;
}

.cbm-sub-link {
    display: block;
    padding: 12px 16px;
    color: var(--cbm-text-muted);
    font-size: 14px;
    font-weight: 400;
    text-decoration: none;
    transition: var(--cbm-transition);
    border-radius: 8px;
}

.cbm-sub-link:hover {
    color: var(--cbm-text);
    background: rgba(255, 255, 255, 0.05);
    padding-left: 20px;
}

.cbm-sub-item.cbm-active > .cbm-sub-link {
    color: var(--cbm-primary);
    background: rgba(59, 130, 246, 0.1);
    font-weight: 600;
}

/* Caret */
.cbm-caret {
    width: 12px;
    height: 12px;
    transition: transform 0.3s;
    opacity: 0.6;
}
.cbm-has-sub:hover > .cbm-link .cbm-caret {
    transform: rotate(180deg);
    opacity: 1;
}

/* ── Mobile toggle ──────────────────────────────────────────── */
.cbm-toggle {
    display: none;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--cbm-glass-border);
    cursor: pointer;
    width: 44px;
    height: 44px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 10px;
    transition: var(--cbm-transition);
}

.cbm-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--cbm-text);
    border-radius: 2px;
    transition: var(--cbm-transition);
}

.cbm-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.cbm-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.cbm-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* ── Sticky & Scrolled ─────────────────────────────────────────── */
.cbm-sticky {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    border-bottom: 1px solid var(--cbm-glass-border);
    animation: cbmStickyAnim 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.cbm-scrolled {
    padding: 4px 0;
    background: rgba(15, 23, 42, 0.98);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.cbm-scrolled .cbm-link {
    padding-top: 14px;
    padding-bottom: 14px;
}

@keyframes cbmStickyAnim {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

/* ── Size variants ──────────────────────────────────────────── */
.cbm-size-sm .cbm-link { padding: 12px 16px; font-size: 14px; }
.cbm-size-lg .cbm-link { padding: 22px 28px; font-size: 16px; }
.cbm-size-xl .cbm-link { padding: 26px 32px; font-size: 18px; }

/* ── E-commerce Items ───────────────────────────────────────── */
.cbm-item-right {
    margin-left: auto;
}

#eCart {
    background: var(--cbm-primary);
    color: #fff;
    min-width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    font-size: 11px;
    font-weight: 800;
    border-radius: 50%;
    margin-left: 6px;
    display: inline-block;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

/* ── Themes ─────────────────────────────────────────────────── */
.cbm-theme-light {
    --cbm-bg: rgba(255, 255, 255, 0.95);
    --cbm-text: #1e293b;
    --cbm-text-muted: #64748b;
    --cbm-glass-bg: rgba(0, 0, 0, 0.05);
    --cbm-glass-border: rgba(0, 0, 0, 0.08);
}
.cbm-theme-light .cbm-sub {
    background: #ffffff;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
}

.cbm-theme-primary {
    --cbm-bg: rgba(37, 99, 235, 0.95);
    --cbm-primary: #fbbf24;
    --cbm-primary-hover: #f59e0b;
}

/* ── Vertical Mode (Sidebar / Column) ────────────────────────── */
.cbm-nav.cbm-vertical {
    border-radius: var(--cbm-radius);
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.cbm-nav.cbm-vertical .cbm-wrap {
    padding: 12px 10px;
    display: block;
    width: 100%;
}
.cbm-nav.cbm-vertical .cbm-list {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
}
.cbm-nav.cbm-vertical .cbm-item {
    width: 100%;
}
.cbm-nav.cbm-vertical .cbm-link {
    padding: 10px 14px;
    font-size: 14px;
    justify-content: space-between;
}
.cbm-nav.cbm-vertical .cbm-sub {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    background: rgba(0,0,0,0.15);
    border: none;
    box-shadow: none;
    padding: 4px 0 4px 14px;
    margin: 4px 0;
    border-left: 2px solid var(--cbm-primary);
    border-radius: 0 8px 8px 0;
    display: none;
}
.cbm-nav.cbm-vertical .cbm-has-sub.cbm-open > .cbm-sub {
    display: block;
}
.cbm-nav.cbm-vertical .cbm-sub-link {
    padding: 6px 12px;
    font-size: 13px;
}
.cbm-nav.cbm-vertical .cbm-toggle {
    display: none;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 992px) {
    .cbm-toggle { display: flex; }
    .cbm-list {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--cbm-bg);
        backdrop-filter: blur(20px);
        padding: 20px;
        gap: 4px;
        border-bottom: 1px solid var(--cbm-glass-border);
        max-height: 80vh;
        overflow-y: auto;
    }
    .cbm-list.cbm-open { display: flex; }
    .cbm-item { width: 100%; }
    .cbm-item-right { margin-left: 0; }
    .cbm-link { padding: 14px 16px !important; border-radius: 10px; }
    
    .cbm-sub {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        background: transparent;
        border: none;
        box-shadow: none;
        padding-left: 20px;
        display: none;
    }
    .cbm-has-sub.cbm-open > .cbm-sub { display: block; }
    .cbm-item.cbm-active > .cbm-link::after { display: none; }
}

@media print { .cbm-nav { display: none; } }