/**
 * KAAI Email Intelligence Panel - email.css
 * Mother's email monitoring and cataloging system
 * v1.0 (2026-04-05)
 */

/* ── Panel shell ────────────────────────────────────────────────────────────── */
.email-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-primary, #0a0a0a);
    color: var(--text-primary, #e5e7eb);
    font-size: 13px;
    overflow: hidden;
}

/* ── Header ──────────────────────────────────────────────────────────────────── */
.email-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 10px;
    border-bottom: 1px solid #1e1e1e;
    background: #0d0d0d;
    flex-shrink: 0;
    gap: 12px;
}
.email-header-left  { display: flex; align-items: center; gap: 12px; }
.email-header-right { display: flex; align-items: center; gap: 8px; }

.email-title {
    font-size: 15px;
    font-weight: 700;
    color: #60a5fa;
    letter-spacing: 0.3px;
}

.email-badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: #f87171;
    animation: email-pulse-badge 2.5s infinite;
}

@keyframes email-pulse-badge {
    0%, 100% { border-color: rgba(248,113,113,0.3); }
    50%       { border-color: rgba(248,113,113,0.7); }
}

.email-badge-pill.email-badge-ok {
    background: rgba(74, 222, 128, 0.08);
    border-color: rgba(74, 222, 128, 0.2);
    color: #4ade80;
    animation: none;
}

