/* NewsLog Widget CSS */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: auto; overflow-x: hidden; width: 100%; max-width: 100vw; }
body { font-family: var(--nl-font, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif); color: var(--nl-text, #1E293B); background: var(--nl-bg, #FFFFFF); overflow-x: hidden; width: 100%; max-width: 100vw; }

.nl-widget { padding: 0; }
.nl-container { margin: 0 auto; padding: 16px; }

/* Header */
.nl-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.nl-header-left { flex: 1; min-width: 0; }
.nl-title { font-size: 1.25rem; font-weight: 700; color: var(--nl-text, #1E293B); line-height: 1.3; }
.nl-description { font-size: 0.875rem; color: var(--nl-text2, #64748B); margin-top: 4px; }
.nl-header-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }

/* Badges */
.nl-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.06em;
  padding: 3px 8px; border-radius: 99px; text-transform: uppercase;
}
.nl-badge-live { background: var(--nl-live-bg, rgba(22,163,74,0.12)); color: var(--nl-live, #16A34A); }
.nl-badge-live::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--nl-live, #16A34A); animation: nl-pulse 1.5s infinite; }
.nl-badge-paused { background: rgba(245,158,11,0.12); color: #B45309; }
.nl-badge-ended { background: rgba(107,114,128,0.12); color: #6B7280; }
@keyframes nl-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

.nl-header-badges { display: flex; align-items: center; gap: 6px; }
.nl-entry-count { font-size: 0.75rem; color: var(--nl-text2, #64748B); }

/* New updates bar */
.nl-new-updates-bar {
  background: var(--nl-primary, #2563EB); color: var(--nl-primary-text, #fff);
  padding: 8px 16px; border-radius: 8px; margin-bottom: 12px;
  cursor: pointer; font-size: 0.875rem; font-weight: 500; text-align: center;
  transition: opacity 0.2s;
}
.nl-new-updates-bar:hover { opacity: 0.9; }

/* Search */
.nl-search-wrap { margin-bottom: 10px; }
.nl-search {
  width: 100%; padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--nl-border, #E2E8F0);
  background: var(--nl-surface, #F8FAFC); color: var(--nl-text, #1E293B);
  font-size: 0.875rem; outline: none; font-family: inherit;
}
.nl-search:focus { border-color: var(--nl-primary, #2563EB); }

/* Feed */
.nl-feed { display: flex; flex-direction: column; gap: 12px; }
.nl-empty { padding: 32px 16px; text-align: center; color: var(--nl-text2, #64748B); font-size: 0.875rem; }

/* Entries — card style (default) */
.nl-widget[data-style="card"] .nl-entry {
  background: var(--nl-surface, #F8FAFC); border: 1px solid var(--nl-border, #E2E8F0);
  border-radius: 10px; padding: 14px 16px;
  border-left: 3px solid var(--nl-border, #E2E8F0);
}
/* Entries — timeline style */
.nl-widget[data-style="timeline"] .nl-entry {
  padding: 6px 0 18px 40px;
  position: relative;
  margin-left: 12px;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.nl-widget[data-style="timeline"] .nl-entry::before {
  content: ''; position: absolute; left: 7px; top: 18px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--nl-bg, #fff); border: 2px solid var(--nl-border, #E2E8F0);
  box-shadow: 0 0 0 3px var(--nl-bg, #fff);
}
.nl-widget[data-style="timeline"] .nl-entry.nl-entry-breaking::before { background: var(--nl-breaking, #DC2626); }
.nl-widget[data-style="timeline"] .nl-entry.nl-entry-pinned::before { background: var(--nl-pinned, #F59E0B); }
.nl-widget[data-style="timeline"] .nl-entry::after {
  content: '';
  position: absolute;
  left: 22px;
  top: 24px;
  width: 12px;
  height: 1px;
  background: var(--nl-border, #E2E8F0);
  opacity: 0.7;
}
.nl-widget[data-style="timeline"] .nl-entry-body {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0 0 8px 0;
  box-shadow: none;
}
.nl-widget[data-style="timeline"] .nl-feed::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--nl-border, #E2E8F0);
  opacity: 0.6;
}
.nl-widget[data-style="timeline"] .nl-feed { position: relative; }
.nl-widget[data-style="timeline"] .nl-entry + .nl-entry { padding-top: 8px; }
.nl-widget[data-style="timeline"] .nl-entry-content {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}
.nl-widget[data-style="timeline"] .nl-entry:last-child .nl-entry-content { padding-bottom: 0; }

/* Entry types */
.nl-entry-breaking { border-left-color: var(--nl-breaking, #DC2626) !important; }
.nl-entry-summary { border-left-color: #0D9488 !important; }
.nl-entry-pinned-top { border-left-color: var(--nl-pinned, #F59E0B) !important; }

/* Pinned banner */
.nl-pinned-banner {
  background: var(--nl-pinned, #F59E0B); color: #fff;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  padding: 3px 10px; margin-bottom: 10px;
  border-radius: 7px 7px 0 0;
}
.nl-widget[data-style="card"] .nl-pinned-banner { margin: -14px -16px 10px; }
.nl-widget[data-style="timeline"] .nl-pinned-banner { margin: 0 0 8px 0; padding-left: 10px; border-radius: 6px; }

/* Entry content */
.nl-entry-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.nl-avatar {
  width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.nl-avatar-placeholder {
  background: var(--nl-primary, #2563EB); color: var(--nl-primary-text, #fff);
  font-size: 0.7rem; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.nl-author { font-size: 0.8rem; font-weight: 600; color: var(--nl-text, #1E293B); }
.nl-time { font-size: 0.73rem; color: var(--nl-text2, #64748B); margin-left: auto; }

.nl-type-badge {
  font-size: 0.62rem; font-weight: 700; padding: 2px 6px; border-radius: 3px; text-transform: uppercase; letter-spacing: 0.05em;
}
.nl-type-breaking { background: var(--nl-breaking, #DC2626); color: #fff; }
.nl-type-pinned { background: var(--nl-pinned, #F59E0B); color: #fff; }
.nl-type-summary { background: #0D9488; color: #fff; }

.nl-entry-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 6px;
  color: var(--nl-text, #1E293B);
}

.nl-entry-content { font-size: 0.9375rem; line-height: 1.65; color: var(--nl-text, #1E293B); overflow: hidden; word-break: break-word; }
.nl-entry-content p { margin-bottom: 8px; }
.nl-entry-content p:last-child { margin-bottom: 0; }
.nl-entry-content img { max-width: 100%; border-radius: 6px; margin-top: 8px; display: block; }
.nl-entry-content iframe { max-width: 100%; border-radius: 6px; margin-top: 8px; display: block; }
.nl-entry-content video, .nl-entry-content audio { max-width: 100%; margin-top: 8px; display: block; }
.nl-entry-content a { color: var(--nl-primary, #2563EB); }
.nl-entry-content blockquote { border-left: 3px solid var(--nl-border, #E2E8F0); padding-left: 12px; color: var(--nl-text2, #64748B); margin: 8px 0; }
.nl-entry-content h2 { font-size: 1.1rem; font-weight: 700; margin: 10px 0 6px; }
.nl-entry-content h3 { font-size: 1rem; font-weight: 600; margin: 8px 0 4px; }
.nl-entry-content ul { list-style: disc; padding-left: 20px; margin: 6px 0; }
.nl-entry-content ol { list-style: decimal; padding-left: 20px; margin: 6px 0; }
.nl-entry-content li { margin-bottom: 3px; }

/* Tweet embed */
.nl-embed-tweet { margin-top: 10px; }
.nl-embed-tweet .twitter-tweet { margin: 0 !important; }

/* Conversation mode */
.nl-widget[data-conversation="true"] .nl-feed { display: flex; flex-direction: column; gap: 12px; }
.nl-widget[data-conversation="true"] .nl-entry {
  width: min(80%, 560px);
  border-radius: 14px; padding: 14px 16px;
  border: 1px solid var(--nl-border, #E2E8F0);
  border-left: 1px solid var(--nl-border, #E2E8F0) !important;
  background: var(--nl-surface, #F8FAFC);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  overflow: hidden; min-width: 0;
}
.nl-widget[data-conversation="true"] .nl-entry[data-author-pos="1"] {
  align-self: flex-end;
  margin-left: auto;
  border-radius: 14px 14px 8px 14px;
}
.nl-widget[data-conversation="true"] .nl-entry[data-author-pos="0"] {
  align-self: flex-start;
  margin-right: auto;
  border-radius: 14px 14px 14px 8px;
}
.nl-widget[data-conversation="true"] .nl-entry[data-author-pos="1"] .nl-entry-header {
  flex-direction: row-reverse;
}
.nl-widget[data-conversation="true"] .nl-entry[data-author-pos="1"] .nl-time {
  margin-left: 0; margin-right: auto;
}
.nl-widget[data-conversation="true"] .nl-entry-header { margin-bottom: 8px; }
.nl-widget[data-conversation="true"] .nl-avatar { width: 30px; height: 30px; }
.nl-widget[data-conversation="true"] .nl-author { font-size: 0.82rem; }
.nl-widget[data-conversation="true"] .twitter-tweet,
.nl-widget[data-conversation="true"] .twitter-tweet iframe {
  max-width: 100% !important;
  width: 100% !important;
}

/* Embeds */
.nl-embed { margin-top: 10px; }
.nl-embed-youtube iframe { width: 100%; aspect-ratio: 16/9; border-radius: 6px; border: none; }
.nl-embed-link { border: 1px solid var(--nl-border, #E2E8F0); border-radius: 8px; overflow: hidden; }
.nl-embed-link img { width: 100%; max-height: 180px; object-fit: cover; display: block; }
.nl-embed-link-body { padding: 10px 12px; }
.nl-embed-link-body strong { display: block; font-size: 0.875rem; color: var(--nl-text, #1E293B); margin-bottom: 4px; }
.nl-embed-link-body p { font-size: 0.8rem; color: var(--nl-text2, #64748B); margin-bottom: 6px; }
.nl-embed-link-body a { font-size: 0.75rem; color: var(--nl-primary, #2563EB); }

/* Load more */
.nl-load-more {
  display: block; width: 100%; margin-top: 12px; padding: 10px 16px;
  border-radius: 8px; border: 1px solid var(--nl-border, #E2E8F0);
  background: var(--nl-surface, #F8FAFC); color: var(--nl-text2, #64748B);
  font-size: 0.875rem; font-weight: 500; cursor: pointer; font-family: inherit;
  transition: all 0.15s;
}
.nl-load-more:hover { border-color: var(--nl-primary, #2563EB); color: var(--nl-primary, #2563EB); }
.nl-load-more:disabled { opacity: 0.5; cursor: wait; }

/* Footer */
.nl-footer { text-align: center; padding: 16px 0 8px; }
.nl-powered { font-size: 0.7rem; color: var(--nl-text2, #64748B); opacity: 0.6; }
.nl-powered:hover { opacity: 1; }

/* Notifications toggle */
.nl-notify-btn {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.73rem; padding: 3px 8px; border-radius: 5px;
  background: var(--nl-surface, #F8FAFC); border: 1px solid var(--nl-border, #E2E8F0);
  color: var(--nl-text2, #64748B); cursor: pointer; transition: all 0.15s;
}
.nl-notify-btn:hover { border-color: var(--nl-primary, #2563EB); color: var(--nl-primary, #2563EB); }

/* Dark mode */
.nl-widget[data-mode="dark"],
body[data-mode="dark"] .nl-widget {
  --nl-bg: #0C0E12;
  --nl-surface: #14171E;
  --nl-text: #E8EAF0;
  --nl-text2: #8B90A0;
  --nl-border: #2A2F3A;
}

/* Responsive */
@media (max-width: 480px) {
  .nl-container { padding: 12px; }
  .nl-title { font-size: 1.1rem; }
  .nl-entry-header { gap: 6px; }
}

/* Share button */
.nl-entry-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
  padding-top: 4px;
}
.nl-widget[data-style="timeline"] .nl-entry-footer {
  margin-top: 8px;
  padding-top: 0;
}
.nl-widget[data-style="timeline"] .nl-entry-body::after {
  content: '';
  display: block;
  border-bottom: 1px solid var(--nl-border, #E2E8F0);
  margin-top: 8px;
}
.nl-widget[data-style="timeline"] .nl-entry:last-child .nl-entry-body::after {
  border-bottom: none;
}
.nl-share-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--nl-text2, #64748B);
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s;
}
.nl-share-btn:hover {
  color: var(--nl-primary, #2563EB);
}

/* Highlight per entry condivisa */
.nl-highlight {
  animation: nl-highlight-pulse 3s ease-out;
}
@keyframes nl-highlight-pulse {
  0%, 15% { box-shadow: 0 0 0 3px var(--nl-primary, #2563EB); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Shared entry separator */
.nl-shared-separator {
  text-align: center;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--nl-text2, #64748B);
  padding: 12px 0 4px;
}

/* Share toast */
.nl-share-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--nl-text, #1E293B);
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 1000;
}
.nl-share-toast.nl-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.nl-share-inline {
  margin-left: 8px;
  font-size: 0.72rem;
  color: var(--nl-text2, #64748B);
  opacity: 0;
  transition: opacity 0.2s;
}
.nl-share-inline.nl-show { opacity: 1; }

/* Animation */
.nl-entry { animation: nl-entry-in 0.25s ease-out; }
@keyframes nl-entry-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
