/* =========================================================================
 * StarSail 统一顶部导航栏
 * 由 static/js/navbar.js 注入到 #app-navbar-mount 挂载点
 * 适配三页：starsea / chat / my
 * 设计 token 与 starsea.css / my.css 现有 token 对齐
 * ========================================================================= */

:root {
    --nav-bg: rgba(6, 9, 26, 0.65);
    --nav-border: rgba(255, 255, 255, 0.08);
    --nav-blur: saturate(140%) blur(16px);
    --nav-height: 64px;
    --nav-radius: 999px;
    --tab-active-bg: linear-gradient(135deg, #c9a96e 0%, #e8d5a8 100%);
    --tab-active-text: #1a1a2e;
    --tab-text: rgba(255, 255, 255, 0.75);
    --tab-hover-bg: rgba(255, 255, 255, 0.06);
    --brand-cyan: #4fc3f7;
}


/* ---- 容器 ---- */

.app-navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--nav-bg);
    backdrop-filter: var(--nav-blur);
    -webkit-backdrop-filter: var(--nav-blur);
    border-bottom: 1px solid var(--nav-border);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 6px 24px rgba(0, 0, 0, 0.25);
}

.app-navbar-inner {
    max-width: 1280px;
    margin: 0 auto;
    height: var(--nav-height);
    padding: 0 24px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 24px;
}


/* ---- 品牌区 ---- */

.app-nav-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    flex-shrink: 0;
}

.app-nav-brand .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(79, 195, 247, 0.18) 0%, rgba(201, 169, 110, 0.18) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--brand-cyan);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.app-nav-brand:hover .brand-mark {
    transform: rotate(-8deg);
    box-shadow: 0 0 16px rgba(79, 195, 247, 0.35);
}

.app-nav-brand .brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.app-nav-brand .brand-text b {
    font-family: 'Cormorant Garamond', 'Outfit', serif;
    font-size: 20px;
    font-weight: 600;
    color: #f3eada;
    letter-spacing: 0.5px;
}

.app-nav-brand .brand-text i {
    font-style: normal;
    font-family: 'Outfit', sans-serif;
    font-size: 10px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 2px;
    margin-top: 2px;
}


/* ---- Tab 导航胶囊 ---- */

.app-nav-tabs {
    display: flex;
    gap: 4px;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--nav-border);
    border-radius: var(--nav-radius);
    padding: 4px;
    width: fit-content;
    margin: 0 auto;
}

.app-nav-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--nav-radius);
    color: var(--tab-text);
    text-decoration: none;
    font-family: 'Outfit', 'PingFang SC', sans-serif;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.3px;
    transition: color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
}

.app-nav-tab i {
    font-style: normal;
    font-size: 15px;
    line-height: 1;
}

.app-nav-tab:hover {
    color: #fff;
    background: var(--tab-hover-bg);
}

.app-nav-tab.active {
    color: var(--tab-active-text);
    background: var(--tab-active-bg);
    box-shadow: 0 4px 16px rgba(201, 169, 110, 0.3), 0 0 0 1px rgba(201, 169, 110, 0.4) inset;
    font-weight: 600;
}

.app-nav-tab.active i {
    filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.15));
}


/* ---- 用户区 ---- */

.app-nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    justify-self: end;
}

.app-nav-user .user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 14px 4px 4px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--nav-border);
    border-radius: 999px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
    user-select: none;
}

.app-nav-user .user-chip:hover {
    border-color: var(--brand-cyan);
    background: rgba(79, 195, 247, 0.08);
    transform: translateY(-1px);
}

.app-nav-user .user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-cyan) 0%, #29b6f6 100%);
    color: #0a1426;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.app-nav-user .user-avatar .user-avatar-initial {
    line-height: 1;
}

.app-nav-user .user-avatar .user-avatar-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.app-nav-user .user-name {
    font-family: 'Outfit', 'PingFang SC', sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: #f3eada;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-nav-user .logout-btn {
    background: transparent;
    border: 1px solid var(--nav-border);
    color: rgba(255, 255, 255, 0.65);
    font-family: 'Outfit', 'PingFang SC', sans-serif;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.app-nav-user .logout-btn:hover {
    border-color: #ff6f7d;
    color: #ff6f7d;
    background: rgba(255, 111, 125, 0.08);
}


/* =========================================================================
 * 响应式
 * ========================================================================= */

@media (max-width: 960px) {
    .app-navbar-inner {
        gap: 12px;
        padding: 0 16px;
    }
    .app-nav-tab {
        padding: 7px 12px;
        font-size: 13px;
    }
}

@media (max-width: 720px) {
    .app-nav-brand .brand-text {
        display: none;
    }
    .app-nav-tab span {
        display: none;
    }
    .app-nav-tab {
        padding: 8px 10px;
    }
    .app-nav-tab i {
        font-size: 17px;
    }
    .app-nav-user .user-name {
        max-width: 60px;
    }
    .app-nav-user .logout-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .app-nav-user .user-name {
        display: none;
    }
    .app-nav-user .user-chip {
        padding: 3px;
    }
}


/* =========================================================================
 * chat 页面状态条（替代原 chat-header 内的连接状态指示器）
 * 仅在 chat.html 使用
 * ========================================================================= */

.chat-status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    font-family: 'Outfit', 'PingFang SC', sans-serif;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(8, 12, 24, 0.45);
    border-bottom: 1px solid var(--nav-border);
}

.chat-status-bar .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
    display: inline-block;
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.6);
    animation: chat-status-pulse 2s infinite;
}

.chat-status-bar .status-dot.disconnected {
    background: #ef5350;
    animation: none;
}

@keyframes chat-status-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.5);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(76, 175, 80, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}