/* ========================================
   Common Styles - 知识分享站
   ======================================== */

/* CSS Variables */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --light-bg: #f8f9fa;
    --dark-bg: #1a252f;
    --text-color: #333;
    --text-light: #666;
    --border-color: #eee;
    --article-bg: #fff;
    --toc-width: 280px;
}

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    color: var(--text-color);
    line-height: 1.6;
    background-color: #fff;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ========================================
   Navigation Bar - 导航栏
   ======================================== */
.navbar {
    background: var(--primary-color);
    color: white;
    padding: 1rem 5%;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    width: 100%;
    flex-wrap: nowrap;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.nav-links a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
    padding: 0.5rem 0;
    white-space: nowrap;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--secondary-color);
}

/* Auth Section - Login/User on right */
.auth-section {
    display: flex;
    align-items: center;
}

@media (min-width: 1201px) {
    .mobile-nav-auth,
    .mobile-user-menu {
        display: none !important;
    }
}

/* Auth Module - Search + User combined */
.auth-module {
    display: flex;
    align-items: center;
    margin-left: auto;
    gap: 20px;
}

.search-box {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 0.5rem 1rem;
}

#authButtons.auth-section {
    padding-left: 1rem;
}

.user-dropdown.auth-section {
    padding-left: 0;
}

/* Dropdown Menu */
.dropdown {
    position: relative;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.dropdown-toggle::after {
    content: '▼';
    font-size: 0.7rem;
    margin-left: 0.3rem;
}

.dropdown-content {
    display: none;
    position: absolute;
    background: white;
    min-width: 200px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    border-radius: 8px;
    top: 100%;
    left: 0;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.dropdown:hover .dropdown-content {
    display: block;
}

.dropdown-content a {
    color: var(--text-color);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.3s;
    border-bottom: 1px solid #f0f0f0;
}

.dropdown-content a:last-child {
    border-bottom: none;
}

.dropdown-content a:hover {
    background: var(--light-bg);
    color: var(--secondary-color);
}

.dropdown-content .topic-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

/* Search Box */
.search-box {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 0.5rem 1rem;
}

.search-box input {
    background: transparent;
    border: none;
    color: white;
    outline: none;
    width: 150px;
    font-size: 0.9rem;
}

.search-box input::placeholder {
    color: rgba(255,255,255,0.7);
}

.search-box button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
}

/* Login Button */
.nav-login-btn {
    background: var(--secondary-color);
    color: white !important;
    padding: 0.5rem 1.25rem !important;
    border-radius: 20px;
    font-weight: 500;
    transition: all 0.3s;
}

.nav-login-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

/* ========================================
   Breadcrumb - 面包屑
   ======================================== */
.breadcrumb {
    background: white;
    padding: 1rem 5%;
    border-bottom: 1px solid var(--border-color);
}

.breadcrumb-container,
.breadcrumb-content {
    max-width: 1400px;
    margin: 0 auto;
    font-size: 0.9rem;
    color: var(--text-light);
}

.breadcrumb a {
    color: var(--text-light);
    text-decoration: none;
    transition: color 0.3s;
}

.breadcrumb a:hover {
    color: var(--secondary-color);
}

/* ========================================
   Footer - 页脚
   ======================================== */
.footer {
    background: var(--dark-bg);
    color: rgba(255,255,255,0.8);
    padding: 4rem 5% 2rem;
    margin-top: 4rem;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 3rem;
}

.footer-section h3 {
    color: white;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

.footer-center {
    grid-column: 1 / -1;
    text-align: center;
}

.footer-center h3 {
    font-size: 1.3rem;
}

.footer-center p {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: 0.75rem;
}

.footer-links a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: color 0.3s;
}

.footer-links a:hover {
    color: white;
}

.footer-bottom {
    max-width: 1400px;
    margin: 3rem auto 0;
    padding-top: 2rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    text-align: center;
    font-size: 0.9rem;
    color: rgba(255,255,255,0.6);
}

.footer-bottom a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
}

