/* ============================================================
   WikiLive Enhancements: Trending Topics, Live Edit Feed, Citation Generator
   ============================================================ */

/* ── Shared utils ── */
@keyframes wle-fadeIn   { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }
@keyframes wle-slideUp  { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:none; } }
@keyframes wle-pulse    { 0%,100% { opacity:1; } 50% { opacity:0.35; } }
@keyframes wle-spin     { to { transform:rotate(360deg); } }

/* ══════════════════════════════════════════
   1. TRENDING TOPICS
   ══════════════════════════════════════════ */
#wle-trending-panel {
    padding: 10px 16px 14px;
    animation: wle-fadeIn 0.4s ease;
    background: transparent;
}

.wle-trending-header {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 10px;
    font-size: 0.78em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #888;
}

.wle-fire { font-size: 1.15em; }

.wle-refresh-btn {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1em;
    color: #aaa;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.2s, transform 0.35s;
    line-height: 1;
}
.wle-refresh-btn:hover { color: #555; transform: rotate(180deg); }

.wle-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.wle-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 13px;
    background: #f0f4ff;
    border: 1px solid #dde5ff;
    border-radius: 20px;
    font-size: 0.81em;
    color: #2a3560;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
    font-family: inherit;
}
.wle-chip:hover {
    background: #e0e8ff;
    border-color: #99b4ff;
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(70,100,220,0.14);
}

.wle-rank {
    font-size: 0.72em;
    font-weight: 800;
    color: #99a;
    min-width: 13px;
    text-align: right;
}

.wle-loading { font-size: 0.83em; color: #bbb; padding: 4px 2px; }


/* ══════════════════════════════════════════
   2. LIVE EDIT FEED
   ══════════════════════════════════════════ */
#wle-edit-feed {
    position: fixed;
    bottom: 22px;
    right: 22px;
    width: 340px;
    max-width: calc(100vw - 28px);
    background: #fff;
    border: 1px solid #e0e6f0;
    border-radius: 14px;
    box-shadow: 0 6px 28px rgba(0,0,0,0.13);
    z-index: 1000;
    font-size: 0.82em;
    animation: wle-slideUp 0.3s ease;
    transition: opacity 0.3s;
}
#wle-edit-feed.wle-hidden { display: none; }

.wle-ef-header {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #eef0f5;
    border-radius: 14px 14px 0 0;
    background: #f7f9ff;
    user-select: none;
}
.wle-ef-header:hover { background: #eef2ff; }

.wle-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e04040;
    flex-shrink: 0;
    animation: wle-pulse 1.4s infinite;
}

