/* =========================================================================
   email.css — Full-featured email inbox / composer
   ========================================================================= */

/* ── layout ──────────────────────────────────────────────────────────────── */
.email-app {
    display: flex;
    height: calc(100vh - var(--navbar-height, 60px));
    background: var(--bg-primary, #0f0f0f);
    overflow: hidden;
}

/* ── sidebar ─────────────────────────────────────────────────────────────── */
.email-sidebar {
    display: flex;
    flex-direction: column;
    width: 220px;
    min-width: 180px;
    border-right: 1px solid var(--border-color, rgba(168,85,247,0.15));
    background: var(--bg-secondary, #111);
    flex-shrink: 0;
}

.email-sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color, rgba(168,85,247,0.12));
}

.email-compose-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.6rem 1rem;
    background: var(--accent, #a855f7);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.email-compose-btn:hover { opacity: 0.85; }

.email-folder-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.email-folder-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 1rem;
    cursor: pointer;
    color: var(--text-secondary, #aaa);
    font-size: 0.88rem;
    border-radius: 0;
    transition: background 0.1s, color 0.1s;
    border-left: 3px solid transparent;
}
.email-folder-item:hover {
    background: rgba(168,85,247,0.08);
    color: var(--text-primary, #f0f0f0);
}
.email-folder-item.active {
    background: rgba(168,85,247,0.12);
    color: var(--accent, #a855f7);
    border-left-color: var(--accent, #a855f7);
    font-weight: 600;
}
.email-folder-item i { width: 16px; text-align: center; }
.email-folder-badge {
    margin-left: auto;
    background: var(--accent, #a855f7);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* ── list panel ──────────────────────────────────────────────────────────── */
.email-list-panel {
    display: flex;
    flex-direction: column;
    width: 340px;
    min-width: 260px;
    border-right: 1px solid var(--border-color, rgba(168,85,247,0.15));
    background: var(--bg-primary, #0f0f0f);
    flex-shrink: 0;
}

.email-list-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color, rgba(168,85,247,0.12));
}

.email-search-input {
    flex: 1;
    padding: 0.4rem 0.75rem;
    background: var(--bg-secondary, #111);
    border: 1px solid var(--border-color, rgba(168,85,247,0.15));
    border-radius: 20px;
    color: var(--text-primary, #f0f0f0);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.15s;
}
.email-search-input:focus { border-color: var(--accent, #a855f7); }
.email-search-input::placeholder { color: var(--text-secondary, #666); }

.email-refresh-btn {
    background: none;
    border: none;
    color: var(--text-secondary, #aaa);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 6px;
    transition: color 0.15s;
}
.email-refresh-btn:hover { color: var(--accent, #a855f7); }

.email-list {
    flex: 1;
    overflow-y: auto;
}

.email-list-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 0.75rem;
    color: var(--text-secondary, #666);
    font-size: 0.9rem;
}
.email-list-empty i { font-size: 2.5rem; opacity: 0.4; }

.email-list-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.85rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color, rgba(168,85,247,0.07));
    transition: background 0.1s;
    position: relative;
}
.email-list-item:hover { background: rgba(168,85,247,0.06); }
.email-list-item.selected { background: rgba(168,85,247,0.12); }
.email-list-item.unread .email-item-subject { font-weight: 700; color: var(--text-primary, #f0f0f0); }
.email-list-item.unread::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--accent, #a855f7);
}

.email-item-row1 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.email-item-from {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary, #f0f0f0);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.email-item-date {
    font-size: 0.75rem;
    color: var(--text-secondary, #888);
    white-space: nowrap;
    flex-shrink: 0;
}
.email-item-subject {
    font-size: 0.85rem;
    color: var(--text-secondary, #bbb);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.email-item-snippet {
    font-size: 0.78rem;
    color: var(--text-secondary, #777);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── detail panel ────────────────────────────────────────────────────────── */
.email-detail-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.email-detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 1rem;
    color: var(--text-secondary, #666);
}
.email-detail-empty i { font-size: 3rem; opacity: 0.3; }
.email-detail-empty p { font-size: 0.95rem; }

.email-detail-header {
    padding: 1.25rem 1.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color, rgba(168,85,247,0.12));
    flex-shrink: 0;
}

.email-detail-subject {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary, #f0f0f0);
    margin: 0 0 0.6rem;
}

.email-detail-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.email-detail-from {
    font-size: 0.88rem;
    color: var(--text-secondary, #bbb);
}
.email-detail-from strong { color: var(--text-primary, #f0f0f0); }

.email-detail-date {
    font-size: 0.8rem;
    color: var(--text-secondary, #888);
    white-space: nowrap;
}

.email-detail-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.6rem 1.5rem;
    border-bottom: 1px solid var(--border-color, rgba(168,85,247,0.08));
    flex-shrink: 0;
}

.email-action-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    background: var(--bg-secondary, #111);
    border: 1px solid var(--border-color, rgba(168,85,247,0.15));
    border-radius: 6px;
    color: var(--text-secondary, #aaa);
    font-size: 0.82rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}
.email-action-btn:hover { border-color: var(--accent, #a855f7); color: var(--accent, #a855f7); }
.email-action-btn.danger:hover { border-color: #ef4444; color: #ef4444; }

.email-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    font-size: 0.92rem;
    line-height: 1.7;
    color: var(--text-primary, #e0e0e0);
    white-space: pre-wrap;
    word-break: break-word;
}

.email-detail-attachments {
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border-color, rgba(168,85,247,0.12));
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    flex-shrink: 0;
}

.email-attachment-chip {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    background: var(--bg-secondary, #111);
    border: 1px solid var(--border-color, rgba(168,85,247,0.15));
    border-radius: 20px;
    font-size: 0.78rem;
    color: var(--text-secondary, #aaa);
    text-decoration: none;
    transition: border-color 0.15s;
}
.email-attachment-chip:hover { border-color: var(--accent, #a855f7); color: var(--accent, #a855f7); }

/* ── compose overlay ─────────────────────────────────────────────────────── */
.email-compose-overlay {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 540px;
    max-width: calc(100vw - 3rem);
    background: var(--bg-secondary, #111);
    border: 1px solid var(--border-color, rgba(168,85,247,0.25));
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    z-index: 900;
    resize: both;
    overflow: hidden;
    min-height: 360px;
    max-height: 70vh;
}

.email-compose-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary, #1a1a1a);
    cursor: move;
    border-bottom: 1px solid var(--border-color, rgba(168,85,247,0.15));
    user-select: none;
}

.email-compose-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary, #f0f0f0);
}

.email-compose-close {
    background: none;
    border: none;
    color: var(--text-secondary, #aaa);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.2rem;
    transition: color 0.15s;
}
.email-compose-close:hover { color: #ef4444; }

.email-compose-fields {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--border-color, rgba(168,85,247,0.12));
}

.email-compose-field {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color, rgba(168,85,247,0.08));
    padding: 0 1rem;
}
.email-compose-field:last-child { border-bottom: none; }

.email-compose-label {
    width: 48px;
    flex-shrink: 0;
    font-size: 0.8rem;
    color: var(--text-secondary, #888);
    font-weight: 600;
}

.email-compose-input {
    flex: 1;
    padding: 0.6rem 0;
    background: none;
    border: none;
    color: var(--text-primary, #f0f0f0);
    font-size: 0.88rem;
    outline: none;
}
.email-compose-input::placeholder { color: var(--text-secondary, #555); }

.email-compose-body-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.email-compose-body {
    flex: 1;
    padding: 1rem;
    background: none;
    border: none;
    color: var(--text-primary, #f0f0f0);
    font-size: 0.9rem;
    line-height: 1.6;
    resize: none;
    outline: none;
    font-family: inherit;
    min-height: 160px;
}

.email-compose-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    border-top: 1px solid var(--border-color, rgba(168,85,247,0.12));
}

.email-compose-send-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.2rem;
    background: var(--accent, #a855f7);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.email-compose-send-btn:hover { opacity: 0.85; }
.email-compose-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.email-compose-save-draft {
    background: none;
    border: 1px solid var(--border-color, rgba(168,85,247,0.15));
    border-radius: 6px;
    color: var(--text-secondary, #aaa);
    font-size: 0.82rem;
    padding: 0.45rem 0.8rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}
.email-compose-save-draft:hover { border-color: var(--accent, #a855f7); color: var(--accent, #a855f7); }

.email-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary, #888);
    gap: 0.5rem;
}

/* ── reply inline ────────────────────────────────────────────────────────── */
.email-reply-box {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color, rgba(168,85,247,0.12));
    background: var(--bg-secondary, rgba(0,0,0,0.3));
    flex-shrink: 0;
}

.email-reply-label {
    font-size: 0.78rem;
    color: var(--text-secondary, #888);
    margin-bottom: 0.4rem;
    font-weight: 600;
}

.email-reply-textarea {
    width: 100%;
    min-height: 80px;
    max-height: 200px;
    padding: 0.65rem 0.85rem;
    background: var(--bg-tertiary, #1a1a1a);
    border: 1px solid var(--border-color, rgba(168,85,247,0.15));
    border-radius: 8px;
    color: var(--text-primary, #f0f0f0);
    font-size: 0.88rem;
    line-height: 1.5;
    resize: vertical;
    outline: none;
    font-family: inherit;
    box-sizing: border-box;
}
.email-reply-textarea:focus { border-color: var(--accent, #a855f7); }

.email-reply-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    justify-content: flex-end;
}

.email-reply-send {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    background: var(--accent, #a855f7);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.email-reply-send:hover { opacity: 0.85; }
.email-reply-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .email-list-panel { width: 100%; min-width: 0; }
    .email-detail-panel { display: none; }
    .email-detail-panel.mobile-visible { display: flex; }
    .email-list-panel.mobile-hidden { display: none; }
}
@media (max-width: 600px) {
    .email-sidebar { display: none; }
    .email-compose-overlay { width: calc(100vw - 1rem); right: 0.5rem; bottom: 0.5rem; }
}
