/* ============================================================
   News Digest AI — Frontend Widget Styles
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700&family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@300;400;500&display=swap');

/* ── CSS Variables ── */
.nd-widget {
    --nd-radius:      12px;
    --nd-gap:         1rem;
    --nd-transition:  0.25s ease;
    font-family: 'IBM Plex Sans', sans-serif;
    max-width: 780px;
    margin: 2rem auto;
    border-radius: var(--nd-radius);
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,.18);
    position: relative;
}

/* ── Dark Theme ── */
.nd-theme-dark {
    --nd-bg:          #0d0f14;
    --nd-surface:     #161921;
    --nd-border:      rgba(255,255,255,.07);
    --nd-text:        #e8eaf0;
    --nd-muted:       #6b7280;
    --nd-accent:      #5eead4;  /* teal */
    --nd-accent2:     #818cf8;  /* indigo */
    --nd-card-bg:     #1e2230;
    --nd-hover:       #252a3a;
    background: var(--nd-bg);
    color: var(--nd-text);
}

/* ── Light Theme ── */
.nd-theme-light {
    --nd-bg:          #f8f9fc;
    --nd-surface:     #ffffff;
    --nd-border:      rgba(0,0,0,.08);
    --nd-text:        #1a1d2e;
    --nd-muted:       #6b7280;
    --nd-accent:      #0d9488;
    --nd-accent2:     #4f46e5;
    --nd-card-bg:     #ffffff;
    --nd-hover:       #f0f4ff;
    background: var(--nd-bg);
    color: var(--nd-text);
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
}

/* ── Auto Theme ── */
.nd-theme-auto {
    --nd-bg:          #f8f9fc;
    --nd-surface:     #ffffff;
    --nd-border:      rgba(0,0,0,.08);
    --nd-text:        #1a1d2e;
    --nd-muted:       #6b7280;
    --nd-accent:      #0d9488;
    --nd-accent2:     #4f46e5;
    --nd-card-bg:     #ffffff;
    --nd-hover:       #f0f4ff;
    background: var(--nd-bg);
    color: var(--nd-text);
}
@media (prefers-color-scheme: dark) {
    .nd-theme-auto {
        --nd-bg:      #0d0f14;
        --nd-surface: #161921;
        --nd-border:  rgba(255,255,255,.07);
        --nd-text:    #e8eaf0;
        --nd-muted:   #6b7280;
        --nd-accent:  #5eead4;
        --nd-accent2: #818cf8;
        --nd-card-bg: #1e2230;
        --nd-hover:   #252a3a;
    }
}

/* ── Header ── */
.nd-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--nd-surface);
    border-bottom: 1px solid var(--nd-border);
}

.nd-header__left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.nd-pulse {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--nd-accent);
    border-radius: 50%;
    animation: nd-pulse 2s ease-in-out infinite;
}
@keyframes nd-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .5; transform: scale(1.4); }
}

.nd-label {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: .9rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--nd-accent);
}

.nd-header__right {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.nd-badge {
    font-family: 'IBM Plex Mono', monospace;
    font-size: .7rem;
    padding: .2rem .5rem;
    border-radius: 4px;
    border: 1px solid var(--nd-accent2);
    color: var(--nd-accent2);
    letter-spacing: .08em;
}

.nd-date {
    font-size: .78rem;
    color: var(--nd-muted);
    font-family: 'IBM Plex Mono', monospace;
}

/* ── Digest Block ── */
.nd-digest {
    padding: 1.5rem;
    background: var(--nd-bg);
    border-bottom: 1px solid var(--nd-border);
}

.nd-digest__text {
    font-size: 1.05rem;
    line-height: 1.75;
    color: var(--nd-text);
    margin: 0 0 1rem;
}

/* Key points */
.nd-points {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.nd-points__item {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    font-size: .9rem;
    color: var(--nd-muted);
    line-height: 1.55;
}

.nd-points__dot {
    flex-shrink: 0;
    width: 6px;
    height: 6px;
    margin-top: .45rem;
    background: var(--nd-accent);
    border-radius: 50%;
}

/* ── Sources / Articles ── */
.nd-articles {
    padding: 1.25rem 1.5rem;
    background: var(--nd-bg);
    border-bottom: 1px solid var(--nd-border);
}

.nd-articles__title {
    font-family: 'Syne', sans-serif;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--nd-muted);
    margin: 0 0 .75rem;
}

.nd-articles__list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.nd-article {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .75rem 1rem;
    background: var(--nd-card-bg);
    border: 1px solid var(--nd-border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--nd-text);
    transition: background var(--nd-transition), border-color var(--nd-transition), transform var(--nd-transition);
}

.nd-article:hover {
    background: var(--nd-hover);
    border-color: var(--nd-accent2);
    transform: translateX(3px);
    text-decoration: none;
    color: var(--nd-text);
}

.nd-article__body {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    min-width: 0;
}

.nd-article__source {
    font-family: 'IBM Plex Mono', monospace;
    font-size: .68rem;
    color: var(--nd-accent);
    letter-spacing: .04em;
    text-transform: uppercase;
}

.nd-article__title {
    font-size: .88rem;
    line-height: 1.4;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 580px;
}

.nd-article__arrow {
    flex-shrink: 0;
    color: var(--nd-muted);
    font-size: 1rem;
    transition: color var(--nd-transition);
}

.nd-article:hover .nd-article__arrow {
    color: var(--nd-accent);
}

/* ── Error ── */
.nd-error {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.25rem 1.5rem;
    background: rgba(239,68,68,.08);
    border-left: 3px solid #ef4444;
}

.nd-error__icon { font-size: 1.25rem; }
.nd-error p { margin: 0; font-size: .9rem; color: #fca5a5; }

/* ── Footer ── */
.nd-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1.5rem;
    background: var(--nd-surface);
    font-size: .75rem;
    color: var(--nd-muted);
    font-family: 'IBM Plex Mono', monospace;
}

.nd-refresh-btn {
    background: transparent;
    border: 1px solid var(--nd-border);
    color: var(--nd-muted);
    border-radius: 6px;
    padding: .3rem .7rem;
    font-size: .75rem;
    font-family: 'IBM Plex Sans', sans-serif;
    cursor: pointer;
    transition: all var(--nd-transition);
}

.nd-refresh-btn:hover {
    border-color: var(--nd-accent);
    color: var(--nd-accent);
}

.nd-refresh-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ── Loading overlay ── */
.nd-widget--loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(13,15,20,.6);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--nd-radius);
    z-index: 10;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .nd-header { flex-direction: column; align-items: flex-start; gap: .5rem; }
    .nd-article__title { max-width: 220px; }
}
