/* ═══════════════════════════════════════════════════════════════
   DAILY BRIEF — ProductiveApp v4.0
   Widget inline dashboard + overlay login
   ═══════════════════════════════════════════════════════════════ */

/* ─── INLINE WIDGET (.mbw-*) ─────────────────────────────────── */

.mbw-card {
    position: relative;
    border-radius: 20px;
    background: linear-gradient(165deg,
        rgba(var(--accent-rgb, 139,92,246), 0.06) 0%,
        var(--bg-card, rgba(20,28,50,0.8)) 40%,
        rgba(var(--accent-rgb, 139,92,246), 0.03) 100%);
    border: 1px solid rgba(255,255,255,0.08);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    overflow: hidden;
    margin-bottom: 20px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.mbw-card:hover {
    border-color: rgba(var(--accent-rgb, 139,92,246), 0.2);
    box-shadow: 0 8px 40px rgba(var(--accent-rgb, 139,92,246), 0.08);
}

.mbw-card-glow {
    position: absolute;
    top: 0; left: 10%; right: 10%;
    height: 1px;
    background: linear-gradient(90deg,
        transparent,
        var(--accent, #8b5cf6) 30%,
        rgba(234,179,8,0.6) 70%,
        transparent);
    opacity: 0.5;
    pointer-events: none;
}

.mbw-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}
.mbw-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.mbw-title-icon {
    font-size: 24px;
    filter: drop-shadow(0 0 8px rgba(234,179,8,0.4));
}
.mbw-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--text, #fff);
    letter-spacing: -0.02em;
}
.mbw-subtitle {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--text-muted, rgba(255,255,255,0.4));
    font-weight: 400;
}

.mbw-refresh-btn {
    width: 34px; height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
    color: var(--text-muted, rgba(255,255,255,0.4));
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.mbw-refresh-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text, #fff);
    border-color: rgba(255,255,255,0.15);
    transform: rotate(90deg);
}

.mbw-body {
    padding: 16px 24px 20px;
}

/* Stats Grid */
.mbw-stats-grid {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.mbw-stat {
    flex: 1;
    min-width: 72px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    border-radius: 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}
.mbw-stat:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.1);
    transform: translateY(-2px);
}
.mbw-stat--warn {
    border-color: rgba(239,68,68,0.25);
    background: rgba(239,68,68,0.06);
}
.mbw-stat--warn .mbw-stat-val { color: #ef4444 !important; }

.mbw-stat-icon {
    font-size: 18px;
    line-height: 1;
}
.mbw-stat-val {
    font-size: 22px;
    font-weight: 800;
    color: var(--accent, #8b5cf6);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.mbw-stat-lbl {
    font-size: 10px;
    color: var(--text-muted, rgba(255,255,255,0.4));
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Events chips */
.mbw-events-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}
.mbw-event-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 10px;
    background: rgba(var(--accent-rgb, 139,92,246), 0.1);
    border: 1px solid rgba(var(--accent-rgb, 139,92,246), 0.15);
    font-size: 12px;
    color: var(--text-secondary, rgba(255,255,255,0.7));
}
.mbw-event-time {
    font-weight: 700;
    color: var(--accent, #8b5cf6);
    font-size: 11px;
}
.mbw-event-none {
    opacity: 0.5;
    border-color: rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.03);
}

/* Deals section */
.mbw-deals-section {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.mbw-deal-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(234,179,8,0.05);
    border: 1px solid rgba(234,179,8,0.1);
    font-size: 12px;
}
.mbw-deal-icon { font-size: 14px; }
.mbw-deal-name {
    font-weight: 600;
    color: var(--text, #fff);
    flex: 1;
}
.mbw-deal-contact {
    color: var(--text-muted, rgba(255,255,255,0.4));
    font-size: 11px;
}
.mbw-deal-warn {
    color: #f59e0b;
    font-weight: 600;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(245,158,11,0.12);
}

/* Divider */
.mbw-divider {
    height: 1px;
    margin: 16px 0;
    background: linear-gradient(90deg,
        transparent,
        rgba(255,255,255,0.08) 30%,
        var(--accent, #8b5cf6) 50%,
        rgba(255,255,255,0.08) 70%,
        transparent);
    opacity: 0.5;
}

/* AI Section */
.mbw-ai-section {
    min-height: 60px;
}
.mbw-ai-header {
    margin-bottom: 10px;
}
.mbw-ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 8px;
    background: rgba(var(--accent-rgb, 139,92,246), 0.12);
    border: 1px solid rgba(var(--accent-rgb, 139,92,246), 0.2);
    font-size: 12px;
    font-weight: 600;
    color: var(--accent, #8b5cf6);
}

.mbw-ai-text {
    font-size: 13.5px;
    line-height: 1.7;
    color: var(--text-secondary, rgba(255,255,255,0.75));
}
.mbw-ai-text strong {
    color: var(--text, #fff);
    font-weight: 600;
}
.mbw-ai-unavail {
    opacity: 0.5;
    font-style: italic;
    text-align: center;
    padding: 12px 0;
}

.mbw-h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent, #8b5cf6);
    margin: 14px 0 4px;
}
.mbw-h3:first-child { margin-top: 0; }
.mbw-h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent, #8b5cf6);
    opacity: 0.85;
    margin: 10px 0 4px;
}
.mbw-p {
    font-size: 13.5px;
    line-height: 1.7;
    color: var(--text-secondary, rgba(255,255,255,0.75));
    margin: 0 0 6px;
}
.mbw-list {
    list-style: none;
    padding: 0;
    margin: 6px 0 8px;
}
.mbw-list li {
    position: relative;
    padding: 4px 0 4px 16px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary, rgba(255,255,255,0.75));
    border-left: 2px solid rgba(var(--accent-rgb, 139,92,246), 0.3);
    margin-bottom: 2px;
}
.mbw-list li::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 12px;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent, #8b5cf6);
    opacity: 0.6;
}

