:root {
    --color-primary: #3b82f6;
    --color-secondary: #8b5cf6;
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-bg-dark: #0f172a;
    --color-bg-medium: #1e293b;
    --color-bg-card: rgba(30, 41, 59, 0.6);
    --color-text: #e2e8f0;
    --color-text-muted: #94a3b8;
    --color-border: rgba(59, 130, 246, 0.2);
    --transition: 0.3s ease;
}

/* Darker grays for light theme */
body.light-theme {
    --color-bg-dark: #d9dde1;      
    --color-bg-medium: #e8eaec;    
    --color-bg-card: rgba(243, 244, 246, 0.95); 
    --color-text: #1f2937;
    --color-text-muted: #6b7280;
    --color-border: rgba(107, 114, 128, 0.25);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--color-bg-dark) 0%, var(--color-bg-medium) 100%);
    color: var(--color-text);
    height: 100vh;
    overflow: hidden;
    padding: 20px;
    transition: background var(--transition), color var(--transition);
}

/* Darker body gradient for light theme */
body.light-theme { background: linear-gradient(135deg, #c5c9cf 0%, #d9dde1 100%); }

.container { display: flex; flex-direction: column; height: 100%; background: var(--color-bg-card); border-radius: 16px; overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); backdrop-filter: blur(10px); transition: background var(--transition), box-shadow var(--transition); }
body.light-theme .container { box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15); border: 1px solid rgba(0, 0, 0, 0.1); }

.main-bar { padding: 16px 24px; background: var(--color-bg-dark); border-bottom: 1px solid var(--color-border); display: flex; align-items: center; gap: 16px; flex-wrap: wrap; transition: background var(--transition); }
.logo { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: bold; background: linear-gradient(135deg, var(--color-primary), var(--color-secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-right: 16px; }
.logo svg { width: 32px; height: 32px; fill: var(--color-primary); }
.search-container { position: relative; flex: 1; max-width: 400px; }
.search-input { width: 100%; padding: 10px 16px 10px 40px; background: var(--color-bg-medium); border: 1px solid var(--color-border); border-radius: 10px; color: var(--color-text); font-size: 14px; transition: all var(--transition); }
.search-input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; opacity: 0.5; }
.btn { padding: 10px 20px; background: var(--color-bg-medium); border: 1px solid var(--color-border); border-radius: 10px; color: var(--color-text); cursor: pointer; transition: all var(--transition); font-size: 14px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.btn:hover { background: rgba(59, 130, 246, 0.2); border-color: var(--color-primary); transform: translateY(-2px); }
.btn-success { background: rgba(34, 197, 94, 0.2); border-color: rgba(34, 197, 94, 0.3); color: var(--color-success); }
.btn-success:hover { background: rgba(34, 197, 94, 0.3); }
.btn-icon { width: 42px; height: 42px; padding: 0; justify-content: center; position: relative; }
.filter-badge { position: absolute; top: -6px; right: -6px; background: var(--color-primary); color: white; font-size: 10px; font-weight: bold; padding: 2px 6px; border-radius: 10px; min-width: 18px; text-align: center; box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4); animation: badge-pulse 2s ease-in-out infinite; }
@keyframes badge-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
.filter-dropdown { position: relative; }
.filter-menu, .language-menu { position: absolute; top: calc(100% + 8px); left: 0; background: var(--color-bg-dark); border: 1px solid var(--color-border); border-radius: 12px; padding: 8px; min-width: 200px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4); display: none; z-index: 1000; backdrop-filter: blur(10px); max-height: 400px; overflow-y: auto; }
body.light-theme .filter-menu, body.light-theme .language-menu { box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2); }
.filter-menu.active, .language-menu.active { display: block; }
.filter-option, .language-option { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; cursor: pointer; transition: all var(--transition); user-select: none; }
.filter-option:hover, .language-option:hover { background: rgba(59, 130, 246, 0.1); }
.language-option { justify-content: space-between; }
.language-option.active { background: rgba(59, 130, 246, 0.2); border-left: 3px solid var(--color-primary); }

.language-flag {
    font-size: 24px; /* Default for emojis */
    font-weight: 600;
    width: 30px; 
    text-align: center;
    line-height: 24px; /* Aligned with emojis */
    flex-shrink: 0;
    display: inline-block; /* For line-height */
}
/* Specific style for text flags (EN, AR) */
.language-flag:not(:empty):not(:has(> *)) {
    font-size: 13px; /* Reduced size */
    font-weight: 700;
    line-height: 24px; /* Keep the same line height for alignment */
}