/* ── Stats bar ───────────────────────────────────────────────────────────────── */
.email-stats-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 7px 16px;
    background: #0d0d0d;
    border-bottom: 1px solid #1e1e1e;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.email-stat {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #666;
    white-space: nowrap;
}
.email-stat b { color: #ddd; }
.email-stat-icon { font-size: 13px; }

/* ── Tabs ────────────────────────────────────────────────────────────────────── */
.email-tabs {
    display: flex;
    gap: 0;
    padding: 0 16px;
    background: #0d0d0d;
    border-bottom: 1px solid #1e1e1e;
    flex-shrink: 0;
}

.email-tab {
    padding: 9px 14px;
    font-size: 12px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    white-space: nowrap;
    user-select: none;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 5px;
}
.email-tab:hover { color: #aaa; }
.email-tab.active {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
    font-weight: 600;
}
.email-tab-badge {
    background: #dc2626;
    color: #fff;
    border-radius: 9999px;
    padding: 0 5px;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    text-align: center;
}

/* ── Body ────────────────────────────────────────────────────────────────────── */
.email-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ── Company sidebar ─────────────────────────────────────────────────────────── */
.email-sidebar {
    flex: 0 0 240px;
    min-width: 180px;
    border-right: 1px solid #1e1e1e;
    overflow-y: auto;
    background: #0a0a0a;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: #2a2a2a transparent;
}
.email-sidebar::-webkit-scrollbar { width: 4px; }
.email-sidebar::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 2px; }

.email-sidebar-header {
    padding: 6px 12px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: #444;
}

.email-folder {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    cursor: pointer;
    border-radius: 5px;
    margin: 1px 6px;
    transition: background 0.1s;
    position: relative;
}
.email-folder:hover { background: #151515; }
.email-folder.active { background: #1a2a3a; }

.email-folder-icon { font-size: 15px; flex-shrink: 0; }
.email-folder-name {
    flex: 1;
    font-size: 12px;
    color: #ccc;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.email-folder.active .email-folder-name { color: #60a5fa; font-weight: 600; }

.email-folder-count {
    font-size: 10px;
    background: #222;
    color: #666;
    border-radius: 9999px;
    padding: 1px 6px;
    flex-shrink: 0;
}
.email-folder-count.has-unread {
    background: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
    font-weight: 700;
}

.email-folder-new-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #f87171;
    flex-shrink: 0;
    animation: email-pulse-badge 2s infinite;
}

/* ── Email list pane ─────────────────────────────────────────────────────────── */
.email-list-pane {
    flex: 1;
    overflow-y: auto;
    background: #0d0d0d;
    border-right: 1px solid #1e1e1e;
    scrollbar-width: thin;
    scrollbar-color: #2a2a2a transparent;
}
.email-list-pane::-webkit-scrollbar { width: 4px; }
.email-list-pane::-webkit-scrollbar-thumb { background: #2a2a2a; }

.email-list-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 200px;
    color: #333;
    font-size: 13px;
    text-align: center;
}
.email-list-empty-icon { font-size: 40px; opacity: 0.3; }

/* Queue card (attention view) */
.email-queue-card {
    padding: 14px 16px;
    border-bottom: 1px solid #1a1a1a;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}
.email-queue-card:hover  { background: #111; }
.email-queue-card.active { background: #0f1f2f; }

.email-qc-top {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 5px;
}

.email-pri-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
}
.email-pri-critical { background: #f87171; }
.email-pri-high     { background: #fb923c; }
.email-pri-medium   { background: #fbbf24; }
.email-pri-low      { background: #4ade80; }

.email-qc-meta { flex: 1; min-width: 0; }
.email-qc-subject {
    font-size: 13px;
    font-weight: 600;
    color: #e5e7eb;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.email-queue-card:not(.is-read) .email-qc-subject { color: #fff; }

.email-qc-from {
    font-size: 11px;
    color: #555;
    margin-top: 1px;
}
.email-qc-company {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: rgba(96,165,250,0.08);
    border: 1px solid rgba(96,165,250,0.15);
    color: #60a5fa;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
}

.email-qc-row2 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 5px;
    flex-wrap: wrap;
}

.email-qc-reason {
    font-size: 11px;
    color: #888;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-qc-time { font-size: 10px; color: #444; flex-shrink: 0; }

.email-cat-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    flex-shrink: 0;
}

/* Category colours */
.email-cat-security    { background: rgba(248,113,113,0.15); color: #f87171; }
.email-cat-verification{ background: rgba(251,191,36, 0.15); color: #fbbf24; }
.email-cat-welcome     { background: rgba(74,222,128, 0.15); color: #4ade80; }
.email-cat-billing     { background: rgba(96,165,250, 0.15); color: #60a5fa; }
.email-cat-credentials { background: rgba(167,139,250,0.15); color: #a78bfa; }
.email-cat-commercial  { background: rgba(251,191,36, 0.15); color: #fbbf24; }
.email-cat-update      { background: rgba(156,163,175,0.15); color: #9ca3af; }
.email-cat-newsletter  { background: rgba(75,85,99,  0.15); color: #4b5563; }
.email-cat-general     { background: rgba(75,85,99,  0.10); color: #6b7280; }
.email-cat-developer   { background: rgba(52,211,153,0.15); color: #34d399; }
.email-cat-legal       { background: rgba(156,163,175,0.10); color: #6b7280; }
.email-cat-finance     { background: rgba(250,204,21, 0.15); color: #facc15; }

/* Regular email row (Companies view) */
.email-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid #151515;
    cursor: pointer;
    transition: background 0.1s;
}
.email-row:hover { background: #111; }
.email-row.active { background: #0f1f2f; }
.email-row.unread .email-row-subject { color: #fff; font-weight: 600; }

.email-row-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
}

.email-row-body { flex: 1; min-width: 0; }
.email-row-subject {
    font-size: 12px;
    color: #ccc;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.email-row-sender { font-size: 11px; color: #555; margin-top: 1px; }
.email-row-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 3px;
    flex-wrap: wrap;
}
.email-row-time { font-size: 10px; color: #444; flex-shrink: 0; }

/* ── Detail pane ─────────────────────────────────────────────────────────────── */
.email-detail-pane {
    flex: 0 0 38%;
    min-width: 280px;
    overflow-y: auto;
    background: #0a0a0a;
    padding: 20px;
    scrollbar-width: thin;
    scrollbar-color: #2a2a2a transparent;
}
.email-detail-pane::-webkit-scrollbar { width: 4px; }
.email-detail-pane::-webkit-scrollbar-thumb { background: #2a2a2a; }

.email-detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 200px;
    color: #333;
    font-size: 13px;
    text-align: center;
}
.email-detail-empty-icon { font-size: 48px; opacity: 0.25; }

.email-detail-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: email-fade-in 0.2s ease;
}

@keyframes email-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.email-detail-company {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    color: #60a5fa;
    margin-bottom: 2px;
}

.email-detail-subject {
    font-size: 15px;
    font-weight: 700;
    color: #f3f4f6;
    line-height: 1.4;
    margin-bottom: 2px;
}

.email-detail-from {
    font-size: 11px;
    color: #555;
    margin-bottom: 8px;
}

.email-detail-divider {
    width: 100%;
    height: 1px;
    background: #1e1e1e;
    margin: 6px 0;
}

.email-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    padding: 3px 0;
    gap: 10px;
}
.email-detail-row span:first-child { color: #444; white-space: nowrap; }
.email-detail-row span:last-child  { color: #aaa; text-align: right; }

.email-detail-preview {
    margin-top: 8px;
    padding: 10px 12px;
    background: #111;
    border: 1px solid #1e1e1e;
    border-radius: 6px;
    font-size: 12px;
    color: #888;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 160px;
    overflow-y: auto;
}

.email-detail-reason {
    margin-top: 6px;
    padding: 8px 10px;
    background: rgba(251,191,36,0.06);
    border: 1px solid rgba(251,191,36,0.2);
    border-radius: 5px;
    font-size: 11px;
    color: #fbbf24;
}

.email-detail-actions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.email-btn {
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid #2a2a2a;
    background: #1a1a1a;
    color: #aaa;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}
.email-btn:hover { background: #222; color: #fff; }
.email-btn-primary {
    background: rgba(96,165,250,0.12);
    border-color: rgba(96,165,250,0.3);
    color: #60a5fa;
}
.email-btn-primary:hover { background: rgba(96,165,250,0.2); }
.email-btn-danger {
    background: rgba(248,113,113,0.08);
    border-color: rgba(248,113,113,0.25);
    color: #f87171;
}
.email-btn-danger:hover { background: rgba(248,113,113,0.15); }

/* ── Loading / error ──────────────────────────────────────────────────────────── */
.email-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 24px 16px;
    color: #444;
    font-size: 12px;
}
.email-spin {
    display: inline-block;
    animation: email-spin 1s linear infinite;
}
@keyframes email-spin { to { transform: rotate(360deg); } }

.email-error {
    padding: 16px;
    color: #f87171;
    font-size: 12px;
}

/* ── Add account card ──────────────────────────────────────────────────────────── */
.email-add-account {
    margin: 16px;
    padding: 14px;
    background: #111;
    border: 1px dashed #2a2a2a;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
}
.email-add-account:hover { border-color: #60a5fa55; }
.email-add-account-icon { font-size: 24px; margin-bottom: 4px; }
.email-add-account-label { font-size: 12px; color: #555; }

/* ── Responsive ───────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .email-sidebar { flex: 0 0 160px; }
    .email-detail-pane { display: none; }
}
@media (max-width: 600px) {
    .email-sidebar { display: none; }
}

