/* ============================================
   MailVault · 暗夜琥珀主题
   ============================================ */

:root {
    --ink-deepest: #07070c;
    --ink-deep: #0d0d17;
    --ink: #111119;
    --ink-raised: #181825;
    --ink-high: #1e1e2e;

    --border-subtle: #1c1c2e;
    --border: #262640;

    --text-dim: #5c5c7a;
    --text-body: #9292b0;
    --text-bright: #c8c8e0;
    --text-white: #e8e8f8;

    --amber: #d4a853;
    --amber-glow: #f0c060;
    --amber-dim: #8b6914;
    --amber-bg: rgba(212, 168, 83, 0.08);

    --green: #6b9080;
    --red: #c47a6b;

    --font-display: 'Playfair Display', 'Georgia', 'Times New Roman', serif;
    --font-mono: 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
    --font-body: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --shadow-glow: 0 0 30px rgba(212, 168, 83, 0.06);
    --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.4);
    --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== 基础 ==================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    background: var(--ink-deepest);
    color: var(--text-body);
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 14px;
    line-height: 1.6;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==================== 背景纹理 ==================== */
.bg-texture {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(ellipse at 80% 20%, rgba(212, 168, 83, 0.03) 0%, transparent 60%),
        radial-gradient(ellipse at 20% 80%, rgba(139, 105, 20, 0.02) 0%, transparent 50%);
}

.bg-texture::after {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.4;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    mix-blend-mode: overlay;
}

/* ==================== 布局 ==================== */
.app {
    position: relative;
    z-index: 1;
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ==================== 左栏 ==================== */
.sidebar {
    width: 260px;
    min-width: 260px;
    display: flex;
    flex-direction: column;
    background: var(--ink-deep);
    border-right: 1px solid var(--border-subtle);
    backdrop-filter: blur(10px);
}

.sidebar-header {
    padding: 24px 20px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 18px;
    color: var(--amber);
    filter: drop-shadow(0 0 6px rgba(212, 168, 83, 0.5));
}

.logo-text {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    font-style: italic;
    color: var(--text-white);
    letter-spacing: 0.5px;
}

/* 连接状态 */
.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(107, 144, 128, 0.12);
    border: 1px solid rgba(107, 144, 128, 0.2);
    transition: var(--transition-smooth);
}

.connection-status.offline {
    background: rgba(196, 122, 107, 0.12);
    border-color: rgba(196, 122, 107, 0.2);
}

.pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 6px rgba(107, 144, 128, 0.6);
    animation: pulse 2s ease-in-out infinite;
}

.pulse-dot.dead {
    background: var(--red);
    box-shadow: 0 0 6px rgba(196, 122, 107, 0.6);
    animation: none;
}

.status-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-bright);
    letter-spacing: 0.5px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ==================== 邮箱卡片 ==================== */
.mailbox-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mailbox-card {
    position: relative;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

.mailbox-card-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--ink);
    border: 1px solid transparent;
    transition: var(--transition-fast);
    position: relative;
    z-index: 1;
}

.mailbox-card:hover .mailbox-card-inner {
    background: var(--ink-raised);
    border-color: var(--border);
}

.mailbox-card.active .mailbox-card-inner {
    background: var(--ink-high);
    border-color: var(--amber-dim);
}

.mailbox-card.active {
    box-shadow: var(--shadow-glow);
}

.mailbox-glow {
    position: absolute;
    inset: -2px;
    border-radius: var(--radius-md);
    opacity: 0;
    transition: opacity 0.3s;
    background: linear-gradient(135deg, rgba(212, 168, 83, 0.15), transparent);
    z-index: 0;
}

.mailbox-card.active .mailbox-glow {
    opacity: 1;
}

.mailbox-card.has-error {
    opacity: 0.6;
}

.mailbox-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--ink-high), var(--ink-raised));
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    color: var(--amber);
    flex-shrink: 0;
}

.mailbox-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mailbox-addr {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-bright);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mailbox-meta {
    font-size: 10px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    letter-spacing: 0.3px;
}