.language-name { flex: 1; font-size: 14px; color: var(--color-text); }
.filter-option input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--color-primary); }
.filter-option span { flex: 1; font-size: 14px; color: var(--color-text); }
.filter-actions { display: flex; gap: 8px; padding: 8px 4px 4px; border-top: 1px solid var(--color-border); margin-top: 8px; }
.filter-action-btn { flex: 1; padding: 8px; background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.3); border-radius: 8px; color: var(--color-primary); cursor: pointer; font-size: 13px; transition: all var(--transition); }
.filter-action-btn:hover { background: rgba(59, 130, 246, 0.2); }
.time-filter-panel { position: absolute; top: calc(100% + 8px); left: 0; background: var(--color-bg-dark); border: 1px solid var(--color-border); border-radius: 12px; padding: 20px; min-width: 350px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4); display: none; z-index: 1000; backdrop-filter: blur(10px); }
body.light-theme .time-filter-panel { box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2); }
.time-filter-panel.active { display: block; }
.time-filter-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; color: var(--color-primary); }
.time-range-group { margin-bottom: 16px; }
.time-range-label { font-size: 13px; color: var(--color-text-muted); margin-bottom: 8px; font-weight: 500; }
.time-fields { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.time-field { display: flex; flex-direction: column; gap: 4px; }
.time-field label { font-size: 11px; color: var(--color-text-muted); }
.time-field input { padding: 8px; background: var(--color-bg-medium); border: 1px solid var(--color-border); border-radius: 6px; color: var(--color-text); font-size: 13px; transition: all var(--transition); }
.time-field input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }
.time-filter-actions { display: flex; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--color-border); }
.time-filter-btn { flex: 1; padding: 10px; border: 1px solid var(--color-border); border-radius: 8px; cursor: pointer; font-size: 14px; transition: all var(--transition); background: var(--color-bg-medium); color: var(--color-text); }
.time-filter-btn.primary { background: rgba(59, 130, 246, 0.2); border-color: var(--color-primary); color: var(--color-primary); }
.time-filter-btn:hover { background: rgba(59, 130, 246, 0.2); border-color: var(--color-primary); }
.period-display { font-size: 12px; color: var(--color-text-muted); margin-top: 12px; padding: 8px; background: rgba(59, 130, 246, 0.1); border-radius: 6px; text-align: center; }
.time-tabs { display: flex; gap: 8px; }
.time-tab { padding: 10px 16px; background: transparent; border: 1px solid transparent; border-radius: 10px; color: var(--color-text-muted); cursor: pointer; transition: all var(--transition); font-size: 14px; }
.time-tab.active { background: rgba(59, 130, 246, 0.15); border-color: var(--color-primary); color: var(--color-primary); }
.theme-toggle { width: 42px; height: 42px; padding: 0; background: var(--color-bg-medium); border: 1px solid var(--color-border); border-radius: 10px; color: var(--color-text); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--transition); }
.theme-toggle:hover { background: rgba(59, 130, 246, 0.2); border-color: var(--color-primary); }
.export-panel { position: absolute; top: calc(100% + 8px); right: 0; background: var(--color-bg-dark); border: 1px solid var(--color-border); border-radius: 12px; padding: 12px; min-width: 280px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4); display: none; z-index: 1000; backdrop-filter: blur(10px); }
body.light-theme .export-panel { box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2); }
.export-panel.active { display: block; }
.export-option { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; cursor: pointer; transition: all var(--transition); margin-bottom: 8px; border: 2px solid transparent; }
.export-option:last-child { margin-bottom: 0; }
.export-option:hover { transform: translateX(5px); border-color: currentColor; }
.export-option.pdf { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.export-option.pdf:hover { background: rgba(239, 68, 68, 0.25); }
.export-option.csv { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.export-option.csv:hover { background: rgba(34, 197, 94, 0.25); }
.export-option.jpg { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
.export-option.jpg:hover { background: rgba(139, 92, 246, 0.25); }
.export-icon { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; border-radius: 10px; font-size: 24px; font-weight: bold; flex-shrink: 0; }
.export-option.pdf .export-icon { background: rgba(239, 68, 68, 0.2); }
.export-option.csv .export-icon { background: rgba(34, 197, 94, 0.2); }
.export-option.jpg .export-icon { background: rgba(139, 92, 246, 0.2); }
.export-details { flex: 1; }
.export-title { font-size: 15px; font-weight: 700; margin-bottom: 2px; }
.export-desc { font-size: 12px; opacity: 0.8; }
.canvas-section { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }
.zoom-controls { position: absolute; top: 16px; right: 16px; display: flex; gap: 8px; z-index: 10; }
.zoom-btn { width: 42px; height: 42px; background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: 10px; color: var(--color-primary); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--transition); font-size: 20px; font-weight: bold; backdrop-filter: blur(10px); }
.zoom-btn:hover { background: rgba(59, 130, 246, 0.2); transform: scale(1.05); }
.credibility-ring-floating { position: absolute; bottom: 24px; right: 24px; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; background: var(--color-bg-card); border: 2px solid var(--color-border); border-radius: 16px; padding: 16px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4); backdrop-filter: blur(10px); transition: all var(--transition); }
body.light-theme .credibility-ring-floating { box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2); }
.credibility-ring-floating:hover { transform: translateY(-5px); box-shadow: 0 15px 50px rgba(59, 130, 246, 0.4); border-color: var(--color-primary); }
.verdict-text { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.credibility-ring { width: 70px; height: 70px; position: relative; flex-shrink: 0; }
.credibility-ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
#credCircleBg { stroke: var(--color-border); stroke-width: 6; fill: none; }
#credCircle { transition: stroke-dashoffset 0.5s ease; }
.credibility-ring .score-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 18px; transition: color 0.5s ease; }
.verdict-credible { color: var(--color-success); }
.verdict-mitige { color: var(--color-warning); }
.verdict-suspect { color: var(--color-danger); }
.canvas-container { flex: 1; overflow: auto; cursor: grab; position: relative; user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; }
.canvas-container:active { cursor: grabbing; }
.timeline-wrapper { display: inline-flex; gap: 32px; transform-origin: 0 0; padding: 32px; position: absolute; top: 0; left: 0; min-width: 100%; min-height: 100%; cursor: grab; align-items: flex-start; }
.timeline-wrapper:active { cursor: grabbing; }
.timeline-group { display: flex; flex-direction: column; gap: 24px; min-width: 380px; max-width: 420px; }
.timeline-header { text-align: center; padding: 12px; background: rgba(59, 130, 246, 0.15); border: 1px solid var(--color-primary); border-radius: 10px; color: var(--color-primary); font-weight: 600; cursor: grab; font-size: 14px; }
.timeline-header:active { cursor: grabbing; }
.timeline-connector { display: flex; align-items: center; justify-content: center; width: 80px; position: relative; cursor: grab; padding-top: 48px; align-self: flex-start; height: 100px; }
.timeline-connector:active { cursor: grabbing; }
.timeline-arrow-container { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: relative; }
.timeline-line { position: absolute; width: 2px; height: 2px; top: 50%; left: 0; right: 0; transform: translateY(-50%); background: linear-gradient(90deg, rgba(59, 130, 246, 0.6), rgba(139, 92, 246, 0.4), rgba(59, 130, 246, 0.6)); }
.timeline-arrow { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--color-primary), var(--color-secondary)); border-radius: 50%; box-shadow: 0 2px 10px rgba(59, 130, 246, 0.4); z-index: 1; }
.timeline-arrow svg { width: 16px; height: 16px; fill: white; }
.card { background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: 16px; overflow: hidden; transition: all var(--transition); cursor: grab; backdrop-filter: blur(10px); position: relative; }
.card:active { cursor: grabbing; }
.card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: radial-gradient( circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(59, 130, 246, 0.15) 0%, transparent 60% ); opacity: 0; transition: opacity 0.3s ease; pointer-events: none; z-index: 1; }
.card:hover::before { opacity: 1; }
.card:hover { transform: translateY(-5px); box-shadow: 0 10px 30px rgba(59, 130, 246, 0.3); border-color: var(--color-primary); }
body.light-theme .card:hover { box-shadow: 0 10px 30px rgba(59, 130, 246, 0.2); }
.card-date { font-size: 11px; color: var(--color-text-muted); padding: 6px 16px; text-align: right; opacity: 0.8; border-bottom: 1px dashed var(--color-border); margin-bottom: -1px; }
.card-header { display: flex; align-items: center; gap: 8px; padding: 12px 16px; background: var(--color-bg-dark); border-bottom: 1px solid var(--color-border); position: relative; z-index: 2; }
.media-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.media-icon svg { width: 20px; height: 20px; }
.media-icon.news { background: rgba(59, 130, 246, 0.2); color: var(--color-primary); }
.media-icon.social { background: rgba(139, 92, 246, 0.2); color: var(--color-secondary); }
.media-icon.video { background: rgba(239, 68, 68, 0.2); color: var(--color-danger); }
.media-icon.image { background: rgba(168, 85, 247, 0.2); color: #a855f7; }
.media-icon.agency { background: rgba(34, 197, 94, 0.2); color: var(--color-success); }
.media-icon.think { background: rgba(245, 158, 11, 0.2); color: var(--color-warning); }
.source-logo, .source-logo-placeholder { width: 24px; height: 24px; border-radius: 4px; flex-shrink: 0; background-color: rgba(128, 128, 128, 0.1); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.source-logo { object-fit: contain; }
.source-name { flex: 1; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-right: 8px; }
.external-link { width: 32px; height: 32px; border-radius: 8px; background: rgba(34, 197, 94, 0.2); color: var(--color-success); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all var(--transition); pointer-events: auto; flex-shrink: 0; }
.external-link:hover { background: rgba(34, 197, 94, 0.3); transform: scale(1.1); }
.card-content { padding: 20px; color: var(--color-text-muted); line-height: 1.6; font-size: 14px; position: relative; z-index: 2; }
.stats-bar { padding: 16px 24px; background: var(--color-bg-dark); border-top: 1px solid var(--color-border); display: flex; align-items: center; transition: background var(--transition); }
.stats-text { flex: 1; font-size: 14px; color: var(--color-text-muted); font-weight: 500; }
.subject-highlight { color: var(--color-primary); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.history-panel { position: fixed; top: 0; right: -400px; width: 400px; height: 100vh; background: var(--color-bg-dark); border-left: 1px solid var(--color-border); box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5); transition: right 0.3s ease; z-index: 2000; overflow-y: auto; backdrop-filter: blur(10px); }
body.light-theme .history-panel { box-shadow: -10px 0 40px rgba(0, 0, 0, 0.2); }
.history-panel.active { right: 0; }
.history-header { padding: 24px; background: linear-gradient(135deg, var(--color-primary), var(--color-secondary)); color: white; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; }
.history-title { font-size: 20px; font-weight: 700; }
.history-close { width: 36px; height: 36px; background: rgba(255, 255, 255, 0.2); border: none; border-radius: 8px; color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--transition); }
.history-close:hover { background: rgba(255, 255, 255, 0.3); transform: scale(1.1); }
.history-content { padding: 24px; }
.history-item { padding: 16px; background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: 12px; margin-bottom: 16px; cursor: pointer; transition: all var(--transition); }
.history-item:hover { border-color: var(--color-primary); transform: translateX(-5px); box-shadow: 0 5px 20px rgba(59, 130, 246, 0.3); }
.history-item-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.history-item-date { font-size: 13px; color: var(--color-text-muted); }
.history-item-score { font-size: 16px; font-weight: 700; }
.history-item-details { font-size: 12px; color: var(--color-text-muted); line-height: 1.6; }
.history-item-subject { color: var(--color-primary); font-weight: 600; margin-bottom: 4px; }
.history-empty { text-align: center; padding: 40px 20px; color: var(--color-text-muted); }
.history-empty svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: 0.5; }
.canvas-container::-webkit-scrollbar { width: 10px; height: 10px; }
.canvas-container::-webkit-scrollbar-track { background: var(--color-bg-medium); border-radius: 10px; }
.canvas-container::-webkit-scrollbar-thumb { background: rgba(59, 130, 246, 0.5); border-radius: 10px; }
.canvas-container::-webkit-scrollbar-thumb:hover { background: rgba(59, 130, 246, 0.7); }
.icon { width: 20px; height: 20px; }
.card.error-card .card-content { color: var(--color-danger); font-style: italic; }