/* =============================================
   AGD Email Module Styles
   All classes use agd-eml-* prefix.
   Colors via CSS variables only.
   ============================================= */

/* ===== LAYOUT ===== */
.agd-eml-header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.agd-eml-view-toggle { display: flex; gap: 2px; }

/* ===== CONVERSATION LAYOUT (Mode B) ===== */
.agd-eml-conversation-layout { display: flex; flex: 1; min-height: 0; gap: 0; background: var(--agd-border, #333); position: relative; }
.agd-eml-conv-sidebar { width: 350px; min-width: 0; background: var(--agd-bg-surface, #1e1e2e); overflow: hidden; display: flex; flex-direction: column; transition: width 0.25s ease, opacity 0.2s ease; border-right: 1px solid var(--agd-border, #333); }
.agd-eml-conv-sidebar.collapsed { width: 0; opacity: 0; border-right: none; }
.agd-eml-conversation-list { width: 350px; min-width: 300px; background: var(--agd-bg-surface, #1e1e2e); overflow-y: auto; display: flex; flex-direction: column; }
.agd-eml-conv-toggle { position: absolute; left: 350px; top: 50%; transform: translateY(-50%); z-index: 10; width: 20px; height: 48px; border: 1px solid var(--agd-border, #333); border-left: none; border-radius: 0 6px 6px 0; background: var(--agd-bg-surface, #1e1e2e); color: var(--agd-text-muted, #888); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; transition: left 0.25s ease, background 0.15s, color 0.15s; }
.agd-eml-conv-sidebar.collapsed ~ .agd-eml-conv-toggle { left: 0; }
.agd-eml-conv-toggle:hover { background: var(--agd-bg-elevated, #2a2a3e); color: var(--agd-text-primary, #eee); }
.agd-eml-thread-view { flex: 1; background: var(--agd-bg-base, #181825); display: flex; flex-direction: column; }

/* ===== CLASSIC LAYOUT (Mode A) ===== */
.agd-eml-classic-layout { display: flex; flex: 1; min-height: 0; gap: 0; background: var(--agd-border, #333); position: relative; }
.agd-eml-classic-sidebar { width: 220px; min-width: 0; overflow: hidden; display: flex; flex-direction: column; transition: width 0.25s ease, opacity 0.2s ease; border-right: 1px solid var(--agd-border, #333); background: var(--agd-bg-surface, #1e1e2e); }
.agd-eml-classic-sidebar.collapsed { width: 0; opacity: 0; border-right: none; }
.agd-eml-classic-toggle { position: absolute; left: 220px; top: 50%; transform: translateY(-50%); z-index: 10; width: 20px; height: 48px; border: 1px solid var(--agd-border, #333); border-left: none; border-radius: 0 6px 6px 0; background: var(--agd-bg-surface, #1e1e2e); color: var(--agd-text-muted, #888); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; transition: left 0.25s ease, background 0.15s, color 0.15s; }
.agd-eml-classic-sidebar.collapsed ~ .agd-eml-classic-toggle { left: 0; }
.agd-eml-classic-toggle:hover { background: var(--agd-bg-elevated, #2a2a3e); color: var(--agd-text-primary, #eee); }
.agd-eml-folder-tree { width: 220px; min-width: 180px; height: 100%; background: var(--agd-bg-surface, #1e1e2e); overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; padding: 8px 0; }
.agd-eml-message-list { width: 420px; min-width: 300px; max-width: 600px; height: 100%; background: var(--agd-bg-surface, #1e1e2e); overflow: hidden; display: flex; flex-direction: column; resize: horizontal; }
.agd-eml-reading-pane { flex: 1; height: 100%; background: var(--agd-bg-base, #181825); display: flex; flex-direction: column; overflow-y: auto; }

/* ===== NO ACCOUNTS ===== */
.agd-eml-no-accounts { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; text-align: center; gap: 16px; color: var(--agd-text-secondary); }
.agd-eml-no-accounts h2 { color: var(--agd-text-primary); margin: 0; }

/* ===== SEARCH BAR ===== */
.agd-eml-conv-search { padding: 12px 14px; border-bottom: 1px solid var(--agd-border); }
.agd-eml-conv-account-filter { padding: 8px 14px; border-bottom: 1px solid var(--agd-border); }

/* ===== CONVERSATION ITEMS CONTAINER ===== */
.agd-eml-conv-items { flex: 1; overflow-y: auto; }
.agd-eml-conv-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; gap: 12px; color: var(--agd-text-muted); }

/* ===== CONVERSATION CARD ===== */
.agd-eml-conv-card { display: flex; padding: 14px 16px; gap: 12px; cursor: pointer; border-bottom: 1px solid var(--agd-border, #333); transition: background 0.15s; }
.agd-eml-conv-card:hover { background: var(--agd-bg-elevated, #2a2a3e); }
.agd-eml-conv-card.active { background: var(--agd-brand-color, #6366F1); color: var(--agd-text-on-brand); }
.agd-eml-conv-card.active .agd-eml-conv-name,
.agd-eml-conv-card.active .agd-eml-conv-time,
.agd-eml-conv-card.active .agd-eml-conv-subject,
.agd-eml-conv-card.active .agd-eml-conv-preview { color: var(--agd-text-on-brand); }
.agd-eml-conv-card.active .agd-eml-conv-badge { background: rgba(255,255,255,0.25); color: var(--agd-text-on-brand); }
.agd-eml-conv-card.unread .agd-eml-conv-name { font-weight: 700; }

.agd-eml-conv-avatar { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 16px; color: var(--agd-text-on-brand); flex-shrink: 0; }
.agd-eml-conv-content { flex: 1; min-width: 0; }
.agd-eml-conv-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 3px; }
.agd-eml-conv-name { font-size: 14px; font-weight: 700; color: var(--agd-text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agd-eml-conv-time { font-size: 11px; color: var(--agd-text-muted); flex-shrink: 0; margin-left: 8px; }
.agd-eml-conv-subject { font-size: 13px; font-weight: 600; color: var(--agd-text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.agd-eml-conv-preview { font-size: 12px; color: var(--agd-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agd-eml-conv-actions { display: flex; flex-direction: column; align-items: center; gap: 4px; flex-shrink: 0; align-self: center; }
.agd-eml-conv-badge { background: var(--agd-brand-color, #6366F1); color: var(--agd-text-on-brand); border-radius: 10px; padding: 2px 7px; font-size: 11px; font-weight: 600; }
.agd-eml-conv-badge-unread { background: var(--agd-brand-color, #6366F1); }
.agd-eml-conv-delete { display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--agd-text-muted, #888); opacity: 0; transition: opacity 0.15s, color 0.15s; padding: 2px; border-radius: 4px; }
.agd-eml-conv-card:hover .agd-eml-conv-delete { opacity: 1; }
.agd-eml-conv-delete:hover { color: var(--agd-clr-danger); background: rgba(239, 68, 68, 0.1); }

/* ===== THREAD VIEW ===== */
.agd-eml-thread-header { padding: 16px 20px; border-bottom: 1px solid var(--agd-border); display: flex; align-items: center; justify-content: space-between; }
.agd-eml-thread-subject { flex: 1; min-width: 0; }
.agd-eml-thread-subject h2 { font-size: 18px; font-weight: 600; color: var(--agd-text-primary); margin: 0 0 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agd-eml-thread-count { font-size: 12px; color: var(--agd-text-muted); }
.agd-eml-thread-actions { flex-shrink: 0; margin-left: 12px; }
.agd-eml-thread-participants { font-size: 13px; color: var(--agd-text-secondary); }
.agd-eml-thread-messages { flex: 1; overflow-y: auto; padding: 12px 20px; display: flex; flex-direction: column; gap: 8px; }
.agd-eml-quick-reply { padding: 10px 20px; border-top: 1px solid var(--agd-border); display: flex; gap: 10px; align-items: flex-end; }
.agd-eml-quick-reply-textarea { flex: 1; resize: none; overflow-y: auto; min-height: 36px; max-height: 150px; padding: 8px 12px; border: 1px solid var(--agd-border, #444); border-radius: 18px; background: var(--agd-input-bg, #2a2a3e); color: var(--agd-text-primary, #1e293b); font-family: inherit; font-size: 14px; line-height: 1.4; outline: none; transition: border-color 0.15s; }
.agd-eml-quick-reply-textarea:focus { border-color: var(--agd-brand-color, #6366F1); }
.agd-eml-quick-reply-textarea::placeholder { color: var(--agd-text-muted, #888); }
.agd-eml-send-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: none; border-radius: 50%; background: var(--agd-brand-color, #6366F1); color: var(--agd-text-on-brand); cursor: pointer; padding: 0; flex-shrink: 0; transition: background 0.15s, transform 0.1s; }
.agd-eml-send-btn:hover:not(:disabled) { background: var(--agd-brand-hover, #4F46E5); transform: scale(1.05); }
.agd-eml-send-btn:disabled { opacity: 0.4; cursor: default; }
.agd-eml-thread-reply-actions { display: flex; gap: 4px; flex-shrink: 0; align-items: flex-end; }

/* ===== DATE HEADER (WhatsApp-style separator) ===== */
.agd-eml-thread-date-header { display: flex; justify-content: center; padding: 8px 0; }
.agd-eml-thread-date-header span { background: var(--agd-bg-elevated, #2a2a3e); color: var(--agd-text-muted, #888); font-size: 11px; font-weight: 600; padding: 3px 14px; border-radius: 10px; }

/* ===== MESSAGE BUBBLE ===== */
.agd-eml-bubble { padding: 6px 12px; border-radius: 10px; }
.agd-eml-bubble-sent { background: var(--agd-brand-color, #6366F1); color: var(--agd-text-on-brand); border-bottom-right-radius: 2px; }
.agd-eml-bubble-sent .agd-eml-bubble-header,
.agd-eml-bubble-sent .agd-eml-bubble-body { color: var(--agd-text-on-brand); }
.agd-eml-bubble-received { background: var(--agd-bg-elevated, #2a2a3e); color: var(--agd-text-primary); border-bottom-left-radius: 2px; }
.agd-eml-bubble-body { font-size: 13px; line-height: 1.4; }
.agd-eml-bubble-body p { margin: 0; }
.agd-eml-bubble-body a { color: var(--agd-clr-info-light); text-decoration: underline; }
.agd-eml-bubble-sent .agd-eml-bubble-body a { color: var(--agd-clr-info-light); }
.agd-eml-bubble-footer { display: flex; justify-content: flex-end; align-items: center; gap: 4px; margin-top: 2px; }
.agd-eml-bubble-time { font-size: 10px; opacity: 0.5; }

/* Sending state */
.agd-eml-bubble-sending { opacity: 0.7; }
.agd-eml-bubble-status { font-size: 10px; opacity: 0.7; margin-left: auto; flex-shrink: 0; display: flex; align-items: center; gap: 4px; }
.agd-eml-bubble-status-failed { color: var(--agd-clr-danger); opacity: 1; font-weight: 600; }
.agd-eml-bubble-failed { border: 1px solid var(--agd-clr-danger); opacity: 0.8; }

/* Countdown (undo-send) state */
.agd-eml-bubble-countdown { opacity: 0.85; border: 1px dashed rgba(255,255,255,0.3); }
.agd-eml-bubble-countdown-bar { display: flex; align-items: center; gap: 8px; width: 100%; }
.agd-eml-bubble-countdown-text { font-size: 11px; font-weight: 600; opacity: 0.8; white-space: nowrap; animation: agd-eml-countdown-pulse 1s ease-in-out infinite; }
.agd-eml-bubble-countdown-btn { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border: none; border-radius: 50%; cursor: pointer; padding: 0; transition: transform 0.15s, background 0.15s; flex-shrink: 0; }
.agd-eml-bubble-btn-cancel { background: var(--agd-clr-danger); color: var(--agd-text-on-brand); }
.agd-eml-bubble-btn-cancel:hover { background: var(--agd-clr-danger-dark); transform: scale(1.15); }
.agd-eml-bubble-btn-sendnow { background: var(--agd-clr-success); color: var(--agd-text-on-brand); }
.agd-eml-bubble-btn-sendnow:hover { background: var(--agd-clr-success-dark); transform: scale(1.15); }

@keyframes agd-eml-countdown-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Sending dots animation */
.agd-eml-bubble-sending-dots { display: inline-flex; gap: 3px; align-items: center; }
.agd-eml-bubble-sending-dots span { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: agd-eml-dot-pulse 1.2s ease-in-out infinite; }
.agd-eml-bubble-sending-dots span:nth-child(2) { animation-delay: 0.2s; }
.agd-eml-bubble-sending-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes agd-eml-dot-pulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.1); }
}

/* ===== FOLDER TREE ===== */
.agd-eml-folder-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--agd-text-muted); gap: 8px; padding: 20px; text-align: center; }

/* Collapsible account header */
.agd-eml-folder-acc-header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--agd-text-primary, #e0e0e0); border-bottom: 1px solid var(--agd-border, #333); transition: background 0.15s; user-select: none; }
.agd-eml-folder-acc-header:hover { background: var(--agd-bg-elevated, #2a2a3e); }
.agd-eml-folder-acc-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agd-eml-folder-chevron { transition: transform 0.2s; flex-shrink: 0; }
.agd-eml-folder-chevron.expanded { transform: rotate(90deg); }

/* Color disk (account identifier) */
.agd-eml-acc-color-disk { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; cursor: pointer; border: 2px solid transparent; transition: border-color 0.15s, transform 0.15s; }
.agd-eml-acc-color-disk:hover { border-color: rgba(255,255,255,0.5); transform: scale(1.2); }

/* Reorder buttons */
.agd-eml-acc-reorder { display: flex; flex-direction: column; gap: 0; margin-left: auto; flex-shrink: 0; opacity: 0; transition: opacity 0.15s; }
.agd-eml-folder-acc-header:hover .agd-eml-acc-reorder { opacity: 1; }
.agd-eml-acc-move-btn { display: flex; align-items: center; justify-content: center; width: 18px; height: 12px; cursor: pointer; color: var(--agd-text-muted, #888); transition: color 0.15s; border-radius: 2px; }
.agd-eml-acc-move-btn:hover { color: var(--agd-text-primary, #fff); background: rgba(255,255,255,0.08); }

/* Color picker (inline row of swatches) */
.agd-eml-color-picker { display: flex; gap: 6px; padding: 8px 14px 8px 36px; background: var(--agd-bg-elevated, #2a2a3e); border-bottom: 1px solid var(--agd-border, #333); flex-wrap: wrap; }
.agd-eml-color-swatch { width: 22px; height: 22px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: border-color 0.15s, transform 0.15s; }
.agd-eml-color-swatch:hover { transform: scale(1.15); border-color: rgba(255,255,255,0.4); }
.agd-eml-color-swatch.active { border-color: var(--agd-text-on-brand); transform: scale(1.15); box-shadow: 0 0 0 2px rgba(255,255,255,0.3); }

/* Folder items */
.agd-eml-folder-acc-folders { }
.agd-eml-folder-item { display: flex; align-items: center; padding: 7px 14px 7px 36px; gap: 8px; cursor: pointer; font-size: 13px; color: var(--agd-text-secondary, #ccc); transition: background 0.15s; }
.agd-eml-folder-item:hover { background: var(--agd-bg-elevated, #2a2a3e); }
.agd-eml-folder-item.active { background: var(--agd-brand-color, #6366F1); color: var(--agd-text-on-brand); }
.agd-eml-folder-badge { margin-left: auto; font-size: 10px; font-weight: 700; color: var(--agd-text-on-brand); background: var(--agd-brand-color, #6366F1); border-radius: 10px; min-width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
.agd-eml-folder-item.active .agd-eml-folder-badge { background: rgba(255,255,255,0.25); }

/* ===== MESSAGE LIST (Classic Mode - Outlook Card Layout) ===== */
.agd-eml-msglist-toolbar { padding: 8px 14px; border-bottom: 1px solid var(--agd-border); }
.agd-eml-msglist-cards { flex: 1; overflow-y: auto; }
.agd-eml-msglist-no-data { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; padding: 40px 20px; gap: 12px; color: var(--agd-text-muted); }
.agd-eml-msglist-no-data p { margin: 0; }
.agd-eml-unread-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--agd-brand-color, #6366F1); flex-shrink: 0; }

/* Outlook-style card rows */
.agd-eml-msg-card { padding: 8px 14px; cursor: pointer; border-bottom: 1px solid var(--agd-border, #333); transition: background 0.15s; }
.agd-eml-msg-card:hover { background: var(--agd-bg-elevated, #2a2a3e); }
.agd-eml-msg-card.active { background: var(--agd-brand-color, #6366F1); color: var(--agd-text-on-brand); }
.agd-eml-msg-card.active .agd-eml-msg-card-time,
.agd-eml-msg-card.active .agd-eml-msg-card-subject,
.agd-eml-msg-card.active .agd-eml-msg-card-preview { color: var(--agd-text-on-brand); }
.agd-eml-msg-card.unread .agd-eml-msg-card-sender { font-weight: 700; }
.agd-eml-msg-card.unread .agd-eml-msg-card-subject { font-weight: 600; }

.agd-eml-msg-card-line1 { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.agd-eml-msg-card-sender { flex: 1; font-size: 13px; font-weight: 600; color: var(--agd-text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agd-eml-msg-card-delete { display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--agd-text-muted, #888); opacity: 0; transition: opacity 0.15s, color 0.15s; flex-shrink: 0; padding: 2px; border-radius: 4px; }
.agd-eml-msg-card:hover .agd-eml-msg-card-delete { opacity: 1; }
.agd-eml-msg-card-delete:hover { color: var(--agd-clr-danger); background: rgba(239, 68, 68, 0.1); }
.agd-eml-msg-card-time { flex-shrink: 0; font-size: 11px; color: var(--agd-text-muted); }
.agd-eml-msg-card-subject { font-size: 12px; color: var(--agd-text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 1px; }
.agd-eml-msg-card-preview { font-size: 11px; color: var(--agd-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== READING PANE ===== */
.agd-eml-reading-header { padding: 20px; border-bottom: 1px solid var(--agd-border); }
.agd-eml-reading-subject h2 { font-size: 20px; font-weight: 600; color: var(--agd-text-primary); margin: 0 0 12px 0; }
.agd-eml-reading-meta { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--agd-text-secondary); }
.agd-eml-reading-from-name { font-weight: 600; color: var(--agd-text-primary); margin-right: 6px; }
.agd-eml-reading-from-email { color: var(--agd-text-muted); }
.agd-eml-reading-to-label,
.agd-eml-reading-cc-label { color: var(--agd-text-muted); margin-right: 4px; }
.agd-eml-reading-date { color: var(--agd-text-muted); font-size: 12px; }
.agd-eml-reading-actions { padding: 10px 20px; border-bottom: 1px solid var(--agd-border); display: flex; gap: 6px; }
.agd-eml-reading-body { flex: 1; padding: 20px; overflow-y: auto; color: var(--agd-text-primary); font-size: 14px; line-height: 1.6; }
.agd-eml-reading-body-light { background: var(--agd-white); color: var(--agd-text-heading); border-radius: 6px; margin: 0 16px 16px 16px; }
.agd-eml-reading-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 12px; color: var(--agd-text-muted); }
.agd-eml-reading-attachments { padding: 14px 20px; border-top: 1px solid var(--agd-border); }
.agd-eml-reading-attachments h4 { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--agd-text-secondary); margin: 0 0 10px 0; }
.agd-eml-reading-attachment-list { display: flex; gap: 8px; flex-wrap: wrap; }
.agd-eml-reading-attachment-item { display: flex; align-items: center; gap: 6px; padding: 6px 12px; background: var(--agd-bg-elevated, #2a2a3e); border-radius: 6px; font-size: 13px; }
.agd-eml-att-name { color: var(--agd-text-primary); }
.agd-eml-att-size { color: var(--agd-text-muted); font-size: 11px; }

/* ===== COMPOSE ===== */
.agd-eml-compose-row { display: flex; align-items: center; padding: 10px 18px; gap: 10px; border-bottom: 1px solid var(--agd-border); }
.agd-eml-compose-label { width: 50px; font-size: 13px; color: var(--agd-text-muted); flex-shrink: 0; }
.agd-eml-compose-toolbar { display: flex; padding: 8px 16px; gap: 4px; border-bottom: 1px solid var(--agd-border); }
.agd-eml-compose-actions { display: flex; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--agd-border); }
.agd-eml-compose-body { flex: 1; padding: 0; min-height: 200px; }
.agd-eml-duplicate-warning { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px; margin: 0 16px 8px 16px; background: var(--agd-warning-bg, #fff3cd); border: 1px solid var(--agd-warning-border, #ffc107); border-radius: 6px; color: var(--agd-warning-text, #856404); font-size: 13px; }
.agd-eml-duplicate-warning .k-svg-icon { flex-shrink: 0; }
.agd-eml-duplicate-actions { display: flex; gap: 8px; margin-left: auto; }

/* ===== PLACEHOLDER / EMPTY STATE ===== */
.agd-eml-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--agd-text-muted); gap: 12px; padding: 40px; text-align: center; }
.agd-eml-empty h3 { color: var(--agd-text-secondary); margin: 0; font-size: 16px; font-weight: 600; }
.agd-eml-empty p { margin: 0; font-size: 13px; color: var(--agd-text-muted); }

/* ===== COMPOSE EDITOR ===== */
.agd-eml-compose-form { display: flex; flex-direction: column; height: 100%; }
.agd-eml-compose-editor { flex: 1; padding: 0; overflow: hidden; }

/* Dark theme for Telerik Editor inside compose window */
.agd-eml-compose-window .k-editor { border: none; }
.agd-eml-compose-window .k-editor .k-toolbar,
.agd-eml-compose-window .k-editor .k-toolbar-group,
.agd-eml-compose-window .k-editor .k-button-group {
    background-color: var(--agd-bg-surface, #1e1e2e) !important;
    border-color: var(--agd-border, #333) !important;
}
.agd-eml-compose-window .k-editor .k-toolbar .k-button,
.agd-eml-compose-window .k-editor .k-toolbar .k-icon,
.agd-eml-compose-window .k-editor .k-toolbar .k-svg-icon {
    color: var(--agd-text-secondary, #ccc) !important;
}
.agd-eml-compose-window .k-editor .k-toolbar .k-button:hover {
    background-color: var(--agd-bg-elevated, #2a2a3e) !important;
}
.agd-eml-compose-window .k-editor .k-toolbar .k-button.k-selected {
    background-color: var(--agd-brand-color, #6366F1) !important;
    color: var(--agd-text-on-brand) !important;
}
.agd-eml-compose-window .k-editor .k-toolbar .k-dropdown,
.agd-eml-compose-window .k-editor .k-toolbar .k-picker {
    background-color: var(--agd-bg-elevated, #2a2a3e) !important;
    border-color: var(--agd-border, #333) !important;
    color: var(--agd-text-secondary, #ccc) !important;
}
.agd-eml-compose-window .k-editor .k-editable-area,
.agd-eml-compose-window .k-editor .k-editor-content,
.agd-eml-compose-window .k-editor .k-content,
.agd-eml-compose-window .k-editor iframe {
    background-color: var(--agd-bg-base, #181825) !important;
}
.agd-eml-compose-window .k-editor .k-editable-area .k-content,
.agd-eml-compose-window .k-editor .k-editable-area .ProseMirror {
    background-color: var(--agd-bg-base, #181825) !important;
    color: var(--agd-text-primary, #e0e0e0) !important;
}
.agd-eml-compose-window .k-editor .ProseMirror {
    background-color: var(--agd-bg-base, #181825) !important;
    color: var(--agd-text-primary, #e0e0e0) !important;
}
.agd-eml-compose-window .k-editor .ProseMirror p.is-editor-empty::before {
    color: var(--agd-text-muted, #666) !important;
}
.agd-eml-compose-bcc-toggle { border-bottom: none; padding-top: 0; }
.agd-eml-compose-actions-left { display: flex; align-items: center; gap: 10px; }
.agd-eml-compose-actions-right { display: flex; align-items: center; gap: 6px; }

/* ===== COMPOSE ATTACHMENTS ===== */
.agd-eml-attachments { padding: 6px 16px; border-top: 1px solid var(--agd-border); }
.agd-eml-attachments-header { display: flex; align-items: center; gap: 8px; }
.agd-eml-attach-btn-wrap { position: relative; display: inline-flex; overflow: hidden; border-radius: 4px; cursor: pointer; }
.agd-eml-attach-btn-visual { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; font-size: 13px; color: var(--agd-text-secondary); pointer-events: none; }
.agd-eml-attach-btn-visual.agd-eml-attach-btn-clickable { pointer-events: auto; cursor: pointer; border-radius: 4px; }
.agd-eml-attach-btn-visual.agd-eml-attach-btn-clickable:hover { background: var(--agd-bg-hover, rgba(255,255,255,0.06)); color: var(--agd-text-primary); }
.agd-eml-attach-btn-wrap:hover .agd-eml-attach-btn-visual { background: var(--agd-bg-hover, rgba(255,255,255,0.06)); color: var(--agd-text-primary); }
.agd-eml-attach-file-input { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.agd-eml-attachments-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.agd-eml-attachment-item { display: flex; align-items: center; gap: 4px; padding: 4px 8px; background: var(--agd-bg-elevated, #2a2a3e); border-radius: 6px; font-size: 12px; }
.agd-eml-attachment-name { color: var(--agd-text-primary); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agd-eml-attachment-size { color: var(--agd-text-muted); font-size: 11px; }
.agd-eml-attachment-item .k-button { padding: 2px; min-width: auto; }

/* TelerikFileSelect inside compose window - compact styling */
.agd-eml-fileselect { display: inline-flex; }
.agd-eml-fileselect .k-upload { border: none; background: transparent; padding: 0; }
.agd-eml-fileselect .k-upload .k-dropzone { padding: 0; border: none; background: transparent; }
.agd-eml-fileselect .k-upload .k-upload-button { font-size: 13px; }
/* Hide built-in file list - we show our own uploaded file list */
.agd-eml-fileselect .k-upload-files { display: none; }
.agd-eml-fileselect .k-upload .k-dropzone-hint { display: none; }

/* ===== EMAIL SETUP (Settings > Email Tab) ===== */
.agd-eml-setup {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 0;
}

/* Expander: dark theme overrides matching agd-expander pattern */
.agd-eml-expander {
    background-color: var(--agd-bg-card) !important;
    border: 1px solid var(--agd-border-color) !important;
    border-radius: 10px !important;
    overflow: hidden;
}

.agd-eml-expander .k-expander-header {
    background-color: var(--agd-bg-secondary) !important;
    border: none !important;
    padding: 14px 20px !important;
    color: var(--agd-text-on-dark) !important;
}

.agd-eml-expander .k-expander-header:hover {
    background-color: var(--agd-bg-tertiary) !important;
}

.agd-eml-expander .k-expander-indicator,
.agd-eml-expander .k-expander-indicator .k-svg-icon,
.agd-eml-expander .k-icon {
    color: var(--agd-text-light) !important;
}

.agd-eml-expander .k-expander-content-wrapper {
    background-color: var(--agd-white) !important;
}

/* Section title & count */
.agd-eml-section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--agd-text-color);
}

.agd-eml-section-count {
    font-size: 14px;
    color: var(--agd-text-muted);
    margin-left: 6px;
}

/* Section body & toolbar */
.agd-eml-section-body {
    padding: 16px 20px;
}

.agd-eml-section-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
    gap: 8px;
}

/* Info text (no accounts, no signatures, etc.) */
.agd-info-text,
.agd-eml-section-body .agd-info-text {
    color: var(--agd-text-muted) !important;
    font-size: 14px;
    padding: 12px 16px;
    background-color: var(--agd-bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--agd-bg-card-hover);
    margin-top: 8px;
}

/* Grid overrides inside email setup to ensure dark theme */
.agd-eml-setup .agd-dark-grid .k-grid-header,
.agd-eml-setup .agd-dark-grid .k-grid-header-wrap,
.agd-eml-setup .agd-dark-grid .k-table-thead,
.agd-eml-setup .agd-dark-grid .k-table-th {
    background-color: var(--agd-bg-tertiary) !important;
    color: var(--agd-text-light) !important;
    border-color: var(--agd-border-color) !important;
}

.agd-eml-setup .agd-dark-grid .k-table-td {
    color: var(--agd-text-color) !important;
}

.agd-eml-setup .agd-dark-grid .k-grid-norecords,
.agd-eml-setup .agd-dark-grid .k-grid-norecords-template {
    color: var(--agd-text-light) !important;
}

/* Grouping header row in grid */
.agd-eml-setup .k-grouping-header {
    background-color: var(--agd-bg-secondary) !important;
    color: var(--agd-text-muted) !important;
    border-color: var(--agd-border-color) !important;
}

/* Auto-reply / notification per-account rows */
.agd-eml-account-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--agd-bg-card-hover);
    color: var(--agd-text-color);
}

.agd-eml-account-setting-row:last-child {
    border-bottom: none;
}

.agd-eml-account-label {
    font-size: 14px;
    color: var(--agd-text-light);
}

/* ===== OUTBOX CARDS ===== */
.agd-eml-outbox-card { border-left: 3px solid var(--agd-brand-color, #6366F1); }
.agd-eml-outbox-card.active { border-left-color: var(--agd-text-on-brand); }

.agd-eml-outbox-countdown { font-size: 12px; color: var(--agd-brand-color, #6366F1); font-weight: 600; padding: 4px 0 2px 0; }

.agd-eml-outbox-progress { height: 3px; background: var(--agd-border, #333); border-radius: 2px; overflow: hidden; margin-bottom: 6px; }
.agd-eml-outbox-progress-bar { height: 100%; background: var(--agd-brand-color, #6366F1); border-radius: 2px; transition: width 1s linear; }

.agd-eml-outbox-actions { display: flex; gap: 6px; padding-top: 2px; }
.agd-eml-outbox-btn-cancel { background: none; border: 1px solid var(--agd-danger, #dc2626); color: var(--agd-danger, #dc2626); padding: 2px 10px; border-radius: 4px; font-size: 11px; cursor: pointer; transition: background 0.15s, color 0.15s; }
.agd-eml-outbox-btn-cancel:hover { background: var(--agd-danger, #dc2626); color: var(--agd-text-on-brand); }

.agd-eml-outbox-status { font-size: 11px; font-weight: 600; padding: 4px 0; }
.agd-eml-outbox-status.queued { color: var(--agd-warning, #d97706); }
.agd-eml-outbox-status.sending { color: var(--agd-brand-color, #6366F1); }
.agd-eml-outbox-status.failed { color: var(--agd-danger, #dc2626); }

/* ===== BUBBLE WRAPPER (context menu target) ===== */
.agd-eml-bubble-wrapper { position: relative; max-width: 75%; }
.agd-eml-bubble-wrapper-sent { align-self: flex-end; }
.agd-eml-bubble-wrapper-received { align-self: flex-start; }

/* ===== QUICK REPLY TOOLBAR TOGGLES ===== */
.agd-eml-toolbar-toggle { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 1px solid var(--agd-border, #444); border-radius: 50%; background: transparent; color: var(--agd-text-muted, #888); cursor: pointer; padding: 0; flex-shrink: 0; transition: background 0.15s, color 0.15s, border-color 0.15s; }
.agd-eml-toolbar-toggle:hover { border-color: var(--agd-brand-color, #6366F1); color: var(--agd-brand-color, #6366F1); background: rgba(99, 102, 241, 0.08); }
.agd-eml-toolbar-toggle.active { background: var(--agd-brand-color, #6366F1); border-color: var(--agd-brand-color, #6366F1); color: var(--agd-text-on-brand); }
[data-theme="light"] .agd-eml-toolbar-toggle { border-color: var(--agd-border-medium); color: var(--agd-text-caption); }
[data-theme="light"] .agd-eml-toolbar-toggle:hover { border-color: var(--agd-primary); color: var(--agd-primary); background: rgba(79, 70, 229, 0.06); }
[data-theme="light"] .agd-eml-toolbar-toggle.active { background: var(--agd-primary); border-color: var(--agd-primary); color: var(--agd-text-on-brand); }

/* ===== LIGHT THEME: Conversation Bubbles ===== */
[data-theme="light"] .agd-eml-bubble-received { background: var(--agd-bg-card-hover); color: var(--agd-text-heading); }
[data-theme="light"] .agd-eml-bubble-sent { background: var(--agd-primary); color: var(--agd-text-on-brand); }
[data-theme="light"] .agd-eml-bubble-sent .agd-eml-bubble-body a { color: var(--agd-clr-info-light); }
[data-theme="light"] .agd-eml-bubble-received .agd-eml-bubble-body a { color: var(--agd-primary); }
[data-theme="light"] .agd-eml-thread-date-header span { background: var(--agd-border-subtle); color: var(--agd-text-caption); }
[data-theme="light"] .agd-eml-thread-header { border-bottom-color: var(--agd-border-subtle); }
[data-theme="light"] .agd-eml-quick-reply { border-top-color: var(--agd-border-subtle); }
[data-theme="light"] .agd-eml-quick-reply-textarea { background: var(--agd-bg-card); color: var(--agd-text-heading); border-color: var(--agd-border-subtle); }
[data-theme="light"] .agd-eml-quick-reply-textarea:focus { border-color: var(--agd-primary); }

/* ===== PINNED SECTION ===== */
.agd-eml-pinned-separator { padding: 4px 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--agd-text-muted); letter-spacing: 0.5px; background: var(--agd-bg-base); border-bottom: 1px solid var(--agd-border); }

/* ===== LIGHT THEME: Email Setup (Settings) ===== */
[data-theme="light"] .agd-eml-expander {
    background-color: var(--agd-white) !important;
    border-color: var(--agd-border-subtle) !important;
}

[data-theme="light"] .agd-eml-expander .k-expander-header {
    background-color: var(--agd-bg-card) !important;
    color: var(--agd-text-heading) !important;
}

[data-theme="light"] .agd-eml-expander .k-expander-header:hover {
    background-color: var(--agd-bg-card-hover) !important;
}

[data-theme="light"] .agd-eml-expander .k-expander-indicator,
[data-theme="light"] .agd-eml-expander .k-expander-indicator .k-svg-icon,
[data-theme="light"] .agd-eml-expander .k-icon {
    color: var(--agd-text-body) !important;
}

[data-theme="light"] .agd-eml-expander .k-expander-content-wrapper {
    background-color: var(--agd-white) !important;
}

[data-theme="light"] .agd-eml-section-title {
    color: var(--agd-text-heading);
}

[data-theme="light"] .agd-eml-section-count {
    color: var(--agd-text-caption);
}

[data-theme="light"] .agd-info-text,
[data-theme="light"] .agd-eml-section-body .agd-info-text {
    color: var(--agd-text-caption) !important;
    background-color: var(--agd-bg-card);
    border-color: var(--agd-border-subtle);
}

[data-theme="light"] .agd-eml-account-setting-row {
    border-bottom-color: var(--agd-border-subtle);
    color: var(--agd-text-heading);
}

[data-theme="light"] .agd-eml-account-label {
    color: var(--agd-text-sub);
}

/* ===== DELETE CONFIRMATION DIALOG ===== */
.agd-eml-delete-confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.agd-eml-delete-confirm {
    background: var(--agd-bg-surface, #1e1e2e);
    border: 1px solid var(--agd-border, #333);
    border-radius: 12px;
    padding: 28px 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.agd-eml-delete-confirm-icon {
    color: var(--agd-warning, #f59e0b);
    margin-bottom: 12px;
}

.agd-eml-delete-confirm h4 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--agd-text-primary, #eee);
}

.agd-eml-delete-confirm p {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: var(--agd-text-secondary, #aaa);
}

.agd-eml-delete-confirm-subject {
    background: var(--agd-bg-elevated, #2a2a3e);
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--agd-text-primary, #eee);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agd-eml-delete-confirm-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}
