@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-arabic: 'Cairo', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-muted: #e2e8f0;

  --border: #e2e8f0;
  --border-focus: #94a3b8;
  --border-subtle: #f1f5f9;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --badge-crit-bg: #fef2f2;
  --badge-crit-text: #991b1b;
  --badge-crit-border: #fecaca;

  --badge-high-bg: #fff7ed;
  --badge-high-text: #9a3412;
  --badge-high-border: #fed7aa;

  --badge-med-bg: #fefce8;
  --badge-med-text: #854d0e;
  --badge-med-border: #fef08a;

  --badge-success-bg: #f0fdf4;
  --badge-success-text: #166534;
  --badge-success-border: #bbf7d0;

  --accent-blue: #0284c7;
  --accent-blue-subtle: #e0f2fe;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-modal: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* RTL & BiDi Rules */
html[dir="rtl"] {
  direction: rtl;
}

html[dir="rtl"] body {
  direction: rtl;
  text-align: right;
  font-family: var(--font-arabic);
}

html[dir="ltr"] {
  direction: ltr;
}

html[dir="ltr"] body {
  direction: ltr;
  text-align: left;
  font-family: var(--font-sans);
}

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 24px 64px 24px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-title h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  background: var(--badge-success-bg);
  border: 1px solid var(--badge-success-border);
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 500;
  color: var(--badge-success-text);
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #16a34a;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Minimal Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--text-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: #1e293b;
}

.btn-subscribe {
  background-color: #0284c7;
  color: #ffffff;
  box-shadow: 0 1px 2px 0 rgba(2, 132, 199, 0.2);
}

.btn-subscribe:hover {
  background-color: #0369a1;
}

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

.db-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
}

/* Metric Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s;
}

.stat-card:hover {
  border-color: #cbd5e1;
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.stat-card.critical .stat-value { color: #dc2626; }
.stat-card.high .stat-value { color: #ea580c; }
.stat-card.exploited .stat-value { color: #b91c1c; }

.stat-desc {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
}

/* Channels & Status Strip */
.status-strip {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
}

.channels-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.channels-label {
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.channel-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
}

.channel-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #94a3b8;
}

.channel-dot.enabled {
  background-color: #16a34a;
}

.channel-test-link {
  background: none;
  border: none;
  color: var(--accent-blue);
  font-size: 11px;
  cursor: pointer;
  margin-left: 2px;
  font-weight: 500;
}

.channel-test-link:hover {
  text-decoration: underline;
}

.schedule-note {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Filter Bar */
.filter-bar {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-card);
}

.filter-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.search-box {
  position: relative;
  min-width: 260px;
  flex: 1;
}

.search-input {
  width: 100%;
  padding: 7px 12px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: all 0.15s;
}

.search-input:focus {
  background-color: #ffffff;
  border-color: var(--border-focus);
}

.select-filter {
  padding: 7px 10px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-secondary);
  outline: none;
  cursor: pointer;
}

.select-filter:focus {
  border-color: var(--border-focus);
  background-color: #ffffff;
}

.checkbox-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px 10px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  user-select: none;
}

.checkbox-toggle input[type="checkbox"] {
  accent-color: var(--text-primary);
  cursor: pointer;
}

/* Vulnerabilities Grid */
.vuln-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.vuln-item {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.vuln-item:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-hover);
}

.vuln-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
}

.vuln-identity {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.cve-badge {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background-color 0.15s;
}

.cve-badge:hover {
  background-color: var(--bg-muted);
}

.copy-button {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 2px;
  font-size: 12px;
  font-family: var(--font-mono);
}

.copy-button:hover {
  color: var(--text-primary);
}

/* Minimal Badges */
.badge-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 9999px;
  letter-spacing: 0.02em;
}

.badge-tag.critical {
  background-color: var(--badge-crit-bg);
  color: var(--badge-crit-text);
  border: 1px solid var(--badge-crit-border);
}

.badge-tag.high {
  background-color: var(--badge-high-bg);
  color: var(--badge-high-text);
  border: 1px solid var(--badge-high-border);
}

.badge-tag.medium {
  background-color: var(--badge-med-bg);
  color: var(--badge-med-text);
  border: 1px solid var(--badge-med-border);
}

.badge-tag.exploited {
  background-color: #fff1f2;
  color: #9f1239;
  border: 1px solid #fecdd3;
  font-weight: 600;
}

