/* ═══════════════════════════════════════════════════════════════════
   NEUROCUOLE — 5. Personal Mail Shell  (ol-*)
   Outlook-style three-column layout.
   Single canonical definition — zero duplicate rules.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Shell layout ─────────────────────────────────────────────────── */
.ol-shell {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: #fff;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 0.875rem;
    color: #1f2937;
}

/* Strip nc-content padding when mail page is active */
.nc-content:has(.ol-shell) {
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

/* ── Top bar ──────────────────────────────────────────────────────── */
.ol-topbar {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--nc-teal-900);
    padding: 0 0.75rem;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    min-height: 46px;
}

.ol-topbar-compose {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 1rem;
    background: #fff;
    color: var(--nc-teal-800);
    border: none;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    margin-right: 0.75rem;
    flex-shrink: 0;
    transition: background 0.15s, box-shadow 0.15s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}
.ol-topbar-compose:hover { background: #f0f0f0; }

.ol-topbar-nav {
    display: flex;
    align-items: stretch;
    gap: 0;
    flex: 1;
    min-width: 0;
    height: 100%;
}

.ol-topbar-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 1rem;
    border: none;
    background: none;
    color: rgba(255,255,255,0.65);
    font-size: 0.83rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: color 0.1s, border-color 0.1s, background 0.1s;
    height: 100%;
}
.ol-topbar-tab:hover { color: #fff; background: rgba(255,255,255,0.06); }
.ol-topbar-tab--active { color: #fff; font-weight: 700; border-bottom-color: var(--nc-teal-300); }

.ol-badge { margin-left: 0.2rem; background: var(--nc-teal-400); color: var(--nc-teal-900); font-size: 0.68rem; font-weight: 700; padding: 0.05rem 0.45rem; border-radius: 999px; min-width: 1.1rem; text-align: center; }
.ol-badge--subtle { background: rgba(255,255,255,0.2); color: rgba(255,255,255,0.85); }

.ol-topbar-end {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    flex-shrink: 0;
}

.ol-topbar-sync-error {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: #fbbf24;
    white-space: nowrap;
}

.ol-account { display: flex; align-items: center; gap: 0.4rem; }
.ol-account-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--nc-teal-400); color: var(--nc-teal-900); display: flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 700; flex-shrink: 0; }
.ol-account-email { font-size: 0.73rem; color: rgba(255,255,255,0.65); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }

