/**
 * HuSNS Mobile - 首页样式
 * 朋友圈风格设计
 */

:root {
    /* 从 theme.json 读取的移动端主题颜色 */
    --primary-color: #007AFF;
    --secondary-color: #5856D6;
    --accent-color: #FF9500;
    --background-color: #F2F2F7;
    --card-color: #FFFFFF;
    --text-color: #000000;
    --text-secondary-color: #8E8E93;
    --border-color: #C6C6C8;
    
    /* 兼容性别名 */
    --primary-light: #66b2ff;
    --success-color: #34C759;
    --danger-color: #FF3B30;
    --warning-color: #FF9500;
    
    /* 样式变量（基于主题颜色派生） */
    --text-primary: var(--text-color);
    --text-secondary: var(--text-secondary-color);
    --bg-card: var(--card-color);
    --bg-page: var(--background-color);
    --link-color: var(--primary-color);
}

/* ========== 首页基础样式 ========== */
.home-content {
    background-color: var(--bg-page);
    min-height: 100%;
    -webkit-overflow-scrolling: touch;
}

/* ========== 朋友圈卡片 ========== */
.moment-card {
    background-color: var(--bg-card);
    margin: 8px 0;
    padding: 0;
    border-radius: 12px;
    overflow: visible;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.moment-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

/* ========== 用户信息头部 ========== */
.moment-header {
    display: flex;
    padding: 6px 16px 0px;
    gap: 12px;
}

.moment-avatar {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background-color: #e0e0e0;
}

.moment-user-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.moment-username {
    font-weight: 600;
    font-size: 15px;
    color: var(--link-color);
    text-decoration: none;
    line-height: 1.4;
    flex-shrink: 0;
}

.moment-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.moment-time {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.moment-ip {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    background: rgba(198, 198, 200, 0.3);
    border-radius: 10px;
}

.moment-ip::before {
    content: '';
    width: 12px;
    height: 12px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238E8E93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='1 6 1 22 8 18 16 22 23 18 23 2 16 6 8 2 1 6'/%3E%3Cline x1='8' y1='2' x2='8' y2='18'/%3E%3Cline x1='16' y1='6' x2='16' y2='22'/%3E%3C/svg%3E") no-repeat center center;
    background-size: contain;
    display: inline-block;
}

/* ========== 徽章样式 ========== */
.moment-badge {
    display: inline-block;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
    font-weight: 500;
    flex-shrink: 0;
}

.moment-badge.pinned {
    background: var(--danger-color);
    color: #fff;
}

.moment-badge.featured {
    background: linear-gradient(135deg, var(--accent-color), #ffcc00);
    color: var(--text-color);
}

/* ========== 在线状态 ========== */
.online-badge {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--success-color);
    border-radius: 50%;
    margin-left: 4px;
    vertical-align: middle;
    flex-shrink: 0;
    box-shadow: 0 0 2px rgba(52, 199, 89, 0.5);
}

.online-badge.offline {
    background: var(--text-secondary);
    box-shadow: none;
}

.moment-more {
    color: var(--text-secondary);
    font-size: 20px;
    padding: 8px 4px;
    flex-shrink: 0;
}

/* ========== 内容区域 ========== */
.moment-content {
    padding: 0 16px 12px 74px;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    word-break: break-all;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.moment-content-link {
    text-decoration: none;
    color: inherit;
}

/* ========== 帖子中的圈子名称标签 ========== */
.moment-circle {
    display: inline;
    font-size: 12px;
    margin-right: 4px;
}

.moment-circle .circle-name {
    color: #6366f1;
    font-weight: 500;
}

/* ========== 位置卡片 ========== */
.moment-location-card {
    margin: 6px 16px 6px 74px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--card-color);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
}

.location-pin {
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.location-pin svg {
    width: 12px;
    height: 12px;
    fill: var(--danger-color);
    vertical-align: middle;
}

.location-text {
    font-size: 13px;
    color: var(--text-color);
}

.moment-location-header {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.moment-location-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.moment-location-detail {
    font-size: 12px;
    color: var(--text-secondary);
}

.moment-location-map {
    position: relative;
    height: 100px;
    background: linear-gradient(135deg, var(--background-color) 0%, var(--border-color) 100%);
}

.moment-location-map img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.moment-location-pin {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23007AFF'%3E%3Cpath d='M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z'/%3E%3C/svg%3E") no-repeat center center;
    background-size: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.moment-location-card.no-map .moment-location-map {
    display: none;
}

.moment-location-card.no-map {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    margin: 4px 16px 4px 74px;
    border-radius: 20px;
    box-shadow: none;
    border: 1px solid var(--border-color);
}

.moment-location-card.no-map .moment-location-header {
    border: none;
    padding: 0;
}

.moment-location-card.no-map .moment-location-name {
    margin: 0;
    font-size: 13px;
    font-weight: normal;
}

.moment-location-card.no-map .moment-location-detail {
    display: none;
}

/* ========== 图片网格 ========== */
.moment-images {
    padding: 0 16px 12px 74px;
}

.moment-image-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    border-radius: 4px;
    overflow: hidden;
}

.moment-image-grid.single-image {
    grid-template-columns: 1fr;
    max-width: 65%;
    background: transparent;
}

.moment-image-grid.single-image .moment-img {
    aspect-ratio: auto;
    max-height: 200px;
    object-fit: contain;
    background-color: transparent;
}

.moment-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background-color: var(--border-color);
    transition: opacity 0.2s;
}

.moment-img:active {
    opacity: 0.9;
}

/* ========== 转发预览 ========== */
.moment-repost {
    margin: 0 16px 12px 74px;
    padding: 10px 12px;
    background-color: var(--background-color);
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-color);
}

.moment-repost-link {
    text-decoration: none;
    color: var(--link-color);
}

/* ========== 底部操作栏 ========== */
.moment-actions {
    display: flex;
    align-items: center;
    padding: 8px 16px 12px 25px;
    gap: 24px;
    border-top: 1px solid var(--border-color);
}

.moment-action {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    font-size: 13px;
    background: none;
    border: none;
    padding: 4px 0;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.2s;
}

.moment-action:active {
    opacity: 0.7;
}

.moment-action-icon {
    font-size: 18px;
    line-height: 1;
}

.moment-action.liked {
    color: var(--danger-color);
}

.moment-action.liked .moment-action-icon {
    color: var(--danger-color);
}

.moment-action-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-left: 2px;
}

.moment-action.liked .moment-action-text {
    color: var(--danger-color);
}

/* ========== 评论区域 ========== */
.moment-comments {
    padding: 0 16px 12px 74px;
}

.moment-like-list {
    font-size: 13px;
    color: var(--link-color);
    margin-bottom: 6px;
    line-height: 1.4;
}

.moment-like-icon {
    color: var(--danger-color);
    margin-right: 4px;
}

.moment-comment-list {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
}

.moment-comment-item {
    margin-bottom: 4px;
}

.moment-comment-user {
    color: var(--link-color);
    text-decoration: none;
}

.moment-comment-text {
    color: var(--text-primary);
}

.moment-comment-link {
    text-decoration: none;
}

/* ========== 空状态 ========== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 40px;
    text-align: center;
    background: var(--card-color);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.6;
}

.empty-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-subtext {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ========== 加载动画 ========== */
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 40px;
    text-align: center;
    background: var(--card-color);
}

