/* css/user.css */

/* =========================================
   Dashboard 布局结构
   ========================================= */
body {
    background-color: var(--bg-color);
    min-height: 100vh;
}

/* 侧边栏调整：桌面端常驻 */
@media (min-width: 769px) {
    .sidebar {
        transform: translateX(0); /* 桌面端始终显示 */
        box-shadow: 1px 0 0 var(--border-color); /* 右侧边框代替阴影 */
        background: var(--card-bg);
        z-index: 900; /* 低于 Navbar */
        padding-top: var(--navbar-height); /* 避开 Navbar */
        width: 260px;
    }
    
    /* 桌面端隐藏侧边栏头部的关闭按钮 */
    .sidebar-header.mobile-only {
        display: none;
    }

    /* 主内容区域：留出侧边栏位置 */
    .main-content {
        margin-left: 260px;
        padding: calc(var(--navbar-height) + 24px) 24px 24px;
        width: calc(100% - 260px);
    }
}

/* 移动端样式：主内容占满 */
@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
        padding: calc(var(--navbar-height) + 16px) 16px 16px;
        width: 100%;
    }
    
    /* 移动端侧边栏样式在 common.css 中已定义 (抽屉式) */
    .sidebar {
        z-index: 1200; /* 高于 Overlay */
        padding-top: 0;
    }
}

/* =========================================
   通用组件
   ========================================= */
.container {
    max-width: 1000px;
    margin: 0 auto;
}

.page-title {
    font-size: 28px;
    margin-bottom: 24px;
    font-weight: 500;
}

/* Grid 布局：自适应卡片 */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); /* 自适应列 */
    gap: 24px;
}
@media (max-width: 480px) {
    .settings-grid { grid-template-columns: 1fr; }
}

/* 卡片通用样式 */
.card {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 1px 3px var(--shadow-color);
    overflow: hidden;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
}

.card-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0,0,0,0.02);
}
.card-header h3 {
    font-size: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}
.card-body {
    padding: 24px;
}

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

/* =========================================
   模块特定样式
   ========================================= */

/* 2.1 个人信息 */
.info-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}
.info-row:last-child { border-bottom: none; }
.info-row label { color: var(--text-secondary); font-size: 14px; }
.info-value { font-weight: 500; }
.code-font { font-family: monospace; color: var(--primary-color); }

/* 2.2 社交绑定 */
.social-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
}
.social-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.social-info i { font-size: 20px; width: 24px; text-align: center; }
.social-info span { font-weight: 500; }

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
}
.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    transition: 0.2s;
}
.btn-outline:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}
.btn-outline.linked {
    background-color: rgba(76, 175, 80, 0.1);
    color: #4caf50;
    border-color: #4caf50;
    cursor: default;
}

/* 2.3 & 2.5 安全设置 */
.input-group { margin-bottom: 20px; position: relative; }
/* 复用 Login 页面的 input 样式，但做微调以适应白色背景 */
.input-group input {
    width: 100%;
    height: 48px;
    padding: 14px 12px 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-color);
    outline: none;
}
.input-group input:focus { border-color: var(--primary-color); }
.input-group label {
    position: absolute; left: 12px; top: 14px;
    font-size: 14px; color: var(--text-secondary);
    pointer-events: none; transition: 0.2s;
    background: transparent;
}
.input-group input:focus ~ label,
.input-group input:not(:placeholder-shown) ~ label {
    top: 4px; font-size: 10px;
    color: var(--primary-color);
}

.form-actions { text-align: right; }
.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}
.btn-primary:hover { background: var(--primary-hover); }

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

.passkey-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}
.passkey-info h4 { margin-bottom: 4px; font-size: 16px; }
.passkey-info p { margin: 0; }
#btn-create-passkey {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
}

/* =========================================
   美图收藏 (Masonry) 样式
   ========================================= */

.container-fluid {
    max-width: 1400px; /* 比设置页更宽 */
    margin: 0 auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
}

.form-select {
    padding: 8px 32px 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 14px;
    cursor: pointer;
    outline: none;
    /* 自定义下拉箭头 */
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
}

