/* ==========================================
   复盘啦 - 现代UI设计系统
   Version: 2.0
   ========================================== */

/* CSS变量 - 设计令牌 */
:root {
    /* 主色调 - 蓝色系 */
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --primary-200: #bfdbfe;
    --primary-300: #93c5fd;
    --primary-400: #60a5fa;
    --primary-500: #3b82f6;
    --primary-600: #2563eb;
    --primary-700: #1d4ed8;
    
    /* 中性色 */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* 功能色 */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    /* 股票涨跌色 */
    --stock-up: #ef4444;
    --stock-down: #22c55e;
    --stock-flat: #6b7280;
    
    /* 布局 */
    --sidebar-width: 220px;
    --sidebar-collapsed-width: 64px;
    --topbar-height: 56px;
    
    /* 圆角 */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    /* 阴影 */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* 过渡 */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* 重置样式 */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 
                 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.5;
    overflow: hidden;
}

/* ==========================================
   顶栏
   ========================================== */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: #ffffff;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-toggle {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--gray-600);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.system-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
}

.system-title i {
    color: var(--primary-500);
    font-size: 22px;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.top-notice {
    font-size: 13px;
    color: var(--gray-500);
}

.app-shell .topbar-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--ui-text-muted);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: color var(--transition-fast), background-color var(--transition-fast);
}

.app-shell .topbar-action-btn:hover {
    color: var(--ui-accent-strong);
    background: var(--ui-accent-soft);
}

.app-shell .topbar-action-btn:focus-visible {
    outline: 3px solid var(--ui-focus);
    outline-offset: 2px;
}

/* 访客快捷注册/登录入口 */
.guest-auth-entry {
    display: flex;
    align-items: center;
    gap: 8px;
}

.guest-auth-btn {
    display: inline-block;
    padding: 5px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    color: var(--primary-color, #2563eb);
    border: 1px solid rgba(37, 99, 235, 0.35);
    background: #fff;
    transition: all 0.2s;
    white-space: nowrap;
}

.guest-auth-btn:hover {
    background: rgba(37, 99, 235, 0.06);
}

.guest-auth-btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.25);
}

.guest-auth-btn-primary:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
}

/* 用户信息 */
.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
}

.user-menu {
    position: relative;
}

.user-avatar {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-500);
    border: none;
    border-radius: var(--radius-full);
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: all var(--transition-fast);
}

.user-avatar:hover {
    background: var(--primary-600);
    transform: scale(1.05);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--gray-50);
}

.dropdown-item i {
    color: var(--gray-500);
    width: 16px;
}

.dropdown-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 4px 0;
}

/* ==========================================
   VIP状态展示
   ========================================== */

/* VIP内联标记（顶栏用户名称左侧） */
.vip-inline-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.vip-inline-icon {
    font-size: 13px;
    line-height: 1;
}

.vip-inline-label {
    font-size: 12px;
}

.vip-inline-expiry {
    font-size: 11px;
    font-weight: 500;
}

.vip-inline-badge.vip-inline-permanent {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border: 1px solid #6ee7b7;
    color: #059669;
}

.vip-inline-badge.vip-inline-active {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #fbbf24;
    color: #b45309;
}

.vip-inline-badge.vip-inline-trial {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    border: 1px solid #a5b4fc;
    color: #4338ca;
}

.vip-inline-badge.vip-inline-expiring {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border: 1px solid #f87171;
    color: #dc2626;
    animation: border-pulse 2s ease-in-out infinite;
}

/* 下拉式VIP区域（保留以备后续使用） */
.vip-info-section {
    padding: 12px 16px;
    margin: 0;
    border-radius: var(--radius-md);
    margin: 8px;
    transition: all var(--transition-normal);
}

.vip-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 13px;
}

.vip-icon {
    font-size: 16px;
    line-height: 1;
}

.vip-label {
    font-size: 13px;
    letter-spacing: 0.3px;
}

.vip-expiry {
    margin-top: 6px;
    font-size: 11px;
    line-height: 1.4;
}

.expiry-warning {
    color: #dc2626;
    font-weight: 600;
    animation: pulse 2s ease-in-out infinite;
}

.days-remaining {
    color: #f59e0b;
    font-weight: 500;
}

.vip-permanent-text {
    color: #10b981;
    font-weight: 600;
}

/* VIP状态样式 */
.vip-active-status {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #fbbf24;
}

.vip-active-status .vip-label {
    color: #b45309;
}

.vip-trial-status {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    border: 1px solid #a5b4fc;
}

.vip-trial-status .vip-label {
    color: #4338ca;
}

.vip-expiring-status {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border: 1px solid #f87171;
    animation: border-pulse 2s ease-in-out infinite;
}

.vip-permanent-status {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border: 1px solid #6ee7b7;
}

.vip-permanent-status .vip-label {
    color: #059669;
}

/* 动画效果 */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@keyframes border-pulse {
    0%, 100% {
        border-color: #f87171;
    }
    50% {
        border-color: #ef4444;
    }
}
.dropdown-item:hover {
    background: var(--gray-50);
}