.wle-ef-title { font-weight: 700; color: #222; font-size: 0.93em; }

.wle-ef-page {
    font-size: 0.78em;
    color: #777;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-left: 2px;
}

.wle-ef-chevron { font-size: 0.72em; color: #bbb; flex-shrink: 0; }

.wle-ef-body {
    max-height: 270px;
    overflow-y: auto;
    padding: 8px;
    transition: max-height 0.25s ease;
}
#wle-edit-feed.wle-ef-collapsed .wle-ef-body { display: none; }

.wle-ef-edit {
    padding: 8px 10px;
    border-radius: 9px;
    margin-bottom: 6px;
    background: #fafbff;
    border-left: 3px solid #4a8edb;
    animation: wle-fadeIn 0.3s ease;
}
.wle-ef-edit:last-child { margin-bottom: 0; }
.wle-ef-edit.wle-ef-bot { border-left-color: #ccc; opacity: 0.72; }

.wle-ef-row {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 3px;
}
.wle-ef-editor { font-weight: 600; color: #222; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wle-ef-diff   { color: #4a8edb; text-decoration: none; font-size: 0.82em; white-space: nowrap; flex-shrink: 0; }
.wle-ef-diff:hover { text-decoration: underline; }
.wle-ef-time   { color: #bbb; font-size: 0.79em; white-space: nowrap; flex-shrink: 0; }
.wle-ef-summary { color: #555; font-size: 0.87em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wle-ef-empty   { color: #bbb; text-align: center; padding: 18px 8px; font-style: italic; }


/* ══════════════════════════════════════════
   3. CITATION GENERATOR — MODAL
   ══════════════════════════════════════════ */
#wle-cite-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10500;
    align-items: center;
    justify-content: center;
}
#wle-cite-modal.wle-visible { display: flex; }

.wle-cite-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.42);
    backdrop-filter: blur(3px);
}

.wle-cite-dialog {
    position: relative;
    background: #fff;
    border-radius: 18px;
    padding: 26px 26px 22px;
    width: min(560px, 95vw);
    box-shadow: 0 10px 48px rgba(0,0,0,0.22);
    animation: wle-fadeIn 0.2s ease;
}

.wle-cite-dh {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.08em;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 14px;
}

.wle-cite-x {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1em;
    color: #aaa;
    padding: 4px 8px;
    border-radius: 8px;
    line-height: 1;
    transition: background 0.18s, color 0.18s;
}
.wle-cite-x:hover { background: #f2f2f2; color: #333; }

.wle-cite-meta {
    font-size: 0.83em;
    color: #666;
    background: #f5f8ff;
    border-left: 3px solid #4a8edb;
    border-radius: 8px;
    padding: 9px 13px;
    margin-bottom: 16px;
}

.wle-cite-tabs {
    display: flex;
    gap: 7px;
    margin-bottom: 13px;
}

.wle-cite-tab {
    padding: 6px 18px;
    border: 1px solid #ddd;
    border-radius: 20px;
    background: #f4f4f4;
    cursor: pointer;
    font-size: 0.86em;
    font-weight: 700;
    color: #666;
    font-family: inherit;
    transition: all 0.18s;
}
.wle-cite-tab.active {
    background: #4a8edb;
    border-color: #4a8edb;
    color: #fff;
}
.wle-cite-tab:hover:not(.active) { background: #e8eeff; border-color: #b0c4f0; color: #334; }

.wle-cite-out {
    background: #f9fafb;
    border: 1px solid #e8e8e8;
    border-radius: 11px;
    padding: 15px;
    font-size: 0.87em;
    line-height: 1.65;
    color: #2a2a3a;
    min-height: 80px;
    margin-bottom: 15px;
    font-family: Georgia, 'Times New Roman', serif;
    cursor: text;
    user-select: all;
    white-space: pre-wrap;
    word-break: break-word;
}

.wle-cite-copy {
    width: 100%;
    padding: 11px;
    background: #4a8edb;
    color: #fff;
    border: none;
    border-radius: 11px;
    font-size: 0.95em;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.18s;
}
.wle-cite-copy:hover { background: #2f72c4; }


/* ── Language comparison modal ── */
#wle-lang-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10500;
    align-items: center;
    justify-content: center;
}
#wle-lang-modal.wle-visible { display: flex; }

.wle-lang-dialog { max-width: min(680px, 96vw) !important; }

.wle-lang-loading { color: #bbb; text-align: center; padding: 20px; font-style: italic; font-size: 0.9em; }

.wle-lang-card {
    border: 1px solid #e8ecf5;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 12px;
    background: #fafbff;
    animation: wle-fadeIn 0.3s ease;
}
.wle-lang-card:last-child { margin-bottom: 0; }

.wle-lang-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 9px;
}
.wle-lang-flag  { font-size: 1.4em; line-height: 1; }
.wle-lang-name  { font-weight: 700; color: #222; font-size: 0.9em; flex: 1; }
.wle-lang-link  { font-size: 0.8em; color: #4a8edb; text-decoration: none; }
.wle-lang-link:hover { text-decoration: underline; }

.wle-lang-body {
    font-size: 0.87em;
    line-height: 1.6;
    color: #333;
    margin-bottom: 10px;
    min-height: 36px;
}

.wle-lang-translate-btn {
    padding: 4px 13px;
    font-size: 0.78em;
    border: 1px solid #c8d8f0;
    border-radius: 14px;
    background: #eef4ff;
    color: #4a8edb;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.18s;
}
.wle-lang-translate-btn:hover:not(:disabled) { background: #4a8edb; color: #fff; border-color: #4a8edb; }
.wle-lang-translate-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* 🌍 Global Perspectives trigger button on edit feed */
#wle-lang-trigger {
    display: block;
    width: 100%;
    padding: 7px 14px;
    background: linear-gradient(90deg, #1a1a3e 0%, #2a2a6e 100%);
    color: #fff;
    border: none;
    border-radius: 14px 14px 0 0;
    font-size: 0.82em;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    letter-spacing: 0.02em;
    transition: opacity 0.2s;
    text-align: left;
}
#wle-lang-trigger:hover { opacity: 0.88; }

/* ── Breaking news banner ── */
#wle-breaking-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 99999;
    background: linear-gradient(90deg, #c0392b, #e74c3c);
    color: #fff;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88em;
    font-weight: 600;
    box-shadow: 0 3px 16px rgba(200,0,0,0.35);
    animation: wle-slideDown 0.3s ease;
}
@keyframes wle-slideDown { from { transform: translateY(-100%); } to { transform: none; } }

.wle-breaking-pulse { font-size: 1.2em; animation: wle-pulse 0.8s infinite; }
.wle-breaking-count { background: rgba(0,0,0,0.2); border-radius: 10px; padding: 2px 9px; font-size: 0.88em; }
.wle-breaking-expand, .wle-breaking-dismiss {
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    border-radius: 8px;
    padding: 3px 10px;
    cursor: pointer;
    font-size: 0.85em;
    font-family: inherit;
    transition: background 0.18s;
    white-space: nowrap;
}
.wle-breaking-dismiss { margin-left: auto; padding: 3px 8px; }
.wle-breaking-expand:hover, .wle-breaking-dismiss:hover { background: rgba(255,255,255,0.3); }

/* ── Vandalism toast ── */
#wle-vandalism-toast {
    position: fixed;
    bottom: 80px;
    right: 22px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-left: 4px solid #f39c12;
    color: #444;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 0.83em;
    font-weight: 600;
    max-width: 320px;
    z-index: 1100;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    animation: wle-fadeIn 0.3s ease;
}

/* ── Pageview surge badge on edit feed ── */
#wle-surge-badge {
    margin-left: auto;
    background: #ff6b35;
    color: #fff;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 0.76em;
    font-weight: 700;
    white-space: nowrap;
    cursor: help;
}

/* ── AI Fact Verifier panel ── */
#wle-fact-panel {
    margin: 8px 0 12px;
    border: 1px solid #e0e8f0;
    border-radius: 14px;
    overflow: hidden;
    animation: wle-fadeIn 0.4s ease;
    background: #fff;
}
#wle-fact-panel.wle-hidden { display: none; }

.wle-fact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: linear-gradient(90deg, #f0f4ff, #e8f0ff);
    font-size: 0.84em;
    font-weight: 700;
    color: #334;
    border-bottom: 1px solid #d8e4f0;
}

.wle-fact-dismiss {
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
    font-size: 0.95em;
    padding: 2px 6px;
    border-radius: 6px;
    transition: background 0.18s;
}
.wle-fact-dismiss:hover { background: #eee; color: #333; }

.wle-fact-loading { color: #bbb; text-align: center; padding: 16px; font-style: italic; font-size: 0.88em; }

.wle-fact-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 16px;
    border-bottom: 1px solid #f0f3f8;
    animation: wle-fadeIn 0.3s ease;
}
.wle-fact-item:last-child { border-bottom: none; }

.wle-fact-item.wle-fact-verified  { background: #f6fff8; }
.wle-fact-item.wle-fact-partial   { background: #fffbf0; }
.wle-fact-item.wle-fact-unknown   { background: #fafafa; }

.wle-fact-icon { font-size: 1.1em; flex-shrink: 0; margin-top: 1px; }

.wle-fact-content { flex: 1; min-width: 0; }
.wle-fact-claim    { font-size: 0.86em; color: #222; line-height: 1.5; margin-bottom: 3px; }
.wle-fact-evidence { font-size: 0.79em; color: #555; font-style: italic; line-height: 1.5; margin-top: 3px; white-space: normal; }

.wle-fact-label {
    font-size: 0.72em;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
    padding: 2px 8px;
    border-radius: 10px;
    margin-top: 2px;
}
.wle-fact-verified .wle-fact-label  { background: #d4edda; color: #155724; }
.wle-fact-partial  .wle-fact-label  { background: #fff3cd; color: #856404; }
.wle-fact-unknown  .wle-fact-label  { background: #f0f0f0; color: #666; }

.wle-fact-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 16px;
    background: #f0f4ff;
    border-bottom: 1px solid #dde6f5;
    font-size: 0.84em;
    gap: 10px;
    flex-wrap: wrap;
}

.wle-fact-source-link {
    font-size: 0.82em;
    color: #4a8edb;
    text-decoration: none;
    white-space: nowrap;
}
.wle-fact-source-link:hover { text-decoration: underline; }

/* ── Cite button on infoboxes ── */
.wle-cite-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 0.74em;
    border: 1px solid #c2d6f0;
    border-radius: 12px;
    background: #eef4ff;
    color: #4a8edb;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.18s;
    margin: 4px 0 6px;
    white-space: nowrap;
}
.wle-cite-btn:hover { background: #4a8edb; color: #fff; border-color: #4a8edb; }
