/**
 * HuSNS Mobile Theme - defaultpro
 * 移动端主题样式 - 与原版保持一致的线性图标风格
 */

:root {
    --primary-color: #1890ff;
    --text-color: #333;
    --text-secondary: #999;
    --bg-color: #f5f5f5;
    --border-color: #eee;
    --card-bg: #fff;
}

.dark-mode {
    --primary-color: #1890ff;
    --text-color: #e5e5e5;
    --text-secondary: #888;
    --bg-color: #1a1a1a;
    --border-color: #333;
    --card-bg: #242424;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
}

/* 头部 */
.m-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
    padding-top: env(safe-area-inset-top);
}

.m-header-content {
    display: flex;
    align-items: center;
    height: 44px;
    padding: 0 12px;
}

.m-header-back {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    font-size: 18px;
}

.m-header-title {
    flex: 1;
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    text-align: center;
}

.m-header-right {
    min-width: 60px;
    text-align: right;
}

/* 主内容区 */
.m-main {
    padding-top: calc(44px + env(safe-area-inset-top));
    padding-bottom: calc(60px + env(safe-area-inset-bottom));
    min-height: 100vh;
}

/* 底部 TabBar */
.m-tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.dark-mode .m-tabbar {
    background: #2a2a2a;
    border-top-color: #333;
}

.m-tabbar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 50px;
    color: var(--text-secondary);
    text-decoration: none;
    position: relative;
}

.m-tabbar-item.active {
    color: var(--primary-color);
}

.m-tabbar-icon {
    font-size: 20px;
    margin-bottom: 2px;
}

.m-tabbar-label {
    font-size: 10px;
}

.m-tabbar-publish {
    color: var(--primary-color);
}

.m-tabbar-icon-publish {
    width: 36px;
    height: 36px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    transform: translateY(-8px);
    box-shadow: 0 2px 8px rgba(24, 144, 255, 0.4);
}

.unread-badge {
    position: absolute;
    top: 5px;
    right: 50%;
    transform: translateX(12px);
    background: #ff4d4f;
    color: #fff;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

/* Tab 切换 */
.m-tabs {
    display: flex;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0 16px;
}

.m-tab {
    flex: 1;
    text-align: center;
    padding: 12px 0;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    position: relative;
}

.m-tab.active {
    color: var(--primary-color);
    font-weight: 500;
}

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

/* 动态列表 */
.m-post-list {
    background: var(--bg-color);
}

.m-post-item {
    background: var(--card-bg);
    margin-bottom: 8px;
    padding: 12px;
}

.m-post-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.m-post-header a {
    display: block;
}

.m-post-user-info {
    margin-left: 10px;
    flex: 1;
}

.m-post-username {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
}

.m-post-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.m-post-content {
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 10px;
    word-break: break-word;
}

.m-post-images {
    display: grid;
    gap: 4px;
    margin-bottom: 10px;
}

.m-post-images.single {
    grid-template-columns: 1fr;
}

.m-post-images.single .m-post-image {
    max-height: 300px;
}

.m-post-images.double,
.m-post-images.triple,
.m-post-images.quad,
.m-post-images.many {
    grid-template-columns: repeat(3, 1fr);
}

.m-post-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 4px;
    background: var(--bg-color);
}

/* 转发预览 */
.m-repost-preview {
    background: var(--bg-color);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* 操作按钮 */
.m-post-actions {
    display: flex;
    justify-content: space-between;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.m-action-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 6px 12px;
    cursor: pointer;
}

.m-action-btn:hover,
.m-action-btn:active {
    color: var(--primary-color);
}

.m-action-btn.liked .m-action-icon {
    color: #ff4757;
}

.m-action-btn.favorited .m-action-icon {
    color: #ffa502;
}

.m-action-icon {
    font-size: 18px;
}

/* 加载更多 */
.m-load-more {
    text-align: center;
    padding: 16px;
    background: var(--card-bg);
}

/* 空状态 */
.m-empty {
    text-align: center;
    padding: 60px 20px;
}

.m-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

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

/* 弹窗 */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    align-items: flex-end;
    justify-content: center;
}

.popup-overlay.show {
    display: flex;
}

.popup-box {
    background: var(--card-bg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
}

.popup-title {
    font-size: 16px;
    font-weight: 600;
}

.popup-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
}

.popup-content {
    padding: 16px;
}

/* 登录注册 */
.login-logo {
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 16px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    background: var(--bg-color);
    color: var(--text-color);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
}

.btn-primary:active {
    opacity: 0.8;
}

.form-link {
    text-align: center;
    margin-top: 16px;
}

.form-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 14px;
}

/* 发布 */
.publish-box {
    max-height: 80vh;
}

.pub-textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: none;
    font-size: 15px;
    resize: none;
    background: transparent;
    color: var(--text-color);
    line-height: 1.6;
}

.pub-textarea:focus {
    outline: none;
}

