/* =====================================================
   RAWABET v2 - Enhanced UI/UX Dark Theme
   ===================================================== */

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

:root {
  --bg: #080b12;
  --bg-secondary: #0d1117;
  --card-bg: #111827;
  --card-hover: #161f2e;
  --border: #1e2a3a;
  --border-light: #2a3a50;
  --text: #e2e8f0;
  --text-muted: #7a8899;
  --text-subtle: #4a5568;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59,130,246,0.15);
  --live-green: #10b981;
  --error-red: #ef4444;
  --demo-orange: #f59e0b;
  --radius: 14px;
  --radius-sm: 8px;
  --radius-pill: 99px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --transition: 0.2s ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --font-arabic: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

[dir="rtl"] body { font-family: var(--font-arabic); }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8,11,18,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  height: 60px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-icon { font-size: 22px; }

.logo-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
  line-height: 1;
}

.logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

.lang-switcher { display: flex; gap: 4px; }

.lang-btn {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.5px;
}

.lang-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.lang-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.status-banner {
  text-align: center;
  padding: 7px 20px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
  border-bottom: 1px solid transparent;
}

.status-live {
  background: rgba(16,185,129,0.08);
  color: var(--live-green);
  border-bottom-color: rgba(16,185,129,0.15);
}

.status-error {
  background: rgba(239,68,68,0.08);
  color: var(--error-red);
  border-bottom-color: rgba(239,68,68,0.15);
}

.status-loading {
  background: rgba(59,130,246,0.08);
  color: var(--accent);
  border-bottom-color: rgba(59,130,246,0.15);
}

.status-demo {
  background: rgba(245,158,11,0.08);
  color: var(--demo-orange);
  border-bottom-color: rgba(245,158,11,0.15);
}

.layout-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 16px;
  display: grid;
  grid-template-columns: 260px 1fr 260px;
  gap: 20px;
  align-items: start;
}

.sidebar-left, .sidebar-right {
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color var(--transition);
}

.sidebar-card:hover { border-color: var(--border-light); }

.sidebar-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.stat-row:last-child { border-bottom: none; }

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.about-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
}

.sources-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sources-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 0;
  transition: color var(--transition);
  cursor: default;
}

.sources-list li:hover { color: var(--text); }

.src-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

.feed-main { min-width: 0; }

.feed-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  align-items: center;
}

.search-wrap { flex: 1; position: relative; }

.search-icon {
  position: absolute;
  top: 50%;
  inset-inline-start: 14px;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 15px;
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px 10px 42px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-input::placeholder { color: var(--text-subtle); }

.refresh-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.refresh-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59,130,246,0.4);
}

.refresh-btn:active { transform: translateY(0); }

.source-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.filter-pill {
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.filter-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.filter-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59,130,246,0.3);
}

.loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 60px;
  flex-direction: column;
  gap: 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.tweet-feed {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.tweet-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  padding: 18px 20px;
  transition: background var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  cursor: default;
  position: relative;
  overflow: hidden;
}

.tweet-card::before {
  content: '';
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  width: 3px;
  height: 100%;
  background: var(--source-color, var(--accent));
  border-radius: 3px 0 0 3px;
  opacity: 0;
  transition: opacity var(--transition);
}

.tweet-card:hover {
  background: var(--card-hover);
  border-color: var(--border-light);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.tweet-card:hover::before { opacity: 1; }

.tweet-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: nowrap;
}

.source-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 11px;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}

.tweet-source {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.tweet-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  line-height: 1.2;
}

.tweet-handle {
  font-size: 11px;
  color: var(--text-subtle);
  line-height: 1.2;
}

.tweet-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  background: var(--bg-secondary);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
}

.tweet-snippet {
  font-size: 15px;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 8px;
}

.tweet-title {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-style: italic;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.read-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  padding: 5px 14px;
  border: 1px solid rgba(59,130,246,0.4);
  border-radius: var(--radius-pill);
  font-weight: 600;
  transition: all var(--transition);
  background: transparent;
}

.read-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59,130,246,0.35);
}

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 56px;
  display: block;
  margin-bottom: 16px;
  opacity: 0.6;
}

.empty-state h3 {
  font-size: 18px;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  color: var(--text-muted);
}

.trending-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.tag {
  background: var(--accent-glow);
  border: 1px solid rgba(59,130,246,0.3);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  cursor: default;
  transition: all var(--transition);
  letter-spacing: 0.3px;
}

.tag:hover {
  background: rgba(59,130,246,0.2);
  border-color: var(--accent);
}

.powered-card .powered-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.powered-card .powered-item:last-child { border-bottom: none; }
.powered-icon { font-size: 15px; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 16px;
  margin-top: 40px;
  background: var(--bg-secondary);
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
  align-items: center;
}

.footer-inner span { color: var(--text-subtle); }

[dir="rtl"] .tweet-card::before {
  border-radius: 0 3px 3px 0;
}

[dir="rtl"] .tweet-title {
  direction: ltr;
  text-align: start;
}

[dir="rtl"] .tweet-time {
  margin-inline-start: auto;
  margin-inline-end: 0;
}

@media (max-width: 1100px) {
  .layout-container {
    grid-template-columns: 240px 1fr;
    padding: 16px;
  }
  .sidebar-right { display: none; }
}

@media (max-width: 768px) {
  .layout-container {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .sidebar-left {
    position: static;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .sources-card { grid-column: 1 / -1; }

  .tweet-card { padding: 14px 16px; }

  .tweet-snippet { font-size: 14px; }

  .source-avatar { width: 28px; height: 28px; font-size: 10px; }
}

@media (max-width: 480px) {
  .sidebar-left { grid-template-columns: 1fr; }

  .header-inner {
    flex-direction: column;
    height: auto;
    padding: 10px 14px;
    gap: 8px;
  }

  .site-header { position: relative; }

  .source-filters { gap: 5px; }
  .filter-pill { font-size: 11px; padding: 4px 10px; }

  .feed-toolbar { flex-wrap: wrap; }
  .refresh-btn { width: 100%; justify-content: center; }
}

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

.tweet-card {
  animation: fadeInUp 0.3s ease both;
}

.tweet-card:nth-child(1)  { animation-delay: 0.02s; }
.tweet-card:nth-child(2)  { animation-delay: 0.04s; }
.tweet-card:nth-child(3)  { animation-delay: 0.06s; }
.tweet-card:nth-child(4)  { animation-delay: 0.08s; }
.tweet-card:nth-child(5)  { animation-delay: 0.10s; }
.tweet-card:nth-child(n+6) { animation-delay: 0.12s; }
