/**
 * Mobile Bottom Nav - Frontend Styles
 * 移动端底部导航栏前端样式
 */

/* ========================================
   Desktop: hide everything
   ======================================== */

@media (min-width: 769px) {
    .mbn-root,
    .mbn-bar,
    .mbn-spacer,
    .mbn-overlay,
    .mbn-submenu {
        display: none !important;
    }
}

.mbn-root {
    --mbn-safe-area-bottom: 0px;
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .mbn-root.mbn-safe-area {
        --mbn-safe-area-bottom: env(safe-area-inset-bottom, 0px);
    }
}

@supports (padding-bottom: constant(safe-area-inset-bottom)) {
    .mbn-root.mbn-safe-area {
        --mbn-safe-area-bottom: constant(safe-area-inset-bottom);
    }
}

/* ========================================
   Navigation Bar
   ======================================== */

.mbn-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--mbn-bar-height, 56px) + var(--mbn-safe-area-bottom, 0px));
    padding-bottom: var(--mbn-safe-area-bottom, 0px);
    background-color: var(--mbn-bg, #ffffff);
    z-index: var(--mbn-z, 99999);
    border-top: 1px solid var(--mbn-separator, #e5e5e5);
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.mbn-bar.mbn-blur {
    background-color: transparent;
    background: rgba(255, 255, 255, 0.88);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
}

.mbn-bar.mbn-shadow {
    box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.06);
}

/* ========================================
   Menu Items Container
   ======================================== */

.mbn-items {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: var(--mbn-bar-height, 56px);
    max-width: 600px;
    margin: 0 auto;
    padding: 0 4px;
}

/* ========================================
   Individual Menu Item
   ======================================== */

.mbn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 100%;
    min-width: 0;
    padding: 6px 2px 4px;
    box-sizing: border-box;
    text-decoration: none;
    color: var(--mbn-color, #999999);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    transition: color 0.2s ease;
    background: none;
    border: none;
    outline: none;
    font-family: inherit;
}

.mbn-item:visited {
    color: var(--mbn-color, #999999);
}

.mbn-item.mbn-active,
.mbn-item.mbn-active:visited {
    color: var(--mbn-active, #007aff);
}

.mbn-item:active {
    opacity: 0.7;
    transition: none;
}

/* ========================================
   Icon
   ======================================== */

.mbn-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--mbn-icon-size, 22px);
    height: var(--mbn-icon-size, 22px);
    font-size: var(--mbn-icon-size, 22px);
    line-height: 1;
    flex-shrink: 0;
}

.mbn-item-icon svg {
    width: var(--mbn-icon-size, 22px);
    height: var(--mbn-icon-size, 22px);
    fill: currentColor;
}

.mbn-item-icon i {
    font-size: inherit;
    line-height: 1;
}

.mbn-dot {
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ========================================
   Label
   ======================================== */

.mbn-item-label {
    font-size: var(--mbn-label-size, 10px);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    text-align: center;
    font-weight: 500;
}

/* ========================================
   Content Spacer
   ======================================== */

.mbn-spacer {
    height: calc(var(--mbn-bar-height, 56px) + var(--mbn-safe-area-bottom, 0px));
    width: 100%;
    pointer-events: none;
}

/* ========================================
   Overlay
   ======================================== */

.mbn-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--mbn-overlay, rgba(0, 0, 0, 0.3));
    z-index: calc(var(--mbn-z, 99999) + 1);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

.mbn-overlay.mbn-open {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   Sub-menu Panel
   ======================================== */

.mbn-submenu {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--mbn-bar-height, 56px) + var(--mbn-safe-area-bottom, 0px));
    background: var(--mbn-submenu-bg, #ffffff);
    z-index: calc(var(--mbn-z, 99999) + 2);
    border-radius: 20px 20px 0 0;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.08);
    transform: translateY(100%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1),
                opacity 0.2s ease,
                visibility 0.32s ease;
    overflow: hidden;
    max-height: min(72vh, 560px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mbn-submenu.mbn-open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

/* Sub-menu header */
.mbn-sub-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    background: var(--mbn-submenu-bg, #ffffff);
    position: sticky;
    top: 0;
    z-index: 1;
    box-sizing: border-box;
    max-width: 720px;
    margin: 0 auto;
}

.mbn-sub-heading {
    flex: 1;
    min-width: 0;
}

.mbn-sub-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: 0.01em;
    color: var(--mbn-submenu-color, #1a1a1a);
}

.mbn-sub-title-link {
    text-decoration: none;
    transition: color 0.18s ease, opacity 0.18s ease;
}

.mbn-sub-title-link:visited {
    color: var(--mbn-submenu-color, #1a1a1a);
}

.mbn-sub-title-link:hover,
.mbn-sub-title-link:focus-visible {
    color: var(--mbn-active, #007aff);
    opacity: 0.92;
}

.mbn-sub-title-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mbn-sub-title-hint {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--mbn-active, #007aff);
    opacity: 0.9;
}

.mbn-sub-title-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--mbn-active, #007aff);
}

.mbn-sub-title-arrow svg {
    width: 16px;
    height: 16px;
}

.mbn-sub-close {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 50%;
    font-size: 16px;
    color: #666;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}

.mbn-sub-close:hover,
.mbn-sub-close:active {
    background: rgba(0, 0, 0, 0.08);
    color: #333;
    transform: translateY(-1px);
}

/* Sub-menu list */
.mbn-sub-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 20px 24px;
    box-sizing: border-box;
    max-width: 720px;
    margin: 0 auto;
}

/* Sub-menu items with stagger animation */
.mbn-submenu-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    text-decoration: none;
    color: var(--mbn-submenu-color, #1a1a1a);
    font-size: 14px;
    font-weight: 500;
    border: 1px solid rgba(0, 0, 0, 0.03);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
    transition: background 0.18s ease,
                border-color 0.18s ease,
                box-shadow 0.24s ease,
                opacity 0.28s ease,
                transform 0.28s ease;
    -webkit-tap-highlight-color: transparent;
    opacity: 0;
    transform: translateY(8px);
    overflow: hidden;
}

.mbn-submenu-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 16px;
    background: var(--mbn-active, #007aff);
    border-radius: 0 4px 4px 0;
    opacity: 0.85;
}

.mbn-submenu-item:visited {
    color: var(--mbn-submenu-color, #1a1a1a);
}

.mbn-submenu-item:hover,
.mbn-submenu-item:active {
    background: var(--mbn-submenu-hover, #f8f9fa);
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    transform: translateY(-2px);
}

/* Stagger in animation */
.mbn-submenu.mbn-open .mbn-submenu-item {
    opacity: 1;
    transform: translateY(0);
}

.mbn-submenu.mbn-open .mbn-submenu-item:nth-child(1) { transition-delay: 0.04s; }
.mbn-submenu.mbn-open .mbn-submenu-item:nth-child(2) { transition-delay: 0.08s; }
.mbn-submenu.mbn-open .mbn-submenu-item:nth-child(3) { transition-delay: 0.12s; }
.mbn-submenu.mbn-open .mbn-submenu-item:nth-child(4) { transition-delay: 0.16s; }
.mbn-submenu.mbn-open .mbn-submenu-item:nth-child(5) { transition-delay: 0.20s; }
.mbn-submenu.mbn-open .mbn-submenu-item:nth-child(6) { transition-delay: 0.24s; }
.mbn-submenu.mbn-open .mbn-submenu-item:nth-child(7) { transition-delay: 0.28s; }
.mbn-submenu.mbn-open .mbn-submenu-item:nth-child(8) { transition-delay: 0.32s; }

/* Closing: instant reset (no stagger) */
.mbn-submenu:not(.mbn-open) .mbn-submenu-item {
    transition-delay: 0s;
    transition-duration: 0.1s;
}

/* Sub-menu icon */
.mbn-submenu-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-size: 16px;
    color: var(--mbn-active, #007aff);
    flex-shrink: 0;
    border: none;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
}

.mbn-submenu-icon svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.mbn-submenu-label {
    flex: 1;
    min-width: 0;
    font-weight: 500;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ========================================
   Active indicator dot (optional subtle)
   ======================================== */

.mbn-item.mbn-active::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--mbn-active, #007aff);
    opacity: 0.6;
}

/* Remove dot inside safe area bar */
.mbn-bar.mbn-safe-area .mbn-item.mbn-active::after {
    bottom: 2px;
}
