/* ============================================
   تحسينات التصميم الشاملة - الدليل العربي
   ============================================ */

/* ===== نظام الألوان المحسّن ===== */
:root {
  /* الألوان الأساسية */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #3b82f6;
  --secondary: #1e293b;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  
  /* ألوان إضافية */
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #06b6d4;
  
  /* ظلال محسّنة */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-primary: 0 10px 25px -5px rgba(37, 99, 235, 0.3);
  
  /* انتقالات سلسة */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;
  
  /* حدود محسّنة */
  --radius-sm: 0.5rem;
  --radius-md: 1rem;
  --radius-lg: 1.5rem;
  --radius-xl: 2rem;
}

/* ===== تحسينات البطاقات ===== */
.link-card {
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
  color: #0f172a !important;
  font-weight: 700 !important;
}

.link-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(37, 99, 235, 0.1));
  transition: width var(--transition-base);
  z-index: 0;
}

.link-card:hover::before {
  width: 100%;
}

.link-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-primary);
  border-color: var(--primary);
  color: var(--primary) !important;
  background: #eff6ff !important;
}


/* ===== أيقونات للروابط ===== */
.link-card-icon {
  width: 32px;
  height: 32px;
  margin-bottom: 0.5rem;
  opacity: 0.7;
  transition: all var(--transition-base);
}

.link-card:hover .link-card-icon {
  opacity: 1;
  transform: scale(1.1);
}

/* ===== تحسينات الأقسام ===== */
.section-title {
  position: relative;
  padding-right: 1rem;
  color: #0f172a !important;
  font-weight: 800 !important;
  font-size: 1.4rem !important;
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: -0.5rem;
  right: 0;
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 2px;
  transition: width var(--transition-base);
}

.section-title:hover::after {
  width: 100px;
}

/* ===== تأثيرات الحركة (Animations) ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

.animate-fade-in-up {
  animation: fadeInUp 0.5s ease-out;
}

.animate-fade-in-down {
  animation: fadeInDown 0.5s ease-out;
}

.animate-slide-in-right {
  animation: slideInRight 0.5s ease-out;
}

/* ===== تحسينات البحث ===== */
.search-container {
  position: relative;
  width: 100%;
}

.search-input {
  transition: all var(--transition-base);
  background: white;
  border: 2px solid #e2e8f0;
  font-size: 1rem;
}

.search-input:focus {
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1), 0 4px 12px rgba(37, 99, 235, 0.15);
  border-color: var(--primary);
  background: white;
  outline: none;
}

.search-input::placeholder {
  color: #94a3b8;
  opacity: 0.8;
}

/* تحسينات صندوق البحث */
.search-container::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  border-radius: 1rem;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.05) 0%, rgba(59, 130, 246, 0.05) 100%);
  opacity: 0;
  transition: opacity var(--transition-base);
  pointer-events: none;
  z-index: -1;
}

.search-container:focus-within::before {
  opacity: 1;
}

.search-suggestions,
.search-results {
  position: fixed;
  top: auto;
  right: auto;
  left: auto;
  width: 100%;
  max-width: calc(100vw - 2rem);
  background: white;
  border: 2px solid var(--border);
  border-radius: 1rem;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.2), 0 10px 20px -5px rgba(0, 0, 0, 0.15);
  margin-top: 0.5rem;
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 9999;
  display: none;
  backdrop-filter: blur(10px);
}

/* تحديد موقع النتائج ديناميكياً */
.search-container {
  position: relative;
  width: 100%;
}

.search-results.show {
  display: block;
  animation: fadeInDown 0.3s ease-out;
}

/* Scrollbar محسّن */
.search-results::-webkit-scrollbar {
  width: 8px;
}

.search-results::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.search-results::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.search-results::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.search-results.show {
  display: block;
  animation: fadeInDown 0.3s ease-out;
}

.search-suggestions.show {
  display: block;
  animation: fadeInDown 0.3s ease-out;
}

.suggestion-item,
.result-item {
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
}

.suggestion-item:last-child,
.result-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover,
.result-item:hover {
  background: linear-gradient(90deg, #eff6ff 0%, #f8fafc 100%);
  color: var(--primary);
  transform: translateX(-4px);
  border-right: 3px solid var(--primary);
}

.result-item:active {
  transform: translateX(-2px);
  background: #dbeafe;
}

/* نتائج البحث المحسّنة */
.results-group {
  padding: 0.5rem 0;
}

.results-group-title {
  padding: 0.75rem 1.25rem;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.results-count {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--primary);
  background: rgba(37, 99, 235, 0.1);
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
}

.result-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  color: var(--primary);
  opacity: 0.8;
  transition: all var(--transition-fast);
}

.result-item:hover .result-icon {
  opacity: 1;
  transform: scale(1.1);
}

