/* Mail Manager Layout (Vertical Split) */
.mail-wrapper {
    display: flex; height: calc(100vh - var(--topbar-h));
    margin-top: var(--topbar-h); background: #fff; overflow: hidden;
}

.mail-list-area {
    width: 400px; border-right: 1px solid var(--border-color);
    display: flex; flex-direction: column; height: 100%; background: #fff; position: relative;
}

/* 1. Tabs & Search */
.mail-tabs { display: flex; border-bottom: 1px solid var(--border-color); background: #f8f9fa; flex-shrink: 0; }
.mail-tab {
    flex: 1; padding: 12px 0; text-align: center; cursor: pointer;
    font-weight: 700; color: #a0aec0; font-size: 11px; transition: all 0.2s ease;
    border-bottom: 2px solid transparent; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.mail-tab:hover { background: #edf2f7; color: var(--primary-color); }
.mail-tab.active { color: var(--primary-color); border-bottom: 2px solid var(--primary-color); background: #fff; }

.search-bar { padding: 16px 24px; border-bottom: 1px solid var(--border-color); background: #fff; flex-shrink: 0; }

.mail-bulk-actions {
    display: none; padding: 8px 16px; background: #f7fafc; 
    border-bottom: 1px solid var(--border-color); align-items: center; justify-content: space-between; font-size: 12px;
}
.mail-bulk-actions.active { display: flex; }

/* 2. Mail Items */
.mail-items-container { flex: 1; overflow-y: auto; padding-bottom: 60px; }
.mail-item {
    padding: 16px; border-bottom: 1px solid var(--border-color); cursor: pointer;
    display: flex; align-items: flex-start; transition: 0.2s;
}
.mail-item:hover { background: var(--bg-muted); }
.mail-item.active { background: var(--primary-lv-0); }

.mail-item-checkbox { width: 16px; height: 16px; cursor: pointer; margin-right: 12px; margin-top: 2px; }
.mail-item-content { flex: 1; min-width: 0; }
.mail-item-info { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.mail-date { font-size: 11px; color: var(--text-sub); white-space: nowrap; }

.btn-mail-delete {
    background: #f7fafc; border: 1px solid var(--border-color); color: #718096;
    font-size: 10px; padding: 2px 8px; border-radius: 4px; font-weight: 600;
}
.btn-mail-delete:hover { color: var(--error-color); background: #fff5f5; border-color: #feb2b2; }

/* 3. Content Area */
.mail-content-area { flex: 1; display: flex; flex-direction: column; overflow-y: auto; border-right: 1px solid var(--border-color); }
.mail-content-header { padding: var(--space-lg); border-bottom: 1px solid var(--border-color); }
.mail-body { padding: var(--space-lg); line-height: 1.6; min-height: 200px; }

/* 4. Attachments & AI */
.attachment-area { padding: var(--space-lg); border-top: 1px solid var(--border-color); background: var(--bg-muted); }
.attachment-item {
    display: flex; align-items: center; gap: var(--space-md); background: #fff;
    padding: 12px 20px; border-radius: var(--radius-lg);
    border: 1px solid var(--border-color); margin-bottom: var(--space-sm); cursor: pointer;
    transition: 0.2s;
}
.attachment-item:hover { border-color: var(--primary-color); box-shadow: var(--box-shadow); }
.attachment-item.active { background: var(--primary-lv-0); border-color: var(--primary-color); }

.file-details { flex: 1; min-width: 0; }
.file-name { font-size: 13px; font-weight: 700; max-width: 450px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 11px; color: var(--text-sub); }

.btn-group {
    display: flex; align-items: center; gap: 12px; flex-shrink: 0; justify-content: flex-end;
}

.btn-upload {
    padding: 6px 14px; border-radius: 6px; font-size: 11px; font-weight: 700;
    color: #fff; border: none; cursor: pointer; transition: 0.2s; height: 32px;
}

.btn-ai { background: var(--ai-gradient); }
.btn-ai:hover { filter: brightness(1.1); transform: translateY(-1px); }

.btn-normal { background: var(--primary-color); }
.btn-normal:hover { background: var(--primary-hover); transform: translateY(-1px); }

.ai-recommend {
    font-size: 11px; padding: 6px 12px; border-radius: 6px; font-weight: 600;
    cursor: pointer; transition: 0.2s; display: inline-block;
    max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ai-recommend.smart-mode { background: #eef2ff; color: #4338ca; border: 1px solid #c7d2fe; }
.ai-recommend.manual-mode { background: #f1f5f9; color: #475569; border: 1px dashed #cbd5e1; }
.ai-recommend:hover { transform: scale(1.02); }

/* 5. Preview Area */
.mail-preview-area {
    width: 0; background: #f8f9fa; display: flex; flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); position: relative;
    border-left: 0 solid transparent;
}

.mail-preview-area.active { 
    width: 600px; 
    border-left: 1px solid var(--border-color); 
    visibility: visible;
}

.preview-header {
    height: 56px; padding: 0 24px; border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
    background: #fff; flex-shrink: 0;
}

.preview-header h3 { font-size: 15px; font-weight: 800; color: var(--primary-color); margin: 0; }

#fullViewBtn {
    background: var(--primary-lv-0) !important;
    color: var(--primary-color) !important;
    border: 1px solid var(--primary-lv-1) !important;
    font-weight: 700 !important;
    padding: 4px 16px !important;
    border-radius: 4px !important;
    font-size: 11px !important;
    transition: 0.2s !important;
}
#fullViewBtn:hover { background: var(--primary-lv-1) !important; }

.preview-toggle-handle {
    position: absolute; left: -20px; top: 50%; transform: translateY(-50%);
    width: 20px; height: 60px; background: var(--primary-color); color: #fff;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px 0 0 8px; font-size: 10px; cursor: pointer;
    box-shadow: -2px 0 5px rgba(0,0,0,0.1); z-index: 100;
}
.preview-toggle-handle:hover { background: var(--primary-hover); }

.a4-container {
    flex: 1; padding: 30px; overflow-y: auto; background: #e9ecef;
    display: flex; justify-content: center;
}

.a4-container iframe, .a4-container .preview-placeholder {
    width: 100%; height: 100%; background: #fff; 
    box-shadow: 0 4px 20px rgba(0,0,0,0.08); border-radius: 4px;
}

.preview-placeholder {
    display: flex; align-items: center; justify-content: center;
    text-align: center; color: var(--text-sub); font-size: 13px; line-height: 1.6;
}

.mail-preview-area.active > * { opacity: 1 !important; visibility: visible !important; pointer-events: auto !important; }
.mail-preview-area > *:not(.preview-toggle-handle) { opacity: 0; visibility: hidden; pointer-events: none; transition: 0.2s; }

/* 6. Footer & Others */
.address-book-footer {
    position: absolute; bottom: 0; left: 0; width: 100%; padding: 12px 16px;
    border-top: 1px solid var(--border-color); background: #fff; display: flex; gap: 8px; z-index: 5;
}

.file-log-area {
    display: none; width: 100%; margin-top: 10px; background: #1a202c;
    border-radius: 4px; padding: 12px; font-family: monospace; font-size: 11px; color: #cbd5e0;
}
.file-log-area.active { display: block; }
.log-success { color: #48bb78; font-weight: 700; }

.switch { position: relative; display: inline-block; width: 34px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc; transition: .4s; border-radius: 20px;
}
.slider:before {
    position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px;
    background-color: white; transition: .4s; border-radius: 50%;
}
input:checked+.slider { background: var(--ai-gradient); }
input:checked+.slider:before { transform: translateX(14px); }

/* Restore Path Selector Modal Specific Styles */
.select-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.select-group label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-main);
}

.modal-select {
    width: 100%;
    height: 44px;
    padding: 0 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: #f9f9f9;
    font-size: 14px;
    color: #333;
    outline: none;
    transition: all 0.2s;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L2 4h8L6 8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
}

.modal-select:focus {
    border-color: var(--primary-color);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(30, 81, 73, 0.1);
}

.modal-select option {
    padding: 10px;
}