/* Loading states */
.mbw-ai-gen {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
    font-size: 13px;
    color: var(--text-muted, rgba(255,255,255,0.4));
}
.mbw-dot-pulse {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent, #8b5cf6);
    animation: mbwPulse 1.4s ease-in-out infinite;
}
@keyframes mbwPulse {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

.mbw-loading-stats {
    display: flex;
    gap: 12px;
    padding: 8px 0;
}
.mbw-skeleton {
    height: 60px;
    flex: 1;
    border-radius: 14px;
    background: linear-gradient(90deg,
        rgba(255,255,255,0.03) 25%,
        rgba(255,255,255,0.06) 50%,
        rgba(255,255,255,0.03) 75%);
    background-size: 200% 100%;
    animation: mbwShimmer 1.5s ease-in-out infinite;
}
.mbw-skeleton--sm { max-width: 120px; }
@keyframes mbwShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Fade in animation */
.mbw-fade-in {
    animation: mbwFadeIn 0.5s ease;
}
@keyframes mbwFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Typewriter wrapper */
.mbw-typewriter {
    transition: opacity 0.8s ease, transform 0.8s ease;
}

/* ─── OVERLAY (.db-*) — kept for login brief ──────────────────── */

#daily-brief-overlay {
    --db-accent: #8b5cf6;
    --db-accent2: #6366f1;
    --db-glow: rgba(139,92,246,0.3);
    --db-bg1: #0f1423;
    --db-bg2: #141c32;
    --db-bg3: #0c101e;
    --db-glow-line: rgba(139,92,246,0.6);
}

.db-overlay {
    position: fixed;
    inset: 0;
    z-index: 200000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    opacity: 0;
    pointer-events: auto !important;
    transition: opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.db-overlay.db-visible { opacity: 1; }
.db-overlay.db-closing { opacity: 0; transition: opacity 0.35s ease; pointer-events: none !important; }
.db-overlay * { pointer-events: auto !important; }
.db-overlay.db-closing * { pointer-events: none !important; }

.db-card {
    position: relative;
    width: 92%; max-width: 600px; max-height: 88vh;
    display: flex; flex-direction: column;
    border-radius: 28px;
    background: linear-gradient(165deg, var(--db-bg1) 0%, var(--db-bg2, #141c32) 45%, var(--db-bg3, #0c101e) 100%);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 50px 120px rgba(0,0,0,0.7), 0 0 100px var(--db-glow, rgba(139,92,246,0.1));
    transform: translateY(40px) scale(0.93);
    transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
    overflow: hidden;
}
.db-visible .db-card { transform: translateY(0) scale(1); }
.db-closing .db-card { transform: translateY(20px) scale(0.96); }

.db-card::before {
    content: ''; position: absolute; top: 0; left: 8%; right: 8%; height: 1px;
    background: linear-gradient(90deg, transparent, var(--db-glow-line, rgba(139,92,246,0.6)) 40%, var(--db-accent2, #6366f1) 60%, transparent);
    opacity: 0.8;
}

.db-close {
    position: absolute; top: 18px; right: 18px;
    width: 34px; height: 34px; border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.07);
    background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.35);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease; z-index: 10; flex-shrink: 0;
}
.db-close:hover { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.8); transform: scale(1.08); }

.db-header { padding: 44px 40px 18px; text-align: center; flex-shrink: 0; }
.db-icon-wrap { display: flex; justify-content: center; margin-bottom: 18px; }
.db-icon {
    width: 64px; height: 64px; border-radius: 20px;
    display: flex; align-items: center; justify-content: center; font-size: 30px;
    animation: db-pulse 2.5s ease-in-out infinite;
}
@keyframes db-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); filter: brightness(1.2); } }