.loading-text {
    font-size: 16px;
    color: var(--text-secondary);
    margin-top: 16px;
}

/* ========== 加载更多 ========== */
.load-more {
    padding: 16px;
    text-align: center;
}

.load-more-btn {
    display: inline-block;
    padding: 12px 32px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.load-more-btn:active {
    opacity: 0.8;
}

/* ========== 下拉菜单 ========== */
.moment-more-btn {
    position: relative;
    cursor: pointer;
}

.moment-dropdown {
    display: none;
    position: absolute;
    top: 28px;
    right: 0;
    background: var(--card-color);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    z-index: 9999;
    min-width: 100px;
    overflow: hidden;
    padding: 4px 0;
}

.moment-dropdown.show {
    display: block;
}

.moment-dropdown-item {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text-color);
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.moment-dropdown-item:active {
    background: var(--background-color);
}

.moment-dropdown-item.danger {
    color: var(--danger-color);
}

.moment-dropdown-item .item-icon {
    margin-right: 6px;
    font-size: 14px;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 2px 0;
}

/* ========== 标签栏 ========== */
.tab-bar {
    display: flex;
    background: var(--card-color);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.tab-bar .tab-item {
    flex: 1;
    text-align: center;
    padding: 12px 0;
    font-size: 15px;
    color: var(--text-secondary);
    text-decoration: none;
    position: relative;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.tab-bar .tab-item.active {
    color: var(--text-primary);
    font-weight: 600;
}

.tab-bar .tab-item.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 2px;
}

/* ========== 夜间模式 ========== */
@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #000000;
        --card-color: #1C1C1E;
        --text-color: #FFFFFF;
        --text-secondary-color: #8E8E93;
        --border-color: #3A3A3C;
        
        /* 夜间模式专用颜色 */
        --text-primary: #FFFFFF;
        --text-secondary: #8E8E93;
        --bg-card: #1C1C1E;
        --bg-page: #000000;
        --link-color: #66b2ff;
    }

    .moment-card {
        background-color: var(--bg-card);
    }

    .moment-username,
    .moment-comment-user,
    .moment-like-list,
    .moment-repost-link {
        color: var(--primary-color);
    }

    .moment-content {
        color: var(--text-primary);
    }

    .moment-action {
        color: var(--text-secondary);
    }

    .moment-action.liked {
        color: var(--danger-color);
    }

    .moment-action-text {
        color: var(--text-secondary);
    }

    .moment-action.liked .moment-action-text {
        color: var(--danger-color);
    }

    .moment-repost {
        background-color: #2C2C2E;
        color: #E5E5EA;
    }

    .moment-comment-text,
    .moment-comment-list {
        color: #E5E5EA;
    }

    .moment-img {
        background-color: #2C2C2E;
    }

    .moment-badge.pinned {
        background: #FF453A;
    }

    .moment-badge.featured {
        background: linear-gradient(135deg, #FFD700, #FF9500);
        color: #1C1C1E;
    }

    .moment-dropdown {
        background: #1C1C1E;
    }

    .moment-dropdown-item {
        color: #FFFFFF;
    }

    .moment-dropdown-item:active {
        background: #3A3A3C;
    }

    .dropdown-divider {
        background: #3A3A3C;
    }

    .tab-bar {
        background: #1C1C1E;
        border-bottom-color: #3A3A3C;
    }

    .tab-bar .tab-item {
        color: var(--text-secondary);
    }

    .tab-bar .tab-item.active {
        color: var(--text-primary);
    }

    .tab-bar .tab-item.active::after {
        background: var(--primary-color);
    }

    .image-viewer-overlay {
        background: rgba(0, 0, 0, 0.98);
    }
}

/* ========== iOS安全区域 ========== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .app-tabbar {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ========== 小屏幕适配 ========== */
@media (max-width: 320px) {
    .moment-avatar { width: 40px; height: 40px; }
    .moment-content { padding-left: 60px; }
    .moment-images { padding-left: 60px; }
    .moment-repost { margin-left: 60px; }
    .moment-actions { padding-left: 60px; }
    .moment-comments { padding-left: 60px; }
}

/* ========== 圈子卡片样式 ========== */
.circle-card {
    display: flex;
    align-items: center;
    background-color: var(--bg-card);
    margin: 12px 15px;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    -webkit-tap-highlight-color: transparent;
}

.circle-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 15px;
    flex-shrink: 0;
}