/* 瀑布流栅格 */
.masonry-grid {
    width: 100%;
}

/* 栅格项大小控制 (Sizer) */
.grid-item {
    width: calc(50% - 8px); /* 手机端双列，减去间隙的一半 */
    margin-bottom: 16px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    background: var(--card-bg);
    box-shadow: 0 2px 8px var(--shadow-color);
    transition: transform 0.3s ease;
    /* 初始不可见，防止布局跳动 */
    opacity: 0; 
    animation: reveal 0.5s ease forwards;
}

@keyframes reveal { to { opacity: 1; } }

.grid-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px var(--shadow-color);
    z-index: 2;
}

/* 响应式列数 */
@media (min-width: 600px) {
    .grid-item { width: calc(33.333% - 11px); } /* 平板 3列 */
}

@media (min-width: 1000px) {
    .grid-item { width: calc(25% - 12px); } /* 桌面 4列 */
}

/* 图片内容 */
.grid-item img {
    display: block;
    width: 100%;
    height: auto;
    transition: filter 0.3s;
}

/* 悬停遮罩层 */
.item-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 16px;
    color: white;
}

.grid-item:hover .item-overlay {
    opacity: 1;
}

.item-info {
    transform: translateY(10px);
    transition: transform 0.3s ease;
}
.grid-item:hover .item-info {
    transform: translateY(0);
}

.item-date {
    font-size: 12px;
    opacity: 0.9;
    display: flex; align-items: center; gap: 4px;
}