.db-title { font-size: 24px; font-weight: 800; color: #fff; margin: 0 0 6px; letter-spacing: -0.02em; line-height: 1.3; }
.db-royal-title { color: var(--db-accent, #8b5cf6); font-style: italic; }
.db-subtitle { font-size: 13px; color: rgba(255,255,255,0.4); margin: 0; font-weight: 400; text-transform: uppercase; letter-spacing: 0.08em; }

.db-body {
    flex: 1; overflow-y: auto; padding: 0 40px 4px;
    scrollbar-width: thin; scrollbar-color: var(--db-accent, #8b5cf6) transparent; min-height: 0;
}

.db-stats-row { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.db-stat-item {
    flex: 1; min-width: 90px; display: flex; flex-direction: column;
    align-items: center; gap: 4px; padding: 14px 10px; border-radius: 16px;
    background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06); text-align: center;
}
.db-stat-item.db-stat-overdue { border-color: rgba(239,68,68,0.3); background: rgba(239,68,68,0.08); }
.db-stat-num { font-size: 26px; font-weight: 800; color: var(--db-accent, #8b5cf6); line-height: 1; }
.db-stat-item.db-stat-overdue .db-stat-num { color: #ef4444; }
.db-stat-label { font-size: 11px; color: rgba(255,255,255,0.45); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }

.db-ai-zone { margin-top: 4px; margin-bottom: 16px; }
.db-ai-loading {
    display: flex; flex-direction: column; gap: 12px; padding: 20px;
    border-radius: 16px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06);
}
.db-ai-loading-text { display: flex; align-items: center; justify-content: space-between; }
.db-ai-label { font-size: 13px; color: rgba(255,255,255,0.5); }
.db-spinner {
    width: 28px; height: 28px;
    border: 3px solid rgba(255,255,255,0.08); border-radius: 50%;
    animation: db-spin 0.7s linear infinite; flex-shrink: 0; align-self: center;
}
@keyframes db-spin { to { transform: rotate(360deg); } }

.db-ai-result { animation: db-fade-in 0.5s ease; }
@keyframes db-fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.db-ai-loading.hidden, .db-ai-result.hidden { display: none !important; }

.db-brief-content {}
.db-h3 { font-size: 15px; font-weight: 700; color: var(--db-accent, #8b5cf6); margin: 18px 0 6px; }
.db-h3:first-child { margin-top: 0; }
.db-h4 { font-size: 13px; font-weight: 600; color: var(--db-accent, #8b5cf6); opacity: 0.85; margin: 14px 0 4px; }
.db-p { font-size: 14px; line-height: 1.7; color: rgba(255,255,255,0.78); margin: 0 0 8px; }
.db-list { list-style: none; padding: 0; margin: 6px 0 10px; }
.db-list li {
    position: relative; padding: 5px 0 5px 18px; font-size: 13px; line-height: 1.6;
    color: rgba(255,255,255,0.75); border-left: 2px solid rgba(255,255,255,0.1); margin-bottom: 2px;
}
.db-list li::before {
    content: ''; position: absolute; left: -4px; top: 13px;
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--db-accent, #8b5cf6); opacity: 0.7;
}

.db-footer {
    padding: 16px 40px 32px; display: flex; justify-content: center; gap: 12px; flex-shrink: 0;
}
.db-btn-primary {
    padding: 13px 36px; border-radius: 16px; border: none;
    color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
    transition: all 0.2s ease; letter-spacing: 0.01em;
}
.db-btn-primary:hover { transform: translateY(-2px); filter: brightness(1.15); }
.db-btn-secondary {
    padding: 11px 26px; border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.45); font-size: 14px; font-weight: 500; cursor: pointer;
    transition: all 0.2s ease;
}
.db-btn-secondary:hover { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.7); }

/* ─── MOBILE ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .mbw-card { border-radius: 16px; margin-bottom: 16px; }
    .mbw-header { padding: 16px 16px 0; }
    .mbw-body { padding: 12px 16px 16px; }
    .mbw-stats-grid { gap: 6px; }
    .mbw-stat { min-width: 60px; padding: 10px 6px; }
    .mbw-stat-val { font-size: 18px; }
    .mbw-stat-lbl { font-size: 9px; }
    .mbw-events-row { gap: 6px; }
    .mbw-event-chip { padding: 4px 8px; font-size: 11px; }

    .db-card { width: 96%; max-height: 92vh; border-radius: 22px; }
    .db-header { padding: 32px 24px 14px; }
    .db-body { padding: 0 24px 4px; }
    .db-footer { padding: 12px 24px 28px; }
    .db-title { font-size: 20px; }
    .db-stats-row { gap: 8px; }
    .db-stat-item { padding: 10px 6px; }
    .db-stat-num { font-size: 22px; }
}

/* ─── BRIEF PREMIUM STYLES v2 ────────────────────────────────── */
.mbw-h3--main {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--text, #fff);
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(var(--accent-rgb, 139,92,246), 0.2);
    display: none; /* Hide the raw title since badge already shows it */
}
.mbw-h3 {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--accent, #8b5cf6);
    margin: 16px 0 6px;
    padding: 6px 10px;
    background: rgba(var(--accent-rgb, 139,92,246), 0.08);
    border-radius: 8px;
    border-left: 3px solid var(--accent, #8b5cf6);
}
.mbw-h3:first-child { margin-top: 0; }
.mbw-h4 {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,0.9);
    margin: 12px 0 4px;
}
.mbw-ai-text {
    font-size: 13.5px;
    line-height: 1.75;
    color: var(--text-secondary, rgba(255,255,255,0.78));
}
.mbw-ai-text strong {
    color: var(--text, #fff);
    font-weight: 600;
    background: rgba(var(--accent-rgb, 139,92,246), 0.1);
    padding: 1px 4px;
    border-radius: 4px;
}
.mbw-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 10px;
}
.mbw-list li {
    position: relative;
    padding: 6px 8px 6px 18px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary, rgba(255,255,255,0.78));
    border-left: 2px solid rgba(var(--accent-rgb, 139,92,246), 0.3);
    margin-bottom: 3px;
    background: rgba(255,255,255,0.02);
    border-radius: 0 6px 6px 0;
    transition: background 0.2s ease;
}
.mbw-list li:hover {
    background: rgba(var(--accent-rgb, 139,92,246), 0.06);
}
.mbw-list li::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 14px;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent, #8b5cf6);
    opacity: 0.6;
}
.mbw-list li.mbw-li-num {
    counter-increment: mbw-counter;
}
.mbw-list li.mbw-li-num::before {
    content: counter(mbw-counter);
    width: auto; height: auto;
    border-radius: 4px;
    background: rgba(var(--accent-rgb, 139,92,246), 0.15);
    color: var(--accent, #8b5cf6);
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    left: -6px;
    top: 7px;
    opacity: 1;
}
.mbw-hr {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb, 139,92,246), 0.3), transparent);
    margin: 14px 0;
}
.mbw-p {
    font-size: 13.5px;
    line-height: 1.75;
    color: var(--text-secondary, rgba(255,255,255,0.78));
    margin: 0 0 8px;
}
.mbw-ai-section {
    counter-reset: mbw-counter;
}

/* ─── BRIEF SECTION COLORS v3 ────────────────────────────────── */
.mbw-ai-text .mbw-h3:has(+ .mbw-p strong:first-child) { }
.mbw-ai-text .mbw-list li strong:first-child {
    background: rgba(234,179,8,0.12);
    color: #fbbf24;
}
/* Warning section - orange accent */
.mbw-ai-text .mbw-h3:nth-of-type(2) {
    background: rgba(234,179,8,0.08);
    border-left-color: #f59e0b;
    color: #fbbf24;
}
/* Opportunity section - green */
.mbw-ai-text .mbw-h3:nth-of-type(3) {
    background: rgba(34,197,94,0.08);
    border-left-color: #22c55e;
    color: #4ade80;
}
/* ACTION RAPIDE bold line */
.mbw-ai-text .mbw-p strong:only-child,
.mbw-ai-text > p strong:only-child {
    display: block;
    padding: 10px 14px;
    margin: 8px 0;
    background: linear-gradient(135deg, rgba(var(--accent-rgb, 139,92,246), 0.12), rgba(234,179,8,0.08));
    border-radius: 10px;
    border: 1px solid rgba(var(--accent-rgb, 139,92,246), 0.15);
    font-size: 13px;
    line-height: 1.6;
}
/* Counter reset at ai-section level */
.mbw-ai-section { counter-reset: mbw-counter; }
/* Typewriter wrapper spacing */
.mbw-typewriter { padding: 4px 0; }
.mbw-typewriter .mbw-h3:first-child { margin-top: 4px; }