/* ── Body (2-column: list + reading pane) ─────────────────────────── */
.ol-body {
    display: grid;
    grid-template-columns: 300px 1fr;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ── Message list panel ───────────────────────────────────────────── */
.ol-list { display: flex; flex-direction: column; border-right: 1px solid #e5e7eb; overflow: hidden; background: #fff; }

.ol-list-header { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 0.85rem 0.6rem 1rem; border-bottom: 1px solid #e5e7eb; flex-shrink: 0; background: #fafafa; }
.ol-folder-title { margin: 0; font-size: 0.975rem; font-weight: 700; color: #111827; }
.ol-list-header-badge { font-size: 0.72rem; color: #6b7280; }

.ol-sync-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.08); cursor: pointer; color: rgba(255,255,255,0.75); transition: background 0.12s, color 0.12s; flex-shrink: 0; }
.ol-sync-btn:hover:not(:disabled) { background: rgba(255,255,255,0.16); color: #fff; }
.ol-sync-btn:disabled { opacity: 0.45; cursor: default; }
.ol-sync-btn--spinning svg { animation: ol-spin 0.8s linear infinite; }

.ol-list-search { padding: 0.5rem 0.75rem; border-bottom: 1px solid #e5e7eb; flex-shrink: 0; }
.ol-search-input {
    width: 100%;
    padding: 0.4rem 0.65rem 0.4rem 2rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.8rem;
    background: #f9fafb url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' fill='%239ca3af' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0'/%3E%3C/svg%3E") no-repeat 0.55rem center;
    outline: none;
    color: #111827;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.ol-search-input:focus { border-color: var(--nc-teal-600); box-shadow: 0 0 0 2px rgba(15,148,148,0.15); background-color: #fff; }
.ol-search-input::placeholder { color: #9ca3af; }

.ol-list-body { flex: 1; overflow-y: auto; }

.ol-spinner-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 200px; gap: 0.5rem; color: #9ca3af; }
.ol-spinner { width: 20px; height: 20px; border: 2px solid #e5e7eb; border-top-color: var(--nc-teal-600); border-radius: 50%; animation: ol-spin 0.7s linear infinite; }
@keyframes ol-spin { to { transform: rotate(360deg); } }

.ol-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 220px; gap: 0.6rem; color: #9ca3af; text-align: center; padding: 1rem; }
.ol-empty p { margin: 0; font-size: 0.875rem; }

/* ── Message rows ─────────────────────────────────────────────────── */
.ol-msg-row {
    display: flex;
    align-items: stretch;
    cursor: pointer;
    border-bottom: 1px solid #eff0f1;
    transition: background 0.1s;
    position: relative;
}
.ol-msg-row:hover { background: #f3f6f9; }

/* Selected */
.ol-msg-row--active { background: #e8f2fc; border-left: 3px solid #0078d4; }
.ol-msg-row--active:hover { background: #ddeaf8; }

/* Unread — teal left stripe + faint blue wash */
.ol-msg-row--unread { background: #f5f9ff; }
.ol-msg-row--unread:hover { background: #eaf1fc; }
.ol-msg-row--unread::before { content: ''; display: block; width: 3px; background: var(--nc-teal-600); flex-shrink: 0; align-self: stretch; }

/* Active hides the unread stripe (border-left takes over) */
.ol-msg-row--active::before { display: none; }

/* Inner wrapper — padding here so stripe bleeds full height */
.ol-msg-inner { display: flex; align-items: flex-start; gap: 0.7rem; padding: 0.65rem 0.9rem 0.65rem 0.75rem; flex: 1; min-width: 0; }

.ol-msg-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--nc-teal-100); color: var(--nc-teal-800); display: flex; align-items: center; justify-content: center; font-size: 0.82rem; font-weight: 700; flex-shrink: 0; text-transform: uppercase; margin-top: 1px; }
.ol-msg-row--unread .ol-msg-avatar { background: var(--nc-teal-600); color: #fff; }
.ol-msg-row--active .ol-msg-avatar { background: #0078d4; color: #fff; }

.ol-msg-body { flex: 1; min-width: 0; }
.ol-msg-top { display: flex; align-items: baseline; justify-content: space-between; gap: 0.4rem; margin-bottom: 0.1rem; }
.ol-msg-from { font-size: 0.875rem; font-weight: 500; color: #1f2937; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.ol-msg-row--unread .ol-msg-from { font-weight: 700; color: #0f172a; }
.ol-msg-date { font-size: 0.7rem; color: #9ca3af; flex-shrink: 0; white-space: nowrap; }
.ol-msg-row--unread .ol-msg-date { font-weight: 600; color: #374151; }
.ol-msg-subject { font-size: 0.82rem; color: #374151; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 0.1rem; }
.ol-msg-row--unread .ol-msg-subject { font-weight: 600; color: #111827; }
.ol-msg-preview { font-size: 0.75rem; color: #9ca3af; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ol-msg-indicators { display: flex; flex-direction: column; align-items: center; gap: 4px; flex-shrink: 0; padding-top: 3px; }
.ol-unread-dot { width: 7px; height: 7px; border-radius: 50%; background: #0078d4; flex-shrink: 0; }

.ol-load-more { padding: 0.75rem; text-align: center; border-top: 1px solid #e5e7eb; }
.ol-load-more-btn { background: none; border: 1px solid #d1d5db; border-radius: 6px; padding: 0.4rem 1.2rem; font-size: 0.8rem; color: #374151; cursor: pointer; transition: background 0.1s; }
.ol-load-more-btn:hover { background: #f3f4f6; }
.ol-load-more-btn:disabled { opacity: 0.5; cursor: default; }

/* ── Reading pane ─────────────────────────────────────────────────── */
.ol-reading-pane { display: flex; flex-direction: column; overflow: hidden; background: #fff; }

.ol-reading-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 0.75rem; color: #9ca3af; text-align: center; padding: 2rem; }
.ol-reading-empty-title { margin: 0; font-size: 1rem; font-weight: 600; color: #374151; }
.ol-reading-empty-sub   { margin: 0; font-size: 0.875rem; }

/* ── Email reader ─────────────────────────────────────────────────── */
.ol-reader { display: flex; flex-direction: column; height: 100%; overflow: hidden; }

.ol-reader-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 0.55rem 1.25rem; border-bottom: 1px solid #e5e7eb; flex-shrink: 0; background: #fafafa; }
.ol-reader-toolbar-left { display: flex; align-items: center; gap: 0.4rem; }
.ol-reader-content { flex: 1; overflow-y: auto; padding: 1.5rem 2rem; }

.ol-reader-subject { font-size: 1.2rem; font-weight: 700; color: #0f172a; margin: 0 0 1rem; line-height: 1.35; letter-spacing: -0.01em; }

.ol-reader-meta { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.85rem; background: #f8faff; border: 1px solid #e5e7eb; border-radius: 8px; margin-bottom: 1.5rem; }
.ol-reader-meta-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--nc-teal-600); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; font-weight: 700; flex-shrink: 0; text-transform: uppercase; }
.ol-reader-meta-info { flex: 1; min-width: 0; }
.ol-reader-meta-from { font-weight: 600; color: #111827; font-size: 0.875rem; }
.ol-reader-meta-to   { font-size: 0.8rem; color: #6b7280; margin-top: 0.1rem; }
.ol-reader-meta-label { color: #9ca3af; }
.ol-reader-meta-date  { font-size: 0.78rem; color: #9ca3af; flex-shrink: 0; align-self: center; }

.ol-reader-attachments { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 0.75rem 1rem; margin-bottom: 1.25rem; }
.ol-reader-att-label { display: flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; color: #6b7280; font-weight: 600; margin-bottom: 0.6rem; }
.ol-reader-att-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.ol-att-btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.35rem 0.75rem; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; cursor: pointer; font-size: 0.8rem; color: #374151; transition: background 0.12s, border-color 0.12s; }
.ol-att-btn:hover { background: #f3f4f6; border-color: #9ca3af; }
.ol-att-btn--active { border-color: var(--nc-teal-600); background: var(--nc-teal-50); color: var(--nc-teal-800); }
.ol-att-btn:disabled { opacity: 0.6; cursor: default; }
.ol-att-size { font-size: 0.7rem; color: #9ca3af; }

.ol-att-viewer { border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; margin-bottom: 1rem; background: #fff; }
.ol-att-viewer-bar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; padding: 0.5rem 0.85rem; background: #f3f4f6; border-bottom: 1px solid #e5e7eb; font-size: 0.8rem; }
.ol-att-viewer-name { flex: 1; font-weight: 600; color: #111827; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ol-att-viewer-bar-actions { display: flex; gap: 0.4rem; margin-left: auto; }
.ol-att-viewer-frame { display: block; width: 100%; height: 65vh; border: none; }
.ol-att-viewer-img { display: flex; justify-content: center; padding: 1rem; background: #f9fafb; }
.ol-att-viewer-img img { max-width: 100%; max-height: 70vh; border-radius: 4px; }
.ol-att-viewer-loading { padding: 1rem; color: #6b7280; margin: 0; }
.ol-att-viewer-blocked { display: flex; flex-direction: column; align-items: center; padding: 2rem; gap: 0.75rem; text-align: center; color: #6b7280; }
.ol-att-viewer-blocked p { margin: 0; }

.ol-reader-body { font-size: 0.9rem; line-height: 1.7; color: #374151; }
.ol-reader-plaintext { white-space: pre-wrap; font-family: inherit; font-size: 0.875rem; color: #374151; margin: 0; }

/* ── Compose pane ─────────────────────────────────────────────────── */
.ol-compose { display: flex; flex-direction: column; height: 100%; overflow: hidden; }

.ol-compose-header { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1.25rem; border-bottom: 1px solid #e5e7eb; background: #f8fafc; flex-shrink: 0; }
.ol-compose-title { font-size: 0.875rem; font-weight: 700; color: #111827; }
.ol-compose-header-actions { display: flex; gap: 0.25rem; }

.ol-compose-fields { flex-shrink: 0; border-bottom: 1px solid #e5e7eb; }
.ol-compose-field { display: flex; align-items: center; border-bottom: 1px solid #f3f4f6; padding: 0 1.25rem; }
.ol-compose-field:last-child { border-bottom: none; }
.ol-compose-label { width: 3.5rem; font-size: 0.8rem; font-weight: 600; color: #9ca3af; flex-shrink: 0; }
.ol-compose-input { flex: 1; border: none; outline: none; padding: 0.7rem 0; font-size: 0.875rem; color: #111827; background: transparent; }
.ol-compose-input::placeholder { color: #d1d5db; }

.ol-compose-body { flex: 1; resize: none; border: none; outline: none; padding: 1rem 1.25rem; font-size: 0.875rem; color: #374151; font-family: inherit; line-height: 1.6; background: #fff; min-height: 0; }

.ol-compose-attachments { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0.5rem 1.25rem; border-top: 1px solid #f3f4f6; flex-shrink: 0; }
.ol-att-chip { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.25rem 0.5rem; background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 4px; font-size: 0.78rem; color: #374151; }
.ol-att-chip-remove { border: none; background: none; cursor: pointer; color: #9ca3af; font-size: 0.9rem; line-height: 1; padding: 0 0.1rem; }
.ol-att-chip-remove:hover { color: #dc2626; }

.ol-doc-picker { margin: 0 1.25rem 0.5rem; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; background: #fff; flex-shrink: 0; max-height: 220px; overflow-y: auto; }
.ol-doc-picker-header { display: flex; align-items: center; justify-content: space-between; padding: 0.6rem 0.85rem; background: #f9fafb; border-bottom: 1px solid #e5e7eb; font-size: 0.8rem; font-weight: 600; }
.ol-doc-picker-empty { padding: 0.75rem 0.85rem; color: #9ca3af; font-size: 0.8rem; margin: 0; }
.ol-doc-item { display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.6rem 0.85rem; cursor: pointer; border-bottom: 1px solid #f3f4f6; transition: background 0.1s; }
.ol-doc-item:hover { background: #f9fafb; }
.ol-doc-item:last-child { border-bottom: none; }
.ol-doc-title { font-size: 0.82rem; font-weight: 500; color: #111827; }
.ol-doc-meta  { font-size: 0.72rem; color: #9ca3af; margin-top: 0.1rem; }

.ol-alert { padding: 0.5rem 1.25rem; font-size: 0.8rem; flex-shrink: 0; }
.ol-alert--error   { background: #fef2f2; color: #b91c1c; border-top: 1px solid #fee2e2; }
.ol-alert--success { background: #f0fdf4; color: #15803d; border-top: 1px solid #bbf7d0; }

.ol-compose-footer { display: flex; align-items: center; justify-content: space-between; padding: 0.65rem 1.25rem; border-top: 1px solid #e5e7eb; flex-shrink: 0; background: #f8fafc; }
.ol-compose-footer-primary { display: flex; gap: 0.4rem; }
.ol-compose-footer-tools   { display: flex; gap: 0.25rem; }

/* ── Shared buttons (ol-btn, ol-icon-btn) ─────────────────────────── */
.ol-btn { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.45rem 0.9rem; border-radius: 6px; border: 1px solid transparent; font-size: 0.825rem; font-weight: 500; cursor: pointer; transition: background 0.12s; text-decoration: none; }
.ol-btn--primary { background: var(--nc-teal-600); color: #fff; border-color: var(--nc-teal-600); }
.ol-btn--primary:hover { background: var(--nc-teal-700); }
.ol-btn--send { background: var(--nc-teal-600); color: #fff; border-color: var(--nc-teal-600); }
.ol-btn--send:hover { background: var(--nc-teal-700); }
.ol-btn--ghost { background: transparent; color: #374151; border-color: #d1d5db; }
.ol-btn--ghost:hover { background: #f3f4f6; }
.ol-btn--sm { padding: 0.3rem 0.65rem; font-size: 0.78rem; }
.ol-btn:disabled { opacity: 0.55; cursor: default; }

.ol-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 6px; border: none; background: none; cursor: pointer; color: #6b7280; transition: background 0.1s, color 0.1s; }
.ol-icon-btn:hover { background: #f3f4f6; color: #111827; }
.ol-icon-btn--tool { width: 32px; height: 32px; border: 1px solid #e5e7eb; }
.ol-icon-btn--tool:hover { background: #e5e7eb; }

/* ── Scan result badges ───────────────────────────────────────────── */
.nc-scan-badge { display: inline-block; padding: 0.1rem 0.45rem; border-radius: 4px; font-size: 0.72rem; font-weight: 600; }
.nc-scan-badge--clean  { background: #dcfce7; color: #166534; }
.nc-scan-badge--danger { background: #fee2e2; color: #991b1b; }
.nc-scan-badge--warn   { background: #fef3c7; color: #92400e; }
.nc-scan-badge--muted  { background: #f3f4f6; color: #6b7280; }

/* ── Mailbox picker cards ─────────────────────────────────────────── */
.nc-mailbox-picker { display: flex; flex-direction: column; gap: 0.75rem; max-width: 640px; }

.nc-mailbox-card {
    display: flex; align-items: center; gap: 1rem;
    padding: 1rem 1.25rem;
    background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
    cursor: pointer; transition: box-shadow 0.15s, border-color 0.15s;
}
.nc-mailbox-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); border-color: #1d6a5b; }
.nc-mailbox-card--inactive { opacity: 0.6; }

.nc-mailbox-card-icon {
    flex-shrink: 0; width: 48px; height: 48px;
    background: #f0faf7; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; color: #1d6a5b;
}
.nc-mailbox-card-info { flex: 1; min-width: 0; }
.nc-mailbox-card-name { font-weight: 600; font-size: 0.95rem; color: #111827; }
.nc-mailbox-card-address { font-size: 0.8rem; color: #6b7280; margin-top: 2px; }
.nc-mailbox-card-arrow { color: #9ca3af; }