.circle-info {
    flex: 1;
    min-width: 0;
}

.circle-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.circle-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.circle-stats {
    font-size: 12px;
    color: var(--text-secondary);
}

.circle-stats .stat-divider {
    margin: 0 6px;
}

.circle-join-btn {
    padding: 8px 16px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.circle-join-btn:active {
    opacity: 0.8;
}

.circle-join-btn.joined {
    background: #f0f0f0;
    color: var(--text-secondary);
    cursor: default;
}

.dark-mode .circle-join-btn.joined {
    background: #333;
}

/* ========== 图片查看器 ========== */
.image-viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
}

.image-viewer-overlay.show {
    opacity: 1;
    visibility: visible;
}

.image-viewer-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-viewer-swiper {
    display: flex;
    width: 100%;
    height: 100%;
    transition: transform 0.3s ease;
}

.image-viewer-slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-viewer-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.2s ease;
    -webkit-user-select: none;
    user-select: none;
}

.image-viewer-close {
    position: absolute;
    top: max(env(safe-area-inset-top), 20px);
    right: 20px;
    width: 44px;
    height: 44px;
    background: #e53935;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    border: none;
    box-shadow: 0 2px 8px rgba(229, 57, 53, 0.4);
}

.image-viewer-close svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}

.image-viewer-indicator {
    position: absolute;
    bottom: max(env(safe-area-inset-bottom), 30px);
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 16px;
    border-radius: 20px;
    z-index: 10;
}

.image-viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    border: none;
}

.image-viewer-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.image-viewer-nav svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}

.image-viewer-prev {
    left: 20px;
}

.image-viewer-next {
    right: 20px;
}

.image-viewer-zoom-controls {
    position: absolute;
    bottom: max(env(safe-area-inset-bottom), 80px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 16px;
    z-index: 10;
}

.zoom-btn {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
}

.zoom-btn svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}

/* ========== 视频播放器 ========== */
.video-player-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-player-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-player-fullscreen {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.video-player-close {
    position: absolute;
    top: max(env(safe-area-inset-top), 20px);
    right: 20px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    border: none;
}

/* ========== 位置地图弹窗 ========== */
.location-map-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}