.mailbox-badge {
    min-width: 24px;
    height: 24px;
    border-radius: 12px;
    background: var(--amber);
    color: var(--ink-deepest);
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 7px;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    flex-shrink: 0;
}

/* ==================== 侧栏底部 ==================== */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--ink);
    color: var(--text-body);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    letter-spacing: 0.3px;
}

.btn:hover {
    background: var(--ink-raised);
    border-color: var(--amber-dim);
    color: var(--amber);
}

.btn:active {
    transform: scale(0.98);
}

.btn.loading {
    opacity: 0.6;
    pointer-events: none;
}

.btn-subaccount {
    border-color: var(--amber-dim);
    color: var(--amber);
}

.btn-subaccount:hover {
    background: var(--amber-bg);
    border-color: var(--amber);
    box-shadow: 0 0 20px rgba(212, 168, 83, 0.1);
}

/* ==================== 子账号区域 ==================== */
.sidebar-section {
    padding: 12px;
    border-top: 1px solid var(--border-subtle);
}

.section-label {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
    font-family: var(--font-mono);
}

.subaccount-list {
    max-height: 120px;
    overflow-y: auto;
}

.subaccount-empty {
    font-size: 11px;
    color: var(--text-dim);
    opacity: 0.5;
    padding: 6px 0;
    font-style: italic;
}

.subaccount-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
    margin-bottom: 2px;
}

.subaccount-item:hover {
    background: var(--ink-raised);
}

.subaccount-email {
    font-size: 11px;
    color: var(--text-body);
    font-family: var(--font-mono);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.subaccount-del {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    opacity: 0;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
}

.subaccount-item:hover .subaccount-del {
    opacity: 1;
}

.subaccount-del:hover {
    color: var(--red);
    background: rgba(196, 122, 107, 0.15);
}

/* ==================== 侧栏底部 ==================== */

/* ==================== 中栏 ==================== */
.mail-list-panel {
    width: 380px;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    background: var(--ink);
    border-right: 1px solid var(--border-subtle);
}

.panel-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-subtle);
    min-height: 56px;
    background: var(--ink-deep);
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

.title-icon {
    color: var(--amber);
    font-size: 10px;
    flex-shrink: 0;
}

.title-text {
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-bright);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.refresh-tag {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    flex-shrink: 0;
}

.refresh-icon {
    animation: spin 3s linear infinite;
    font-size: 12px;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==================== 邮件行 ==================== */
.mail-list-scroll {
    flex: 1;
    overflow-y: auto;
}

.mail-row {
    padding: 14px 20px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    transition: var(--transition-fast);
    animation: fadeInUp 0.3s ease both;
}

.mail-row:hover {
    background: var(--ink-raised);
}

.mail-row.active {
    background: var(--amber-bg);
    border-left: 2px solid var(--amber);
    box-shadow: inset 0 0 20px rgba(212, 168, 83, 0.03);
}

.mail-row-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 4px;
}

.mail-row-from {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-bright);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.mail-row-date {
    font-size: 10.5px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    white-space: nowrap;
    flex-shrink: 0;
}

.mail-row-subject {
    font-size: 12px;
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== 右栏 ==================== */
.detail-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--ink-deep);
    min-width: 0;
}

.detail-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* ==================== 空状态 ==================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 30px;
    text-align: center;
    animation: fadeInUp 0.5s ease;
}

