/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f5f5f5;
    color: #333;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

.page {
    min-height: 100vh;
}

/* ========== 登录页 ========== */
.login-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    padding: 40px 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    width: 90%;
    max-width: 360px;
    text-align: center;
}

.login-box h1 {
    font-size: 22px;
    color: #1a1a1a;
    margin-bottom: 30px;
    font-weight: 600;
}

.login-box input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.login-box input:focus {
    border-color: #4a90d9;
}

.login-box button {
    width: 100%;
    padding: 12px;
    background: #4a90d9;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    margin-top: 16px;
    transition: background 0.2s;
}

.login-box button:hover {
    background: #3a7bc8;
}

.error-msg {
    color: #e74c3c;
    font-size: 13px;
    margin-top: 12px;
    min-height: 20px;
}

/* ========== 顶部栏 ========== */
.header {
    background: #4a90d9;
    color: #fff;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 18px;
    font-weight: 600;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ========== 统计栏 ========== */
.stats-bar {
    background: #fff;
    padding: 10px 16px;
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: #666;
    border-bottom: 1px solid #eee;
}

.stats-bar #stats-unread {
    color: #e74c3c;
    font-weight: 500;
}

/* ========== 域名筛选 ========== */
.domain-filter {
    background: #fff;
    padding: 10px 16px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    border-bottom: 1px solid #eee;
    -webkit-overflow-scrolling: touch;
}

.domain-filter::-webkit-scrollbar {
    display: none;
}

.domain-btn {
    flex-shrink: 0;
    padding: 6px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    background: #fff;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.domain-btn.active {
    background: #4a90d9;
    color: #fff;
    border-color: #4a90d9;
}

/* ========== 搜索栏 ========== */
.search-bar {
    background: #fff;
    padding: 10px 16px;
    display: flex;
    gap: 8px;
    border-bottom: 1px solid #eee;
}

.search-bar input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}

.search-bar input:focus {
    border-color: #4a90d9;
}

.search-bar button {
    padding: 8px 16px;
    background: #4a90d9;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 0;
}

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

.email-item {
    background: #fff;
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.15s;
}

.email-item:hover {
    background: #fafafa;
}

.email-item:active {
    background: #f0f0f0;
}

.email-item.unread {
    border-left: 3px solid #4a90d9;
}

.email-item .email-from {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.email-item .email-date {
    font-size: 11px;
    color: #999;
    flex-shrink: 0;
}

.email-item .email-subject {
    font-size: 13px;
    color: #333;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-item.unread .email-subject {
    font-weight: 600;
}

.email-code {
    display: inline-block;
    background: #ff6b35;
    color: #fff;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1px;
    margin-left: 6px;
    vertical-align: middle;
}

.email-item .email-preview {
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
}

.email-item .email-to {
    font-size: 12px;
    color: #999;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-empty {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 14px;
}

/* ========== 分页 ========== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 16px;
    flex-wrap: wrap;
}

.page-btn {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    color: #333;
}

.page-btn.active {
    background: #4a90d9;
    color: #fff;
    border-color: #4a90d9;
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ========== 邮件详情弹窗 ========== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f5f5f5;
    z-index: 200;
    overflow-y: auto;
}

.modal-content {
    max-width: 800px;
    margin: 0 auto;
    min-height: 100vh;
    background: #fff;
}

.modal-header {
    position: sticky;
    top: 0;
    background: #4a90d9;
    padding: 14px 16px;
    z-index: 10;
}

.btn-back {
    background: none;
    border: none;
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    padding: 4px 8px;
}

.detail-body {
    padding: 16px;
}

.detail-meta {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #eee;
}

.detail-meta .detail-subject {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 12px;
    line-height: 1.4;
}

.detail-meta .meta-row {
    font-size: 13px;
    color: #666;
    margin-bottom: 4px;
    line-height: 1.6;
    word-break: break-all;
}

.detail-meta .meta-row strong {
    color: #333;
    font-weight: 500;
}

.detail-content {
    font-size: 14px;
    line-height: 1.7;
    color: #333;
    word-break: break-word;
    overflow-x: auto;
}

.detail-content img {
    max-width: 100%;
    height: auto;
}

/* ========== 加载状态 ========== */
.loading {
    text-align: center;
    padding: 40px;
    color: #999;
}

/* ========== PC端适配 ========== */
@media (min-width: 768px) {
    #main-page {
        max-width: 800px;
        margin: 0 auto;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
    }

    .email-item {
        padding: 16px 20px;
    }

    .header {
        border-radius: 0;
    }
}
