/* ============================================
   CoLab - Common Styles
   共享样式：CSS变量、重置、导航栏、主题切换
============================================ */

/* ============================================
   CSS VARIABLES & THEME SYSTEM
============================================ */
:root {
    /* 主色调 */
    --primary-orange: #F26B38;
    --orange-light: #FF8C5A;
    --primary-orange-dark: #D95A2A;
    --orange-glow: rgba(242, 107, 56, 0.25);

    /* 灰色系统 */
    --deep-black: #0A0A0A;
    --charcoal: #1A1A1A;
    --dark-grey: #2D2D2D;
    --mid-grey: #6E6E6E;
    --light-grey: #DADADA;
    --ultra-light: #F2F2F2;
    --pure-white: #FFFFFF;

    /* 背景和卡片 */
    --card-bg: #FFFFFF;
    --page-bg: #F8F8F8;
    --border-color: #E5E5E5;

    /* 文本颜色 */
    --text-primary: #1A1A1A;
    --text-secondary: #4A4A4A;
    --text-muted: #8A8A8A;

    /* 阴影系统 */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.16);

    /* 过渡动画 */
    --transition-smooth: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

    /* 玻璃态效果 (轻微) */
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(0, 0, 0, 0.06);
}

/* 深色主题 */
[data-theme="dark"] {
    /* 文本颜色反转 */
    --deep-black: #FAFAFA;
    --charcoal: #E8E8E8;
    --dark-grey: #CCCCCC;
    --mid-grey: #999999;
    --light-grey: #404040;
    --ultra-light: #2A2A2A;
    --pure-white: #FAFAFA;

    /* 背景和卡片 */
    --card-bg: #1E1E1E;
    --page-bg: #121212;
    --border-color: #333333;

    /* 文本颜色 */
    --text-primary: #FFFFFF;
    --text-secondary: #B8B8B8;
    --text-muted: #6A6A6A;

    /* 阴影加深 */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.7);

    /* 玻璃态效果 (深色) */
    --glass-bg: rgba(26, 26, 26, 0.85);
    --glass-border: rgba(255, 255, 255, 0.06);
}

/* ============================================
   RESET & BASE STYLES
============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--page-bg);
    color: var(--text-primary);
    line-height: 1.7;
    overflow-x: hidden;
    transition: background 0.5s ease, color 0.5s ease;
}

h1,
h2,
h3,
h4 {
    font-family: 'Merriweather', serif;
}

/* ============================================
   NAVIGATION BAR
============================================ */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.navbar.scrolled {
    box-shadow: var(--shadow-md);
}

.nav-container {
    max-width: 1920px;
    margin: 0 auto;
    padding: 1rem 3rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: transform 0.3s ease;
}

.logo-link:hover {
    transform: scale(1.05);
}

.logo-img {
    height: 90px;
    width: auto;
    object-fit: contain;
    transition: opacity 0.3s ease;
}

.nav-menu {
    display: flex;
    gap: 3rem;
    list-style: none;
}

.nav-link {
    position: relative;
    color: var(--mid-grey);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 0;
    transition: color 0.3s ease;
}

.nav-link:hover {
    color: var(--primary-orange);
}

.nav-link.active {
    color: var(--primary-orange);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-orange), var(--orange-light));
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* ============================================
   THEME SWITCH
============================================ */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
}

.theme-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 32px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    inset: 0;
    cursor: pointer;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 34px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Slider ball with icon inside */
.slider::before {
    content: '☀️';
    position: absolute;
    height: 26px;
    width: 26px;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
}

/* Hide separate sun/moon icons - no longer needed */
.slider .sun,
.slider .moon {
    display: none;
}

/* Dark mode checked state */
.theme-switch input:checked~.slider {
    background: var(--dark-grey);
    border-color: var(--border-color);
}

.theme-switch input:checked~.slider::before {
    content: '🌙';
    transform: translateY(-50%) translateX(28px);
    background: #f0f0f0;
}

/* ============================================
   PROFILE BUTTON
============================================ */
.profile-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--mid-grey);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    padding: 0;
}

/* 未登录状态的头像按钮 */
.profile-btn.not-logged-in {
    background: linear-gradient(135deg, rgba(242, 107, 56, 0.15), rgba(242, 107, 56, 0.08));
    border-color: rgba(242, 107, 56, 0.3);
    color: var(--primary-orange);
}

.profile-btn:hover {
    transform: scale(1.1);
    border-color: var(--primary-orange);
    color: var(--primary-orange);
    box-shadow: var(--shadow-md);
}

.profile-btn-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============================================
   PROFILE DROPDOWN
============================================ */
.profile-dropdown {
    position: fixed;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    width: 240px;
    z-index: 10001;
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    visibility: hidden;
    overflow: hidden;
}

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

.profile-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(242, 107, 56, 0.1), rgba(242, 107, 56, 0.05));
    border-bottom: none;
}

.profile-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--page-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: white;
    box-shadow: 0 4px 15px rgba(242, 107, 56, 0.3);
    animation: float 3s ease-in-out infinite;
    overflow: hidden;
    border: 2px solid var(--primary-orange);
}

.profile-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-info {
    flex: 1;
}

.profile-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.profile-email {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding: 1rem;
    background: var(--page-bg);
    border-bottom: 1px solid var(--border-color);
}

.stat-item {
    text-align: center;
    padding: 0 0.25rem;
    border-right: 1px solid var(--border-color);
}

.stat-item:last-child {
    border-right: none;
}

.stat-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-orange);
    margin-bottom: 0.15rem;
    animation: countUp 1s ease-out;
}

