/* ===== متغيرات الألوان الذكية (للنهاري والليلي) ===== */
:root {
  --bg-primary: #f2f3f7;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --border-color: rgba(0,0,0,0.04);
  --shadow-color: rgba(0,0,0,0.06);
  --header-bg: #0d0d0d;
  --nav-bg: rgba(255,255,255,0.92);
  --sidebar-bg: #ffffff;
  --chip-bg: #f3f4f6;
  --chip-text: #6b7280;
  --green-bg: #f0fdf4;
  --red-bg: #fef2f2;
  --yellow-bg: #fefce8;
  --blue-bg: #eff6ff;
  --skeleton-1: #e8eaf0;
  --skeleton-2: #f4f5f9;
}

body.dark-mode {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --border-color: #334155;
  --shadow-color: rgba(0, 0, 0, 0.4);
  --header-bg: #0b0f19;
  --nav-bg: rgba(30, 41, 59, 0.92);
  --sidebar-bg: #1e293b;
  --chip-bg: #334155;
  --chip-text: #cbd5e1;
  --green-bg: rgba(22, 163, 74, 0.15);
  --red-bg: rgba(239, 68, 68, 0.15);
  --yellow-bg: rgba(234, 179, 8, 0.15);
  --blue-bg: rgba(59, 130, 246, 0.15);
  --skeleton-1: #1e293b;
  --skeleton-2: #334155;
}

* { box-sizing: border-box; scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }

body {
  font-family: 'Cairo', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overscroll-behavior-y: contain;
  padding-bottom: 88px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

@keyframes fadeUp   { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }
@keyframes slideDown{ from{opacity:0;transform:translateY(-8px)} to{opacity:1;transform:translateY(0)} }
@keyframes iconPop  { 0%{transform:scale(1)} 50%{transform:scale(1.25)} 100%{transform:scale(1.12)} }
@keyframes glowPulse { 0%{box-shadow:0 0 8px var(--glow-color, #16a34a)} 50%{box-shadow:0 0 20px var(--glow-color, #16a34a),0 0 30px var(--glow-color, #16a34a)} 100%{box-shadow:0 0 12px var(--glow-color, #16a34a)} }
@keyframes spin     { to{transform:rotate(360deg)} }
@keyframes shimmer  { 0%{background-position:-200% 0} 100%{background-position:200% 0} }
@keyframes outer-sun-glow {
    0% { box-shadow: 0 0 5px currentColor, 0 0 10px rgba(0,0,0,0.2); }
    50% { box-shadow: 0 0 15px currentColor, 0 0 25px rgba(0,0,0,0.3); }
    100% { box-shadow: 0 0 5px currentColor, 0 0 10px rgba(0,0,0,0.2); }
}

.fade-up    { animation: fadeUp 0.32s cubic-bezier(.22,.68,0,1.2) both }
.slide-down { animation: slideDown 0.22s ease both }
.spinner    { animation: spin 0.75s linear infinite }

.skeleton {
  background: linear-gradient(90deg, var(--skeleton-1) 25%, var(--skeleton-2) 50%, var(--skeleton-1) 75%);
  background-size: 200% 100%; animation: shimmer 1.5s ease-in-out infinite;
}

.card { transition: transform .12s cubic-bezier(.22,.68,0,1.2), box-shadow .12s ease; }
.card:active, .card-active:active { transform: scale(0.96); box-shadow: 0 1px 4px var(--shadow-color) !important; }

#app-header { background: var(--header-bg); color: #fff; position: sticky; top: 0; z-index: 50; box-shadow: 0 2px 16px rgba(0,0,0,.25); }

#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: var(--nav-bg); backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color); box-shadow: 0 -8px 30px var(--shadow-color);
}
.nav-btn { flex:1; display:flex; flex-direction:column; align-items:center; padding:6px 0 4px; cursor:pointer; transition:color .15s; color:var(--text-secondary); font-size:11px; font-weight:600; border:none; background:transparent; }
.nav-btn.active { color:#16a34a; }
.nav-pill { display:flex; align-items:center; justify-content:center; border-radius:16px; margin-bottom:2px; transition:all .2s; padding:6px 12px; }
.nav-btn.active .nav-pill { transition:all .25s ease; }
.nav-icon { width:20px; height:20px; transition:transform .2s; color: var(--text-secondary); }
.nav-btn.active .nav-icon { transform:scale(1.12); color: #16a34a;}

.hacked-badge {
  position:absolute; bottom:-8px; left:50%; transform:translateX(-50%);
  background:#ef4444; color:#fff; font-size:9px; font-weight:700;
  padding:2px 6px; border-radius:999px; white-space:nowrap;
  border:1.5px solid var(--bg-card); box-shadow:0 1px 4px var(--shadow-color);
  display:flex; align-items:center; gap:2px;
}

#view-detail {
  position: fixed; inset: 0; z-index: 100; 
  background: var(--bg-primary); overflow-y: auto; display: none;
}

#section-title {
    font-size: 13px; font-weight: 800;
    background: var(--bg-secondary); 
    padding: 4px 15px; border-radius: 10px; display: inline-block;
    position: relative; z-index: 1; text-shadow: none !important;
    transition: all 0.2s ease;
    overflow: visible; 
    animation: outer-sun-glow 2s infinite ease-in-out;
}

#view-detail.active { display: block; animation: cardSlideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }

@keyframes fadeOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-10px); } }
@keyframes bannerShine {
  0% { top: -100%; left: -100%; }
  100% { top: 100%; left: 100%; }
}
.fade-out { animation: fadeOut 0.3s ease-in-out forwards; }