.result-content {
  flex: 1;
  min-width: 0;
}

.result-title {
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
  line-height: 1.4;
}

.result-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.result-arrow {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
  opacity: 0;
  transition: all var(--transition-fast);
  transform: translateX(4px);
}

.result-item:hover .result-arrow {
  opacity: 1;
  transform: translateX(0);
  color: var(--primary);
}

.result-item.more-results {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  cursor: default;
  padding: 0.75rem;
}

.result-item.more-results:hover {
  background: transparent;
  color: var(--text-muted);
  transform: none;
  border-right: none;
}

.coupon-item .result-title {
  color: #10b981;
  font-weight: 800;
}

.coupon-item .result-subtitle {
  color: #059669;
  font-weight: 600;
}

/* ===== فلتر الأقسام ===== */
.filter-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 2rem;
  padding: 0 0.5rem;
}

/* زر "الكل" يأخذ الصف الكامل على الجوال */
.filter-btn[data-filter="all"] {
  grid-column: 1 / -1;
}

@media (min-width: 640px) {
  .filter-buttons {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .filter-btn[data-filter="all"] {
    grid-column: auto;
  }
}

@media (min-width: 768px) {
  .filter-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    grid-template-columns: none;
  }
  
  .filter-btn[data-filter="all"] {
    grid-column: auto;
  }
}

.filter-btn {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
  text-align: center;
  white-space: nowrap;
  min-width: 0;
}

.filter-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: var(--primary);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
  z-index: -1;
}

.filter-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.filter-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: var(--shadow-primary);
  font-weight: 700;
}

.filter-btn.active::before {
  width: 300px;
  height: 300px;
}

/* تحسينات إضافية للجوال */
@media (max-width: 640px) {
  .filter-buttons {
    margin-bottom: 1.5rem;
  }
  
  .filter-btn {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  }
  
  .filter-btn:active {
    transform: scale(0.98);
  }
}

/* ===== تحسينات Hero Section ===== */
.hero-section {
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.1) 0%, transparent 70%);
  animation: pulse 4s ease-in-out infinite;
  pointer-events: none;
}

/* ===== تحسينات Grid الروابط ===== */
.links-grid {
  animation: fadeInUp 0.6s ease-out;
}

.links-grid li {
  animation: fadeInUp 0.6s ease-out;
  animation-fill-mode: both;
}

.links-grid li:nth-child(1) { animation-delay: 0.05s; }
.links-grid li:nth-child(2) { animation-delay: 0.1s; }
.links-grid li:nth-child(3) { animation-delay: 0.15s; }
.links-grid li:nth-child(4) { animation-delay: 0.2s; }
.links-grid li:nth-child(5) { animation-delay: 0.25s; }
.links-grid li:nth-child(6) { animation-delay: 0.3s; }
.links-grid li:nth-child(7) { animation-delay: 0.35s; }
.links-grid li:nth-child(8) { animation-delay: 0.4s; }

/* ===== تحسينات الأزرار ===== */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn-primary:hover::before {
  width: 300px;
  height: 300px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-primary);
}

/* ===== تحسينات الاستجابة ===== */
@media (max-width: 640px) {
  .filter-buttons {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    padding: 0;
  }
  
  .filter-btn {
    padding: 0.65rem 0.75rem;
    font-size: 0.85rem;
  }
  
  /* زر "الكل" يأخذ الصف الكامل */
  .filter-btn[data-filter="all"] {
    grid-column: 1 / -1;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }
  
  /* تحسينات البحث على الجوال */
  .search-results {
    max-height: 75vh;
    font-size: 0.9rem;
    border-radius: 0.75rem;
    max-width: calc(100vw - 1rem) !important;
  }
  
  .search-results.show {
    left: 0.5rem !important;
    right: 0.5rem !important;
    width: auto !important;
  }
  
  .result-item {
    padding: 0.85rem 1rem;
    gap: 0.75rem;
  }
  
  .result-icon {
    width: 20px;
    height: 20px;
  }
  
  .result-title {
    font-size: 0.9rem;
  }
  
  .result-subtitle {
    font-size: 0.75rem;
  }
  
  .results-group-title {
    padding: 0.65rem 1rem;
    font-size: 0.75rem;
  }
  
  .search-input {
    font-size: 0.95rem;
    padding: 0.75rem 1rem;
  }
}

/* ===== تأثيرات التحميل ===== */
.loading-skeleton {
  background: linear-gradient(
    90deg,
    var(--bg) 0%,
    var(--surface) 50%,
    var(--bg) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

/* ===== تحسينات Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Focus States محسّنة ===== */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ===== تحسينات الطباعة ===== */
@media print {
  .filter-buttons,
  .search-suggestions {
    display: none !important;
  }
  
  .link-card {
    break-inside: avoid;
  }
}