.empty-icon {
    font-size: 36px;
    color: var(--text-dim);
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-title {
    font-family: var(--font-display);
    font-size: 16px;
    font-style: italic;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.empty-desc {
    font-size: 12px;
    color: var(--text-dim);
    opacity: 0.6;
    max-width: 240px;
}

/* ==================== 详情卡片 ==================== */
.detail-card {
    animation: fadeInUp 0.35s ease;
}

.detail-meta {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.detail-meta-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.meta-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--amber);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    min-width: 48px;
    flex-shrink: 0;
    padding-top: 1px;
    font-family: var(--font-mono);
    font-size: 10px;
}

.meta-value {
    font-size: 13px;
    color: var(--text-bright);
    word-break: break-all;
    line-height: 1.5;
}

.meta-value.subject {
    font-weight: 500;
    color: var(--text-white);
}

.detail-divider {
    height: 1px;
    background: linear-gradient(90deg, var(--border), transparent);
    margin-bottom: 20px;
}

.detail-body {
    font-size: 13.5px;
    line-height: 1.8;
    color: var(--text-body);
    white-space: pre-wrap;
    word-break: break-all;
    font-weight: 300;
}

/* ==================== Toast ==================== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--ink-high);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 24px;
    color: var(--text-bright);
    font-size: 13px;
    z-index: 1000;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast strong {
    color: var(--amber);
    display: block;
    margin-bottom: 2px;
}

.toast small {
    color: var(--text-dim);
    font-size: 11px;
}

/* ==================== 滚动条 ==================== */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* ==================== 响应式降级 ==================== */
@media (max-width: 900px) {
    .sidebar { width: 200px; min-width: 200px; }
    .mail-list-panel { width: 280px; min-width: 240px; }
}

/* ==================== 模态框 ==================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--ink-deep);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 440px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(212, 168, 83, 0.05);
    animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-style: italic;
    font-weight: 700;
    color: var(--text-white);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 16px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.modal-close:hover {
    background: var(--ink-high);
    color: var(--text-bright);
}

.modal-body {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-desc {
    font-size: 12.5px;
    color: var(--text-dim);
    line-height: 1.6;
}

.modal-field label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
    font-family: var(--font-mono);
}

.input-readonly {
    width: 100%;
    padding: 10px 14px;
    background: var(--ink-deepest);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-body);
    font-size: 13px;
    font-family: var(--font-mono);
    opacity: 0.7;
    cursor: default;
}

.suffix-row {
    display: flex;
    align-items: center;
    background: var(--ink-deepest);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: var(--transition-fast);
}

.suffix-row:focus-within {
    border-color: var(--amber);
    box-shadow: 0 0 0 3px rgba(212, 168, 83, 0.08);
}

.suffix-row input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 10px 14px;
    color: var(--text-bright);
    font-size: 14px;
    font-family: var(--font-mono);
    outline: none;
    min-width: 0;
}

.suffix-domain {
    padding: 10px 14px;
    color: var(--amber);
    font-size: 13px;
    font-family: var(--font-mono);
    font-weight: 500;
    background: rgba(212, 168, 83, 0.06);
    border-left: 1px solid var(--border);
    flex-shrink: 0;
}

.field-hint {
    font-size: 11px;
    color: var(--red);
    margin-top: 4px;
    min-height: 18px;
}

.result-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--ink-deepest);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    gap: 10px;
}

.result-box span {
    font-size: 14px;
    color: var(--amber-glow);
    font-family: var(--font-mono);
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-copy {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    cursor: pointer;
    padding: 6px 10px;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.btn-copy:hover {
    color: var(--amber);
    border-color: var(--amber-dim);
    background: var(--amber-bg);
}

.modal-footer {
    padding: 16px 24px 20px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-primary {
    width: auto;
    background: var(--amber);
    color: var(--ink-deepest);
    border: none;
    font-weight: 600;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-family: var(--font-body);
    transition: var(--transition-fast);
    letter-spacing: 0.3px;
}

.btn-primary:hover {
    background: var(--amber-glow);
    box-shadow: 0 4px 20px rgba(212, 168, 83, 0.3);
    color: var(--ink-deepest);
    border-color: transparent;
}

.btn-ghost {
    width: auto;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-body);
    font-weight: 500;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-family: var(--font-body);
    transition: var(--transition-fast);
}

.btn-ghost:hover {
    background: var(--ink-raised);
    border-color: var(--text-dim);
    color: var(--text-bright);
}

/* ==================== 选中文本 ==================== */
::selection {
    background: rgba(212, 168, 83, 0.25);
    color: var(--text-white);
}