/* ========================================
   Login Modal - 登录模态框
   ======================================== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.modal-container {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 420px;
    margin: 1rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    transform: translateY(-20px);
    transition: transform 0.3s;
    overflow: hidden;
}

.modal-overlay.show .modal-container {
    transform: translateY(0);
}

.modal-header {
    background: linear-gradient(135deg, var(--primary-color), #1a252f);
    color: white;
    padding: 1.5rem;
    text-align: center;
    position: relative;
}

.modal-header h2 {
    font-size: 1.35rem;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.modal-close {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.25rem;
    transition: all 0.3s;
}

.modal-close:hover {
    background: rgba(255,255,255,0.3);
}

.modal-body {
    padding: 2rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s;
    outline: none;
}

.form-group input:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group input::placeholder {
    color: #aaa;
}

.form-group.input-with-icon {
    position: relative;
}

.form-group.input-with-icon i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
}

.form-group.input-with-icon input {
    padding-left: 2.75rem;
}

.login-btn {
    width: 100%;
    padding: 0.9rem;
    background: linear-gradient(135deg, var(--secondary-color), #2980b9);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(52, 152, 219, 0.3);
}

.modal-footer {
    text-align: center;
    padding: 0 2rem 1.5rem;
    color: var(--text-light);
    font-size: 0.85rem;
}

.modal-footer a {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 500;
}

/* ========================================
    Responsive - 响应式设计
     ======================================== */
@media (max-width: 1200px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--primary-color);
        flex-direction: column;
        padding: 1rem;
        gap: 0.5rem;
        transform: none;
        z-index: 999;
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links .dropdown {
        width: 100%;
    }

    .nav-links .dropdown-content {
        position: static;
        box-shadow: none;
        background: rgba(255,255,255,0.1);
        border-radius: 8px;
        margin-top: 0.5rem;
    }

    .nav-links .dropdown-content a {
        color: rgba(255,255,255,0.9);
        padding: 0.75rem 1rem;
    }

    .mobile-menu-btn {
        display: block;
        order: 3;
    }

    .search-box {
        display: none !important;
    }

    .auth-module {
        display: none !important;
    }

    .mobile-nav-auth {
        display: none;
        padding: 1rem;
    }

    .mobile-nav-auth .nav-login-btn {
        display: inline-flex;
        width: 100%;
        justify-content: center;
        box-sizing: border-box;
    }

    .logo {
        font-size: 1.2rem;
        order: 1;
    }

    .mobile-nav-auth {
        display: none;
        padding: 1rem;
    }

    .mobile-nav-auth .nav-login-btn {
        display: inline-flex;
        width: 100%;
        justify-content: center;
        box-sizing: border-box;
    }

    .mobile-user-menu {
        display: none;
        padding: 1rem;
    }

        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.75rem;
        background: rgba(255,255,255,0.1);
        border-radius: 8px;
        cursor: pointer;
        color: white;
    }

    .mobile-user-item .user-avatar {
        width: 36px;
        height: 36px;
    }

    .mobile-user-item .dropdown-arrow {
        margin-left: auto;
        transition: transform 0.3s;
    }

    .mobile-user-item .dropdown-arrow.rotated {
        transform: rotate(180deg);
    }

    .mobile-user-dropdown {
        display: none;
        margin-top: 0.5rem;
        padding: 0.5rem;
        background: rgba(255,255,255,0.95);
        border-radius: 8px;
    }

    .mobile-user-dropdown.show {
        display: block;
    }

    .mobile-user-info {
        padding: 0.5rem;
        color: #333;
    }

    .mobile-user-id {
        font-size: 0.85rem;
        color: #666;
    }

    .mobile-dropdown-item {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.75rem;
        color: #333;
        text-decoration: none;
        border-radius: 6px;
        transition: background 0.2s;
    }

    .mobile-dropdown-item:hover {
        background: #f5f5f5;
    }

    .dropdown-divider {
        height: 1px;
        background: #e0e0e0;
        margin: 0.5rem 0;
    }

    .logout-item {
        color: #dc3545;
    }

    .logout-item:hover {
        background: #fff5f5;
    }
}

/* ========================================
   Page Load Animation - 页面加载动画
   ======================================== */
body {
    opacity: 0;
    transition: opacity 0.3s ease;
}

body.loaded {
    opacity: 1;
}

/* ========================================
   Auth Tabs - 登录/注册标签页
   ======================================== */
.auth-tabs {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
}

.auth-tab {
    flex: 1;
    padding: 1rem;
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    position: relative;
    transition: all 0.3s;
}

