/* 全局样式和重置 */
:root {
    --outlook-blue: #0078d4;
    --outlook-dark-blue: #106ebe;
    --outlook-light-blue: #f0f6fb;
    --outlook-selected-blue: #c7e0f4;
    --border-color: #e1e1e1;
    --background-light: #f5f5f5;
    --background-white: #ffffff;
    --text-primary: #242424;
    --text-secondary: #605e5c;
    --text-dark: #323130;
    --icon-color: #605e5c;
}

body {
    font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif;
    margin: 0;
    background-color: var(--background-light);
    color: var(--text-primary);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

button {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    color: inherit;
    padding: 0;
}

/* 顶部导航栏 */
.top-bar {
    background-color: var(--outlook-blue);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    height: 48px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.top-bar-left, .top-bar-center, .top-bar-right {
    display: flex;
    align-items: center;
}

.menu-toggle {
    font-size: 20px;
    padding: 5px 10px;
    margin-right: 10px;
    color: white;
    border-radius: 2px;
}

.menu-toggle:hover {
    background-color: var(--outlook-dark-blue);
}

.app-title {
    font-size: 18px;
    font-weight: 600;
    margin-right: 20px;
}

.search-bar {
    background-color: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    width: 300px;
    font-family: inherit;
    color: white;
    outline: none;
}

.search-bar::placeholder {
    color: rgba(255, 255, 255, 0.8);
}

.icon-button {
    font-size: 18px;
    color: white;
    padding: 8px;
    margin-left: 5px;
    border-radius: 4px;
}

.icon-button:hover {
    background-color: var(--outlook-dark-blue);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #66bb6a; /* Example avatar color */
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    margin-left: 15px;
    cursor: pointer;
}

/* 主内容容器布局 */
.main-container {
    display: flex;
    flex-grow: 1;
    height: calc(100vh - 48px); /* 减去顶部栏高度 */
}

/* 左侧垂直导航栏 */
.vertical-nav {
    width: 48px;
    background-color: var(--background-white);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 10px;
    flex-shrink: 0;
}

.nav-icon {
    font-size: 20px;
    padding: 10px;
    margin-bottom: 5px;
    color: var(--icon-color);
    border-radius: 4px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.nav-icon:hover {
    background-color: var(--outlook-light-blue);
}

.nav-icon.active {
    color: var(--outlook-blue);
    background-color: var(--outlook-light-blue);
    border-left: 2px solid var(--outlook-blue);
}

.nav-icon img {
    width: 24px; /* 统一图片宽度 */
    height: 24px; /* 统一图片高度 */
    object-fit: contain; /* 确保图片内容完整显示，不变形 */
}

/* 邮件应用主区域 */
.email-app {
    display: flex;
    flex-grow: 1;
    background-color: var(--background-light);
}

/* 左侧邮件列表 */
.email-list {
    width: 320px; /* Adjusted width */
    min-width: 250px;
    max-width: 600px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-color);
    background-color: var(--background-white);
    display: flex;
    flex-direction: column;
}

.email-list-actions {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.new-email-button {
    background-color: var(--outlook-blue);
    color: white;
    padding: 10px 15px;
    border-radius: 4px;
    font-weight: 600;
    margin-bottom: 10px;
    width: 100%;
    text-align: left;
}

.new-email-button:hover {
    background-color: var(--outlook-dark-blue);
}

.tabs {
    display: flex;
    margin-bottom: 10px;
}

.tab-button {
    flex-grow: 1;
    padding: 8px 10px;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-weight: 600;
    text-align: center;
}

.tab-button.active {
    color: var(--outlook-blue);
    border-bottom-color: var(--outlook-blue);
}

.mail-operations {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.op-button {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-dark);
    font-size: 13px;
}

.op-button:hover {
    background-color: var(--outlook-light-blue);
}

.email-list-header {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    background-color: var(--background-light);
}

.email-list-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
}

.email-list ul {
    overflow-y: auto;
    flex-grow: 1;
}

.email-item {
    border-bottom: 1px solid var(--border-color);
}

.email-item a {
    display: block;
    padding: 10px 15px;
    transition: background-color 0.2s ease-in-out;
}

.email-item:hover a {
    background-color: var(--outlook-light-blue);
}

.email-item.active a {
    background-color: var(--outlook-selected-blue); /* Outlook 选中颜色 */
}

/* 未读邮件样式 */
.email-item.unread .email-sender,
.email-item.unread .email-subject {
    font-weight: 700;
    color: var(--text-primary);
}

.email-sender {
    font-size: 0.875rem;
    margin-bottom: 2px;
    color: var(--text-dark);
}

.email-subject {
    font-size: 0.9rem;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-dark);
    font-weight: 600;
}

.email-preview {
    font-size: 0.8rem;
    margin: 0;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 分隔条样式 */
.resizer {
    flex-shrink: 0;
    width: 5px;
    background: var(--border-color);
    cursor: col-resize;
    transition: background-color 0.2s ease;
}

.resizer:hover {
    background: var(--outlook-blue);
}

/* 右侧邮件内容 */
.email-content {
    flex-grow: 1;
    background-color: var(--background-light); /* Changed to light background for card effect */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 15px; /* Padding around the card */
}

.email-content-header {
    background-color: var(--background-white);
    padding: 15px 20px;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    margin-bottom: 1px; /* To separate from meta-actions */
}

.email-content-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.email-content-meta-actions {
    background-color: var(--background-white);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    margin-bottom: 15px; /* Space before email body */
}

.email-meta-info {
    display: flex;
    align-items: center;
    flex-grow: 1;
}

.sender-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--outlook-blue); /* Use Outlook blue for avatar background */
    color: white; /* Ensure text is visible */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    margin-right: 10px;
    flex-shrink: 0;
}

.sender-details {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.sender-email {
    font-weight: 600;
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.recipient-email {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
}

.email-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-left: auto; /* Pushes date to the right */
    flex-shrink: 0;
}

.email-actions {
    display: flex;
    gap: 5px;
    margin-left: 15px;
    flex-shrink: 0;
}

.action-button {
    font-size: 18px;
    color: var(--icon-color);
    padding: 8px;
    border-radius: 4px;
}

.action-button:hover {
    background-color: var(--outlook-light-blue);
}

.email-body {
    flex-grow: 1;
    background-color: var(--background-white);
    padding: 20px;
    line-height: 1.6;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.email-body iframe {
    width: 100%;
    height: 100%; /* Make iframe take full height of its parent */
    border: none;
    visibility: hidden;
}

/* 加载动画 */
.email-content .loader-wrapper {
    position: absolute; /* 相对于父元素 .email-content 定位 */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--background-white);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999; /* 确保在邮件内容之上 */
    transition: opacity 0.3s ease, visibility 0.3s ease;
    border-radius: 8px; /* Apply border-radius to loader as well */
}

.loader {
    border: 5px solid var(--outlook-light-blue);
    border-top: 5px solid var(--outlook-blue);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loader-wrapper.hidden {
    opacity: 0;
    visibility: hidden;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .vertical-nav {
        display: none; /* Hide vertical nav on smaller screens */
    }

    .email-list {
        width: 100%;
        max-width: 100%;
    }

    .email-content {
        display: none; /* Hide email content by default on smaller screens */
    }

    .email-app {
        flex-direction: column;
    }

    .resizer {
        display: none; /* Hide resizer on smaller screens */
    }
}