.dropdown-item:first-child {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.dropdown-item i {
    width: 18px;
    color: var(--gray-500);
}

.dropdown-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 4px 0;
}

/* ==========================================
   主容器
   ========================================== */
.main-container {
    display: flex;
    margin-top: var(--topbar-height);
    height: calc(100vh - var(--topbar-height));
}

/* ==========================================
   侧边栏
   ========================================== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #f0f7ff 0%, #e8f4fd 100%);
    border-right: 1px solid var(--primary-100);
    transition: all var(--transition-slow);
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: 0;
    border-right: none;
}

.sidebar-content {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
}

/* 自定义滚动条 */
.sidebar-content::-webkit-scrollbar {
    width: 4px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--primary-200);
    border-radius: 2px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: var(--primary-300);
}

/* 导航菜单 */
.nav-menu {
    padding: 0 8px;
}

/* 主框架侧边栏采用纯文字导航，禁止图标占用视觉注意力或布局空间。 */
.sidebar i,
.sidebar svg,
.sidebar img {
    display: none !important;
}

.nav-group {
    margin-bottom: 6px;
}

.nav-group-header {
    display: flex;
    align-items: center;
    padding: 12px 12px 6px;
    color: var(--gray-600);
    font-size: 14px;
    font-weight: 700;
    line-height: 20px;
    letter-spacing: 0.1px;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.nav-group-header:hover {
    background: rgba(59, 130, 246, 0.08);
    color: var(--primary-600);
}

.nav-group-header i:first-child {
    width: 20px;
    margin-right: 10px;
    font-size: 14px;
}

.nav-arrow {
    margin-left: auto;
    font-size: 10px;
    transition: transform var(--transition-fast);
}

.nav-group.collapsed .nav-arrow {
    transform: rotate(-90deg);
}

.nav-text {
    white-space: nowrap;
    overflow: hidden;
}

.nav-group-items {
    overflow: hidden;
    transition: max-height var(--transition-slow);
}

.nav-group.collapsed .nav-group-items {
    max-height: 0 !important;
    display: none;
}

/* 导航项 */
.nav-item {
    display: flex;
    align-items: center;
    padding: 8px 12px 8px 28px;
    margin: 1px 0;
    color: var(--gray-700);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    line-height: 20px;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    position: relative;
}

.nav-item:hover {
    background: rgba(59, 130, 246, 0.08);
    color: var(--primary-600);
}

.nav-item.active {
    background: var(--primary-500);
    color: white;
    font-weight: 600;
}

.nav-item.active::before {
    display: none;
}

.nav-item.active:hover {
    background: var(--primary-600);
    color: white;
}

.nav-item i {
    width: 18px;
    margin-right: 10px;
    font-size: 14px;
    text-align: center;
}

/* 工具提示（默认隐藏） */
.nav-tooltip {
    display: none;
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 10px;
    padding: 6px 12px;
    background: var(--gray-800);
    color: white;
    font-size: 12px;
    border-radius: var(--radius-md);
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
}

.sidebar.collapsed .nav-item:hover .nav-tooltip {
    display: block;
}

/* ==========================================
   内容区域
   ========================================== */
.content-area {
    flex: 1;
    position: relative;
    background: white;
    overflow: hidden;
}

.iframe-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

#contentFrame {
    width: 100%;
    height: 100%;
    border: none;
}

/* 加载指示器 */
.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.loading-spinner {
    font-size: 32px;
    color: var(--primary-500);
    margin-bottom: 12px;
}

.loading-text {
    font-size: 14px;
    color: var(--gray-500);
}

/* 错误显示 */
.error-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    padding: 40px;
}

.error-icon {
    font-size: 48px;
    color: var(--danger);
    margin-bottom: 16px;
}

.error-message {
    font-size: 14px;
    color: var(--gray-600);
    margin-bottom: 20px;
}

.retry-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--primary-500);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.retry-button:hover {
    background: var(--primary-600);
}

/* ==========================================
   响应式设计
   ========================================== */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: var(--topbar-height);
        height: calc(100vh - var(--topbar-height));
        z-index: 999;
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }
    
    .sidebar.show {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.collapsed {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }
}

@media (max-width: 768px) {
    .top-notice {
        display: none;
    }
    
    .user-name {
        display: none;
    }
    
    .system-title span {
        display: none;
    }
}

@media (max-width: 480px) {
    .top-bar {
        padding: 0 12px;
    }
    
}

.topbar-mobile-more,
.mobile-account-details,
.sidebar-mobile-header,
.sidebar-backdrop {
    display: none;
}

/* ==========================================
   动画
   ========================================== */