/* 删除按钮 */
.delete-btn {
    position: absolute;
    top: 12px; right: 12px;
    width: 32px; height: 32px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    border: none;
    color: #ff4d4f;
    transform: scale(0.8);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.grid-item:hover .delete-btn {
    opacity: 1;
    transform: scale(1);
}
.delete-btn:hover {
    background: #ff4d4f;
    color: white;
}

/* 状态展示 */
.state-container {
    text-align: center;
    padding: 60px 0;
    color: var(--text-secondary);
}
.spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(0,0,0,0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-icon { font-size: 64px; margin-bottom: 16px; opacity: 0.5; }
.hidden { display: none !important; }

/* 分页 */
.pagination-container {
    display: flex; justify-content: center; align-items: center;
    gap: 20px; margin-top: 40px; margin-bottom: 40px;
}
.page-info { font-weight: 500; }

/* 模态框样式 */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 2000;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden; transition: 0.3s;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal-card {
    background: var(--card-bg);
    width: 90%; max-width: 400px;
    padding: 24px; border-radius: 16px;
    text-align: center;
    transform: scale(0.9); transition: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-overlay.active .modal-card { transform: scale(1); }
.modal-icon {
    width: 64px; height: 64px; border-radius: 50%;
    margin: 0 auto 16px;
    display: flex; align-items: center; justify-content: center;
}
.modal-icon.warning { background: #fff1f0; color: #ff4d4f; }
.modal-icon .material-icons-round { font-size: 32px; }
.modal-actions {
    display: flex; justify-content: center; gap: 12px; margin-top: 24px;
}
.btn-danger {
    background: #ff4d4f; color: white; border: none;
    padding: 8px 24px; border-radius: 8px; cursor: pointer;
}

/* =========================================
   私信页面 (Chat) 样式
   ========================================= */

/* 聊天整体容器：铺满剩余空间 */
.chat-wrapper {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-container {
    flex: 1;
    display: flex;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 4px 12px var(--shadow-color);
    overflow: hidden;
    border: 1px solid var(--border-color);
    height: 100%;
}

/* 左侧联系人 */
.contact-pane {
    width: 300px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: rgba(255,255,255,0.5);
}
[data-theme="dark"] .contact-pane { background: rgba(0,0,0,0.2); }

.pane-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center;
}
.pane-header h3 { font-size: 18px; font-weight: 500; margin: 0; }

.search-bar-container {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    display: flex; gap: 8px;
    animation: fadeIn 0.3s ease;
}
.search-bar-container input {
    flex: 1; padding: 6px 10px; border-radius: 6px;
    border: 1px solid var(--border-color); outline: none;
    background: var(--input-bg); color: var(--text-color);
}

.contact-list {
    flex: 1; overflow-y: auto;
}

.contact-item {
    padding: 12px 16px;
    display: flex; align-items: center; gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid transparent;
}
.contact-item:hover { background: rgba(0,0,0,0.05); }
.contact-item.active { background: rgba(26, 115, 232, 0.1); border-left: 3px solid var(--primary-color); }

.avatar-placeholder {
    width: 40px; height: 40px; border-radius: 50%;
    background: #e0e0e0; color: #757575;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
}

.contact-info { flex: 1; overflow: hidden; }
.contact-name { font-weight: 500; font-size: 14px; margin-bottom: 4px; }
.contact-preview { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 右侧聊天窗口 */
.chat-pane {
    flex: 1;
    display: flex; flex-direction: column;
    position: relative;
    background: var(--card-bg);
}

.chat-empty {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--text-secondary);
}
.chat-empty .material-icons-round { font-size: 64px; margin-bottom: 16px; opacity: 0.3; }

.chat-content {
    display: flex; flex-direction: column; height: 100%;
}

.chat-header {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; gap: 12px;
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(10px);
}
[data-theme="dark"] .chat-header { background: rgba(30,30,30,0.8); }

.header-info { display: flex; align-items: center; gap: 10px; font-weight: 500; }

.messages-area {
    flex: 1; overflow-y: auto;
    padding: 20px;
    display: flex; flex-direction: column; gap: 12px;
}

.message-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}

.message-bubble.sent {
    align-self: flex-end;
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 2px;
}

.message-bubble.received {
    align-self: flex-start;
    background: #f1f3f4;
    color: #202124;
    border-bottom-left-radius: 2px;
}
[data-theme="dark"] .message-bubble.received { background: #3c4043; color: #e8eaed; }

.message-time {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

.input-area {
    padding: 12px;
    border-top: 1px solid var(--border-color);
    display: flex; gap: 10px; align-items: flex-end;
    background: var(--card-bg);
}

.input-area textarea {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 10px 14px;
    background: var(--input-bg);
    color: var(--text-color);
    resize: none; outline: none;
    font-family: inherit;
    max-height: 100px;
}

.send-btn {
    background: var(--primary-color);
    color: white;
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.send-btn:disabled { background: var(--text-secondary); opacity: 0.5; cursor: not-allowed; }

/* 响应式：移动端 */
@media (max-width: 768px) {
    .chat-container { border: none; border-radius: 0; }
    .contact-pane { width: 100%; border-right: none; }
    
    /* 默认显示列表，隐藏聊天 */
    .chat-pane { display: none; }
    
    /* 激活状态：隐藏列表，显示聊天 */
    .chat-container.active-chat .contact-pane { display: none; }
    .chat-container.active-chat .chat-pane { display: flex; }
    
    .chat-wrapper { padding: 0; margin-left: 0; width: 100%; }
}

/* 特殊联系人：系统通知 */
.contact-item.system-item {
    background-color: rgba(255, 152, 0, 0.05); /* 淡淡的橙色背景区分 */
}
.contact-item.system-item .avatar-placeholder {
    background-color: #ff9800;
    color: white;
}
.contact-item.system-item.active {
    background-color: rgba(255, 152, 0, 0.15);
    border-left-color: #ff9800;
}

/* 只读模式：隐藏输入框 */
.chat-pane.read-only .input-area {
    display: none !important;
}

/* 系统消息气泡样式微调 */
.message-bubble.system-msg {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffe0b2;
    align-self: center; /* 居中显示 */
    max-width: 85%;
    border-radius: 8px;
}
[data-theme="dark"] .message-bubble.system-msg {
    background: #4a3b2a;
    color: #ffcc80;
    border-color: #6d4c41;
}
.system-msg-title {
    font-weight: bold;
    margin-bottom: 4px;
    font-size: 15px;
}