.stat-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-menu {
    padding: 0.5rem;
}

.profile-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.2s ease;
    font-size: 0.85rem;
    position: relative;
    overflow: hidden;
}

/* 隐藏菜单项中的emoji */
.profile-menu-item .menu-icon {
    display: none;
}

.profile-menu-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(242, 107, 56, 0.1));
    transition: width 0.3s ease;
}

.profile-menu-item:hover {
    background: var(--page-bg);
    color: var(--primary-orange);
    transform: translateX(5px);
}

.profile-menu-item:hover::before {
    width: 100%;
}

.profile-menu-item.logout {
    color: #e74c3c;
}

.profile-menu-item.logout:hover {
    background: rgba(231, 76, 60, 0.1);
    color: #c0392b;
}

.profile-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   MOBILE MENU BUTTON (汉堡菜单)
============================================ */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 28px;
    color: var(--dark-grey);
    cursor: pointer;
    transition: var(--transition-smooth);
    padding: 0.5rem;
}

.mobile-menu-btn:hover {
    color: var(--primary-orange);
    transform: scale(1.1);
}

.menu-icon {
    display: block;
    line-height: 1;
}

/* ============================================
   MENU OVERLAY (菜单遮罩)
============================================ */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   COMMON BUTTON STYLES
============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-orange), var(--primary-orange-dark));
    color: white;
    box-shadow: 0 4px 16px var(--orange-glow);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(242, 107, 56, 0.4);
}

.btn-outline {
    background: transparent;
    color: var(--primary-orange);
    border: 2px solid var(--primary-orange);
}

.btn-outline:hover {
    background: var(--primary-orange);
    color: white;
    transform: translateY(-2px);
}

/* ============================================
   COACHMARK STYLES
============================================ */
.coachmark {
    position: fixed;
    z-index: 10000;
    max-width: 280px;
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.5;
    animation: cmFade 0.18s ease-out;
}

.coachmark .cm-title {
    font-weight: 800;
    margin-bottom: 4px;
}

.coachmark .cm-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    justify-content: flex-end;
}

.coachmark .cm-btn {
    appearance: none;
    border: none;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    transition: var(--transition-smooth);
}

.coachmark .cm-btn.primary {
    background: var(--primary-orange);
    color: #fff;
}

.coachmark .cm-btn.primary:hover {
    background: var(--primary-orange-dark);
    transform: scale(1.05);
}

.coachmark .cm-btn.ghost {
    background: var(--ultra-light);
    color: var(--text-secondary);
}

.coachmark .cm-btn.ghost:hover {
    background: var(--light-grey);
}

@keyframes cmFade {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.coachmark::before {
    content: '';
    position: absolute;
    top: -10px;
    left: var(--arrow-left, 50%);
    transform: translateX(-50%);
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid var(--card-bg);
    filter: drop-shadow(0 -1px 0 rgba(0, 0, 0, 0.06));
}

/* ============================================
   RESPONSIVE DESIGN - TABLET
============================================ */
@media (max-width: 1199px) {
    .nav-container {
        padding: 1rem 2rem;
    }

    .nav-menu {
        gap: 2rem;
    }
}

/* ============================================
   RESPONSIVE DESIGN - MOBILE
============================================ */
@media (max-width: 767px) {
    .navbar {
        height: 60px;
    }

    .nav-container {
        padding: 0.75rem 1.5rem;
    }

    .logo-img {
        height: 50px;
    }

    /* 显示汉堡菜单按钮 */
    .mobile-menu-btn {
        display: block;
        order: -1;
        margin-right: auto;
    }

    /* 移动端菜单样式 */
    .nav-menu {
        position: fixed;
        top: 60px;
        left: 0;
        width: 100%;
        flex-direction: column;
        background: rgba(255, 255, 255, 1);
        padding: 1.5rem;
        gap: 0;
        border-bottom: 1px solid var(--border-color);
        box-shadow: var(--shadow-lg);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        z-index: 9998;
    }

    [data-theme="dark"] .nav-menu {
        background: rgba(20, 20, 20, 1);
    }

    .nav-menu.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }

    .nav-menu li {
        width: 100%;
    }

    .nav-link {
        display: block;
        padding: 1rem;
        border-radius: 8px;
        text-align: center;
    }

    .nav-link::after {
        display: none;
    }

    .nav-link:hover,
    .nav-link.active {
        background: var(--page-bg);
    }
}

@media (max-width: 480px) {
    .nav-container {
        padding: 0.5rem 1rem;
    }

    .logo-img {
        height: 35px;
    }

    .nav-right {
        gap: 0.75rem;
    }

    .theme-switch {
        width: 50px;
        height: 28px;
    }

    .slider::before {
        height: 20px;
        width: 20px;
        left: 2px;
    }

    .theme-switch input:checked~.slider::before {
        transform: translateY(-50%) translateX(20px);
    }

    .profile-btn {
        width: 38px;
        height: 38px;
    }
}

/* ============================================
   MOBILE OPTIMIZATION - AVATAR PAGES
   ============================================ */
@media (max-width: 767px) {
    /* Tag items - reduce font and padding for mobile */
    .tag-item {
        font-size: 12px;
        padding: calc(var(--chip-pad-y) * 0.5) calc(var(--chip-pad-x) * 0.25);
    }
    
    /* Buttons - reduce font size and padding */
    .btn {
        padding: 0.6rem 0.9rem;
        font-size: 13px;
        white-space: normal;
    }
    
    /* Uploader text - reduce font size */
    .uploader .title {
        font-size: 13px;
        font-weight: 700;
    }
    
    .uploader .hint {
        font-size: 11px;
    }
}