@media (max-width: 1024px) {
    /* 顶栏和 iframe 共享同一视口布局，避免 Safari 将页面留白滚到固定顶栏下。 */
    body.app-shell {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .app-shell .top-bar {
        position: relative;
        inset: auto;
        flex: 0 0 auto;
        height: auto;
        min-height: var(--topbar-height);
        flex-wrap: nowrap;
        gap: 6px;
        padding: 6px 10px;
    }

    .app-shell .top-bar-right {
        min-width: 0;
        flex: 0 0 auto;
        flex-wrap: nowrap;
        gap: 6px;
        margin-left: auto;
    }

    .app-shell .top-bar-left {
        flex: 0 0 auto;
        gap: 6px;
    }

    .app-shell .system-title span,
    .app-shell .top-bar-right > .topbar-action-btn,
    .app-shell .user-name,
    .app-shell .vip-inline-badge,
    .app-shell.is-guest .user-info {
        display: none !important;
    }

    .app-shell .sidebar-toggle {
        width: 40px;
        height: 44px;
    }

    .app-shell .guest-auth-btn {
        padding: 10px 12px;
    }

    .app-shell .topbar-mobile-more {
        display: block;
        position: relative;
    }

    .app-shell .topbar-mobile-more > summary {
        display: flex;
        min-width: 44px;
        min-height: 44px;
        padding: 0 4px;
        list-style: none;
    }

    .topbar-mobile-more > summary::-webkit-details-marker {
        display: none;
    }

    .topbar-mobile-menu {
        position: absolute;
        top: calc(100% + 6px);
        right: 0;
        width: 152px;
        padding: 4px;
        border: 1px solid var(--ui-border);
        border-radius: 8px;
        background: var(--ui-surface-raised);
        box-shadow: var(--ui-shadow-sm);
    }

    .topbar-mobile-menu button,
    .sidebar-mobile-header button {
        min-height: 44px;
        border: 0;
        border-radius: 6px;
        background: transparent;
        color: var(--ui-text);
        font: inherit;
        cursor: pointer;
    }

    .topbar-mobile-menu button {
        display: block;
        width: 100%;
        padding: 0 12px;
        text-align: left;
    }

    .topbar-mobile-menu button:hover,
    .sidebar-mobile-header button:hover {
        background: var(--ui-surface-muted);
    }

    .topbar-mobile-menu button:focus-visible,
    .sidebar-mobile-header button:focus-visible {
        outline: 2px solid var(--ui-accent);
        outline-offset: -2px;
    }

    .app-shell .mobile-account-details {
        display: block;
        padding: 12px 16px;
        border-bottom: 1px solid var(--ui-border);
        color: var(--ui-text-muted);
        white-space: pre-line;
        overflow-wrap: anywhere;
    }

    .app-shell .main-container {
        position: relative;
        flex: 1 1 0;
        min-width: 0;
        min-height: 0;
        height: auto;
        margin-top: 0;
    }

    .app-shell .sidebar {
        position: absolute;
        top: 0;
        bottom: 0;
        height: auto;
        width: min(280px, 82%);
        display: flex;
        flex-direction: column;
        transition: transform 200ms ease;
    }

    .app-shell .sidebar-content {
        flex: 1;
        min-height: 0;
        height: auto;
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
    }

    .app-shell .sidebar-mobile-header {
        display: flex;
        flex: 0 0 auto;
        justify-content: space-between;
        align-items: center;
        padding: 4px 16px;
        border-bottom: 1px solid var(--ui-border);
        color: var(--ui-text-muted);
    }

    .sidebar-mobile-header button {
        padding: 0 12px;
        color: var(--ui-accent);
    }

    .app-shell .sidebar-backdrop:not([hidden]) {
        display: block;
        position: absolute;
        inset: 0;
        z-index: 998;
        border: 0;
        padding: 0;
        background: var(--ui-overlay);
        touch-action: manipulation;
    }

    .app-shell .content-area {
        min-width: 0;
        min-height: 0;
    }

    .app-shell #contentFrame {
        display: block;
        min-width: 0;
        min-height: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-shell .sidebar { transition: none; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.fade-in {
    animation: fadeIn var(--transition-normal);
}

.slide-in {
    animation: slideIn var(--transition-normal);
}

/* ==========================================
   模态框
   ========================================== */
.modal-backdrop {
    z-index: 1050 !important;
}

.modal {
    z-index: 1055 !important;
}

/* ==========================================
   辅助类
   ========================================== */
.text-up { color: var(--stock-up) !important; }
.text-down { color: var(--stock-down) !important; }
.text-flat { color: var(--stock-flat) !important; }
.text-primary { color: var(--primary-500) !important; }
.text-muted { color: var(--gray-500) !important; }

.bg-up { background-color: rgba(239, 68, 68, 0.1) !important; }
.bg-down { background-color: rgba(34, 197, 94, 0.1) !important; }

/* ==========================================
   VIP锁定图标
   ========================================== */
.vip-lock-icon {
    margin-left: 6px;
    color: #f59e0b;
    font-size: 12px;
    animation: lockPulse 2s ease-in-out infinite;
}

.vip-lock-icon i {
    display: inline-block;
}

.vip-lock-icon[title]:hover::after {
    content: attr(title);
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    margin-top: 4px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
}

/* 无权限用户的VIP菜单项样式 */
.nav-item.vip-locked {
    opacity: 0.7;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.05) 0%, rgba(245, 158, 11, 0.02) 100%);
}

.nav-item.vip-locked:hover {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(245, 158, 11, 0.05) 100%);
}

@keyframes lockPulse {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
}