.auth-tab:hover {
    color: var(--primary-color);
}

.auth-tab.active {
    color: var(--secondary-color);
}

.auth-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--secondary-color);
}

.invite-code-hint {
    background: #f0f7ff;
    border: 1px solid #d0e3ff;
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: #0066cc;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.login-btn.register-btn {
    background: linear-gradient(135deg, var(--primary-color), #1a252f);
}

.login-btn.register-btn:hover {
    box-shadow: 0 8px 20px rgba(26, 37, 47, 0.3);
}

.login-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none !important;
}

/* ========================================
    User Dropdown - 用户下拉菜单
    ======================================== */
.user-dropdown {
    position: relative;
    display: none;
}

.user-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.1);
}

.user-dropdown-trigger:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.user-dropdown-trigger.active {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(0.95);
}

/* Avatar with gradient ring */
.user-avatar {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.user-dropdown-trigger:hover .user-avatar {
    transform: scale(1.1);
}

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

.avatar-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.avatar-placeholder i {
    font-size: 1rem;
}

.avatar-placeholder.small {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
}

.avatar-ring {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 50%, #f5576c 100%);
    z-index: -1;
    opacity: 0.6;
}

.user-dropdown-trigger:hover .avatar-ring {
    opacity: 1;
    animation: avatarPulse 2s ease-in-out infinite;
}

@keyframes avatarPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

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

.avatar-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
}

.avatar-placeholder.small {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
}

.avatar-ring {
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 50%, #f5576c 100%);
    z-index: -1;
    animation: avatarPulse 2s ease-in-out infinite;
}

@keyframes avatarPulse {
    0%, 100% {
        opacity: 0.8;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

/* Dropdown menu */
.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 240px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1001;
    overflow: hidden;
    border: 1px solid #e9ecef;
}

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

/* User card in dropdown */
.dropdown-header {
    padding: 1rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-card-avatar {
    position: relative;
    flex-shrink: 0;
}

.user-card-avatar img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.user-card-info {
    flex: 1;
    min-width: 0;
    color: #333;
}

.user-card-name {
    font-weight: 600;
    color: #333 !important;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-card-id {
    font-size: 0.75rem;
    color: #666;
    margin-top: 2px;
}

/* VIP Badge */
.vip-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
    box-shadow: 0 2px 8px rgba(245, 87, 108, 0.3);
}

.vip-badge i {
    color: #ffd700;
}

/* Dropdown divider */
.dropdown-divider {
    height: 1px;
    background: #e9ecef;
    margin: 0;
}

/* Dropdown items */
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    color: #333 !important;
    text-decoration: none;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
    margin: 0 0.5rem;
    border-radius: 6px;
}

.dropdown-item:first-child {
    margin-top: 0.5rem;
}

.dropdown-item:last-child {
    border-bottom: none;
    margin-bottom: 0.5rem;
}

.dropdown-item:hover {
    background: linear-gradient(90deg, #f8f9fa 0%, #eef2f7 100%);
    color: #3498db !important;
    padding-left: 1.125rem;
    padding-right: 0.875rem;
}

.dropdown-item i {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    color: #666;
    transition: color 0.2s ease;
}

.dropdown-item:hover i {
    color: #3498db;
}

.dropdown-item.logout-item {
    color: #dc3545 !important;
}

.dropdown-item.logout-item i {
    color: #dc3545;
}

.dropdown-item.logout-item:hover {
    background: linear-gradient(90deg, #fff5f5 0%, #fff0f0 100%);
    color: #c82333 !important;
    padding-left: 1.125rem;
    padding-right: 0.875rem;
}

.dropdown-item.logout-item:hover i {
    color: #c82333;
}

/* ========================================
    User Info in Navbar (Legacy) - 导航栏用户信息（旧版）
    ======================================== */
#userInfo {
    display: none;
    align-items: center;
    gap: 0.5rem;
}

.user-name {
    color: white;
    font-weight: 500;
    padding: 0.5rem 1rem;
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
}

/* ========================================
    Toast Messages - 提示消息
    ======================================== */
.toast {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 8px;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toastFadeIn 0.3s ease;
    color: white;
    font-weight: 500;
}

.toast-success {
    background: #10b981;
}

.toast-error {
    background: #ef4444;
}

@keyframes toastFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -10px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}
