/**
 * iPhone 邮件应用 - iOS 17 风格
 * 完全还原iOS邮件的高级感和原生app体验
 */

.iphone-mail-page {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ffffff;
    z-index: 2000;
    display: none;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.36, 0.66, 0.04, 1);
}

.iphone-mail-page.show {
    display: flex;
    transform: translateX(0);
}

/* 邮件头部 - 白色主题iOS原生风格 */
.mail-header {
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: #ffffff;
    border-bottom: 0.33px solid rgba(0, 0, 0, 0.1);
}

.mail-back-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #000000;
    font-size: 18px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
    padding: 0;
}

.mail-back-btn:active {
    background-color: rgba(0, 0, 0, 0.05);
    transform: scale(0.95);
}

.mail-back-btn i {
    font-size: 18px;
}

.mail-title {
    font-size: 17px;
    font-weight: 600;
    color: #000000;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
    letter-spacing: -0.4px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.mail-generate-btn {
    background: none;
    border: none;
    color: #007AFF;
    font-size: 17px;
    font-weight: 400;
    cursor: pointer;
    padding: 0;
    transition: opacity 0.2s ease;
}

.mail-generate-btn:active {
    opacity: 0.4;
}

.mail-generate-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.mail-generate-btn.generating {
    opacity: 0.6;
    pointer-events: none;
}

/* 邮件内容区域 - 白色主题 */
.mail-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    background: #f2f2f7;
    -webkit-overflow-scrolling: touch;
}

.mail-content::-webkit-scrollbar {
    width: 0;
    display: none;
}

/* 空状态 */
.mail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px 20px;
    color: #8e8e93;
    text-align: center;
}

.mail-empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.mail-empty-text {
    font-size: 17px;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
    letter-spacing: -0.4px;
    margin-bottom: 8px;
}

.mail-empty-hint {
    font-size: 15px;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
    letter-spacing: -0.4px;
    opacity: 0.7;
}

/* 加载动画 */
.mail-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 40px;
}

.mail-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 122, 255, 0.2);
    border-top-color: #007aff;
    border-radius: 50%;
    animation: mail-spin 1s linear infinite;
}

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

.mail-loading-text {
    margin-top: 16px;
    font-size: 15px;
    color: #8e8e93;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
    letter-spacing: -0.4px;
}

/* 邮件列表 */
.mail-list {
    padding: 0;
}

.mail-item {
    background: #ffffff;
    margin: 8px 16px;
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: background 0.15s ease;
    cursor: pointer;
}

.mail-item:active {
    background: #e5e5ea;
}

.mail-item.unread {
    background: #ffffff;
}

.mail-item.unread .mail-item-sender,
.mail-item.unread .mail-item-subject {
    font-weight: 600;
}

/* 邮件头像容器 - iOS原生风格 */
.mail-item-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
    position: relative;
}

.mail-item-avatar.work {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.mail-item-avatar.personal {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.mail-item-avatar.promotion {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.mail-item-avatar.social {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

/* 头像图片 */
.mail-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* 头像备用图标 */
.mail-avatar-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

/* 邮件内容 */
.mail-item-content {
    flex: 1;
    min-width: 0;
}

.mail-item-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.mail-item-sender {
    font-size: 16px;
    font-weight: 500;
    color: #000000;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
    letter-spacing: -0.4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.mail-item-time {
    font-size: 14px;
    color: #8e8e93;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
    letter-spacing: -0.4px;
    margin-left: 8px;
    flex-shrink: 0;
}

.mail-item-subject {
    font-size: 15px;
    font-weight: 400;
    color: #000000;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
    letter-spacing: -0.4px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-item-preview {
    font-size: 14px;
    color: #8e8e93;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
    letter-spacing: -0.4px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 邮件详情页 - 白色主题 */
.mail-detail-page {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ffffff;
    z-index: 2001;
    display: none;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.36, 0.66, 0.04, 1);
}

.mail-detail-page.show {
    display: flex;
    transform: translateX(0);
}

.mail-detail-header {
    height: 54px;
    display: flex;
    align-items: flex-end;
    padding: 0 16px 10px;
    background: #ffffff;
    border-bottom: 0.33px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.mail-detail-back-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #000000;
    font-size: 18px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
    padding: 0;
}

.mail-detail-back-btn:active {
    background-color: rgba(0, 0, 0, 0.05);
    transform: scale(0.95);
}

.mail-detail-back-btn i {
    font-size: 18px;
}

.mail-detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    background: #ffffff;
    -webkit-overflow-scrolling: touch;
}

.mail-detail-content::-webkit-scrollbar {
    width: 0;
    display: none;
}

.mail-detail-subject {
    font-size: 22px;
    font-weight: 700;
    color: #000000;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
    letter-spacing: -0.4px;
    margin-bottom: 16px;
    line-height: 1.3;
}

.mail-detail-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 0.33px solid rgba(0, 0, 0, 0.1);
}

.mail-detail-sender-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}

.mail-detail-sender-avatar.work {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.mail-detail-sender-avatar.personal {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.mail-detail-sender-avatar.promotion {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.mail-detail-sender-avatar.social {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

/* 详情页头像图片和备用图标样式复用 */
.mail-detail-sender-avatar .mail-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.mail-detail-sender-avatar .mail-avatar-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.mail-detail-sender-info {
    flex: 1;
    min-width: 0;
}

.mail-detail-sender-name {
    font-size: 16px;
    font-weight: 600;
    color: #000000;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
    letter-spacing: -0.4px;
    margin-bottom: 2px;
}

.mail-detail-sender-email {
    font-size: 14px;
    color: #8e8e93;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
    letter-spacing: -0.4px;
}

.mail-detail-time {
    font-size: 14px;
    color: #8e8e93;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
    letter-spacing: -0.4px;
    flex-shrink: 0;
}

.mail-detail-body {
    font-size: 16px;
    line-height: 1.6;
    color: #000000;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
    letter-spacing: -0.4px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* 邮件分类标签 */
.mail-category-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 8px;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
}

.mail-category-badge.work {
    background: rgba(245, 87, 108, 0.15);
    color: #f5576c;
}

.mail-category-badge.personal {
    background: rgba(79, 172, 254, 0.15);
    color: #4facfe;
}

.mail-category-badge.promotion {
    background: rgba(67, 233, 123, 0.15);
    color: #43e97b;
}

.mail-category-badge.social {
    background: rgba(250, 112, 154, 0.15);
    color: #fa709a;
}

/* 附件 */
.mail-attachments {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 0.5px solid rgba(0, 0, 0, 0.1);
}

.mail-attachments-title {
    font-size: 13px;
    font-weight: 600;
    color: #8e8e93;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
}

.mail-attachment-item {
    background: #f2f2f7;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.mail-attachment-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: rgba(0, 122, 255, 0.1);
    flex-shrink: 0;
}

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

.mail-attachment-name {
    font-size: 15px;
    color: #000000;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
    letter-spacing: -0.4px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-attachment-size {
    font-size: 13px;
    color: #8e8e93;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
    letter-spacing: -0.4px;
}

/* 响应式调整 */
@media (max-width: 375px) {
    .mail-title {
        font-size: 15px;
    }
    
    .mail-item {
        padding: 10px 12px;
    }
    
    .mail-item-icon {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
}