.pub-images-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.pub-images-preview img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
}

.pub-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.pub-tools {
    display: flex;
    gap: 8px;
}

.pub-tool {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
}

.pub-tool:active {
    background: var(--border-color);
}

.pub-submit {
    padding: 8px 20px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
}

.pub-submit:active {
    opacity: 0.8;
}

/* 评论 */
.comment-box {
    height: 70vh;
    display: flex;
    flex-direction: column;
}

.comment-popup-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px;
}

.comment-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.comment-header {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.comment-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.comment-info {
    margin-left: 8px;
    flex: 1;
}

.comment-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-color);
}

.comment-time {
    font-size: 11px;
    color: var(--text-secondary);
}

.comment-content {
    font-size: 14px;
    line-height: 1.5;
    margin-left: 40px;
}

.comment-actions {
    display: flex;
    gap: 16px;
    margin-left: 40px;
    margin-top: 6px;
}

.comment-action {
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
}

.comment-action:active {
    color: var(--primary-color);
}

/* 回复楼中楼 */
.comment-replies {
    margin-left: 40px;
    margin-top: 8px;
    padding-left: 12px;
    border-left: 2px solid var(--border-color);
}

.reply-item {
    padding: 8px 0;
    font-size: 13px;
}

.reply-item + .reply-item {
    border-top: 1px dashed var(--border-color);
}

.reply-user {
    color: var(--primary-color);
}

.reply-to {
    color: var(--text-secondary);
}

.reply-content {
    margin-top: 2px;
}

/* 评论输入框 */
.comment-input-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--card-bg);
}

.comment-input-box input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 14px;
    background: var(--bg-color);
    color: var(--text-color);
}

.comment-input-box input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.comment-input-box button {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
}

/* 转发 */
.repost-original {
    background: var(--bg-color);
    padding: 12px;
    border-radius: 8px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* 加载动画 */
.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Toast */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 3000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* 图片预览 */
.m-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

.m-image-modal.show {
    display: flex;
}

.m-image-modal img {
    max-width: 100%;
    max-height: 100%;
}

/* 返回PC版入口 */
.m-desktop-link {
    position: fixed;
    bottom: calc(60px + env(safe-area-inset-bottom) + 10px);
    right: 10px;
    z-index: 99;
}

.m-desktop-link a {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.dark-mode .m-desktop-link a {
    background: #2a2a2a;
    border-color: #333;
    color: #aaa;
}

.m-desktop-link a:active {
    opacity: 0.8;
}

/* ========== 登录/注册页面 ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    background: var(--bg-color);
}

.login-logo {
    text-align: center;
    margin-bottom: 40px;
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
}

.login-form {
    width: 100%;
    max-width: 320px;
}

.login-input {
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 15px;
    background: var(--card-bg);
    color: var(--text-color);
}

.login-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.login-btn {
    width: 100%;
    padding: 14px;
    margin-top: 8px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.login-btn:active {
    opacity: 0.8;
}

.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.login-link {
    display: block;
    text-align: center;
    margin-top: 20px;
    color: var(--primary-color);
    font-size: 14px;
    text-decoration: none;
}

/* 修复登录页面在暗色模式下的输入框背景 */
.dark-mode .login-input {
    background: var(--bg-secondary, #333);
    border-color: #444;
    color: #e0e0e0;
}

/* ========== 用户头像 ========== */
.m-post-avatar,
.comment-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.comment-avatar {
    width: 28px;
    height: 28px;
}

/* ========== 发布页面 ========== */
.pub-page {
    padding: 0;
}

.pub-user-section {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--card-bg);
}

.pub-user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 12px;
}

.pub-user-info {
    flex: 1;
}

.pub-user-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-color);
}

.pub-user-privacy {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.pub-content-section {
    padding: 16px;
    background: var(--card-bg);
}

.pub-publish-btn {
    padding: 6px 16px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 16px;
    font-size: 14px;
    cursor: pointer;
}

.pub-publish-btn:disabled {
    opacity: 0.6;
}

.preview-item img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
}

/* ========== 转发页面 ========== */
.post-card {
    background: var(--card-bg);
    padding: 16px;
    border-radius: 12px;
    margin: 0 16px;
}

.post-user {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.post-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin-right: 10px;
}

.post-info {
    flex: 1;
}

.post-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
}

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

/* ========== 加载状态 ========== */
.loading-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.loading-state .loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 10px;
}

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

.error-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.error-state button {
    margin-top: 12px;
    padding: 8px 20px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 20px;
    cursor: pointer;
}

/* ========== Tab 切换 ========== */
.tab-item {
    cursor: pointer;
}

/* ========== 下拉刷新 ========== */
.m-pull-refresh {
    height: 0;
    overflow: hidden;
    transition: height 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
}

.m-pull-refresh-content {
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.m-pull-refresh-content::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.m-pull-refresh.refreshing .m-pull-refresh-content::before {
    opacity: 1;
}

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