/**
 * Easy Outlook - 样式文件
 * 从原版index.html完整复制，保持样式完全一致
 */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Arial', sans-serif;
    height: 100vh;
    overflow: hidden;
    background-color: #f5f5f5;
}

.app-container {
    display: grid;
    grid-template-columns: 350px 350px 1fr;
    grid-template-rows: 60px 1fr;
    height: 100vh;
    width: 100%;
    overflow: hidden;
    border-collapse: collapse;
}

/* 头部 */
.header {
    grid-column: 1 / 4;
    background-color: #2c3e50;
    color: white;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #1a2530;
    height: 60px;
    box-sizing: border-box;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 500;
}

/* 侧边栏 */
.sidebar,
.email-sidebar {
    grid-row: 2;
    background-color: #f0f0f0;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
    /* 减去头部高度 */
}

.sidebar {
    overflow-y: auto;
    overflow-x: hidden;
}

.email-sidebar {
    overflow: hidden;
}

/* 统一所有区域的边框样式 */
.sidebar,
.email-sidebar,
.main-content {
    border-top: none;
    align-items: stretch;
}

/* 导入邮箱区域样式 */
.sidebar>.sidebar-section:first-child {
    overflow-y: visible;
}

.sidebar {
    grid-column: 1;
}

.email-sidebar {
    grid-column: 2;
}

/* 主内容区域 */
.main-content {
    grid-column: 3;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: calc(100vh - 60px);
    /* 减去头部高度 */
}

/* 统一所有区域的内部分界线样式 */
.sidebar-section,
.email-sidebar .sidebar-section {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    min-height: 42px;
    /* 允许自适应高度，避免遮挡 */
    box-sizing: border-box;
    display: flex;
    align-items: center;
    width: 100%;
    flex: 0 0 auto;
}

.main-toolbar,
.tabs {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    height: 42px;
    /* 保持固定高度 */
    box-sizing: border-box;
    display: flex;
    align-items: center;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 0;
}

/* 统一标题文本样式 */
.sidebar-section h2,
.email-sidebar .sidebar-section h2 {
    font-size: 0.95rem;
    margin-bottom: 0;
    margin-top: 0;
    color: #333;
    line-height: 1.2;
}

/* 折叠/展开按钮 */
.toggle-btn {
    background: none;
    border: none;
    color: #555;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0 5px;
}

.toggle-btn:hover {
    color: #3498db;
    background: none;
}


/* Ensure the first two sections expand fully when opened */
#importContent:not(.collapsed),
#purchaseContent:not(.collapsed) {
    max-height: none;
    overflow: visible;
}


/* Full expand for mailbox list section; left sidebar handles scrolling */
#mailboxContent:not(.collapsed) {
    flex: 0 0 auto;
    overflow: visible;
}

.mailbox-list {
    overflow: visible;
    max-height: none;
}

.section-content {
    width: 100%;
    display: block;
    overflow-y: auto;
    transition: all 0.3s ease;
    max-height: 300px;
    /* 限制高度，避免挤压其他区域 */
    border-top: 1px solid #ddd;
    padding: 10px;
    margin-bottom: 0;
    flex: 0 0 auto;
    /* 防止与其他区域互相遮挡，保持自然高度 */
}

.section-content.collapsed {
    max-height: 0;
    padding: 0;
    margin: 0;
    border: 0;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    pointer-events: none;
}

/* 表单元素 */
.input-group {
    margin-bottom: 12px;
}

.input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

label {
    display: block;
    margin-bottom: 3px;
    font-size: 0.85rem;
    color: #555;
}

.form-control {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
    margin-bottom: 0;
    box-sizing: border-box;
}

.small-input {
    width: 60px;
    padding: 2px 5px;
    font-size: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 3px;
}

textarea {
    width: 100%;
    height: 80px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
    resize: none;
    font-family: inherit;
    box-sizing: border-box;
}

select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    font-size: 0.9rem;
}

/* 按钮 */
button {
    padding: 6px 10px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #2980b9;
}

button.secondary {
    background-color: #95a5a6;
}

button.secondary:hover {
    background-color: #7f8c8d;
}

button.warning {
    background-color: #e74c3c;
}

button.warning:hover {
    background-color: #c0392b;
}

.small-btn {
    padding: 3px 8px;
    font-size: 0.75rem;
}

.control-group {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
}

/* 邮箱列表 */
.mailbox-list-content {
    flex: 1;
    overflow: hidden;
    transition: all 0.3s ease;
    border-top: 1px solid #ddd;
}

.mailbox-list-content.collapsed {
    max-height: 0;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
}

.mailbox-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    list-style-type: none;
    margin: 0;
    border-top: 1px solid #ddd;
    min-height: 200px;
}

