/*
 * Agent 商城 —— 顶部导航栏样式（参考 temp TopBar）
 * 主题色：经典蓝 #3b82f6
 */

:root {
    --brand: #3b82f6;
    --brand-strong: #1d4ed8;
    --brand-dark: #1e40af;
    --brand-soft: #dbeafe;
    --brand-light: #60a5fa;
    --brand-grad: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%);
    --ring: rgba(59, 130, 246, 0.14);
    --btn-glow: rgba(59, 130, 246, 0.28);
    --line-glow: rgba(59, 130, 246, 0.45);

    --bg: #f7f9f8;
    --surface: #ffffff;
    --surface-soft: #f1f5f4;
    --ink: #0f172a;
    --ink-2: #334155;
    --text: #64748b;
    --muted: #94a3b8;
    --line: #e2e8f0;
    --line-soft: #f1f5f9;

    --radius: 10px;
    --radius-lg: 14px;
    --shadow: 0 4px 12px rgba(15, 23, 42, 0.07);
    --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.12);
    --font: Inter, "PingFang SC", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    height: 100%;
    overflow: hidden;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

input {
    font-family: inherit;
    color: var(--ink);
}

/* ========== 顶栏 ========== */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
    height: 62px;
}

.topbar-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    height: 62px;
    display: flex;
    align-items: center;
    gap: 26px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    cursor: pointer;
    flex-shrink: 0;
}

.brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--brand-grad);
    color: #fff;
    font-weight: 800;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 10px var(--btn-glow);
    flex-shrink: 0;
}

.brand-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.2px;
    line-height: 1.2;
}

.brand-sub {
    font-size: 9.5px;
    color: var(--muted);
    letter-spacing: 2.4px;
    font-weight: 600;
    margin-top: 1px;
    line-height: 1.2;
}

.topnav {
    display: flex;
    gap: 2px;
    height: 62px;
    flex-shrink: 0;
}

.topnav-item {
    position: relative;
    padding: 0 15px;
    display: flex;
    align-items: center;
    font-size: 13.5px;
    color: var(--text);
    background: transparent;
    border: none;
    outline: none;
    border-radius: 0;
    box-shadow: none;
    text-decoration: none;
    transition: color 0.18s;
}

.topnav-item:hover {
    color: var(--brand-strong);
    background: transparent;
    box-shadow: none;
}

.topnav-item:focus,
.topnav-item:focus-visible {
    outline: none;
    box-shadow: none;
}

.topnav-item.active {
    color: var(--brand-strong);
    font-weight: 600;
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
}

.topnav-item.active::after {
    content: "";
    position: absolute;
    left: 15px;
    right: 15px;
    bottom: 0;
    height: 2px;
    border-radius: 2px 2px 0 0;
    background: linear-gradient(90deg, var(--brand) 0%, var(--brand-light) 72%, transparent 100%);
}

.topbar-search {
    flex: 1;
    max-width: 320px;
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0 5px 0 15px;
    height: 36px;
    transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

.topbar-search:focus-within {
    border-color: var(--brand);
    background: #fff;
    box-shadow: 0 0 0 3px var(--ring);
}

.topbar-search input {
    flex: 1;
    border: none;
    outline: none;
    background: none;
    font-size: 13px;
    color: var(--ink);
    min-width: 0;
}

.topbar-search input::placeholder {
    color: var(--muted);
}

.topbar-search .search-btn {
    width: 44px;
    height: 26px;
    border-radius: 999px;
    background: var(--brand-grad);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.18s;
    flex-shrink: 0;
}

.topbar-search .search-btn:hover {
    opacity: 0.9;
}

/* ========== 用户入口 ========== */
.user-entry {
    position: relative;
    flex-shrink: 0;
}

.user-avatar-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--brand-grad);
    color: #fff;
    font-weight: 800;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(30, 64, 175, 0.25);
    overflow: hidden;
    padding: 0;
}

.user-avatar-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-popover {
    position: absolute;
    top: 46px;
    right: 0;
    width: 272px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 200;
    display: none;
}

.user-entry.is-open .user-popover {
    display: block;
    animation: pop-in 0.18s ease;
}

/* 原项目用户弹窗已弃用（保留代码但永不显示），统一使用 temp 版弹窗 */
.legacy-popover {
    display: none !important;
}

/* 未登录也允许弹出用户浮窗（与 temp 原型一致），登录态差异由 JS 控制内容 */

@keyframes pop-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.user-popover-header {
    background: var(--brand-grad);
    padding: 20px 16px;
    text-align: center;
    color: #fff;
}

.user-popover-avatar {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    margin: 0 auto 10px;
    background: rgba(255, 255, 255, 0.18);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-popover-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-popover-name {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-popover-email {
    font-size: 12px;
    opacity: 0.78;
    margin-top: 2px;
    word-break: break-all;
}

.user-popover-menu {
    padding: 6px;
}

.user-popover-menu button {
    width: 100%;
    text-align: left;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--ink-2);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.14s, color 0.14s;
}

.user-popover-menu button:hover {
    background: var(--brand-soft);
    color: var(--brand-strong);
}

.user-popover-menu button.danger {
    color: #ef4444;
}

.user-popover-menu button.danger:hover {
    background: #fee2e2;
}

/* 未登录时隐藏「退出登录」（与 temp 原型一致） */
.user-entry[data-auth-state="guest"] .user-popover-menu button.danger {
    display: none;
}

.user-popover-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--line-soft);
    display: flex;
    gap: 8px;
}

.user-popover-footer button {
    flex: 1;
    height: 32px;
    border-radius: 8px;
    font-size: 12px;
    border: 1px solid var(--line);
    color: var(--text);
    background: var(--surface);
}

.user-popover-footer button.primary {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

/* ========== 主内容区与页脚 ========== */
.topbar-main {
    position: fixed;
    top: 62px;
    left: 0;
    right: 0;
    bottom: 48px;
    background: var(--bg);
}

.topbar-main iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.app-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 48px;
    border-top: 1px solid var(--line);
    background: var(--surface);
    padding: 0 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--muted);
    flex-wrap: wrap;
}

.footer-divider {
    color: var(--line);
}

.app-footer .icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ========== 响应式 ========== */
@media (max-width: 1024px) {
    .topbar-inner {
        gap: 14px;
        padding: 0 16px;
    }

    .brand-sub {
        display: none;
    }

    .topbar-search {
        max-width: 200px;
    }

    .topnav-item {
        padding: 0 10px;
        font-size: 13px;
    }

    .topnav-item.active::after {
        left: 10px;
        right: 10px;
    }
}

@media (max-width: 768px) {
    .topbar {
        height: auto;
    }

    .topbar-inner {
        height: auto;
        flex-wrap: wrap;
        padding: 10px 16px;
    }

    .topbar-search {
        flex: 1 1 auto;
        max-width: none;
    }

    .user-entry {
        flex-shrink: 0;
    }

    .topnav {
        width: 100%;
        height: 44px;
        order: 3;
        justify-content: center;
    }

    .topbar-main {
        top: 110px;
    }

    .app-footer {
        height: auto;
        padding: 8px 16px;
    }
}
