/* ============================================
   邮箱简报系统 - 白色主题
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4F46E5;
    --primary-light: #EEF2FF;
    --primary-hover: #4338CA;
    --bg: #F9FAFB;
    --white: #FFFFFF;
    --border: #E5E7EB;
    --border-light: #F3F4F6;
    --text: #111827;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --red: #EF4444;
    --red-light: #FEF2F2;
    --green: #10B981;
    --green-light: #ECFDF5;
    --yellow: #F59E0B;
    --yellow-light: #FFFBEB;
    --blue: #3B82F6;
    --blue-light: #EFF6FF;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
    --shadow: 0 1px 3px rgba(0, 0, 0, .1), 0 1px 2px rgba(0, 0, 0, .06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .1);
    --radius: 8px;
    --radius-sm: 6px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* ---- 顶部导航 ---- */
.topbar {
    display: flex;
    align-items: center;
    height: 56px;
    padding: 0 24px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 32px;
}

.brand-icon {
    font-size: 24px;
}

.brand-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.topbar-nav {
    display: flex;
    gap: 4px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all .15s;
}

.nav-item:hover {
    background: var(--bg);
    color: var(--text);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-icon {
    font-size: 16px;
}

.topbar-actions {
    display: flex;
    gap: 8px;
}

/* ---- 按钮 ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
}

.btn:hover {
    border-color: var(--text-muted);
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--bg);
}

.btn-danger {
    color: var(--red);
    border-color: var(--red);
}

.btn-danger:hover {
    background: var(--red-light);
}

/* ---- 输入框 ---- */
.input,
.input-sm {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    background: var(--white);
    outline: none;
    transition: border-color .15s;
}

.input:focus,
.input-sm:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .1);
}

.input-sm {
    padding: 6px 10px;
    font-size: 13px;
}

.input-color {
    width: 36px;
    height: 36px;
    padding: 2px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--border);
}

/* ---- Tab 内容 ---- */
.tab-content {
    display: none;
    height: calc(100vh - 56px);
}

.tab-content.active {
    display: block;
}

/* ---- 页面容器 ---- */
.page-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 32px 24px;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}

/* ---- 卡片 ---- */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-weight: 600;
    font-size: 15px;
}

.badge {
    background: var(--bg);
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ============================================
   邮件列表布局 (仿邮箱客户端)
   ============================================ */
.email-layout {
    display: flex;
    height: calc(100vh - 56px);
}

.email-sidebar {
    width: 420px;
    min-width: 360px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: var(--white);
}

.email-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    gap: 8px;
    flex-shrink: 0;
}

.email-toolbar-left {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}

.email-toolbar-right {
    display: flex;
    gap: 6px;
    align-items: center;
}

.email-list {
    flex: 1;
    overflow-y: auto;
}

.email-list-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background .1s;
}

.email-list-item:hover {
    background: var(--bg);
}

.email-list-item.active {
    background: var(--primary-light);
    border-left: 3px solid var(--primary);
}

.email-list-item.importance-high {
    border-left: 3px solid var(--red);
}

.email-list-item .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.dot.high {
    background: var(--red);
}

.dot.normal {
    background: var(--blue);
}

.dot.low {
    background: var(--text-muted);
}

.email-list-info {
    flex: 1;
    min-width: 0;
}

.email-list-sender {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-list-subject {
    font-size: 13px;
    color: var(--text);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-list-preview {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-list-time {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.email-list-tags {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.email-tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    background: var(--primary-light);
    color: var(--primary);
}

/* ---- 邮件详情面板 ---- */
.email-detail {
    flex: 1;
    overflow-y: auto;
    background: var(--white);
    display: flex;
    flex-direction: column;
}

.email-detail-header {
    padding: 24px 32px 16px;
    border-bottom: 1px solid var(--border-light);
}

.email-detail-subject {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
    line-height: 1.3;
}

.email-detail-meta {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.email-detail-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.email-detail-from {
    flex: 1;
}

.email-detail-sender-name {
    font-weight: 600;
    font-size: 14px;
}

.email-detail-sender-email {
    font-size: 13px;
    color: var(--text-muted);
}

.email-detail-date {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}

.email-detail-body {
    padding: 24px 32px;
    flex: 1;
    font-size: 14px;
    line-height: 1.8;
    color: var(--text);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.email-detail-tags {
    padding: 0 32px 16px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.email-detail-tags .email-tag {
    font-size: 12px;
    padding: 2px 10px;
}

/* ---- 关键词管理 ---- */
.keyword-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.keyword-form .input {
    flex: 1;
}

.keyword-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.keyword-item:last-child {
    border-bottom: none;
}

.keyword-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.keyword-text {
    flex: 1;
    font-weight: 500;
    font-size: 14px;
}

.keyword-category {
    font-size: 12px;
    color: var(--text-muted);
    padding: 2px 8px;
    background: var(--bg);
    border-radius: 4px;
}

.keyword-toggle {
    width: 40px;
    height: 22px;
    border-radius: 11px;
    background: var(--border);
    cursor: pointer;
    position: relative;
    transition: background .2s;
}

.keyword-toggle::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: transform .2s;
    box-shadow: var(--shadow-sm);
}

.keyword-toggle.active {
    background: var(--green);
}

.keyword-toggle.active::after {
    transform: translateX(18px);
}

.btn-delete {
    padding: 4px 8px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    opacity: .4;
    transition: opacity .15s;
}

.btn-delete:hover {
    opacity: 1;
}

/* ---- 简报 ---- */
.brief-item {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.brief-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg);
    border-bottom: 1px solid var(--border-light);
}

.brief-date {
    font-weight: 600;
    font-size: 15px;
}

.brief-stats {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.brief-stat strong {
    color: var(--text);
}

.brief-body {
    padding: 20px;
    font-size: 14px;
    line-height: 1.8;
    white-space: pre-wrap;
    color: var(--text);
}

/* ---- 设置 ---- */
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-row label {
    font-weight: 500;
    font-size: 14px;
}

/* ---- 空状态 ---- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 14px;
}

.text-muted {
    color: var(--text-muted);
    font-size: 14px;
}

/* ---- Toast ---- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    transition: transform .3s ease;
    box-shadow: var(--shadow-md);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: var(--green);
    color: white;
}

.toast.error {
    background: var(--red);
    color: white;
}

/* ---- 滚动条 ---- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}