/* 3D Update Button */
.btn-3d {
  background: linear-gradient(180deg, #22c55e 0%, #16a34a 50%, #15803d 100%);
  color: white;
  font-size: 16px;
  font-weight: 700;
  padding: 10px 22px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 0 #14532d, 0 6px 12px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.3);
  text-shadow: 0 -1px 0 rgba(0,0,0,0.2);
  transform: translateY(0);
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
}
.btn-3d:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 #14532d, 0 2px 4px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.2);
}

#sidebar-overlay {
  position:fixed; inset:0; z-index:200; background:rgba(0,0,0,.6);
  opacity:0; pointer-events:none; transition:opacity .25s ease;
}
#sidebar-overlay.open { opacity:1; pointer-events:auto; }

#sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 280px; max-width: 80vw;
  z-index: 201; background: var(--sidebar-bg); transform: translateX(-100%); 
  transition: transform .28s cubic-bezier(.22,.68,0,1.2);
  overflow-y: auto; box-shadow: 4px 0 24px var(--shadow-color); 
}
#sidebar.open { transform:translateX(0); }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 15px; justify-items: center; }
.cards-grid-3 { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; }
.cards-list { display:flex; flex-direction:column; gap:10px; }

#version-popup-overlay {
  position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.2s ease;
}
#version-popup-overlay.open { display: flex; opacity: 1; }
#version-popup {
  background: var(--bg-card); width: 280px; border-radius: 24px; padding: 24px;
  text-align: center; transform: scale(0.9); transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 20px 40px var(--shadow-color);
}
#version-popup-overlay.open #version-popup { transform: scale(1); }

.custom-dropdown { position: relative; width: 100%; }
.dropdown-trigger {
  width: 100%; padding: 12px; border-radius: 14px; border: 1.5px solid var(--border-color);
  background: var(--bg-secondary); display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; font-family: 'Cairo', sans-serif; font-size: 13px; color: var(--text-primary);
  transition: all 0.2s;
}
.dropdown-menu {
  position: absolute; top: calc(100% + 5px); left: 0; right: 0;
  background: var(--bg-card); border-radius: 14px; box-shadow: 0 10px 25px var(--shadow-color);
  border: 1px solid var(--border-color); z-index: 10; display: none; overflow: hidden;
}
.dropdown-menu.open { display: block; animation: slideDown 0.2s ease; }
.dropdown-item {
  padding: 10px 12px; display: flex; align-items: center; gap: 10px;
  cursor: pointer; font-size: 13px; color: var(--text-primary); transition: background 0.2s;
}
.dropdown-item:hover { background: var(--chip-bg); color: #16a34a; }
.dropdown-item svg { width: 18px; height: 18px; stroke: var(--text-secondary); }
.dropdown-item:hover svg { stroke: #16a34a; }

.tab-fade-in { animation: fadeUp 0.3s ease-in-out; }

@keyframes cardSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes iconPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1.15); }
}
.nav-btn.active .nav-icon { animation: iconPop 0.3s ease-out forwards; }

.theme-toggle-container {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; background: var(--bg-secondary); border-radius: 14px;
  border: 1px solid var(--border-color); margin-bottom: 10px;
}
.theme-toggle-label {
  display: flex; align-items: center; gap: 10px; font-family: 'Cairo', sans-serif;
  font-size: 12px; font-weight: 700; color: var(--text-primary);
}
.theme-toggle-icon { font-size: 16px; }
.theme-toggle-switch { position: relative; width: 52px; height: 28px; cursor: pointer; }
.theme-toggle-switch input { opacity: 0; width: 0; height: 0; }
.theme-toggle-slider {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: #d1d5db; border-radius: 28px; transition: all 0.3s ease;
}
.theme-toggle-slider::before {
  content: ''; position: absolute; width: 22px; height: 22px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%; transition: all 0.3s ease; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.theme-toggle-switch input:checked + .theme-toggle-slider { background: #16a34a; }
.theme-toggle-switch input:checked + .theme-toggle-slider::before { transform: translateX(24px); }

body.dark-mode .theme-toggle-slider { background: #4b5563; }
body.dark-mode .theme-toggle-switch input:checked + .theme-toggle-slider { background: #16a34a; }