/**
 * iPhone 短信应用 - iOS 白色主题
 * 完全还原iOS短信的高级感和原生app体验
 * 参考备忘录实现，使用白色主题
 */

.iphone-messages-page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.iphone-messages-page.show {
    display: flex;
    animation: slideInFromRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 短信头部 */
.messages-header {
    position: relative;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: #ffffff;
    z-index: 10;
    border-bottom: 0.33px solid rgba(0, 0, 0, 0.1);
}

.messages-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;
    z-index: 11;
}

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

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

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

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

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

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

/* 短信内容区域 */
.messages-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f2f2f7;
    -webkit-overflow-scrolling: touch;
}

.messages-content::-webkit-scrollbar {
    display: none;
}

/* 空状态 */
.messages-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 40px;
    text-align: center;
}

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

.messages-empty-text {
    font-size: 22px;
    font-weight: 600;
    color: #000000;
    margin-bottom: 12px;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
}

.messages-empty-hint {
    font-size: 15px;
    color: #8e8e93;
    line-height: 1.4;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
}

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

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

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

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

/* 短信对话列表 */
.messages-list {
    padding: 0;
}

.messages-item {
    background: #ffffff;
    border-bottom: 0.5px solid #e5e5ea;
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: background 0.2s;
    cursor: pointer;
}

.messages-item:active {
    background: #f2f2f7;
}

/* 短信头像 */
.messages-item-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 2px 12px rgba(102, 126, 234, 0.3);
    font-weight: 600;
    color: #fff;
    overflow: hidden;
}

.messages-item-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.messages-item-avatar.work {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 2px 12px rgba(240, 147, 251, 0.3);
}

.messages-item-avatar.family {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    box-shadow: 0 2px 12px rgba(79, 172, 254, 0.3);
}

.messages-item-avatar.friends {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    box-shadow: 0 2px 12px rgba(250, 112, 154, 0.3);
}

.messages-item-avatar.service {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    box-shadow: 0 2px 12px rgba(67, 233, 123, 0.3);
}

/* 短信内容 */
.messages-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

.messages-item-name {
    font-size: 17px;
    font-weight: 600;
    color: #000000;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
}

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

.messages-item-preview {
    font-size: 15px;
    color: #8e8e93;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 未读标记 */
.messages-item.unread .messages-item-name {
    font-weight: 700;
}

.messages-item.unread .messages-item-preview {
    color: #007aff;
    font-weight: 500;
}

.messages-unread-badge {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    min-width: 24px;
    height: 24px;
    background: #007aff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    padding: 0 6px;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.4);
}

/* 短信详情页 */
.messages-detail-page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    z-index: 1001;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.messages-detail-page.show {
    display: flex;
    animation: slideInFromRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.messages-detail-header {
    padding: 0 16px 10px;
    background: #ffffff;
    border-bottom: 0.33px solid rgba(0, 0, 0, 0.1);
}

.messages-detail-top {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.messages-detail-back-btn {
    background: none;
    border: none;
    color: #007aff;
    font-size: 17px;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 8px 0;
}

.messages-detail-back-btn:active {
    opacity: 0.6;
}

.messages-detail-contact {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 12px;
}

.messages-detail-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.messages-detail-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.messages-detail-name {
    font-size: 17px;
    font-weight: 600;
    color: #000000;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
}

/* 短信气泡容器 */
.messages-detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    -webkit-overflow-scrolling: touch;
    background: #ffffff;
}

.messages-detail-content::-webkit-scrollbar {
    display: none;
}

/* 时间戳分隔线 */
.messages-timestamp {
    text-align: center;
    padding: 8px 0;
}

.messages-timestamp-text {
    display: inline-block;
    background: #e5e5ea;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 12px;
    color: #8e8e93;
    font-weight: 500;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
}

/* 短信气泡 */
.messages-bubble-row {
    display: flex;
    margin-bottom: 8px;
}

.messages-bubble-row.received {
    justify-content: flex-start;
}

.messages-bubble-row.sent {
    justify-content: flex-end;
}

.messages-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 17px;
    line-height: 1.35;
    word-wrap: break-word;
    position: relative;
}

.messages-bubble.received {
    background: #e5e5ea;
    color: #000000;
    border-bottom-left-radius: 6px;
}

.messages-bubble.sent {
    background: #007aff;
    color: #fff;
    border-bottom-right-radius: 6px;
}

.messages-bubble-text {
    word-break: break-word;
}

/* 发送状态 */
.messages-bubble-status {
    font-size: 12px;
    color: #8e8e93;
    text-align: right;
    margin-top: 2px;
    margin-left: 8px;
}

.messages-bubble-sent {
    color: #34c759;
}

.messages-bubble-delivered {
    color: #34c759;
}

.messages-bubble-read {
    color: #34c759;
}

.messages-bubble-failed {
    color: #ff3b30;
}

/* 输入区域模拟 */
.messages-input-area {
    padding: 8px 16px;
    background: #ffffff;
    border-top: 0.33px solid rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.messages-input-field {
    flex: 1;
    background: #f2f2f7;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 17px;
    color: #000000;
    outline: none;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
}

.messages-input-field::placeholder {
    color: #8e8e93;
}

.messages-send-btn {
    width: 36px;
    height: 36px;
    background: #007aff;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.messages-send-btn:active {
    transform: scale(0.95);
    background: #0063d1;
}

.messages-send-btn svg {
    width: 18px;
    height: 18px;
    fill: #fff;
    transform: rotate(-45deg);
}

/* 短信分类标签 */
.messages-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;
}

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

.messages-category-badge.family {
    background: rgba(79, 172, 254, 0.2);
    color: #4facfe;
}

.messages-category-badge.friends {
    background: rgba(250, 112, 154, 0.2);
    color: #fa709a;
}

.messages-category-badge.service {
    background: rgba(67, 233, 123, 0.2);
    color: #43e97b;
}

/* 滑动动画 */
@keyframes slideInFromRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 响应式调整 */
@media (max-width: 375px) {
    .messages-item-avatar {
        width: 48px;
        height: 48px;
        font-size: 22px;
    }
    
    .messages-bubble {
        max-width: 70%;
        font-size: 16px;
    }
}

/* 搜索框（可选） */
.messages-search-bar {
    padding: 8px 16px;
    background: #1c1c1e;
    border-bottom: 0.5px solid rgba(255, 255, 255, 0.1);
}

.messages-search-input {
    width: 100%;
    background: #2c2c2e;
    border: none;
    border-radius: 10px;
    padding: 8px 12px 8px 36px;
    font-size: 16px;
    color: #fff;
    outline: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
}

.messages-search-input::placeholder {
    color: #8e8e93;
}

/* 表情符号支持 */
.emoji {
    display: inline-block;
    font-size: inherit;
    line-height: 1;
    vertical-align: middle;
}