.mailbox-item {
    padding: 8px 12px;
    border: 1px solid #ddd;
    margin-bottom: 6px;
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mailbox-item:hover {
    background-color: #f5f5f5;
    border-color: #bbb;
}

.mailbox-item.selected {
    background-color: #e1f0fa;
    border-color: #3498db;
}

.mailbox-email {
    font-weight: bold;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.delete-mailbox {
    margin-left: 10px;
    background-color: transparent;
    color: #999;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    opacity: 0.7;
    transition: all 0.2s;
}

.delete-mailbox:hover {
    background-color: #e74c3c;
    color: white;
    border-color: #c0392b;
    opacity: 1;
}

/* 邮件列表 */
.email-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    list-style-type: none;
    margin: 0;
    border-top: 1px solid #ddd;
    min-height: 200px;
    position: relative;
}

.email-item {
    padding: 10px 15px;
    border: 1px solid #ddd;
    margin-bottom: 8px;
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.email-item:hover {
    background-color: #f5f5f5;
    border-color: #bbb;
}

.email-item.selected {
    background-color: #e1f0fa;
    border-color: #3498db;
}

.email-item-subject {
    font-weight: bold;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 5px;
}

.email-item-from {
    font-size: 0.8rem;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-item-date {
    font-size: 0.75rem;
    color: #777;
    margin-top: 5px;
}

/* 工具栏 */
.main-toolbar {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    height: 42px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    background-color: #ecf0f1;
}

/* 标签页 */
.tabs {
    display: flex;
    padding: 10px;
    border-bottom: 1px solid #ddd;
    height: 42px;
    box-sizing: border-box;
    align-items: center;
    background-color: #f8f8f8;
}

.tab {
    padding: 0 15px;
    cursor: pointer;
    border-right: 1px solid #ddd;
    font-size: 0.9rem;
    height: 100%;
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
}

.tab:hover {
    background-color: #e8e8e8;
}

.tab.active {
    background-color: white;
    border-bottom: 2px solid #3498db;
    height: calc(100% + 2px);
    position: relative;
    top: 1px;
}

/* 邮件容器 */
.email-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: calc(100vh - 120px);
}

.email-header {
    padding: 10px;
    background-color: #f8f8f8;
    border-bottom: 1px solid #ddd;
}

.email-subject {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.email-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #555;
}

.email-from {
    font-weight: bold;
}

.email-viewer {
    flex: 1;
    overflow: auto;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 170px);
    position: relative;
}

iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.raw-data {
    padding: 15px;
    overflow: auto;
    height: 100%;
    font-family: 'Consolas', 'Monaco', monospace;
    white-space: pre-wrap;
    font-size: 0.9rem;
    background-color: #f8f8f8;
    flex: 1;
}

/* 状态 */
.status-message {
    color: #ecf0f1;
    font-size: 0.9rem;
}

.status-message.error {
    color: #e74c3c;
}

.status-message.success {
    color: #27ae60;
}

.status-message.loading {
    color: #3498db;
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-style: italic;
    color: #666;
    flex: 1;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #7f8c8d;
    padding: 20px;
    min-height: 100px;
    height: 100%;
    width: 100%;
}

.empty-state p {
    margin-bottom: 15px;
    text-align: center;
}

/* 文件上传 */
.file-input {
    opacity: 0;
    position: absolute;
    z-index: -1;
}

.file-input-label {
    display: inline-block;
    padding: 6px 10px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    margin-bottom: 0;
    transition: background-color 0.2s;
}

.file-input-label:hover {
    background-color: #2980b9;
}

.file-input-wrapper {
    position: relative;
    margin-right: 10px;
    display: inline-block;
}

/* 拖拽上传 */
.dropzone {
    border: 2px dashed #ccc;
    transition: all 0.3s ease;
}

.dropzone.dragover {
    border-color: #3498db;
    background-color: #f0f8ff;
}

.drag-hint,
.api-hint {
    font-size: 0.75rem;
    color: #777;
    margin-top: 3px;
    text-align: center;
    font-style: italic;
}

.api-hint {
    text-align: left;
    margin-top: 5px;
}

.api-hint a {
    color: #3498db;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.api-hint a:hover {
    text-decoration: underline;
}

.github-icon {
    margin-right: 3px;
    vertical-align: middle;
    position: relative;
    top: -1px;
}

.separator-input {
    display: flex;
    align-items: center;
    gap: 5px;
}

.separator-input label {
    margin-bottom: 0;
    font-size: 0.8rem;
}

/* Improved, consistent scrollbar styling */
.mailbox-list,
.email-list,
.section-content,
.email-viewer,
.raw-data {
    scrollbar-width: thin;
    /* Firefox */
    scrollbar-color: #b8c2cc transparent;
    scrollbar-gutter: stable both-edges;
}

/* WebKit-based browsers (Chrome, Edge, Safari) */
.mailbox-list::-webkit-scrollbar,
.email-list::-webkit-scrollbar,
.section-content::-webkit-scrollbar,
.email-viewer::-webkit-scrollbar,
.raw-data::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.mailbox-list::-webkit-scrollbar-track,
.email-list::-webkit-scrollbar-track,
.section-content::-webkit-scrollbar-track,
.email-viewer::-webkit-scrollbar-track,
.raw-data::-webkit-scrollbar-track {
    background: transparent;
}

.mailbox-list::-webkit-scrollbar-thumb,
.email-list::-webkit-scrollbar-thumb,
.section-content::-webkit-scrollbar-thumb,
.email-viewer::-webkit-scrollbar-thumb,
.raw-data::-webkit-scrollbar-thumb {
    background-color: #c4ccd5;
    border-radius: 8px;
    border: 2px solid transparent;
    /* creates inner padding */
    background-clip: content-box;
}

.mailbox-list:hover::-webkit-scrollbar-thumb,
.email-list:hover::-webkit-scrollbar-thumb,
.section-content:hover::-webkit-scrollbar-thumb,
.email-viewer:hover::-webkit-scrollbar-thumb,
.raw-data:hover::-webkit-scrollbar-thumb {
    background-color: #a9b4bf;
}

/* Avoid content hidden behind scrollbar and reduce scroll chaining */
.mailbox-list,
.email-list {
    padding-right: 4px;
    overscroll-behavior: contain;
}

.section-content,
.email-viewer,
.raw-data {
    overscroll-behavior: contain;
}