/* ==========================================================================
   模态框样式
   ========================================================================== */
/**
 * 微信风格模态框
 * @selector .modal - 模态框容器
 * @selector .modal-content - 模态框内容
 * @selector .modal-header - 模态框头部
 * @selector .close-modal - 关闭按钮
 * @selector .modal-body - 模态框主体
 * @selector .add-friend-modal - 添加好友模态框
 * @selector .form-group - 表单组
 * @selector .form-note - 表单说明
 * @selector .form-actions - 表单操作按钮
 * @selector .btn-primary - 主要按钮
 * @selector .btn-secondary - 次要按钮
 * @selector .user-info-modal - 用户信息模态框
 * @selector .user-info-content - 用户信息内容
 * @selector .user-info-avatar - 用户头像区域
 * @selector .user-info-item - 用户信息项
 * @selector .info-label - 信息标签
 * @selector .info-value - 信息值
 * @selector .user-info-actions - 用户信息操作按钮
 * @selector .image-preview-modal - 图片预览模态框
 * @selector .close-preview - 关闭预览按钮
 * @selector .image-preview-content - 图片预览内容
 * @selector #previewImage - 预览图片
 * @selector .image-preview-info - 图片预览信息
 */

/* 基础模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background-color: var(--bg-white);
    margin: 15% auto;
    padding: 0;
    border-radius: var(--radius-lg);
    width: 400px;
    max-width: 90%;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease-out;
    position: relative;
    overflow: hidden;
}

/* 确认对话框特定样式 */
#confirmDialog .modal-content {
    width: 360px;
    max-width: 85%;
}

#confirmDialog .modal-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, #fff 0%, #fafafa 100%);
}

#confirmDialog .modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

#confirmDialog .close-modal {
    position: absolute;
    top: 16px;
    right: 16px;
    color: var(--text-secondary);
    font-size: 20px;
    font-weight: 300;
    cursor: pointer;
    line-height: 1;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#confirmDialog .close-modal:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

#confirmDialog .modal-body {
    padding: 24px;
    text-align: center;
}

#confirmDialog .modal-body p {
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    word-wrap: break-word;
}

#confirmDialog .modal-footer {
    padding: 16px 24px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: center;
    background: #fafafa;
}

#confirmDialog .btn {
    min-width: 100px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 500;
}

#confirmDialog .btn-danger {
    order: 2; /* 危险按钮放在右侧 */
}

#confirmDialog .btn-secondary {
    order: 1; /* 取消按钮放在左侧 */
}

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

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.close-modal {
    color: var(--text-secondary);
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    padding: 5px;
}

.close-modal:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* 基础按钮样式 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    min-width: 80px;
}

.btn:focus {
    box-shadow: 0 0 0 2px rgba(7, 193, 96, 0.2);
}

/* 添加好友模态框特定样式 */
.add-friend-modal {
    width: 420px;
}

.add-friend-modal .modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* 基础按钮样式 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    min-width: 80px;
}

.btn:focus {
    box-shadow: 0 0 0 2px rgba(7, 193, 96, 0.2);
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    background: var(--bg-white);
}

.form-group input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(7, 193, 96, 0.1);
}

.form-group input::placeholder {
    color: var(--text-light);
}

.form-note {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
    line-height: 1.4;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn-primary {
    flex: 1;
    padding: 12px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(7, 193, 96, 0.2);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 8px rgba(7, 193, 96, 0.3);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: var(--bg-hover);
    color: var(--text-light);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn-secondary {
    flex: 1;
    padding: 12px 20px;
    background: var(--bg-gray);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--text-light);
}

.btn-secondary:active {
    transform: scale(0.98);
}

/* 危险操作按钮样式 */
.btn-danger {
    background: #f44336;
    color: white;
    box-shadow: 0 2px 4px rgba(244, 67, 54, 0.2);
}

.btn-danger:hover {
    background: #d32f2f;
    box-shadow: 0 4px 8px rgba(244, 67, 54, 0.3);
    transform: translateY(-1px);
}

.btn-danger:active {
    transform: translateY(0);
    background: #b71c1c;
}

.btn-danger:disabled {
    background: var(--bg-hover);
    color: var(--text-light);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* 用户信息模态框特定样式 */
.user-info-modal {
    width: 380px;
}

.user-info-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.user-info-avatar {
    text-align: center;
    margin-bottom: 10px;
}

.user-info-avatar img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary-color);
    box-shadow: 0 4px 12px rgba(7, 193, 96, 0.2);
}

.user-info-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.user-info-item:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 70px;
    font-size: 14px;
}

.info-value {
    color: var(--text-secondary);
    background: var(--bg-gray);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    flex: 1;
    font-size: 14px;
}

.user-info-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.user-info-actions button {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-info-actions button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 图片预览模态框 */
.image-preview-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease;
}

.close-preview {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 32px;
    font-weight: 300;
    cursor: pointer;
    z-index: 1001;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    transition: all 0.2s ease;
    line-height: 1;
}

.close-preview:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.image-preview-content {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    padding: 40px;
    box-sizing: border-box;
}

#previewImage {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
    cursor: zoom-in;
    transition: transform 0.3s ease;
}

#previewImage:active {
    cursor: zoom-out;
    transform: scale(1.5);
}

/* 图片预览信息栏 */
.image-preview-info {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 12px 20px;
    border-radius: 20px;
    font-size: 14px;
    backdrop-filter: blur(10px);
    max-width: 80%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 移动端模态框优化 */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-width: 320px;
        margin: 20% auto;
    }
    
    #confirmDialog .modal-content {
        width: 90%;
        max-width: 300px;
    }
    
    #confirmDialog .modal-header {
        padding: 20px 20px 16px;
    }
    
    #confirmDialog .modal-header h3 {
        font-size: 17px;
    }
    
    #confirmDialog .modal-body {
        padding: 20px;
    }
    
    #confirmDialog .modal-body p {
        font-size: 14px;
    }
    
    #confirmDialog .modal-footer {
        padding: 12px 20px 20px;
        flex-direction: column;
        gap: 10px;
    }
    
    #confirmDialog .btn {
        width: 100%;
        min-width: auto;
        padding: 14px 20px;
        font-size: 16px;
    }
    
    #confirmDialog .btn-danger {
        order: 2;
    }
    
    #confirmDialog .btn-secondary {
        order: 1;
    }
    
    .close-modal {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    /* 图片预览移动端优化 */
    .image-preview-content {
        padding: 20px;
    }
    
    .close-preview {
        top: 15px;
        right: 15px;
        font-size: 28px;
        width: 40px;
        height: 40px;
    }
    
    .image-preview-info {
        bottom: 15px;
        font-size: 12px;
        padding: 8px 16px;
        max-width: 90%;
    }
    
    .file-message.image-file {
        max-width: 100%;
        min-width: 280px;
    }
    
    .image-thumbnail {
        height: 160px;
    }
    
    .file-action-container {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .file-action-btn {
        flex: 1;
        min-width: 80px;
        text-align: center;
        padding: 6px 8px;
        font-size: 11px;
    }
}