/* Ecosystem / Language Minimal Tags */
.badge-eco {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-eco:hover {
  background-color: #ffffff;
  border-color: var(--border-focus);
  color: var(--text-primary);
}

.badge-eco.NODEJS { background-color: #f0fdf4; color: #166534; border-color: #bbf7d0; font-weight: 600; }
.badge-eco.PHP { background-color: #f5f3ff; color: #5b21b6; border-color: #ddd6fe; font-weight: 600; }
.badge-eco.PYTHON { background-color: #eff6ff; color: #1e40af; border-color: #bfdbfe; font-weight: 600; }
.badge-eco.JAVA { background-color: #fff7ed; color: #9a3412; border-color: #fed7aa; font-weight: 600; }
.badge-eco.GO { background-color: #ecfeff; color: #155e75; border-color: #a5f3fc; font-weight: 600; }
.badge-eco.RUBY { background-color: #fff1f2; color: #be123c; border-color: #fecdd3; font-weight: 600; }
.badge-eco.DOTNET { background-color: #fdf4ff; color: #86198f; border-color: #f5d0fe; font-weight: 600; }
.badge-eco.RUST { background-color: #fff7ed; color: #c2410c; border-color: #ffedd5; font-weight: 600; }
.badge-eco.INFRASTRUCTURE { background-color: #f8fafc; color: #334155; border-color: #cbd5e1; }
.badge-eco.OTHER { background-color: #f8fafc; color: #64748b; border-color: var(--border); }

.source-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.vuln-date {
  font-size: 12px;
  color: var(--text-light);
  font-family: var(--font-mono);
}

.vuln-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

.vuln-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.vuln-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
}

.vendor-text {
  color: var(--text-muted);
}

.vendor-text b {
  color: var(--text-primary);
  font-weight: 500;
}

.vuln-footer-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-sent {
  font-size: 11px;
  color: var(--badge-success-text);
  font-weight: 500;
}

.status-pending {
  font-size: 11px;
  color: var(--text-light);
}

.detail-btn {
  background: none;
  border: none;
  color: var(--accent-blue);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}

.detail-btn:hover {
  text-decoration: underline;
}

/* Modals */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background-color: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 650px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px 28px;
  box-shadow: var(--shadow-modal);
  position: relative;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.close-btn {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}

.close-btn:hover {
  color: var(--text-primary);
}

/* Toast Alerts */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background-color: #0f172a;
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-modal);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.2s ease-out;
}

.toast.success { background-color: #0f172a; border-left: 3px solid #16a34a; }
.toast.error { background-color: #0f172a; border-left: 3px solid #dc2626; }

@keyframes toastIn {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  background-color: var(--bg-surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  font-size: 13px;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spinning {
  display: inline-block;
  animation: spin 1s linear infinite;
}

@media (max-width: 768px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
  }
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box {
    min-width: 100%;
  }
}

/* Language Switcher */
.lang-switcher {
  display: inline-flex;
  align-items: center;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px 5px;
  box-shadow: var(--shadow-sm);
  gap: 3px;
}

.lang-btn {
  background: none;
  border: none;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  font-family: inherit;
}

.lang-btn:hover {
  color: var(--text-primary);
}

.lang-btn.active {
  background-color: #0f172a;
  color: #ffffff;
  font-weight: 700;
}

.lang-divider {
  color: var(--border);
  font-size: 11px;
}

/* RTL Specific adjustments */
[dir="rtl"] {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  text-align: right;
}

[dir="rtl"] .brand {
  text-align: right;
}

/* ==========================================
   RTL & ARABIC BIDIRECTIONAL (BiDi) RULES
   ========================================== */

html[dir="rtl"] .brand {
  text-align: right;
}

html[dir="rtl"] .stat-card {
  text-align: right;
}

html[dir="rtl"] .search-input {
  text-align: right;
}

html[dir="rtl"] .vuln-item {
  text-align: right;
  direction: rtl;
}

/* BiDi Isolation: Fixes jumbled text when Arabic sentences contain English words */
.vuln-title,
.vuln-desc,
.modal-content {
  unicode-bidi: isolate;
  word-break: break-word;
}

html[dir="rtl"] .vuln-title,
html[dir="rtl"] .vuln-desc {
  direction: rtl;
  text-align: right;
  unicode-bidi: isolate;
}

/* Ensure code, CVE tokens, numbers, and dates stay strictly LTR without flipping */
.cve-badge,
.badge-tag,
.badge-eco,
.source-badge,
.vuln-date,
.copy-button,
.vendor-text b {
  direction: ltr !important;
  display: inline-flex;
  align-items: center;
  unicode-bidi: isolate;
}

html[dir="rtl"] .modal-content {
  text-align: right;
  direction: rtl;
}

html[dir="rtl"] .toast-container {
  right: auto;
  left: 24px;
}

html[dir="rtl"] .toast.success {
  border-left: none;
  border-right: 3px solid #16a34a;
}

html[dir="rtl"] .toast.error {
  border-left: none;
  border-right: 3px solid #dc2626;
}

