/* ============================================================================
   دواة - إصلاحات التصميم الشاملة
   ============================================================================ */

/* --- الاتجاه العام RTL --- */
html {
  direction: rtl;
}

body {
  font-family: 'Noto Sans Arabic', 'Tajawal', 'Cairo', 'Segoe UI', Tahoma, sans-serif !important;
  direction: rtl;
  text-align: right;
}

/* --- إصلاح القوائم المنسدلة --- */
[data-radix-popper-content-wrapper],
[role="menu"],
[role="listbox"],
.dropdown-menu,
div[class*="dropdown"],
div[class*="popover"],
div[class*="select-content"],
div[class*="MenuContent"],
div[class*="DropdownMenu"],
div[class*="SelectContent"],
div[class*="PopoverContent"],
div[data-state="open"][role="menu"],
div[data-state="open"][role="listbox"] {
  max-width: calc(100vw - 20px) !important;
  max-height: 60vh !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  z-index: 9999 !important;
}

/* --- إصلاح القائمة المنسدلة للفصول --- */
.dawat-chapter-dropdown {
  z-index: 999999 !important;
  position: fixed !important;
}

/* --- إصلاح اتجاه أسماء الفصول RTL --- */
a[href*="/read/"] {
  direction: rtl !important;
  text-align: right !important;
}

[data-radix-popper-content-wrapper] {
  transform-origin: top right !important;
}

[data-side="bottom"] {
  max-height: calc(100vh - var(--radix-popper-anchor-height, 0px) - 20px) !important;
}

[data-side="top"] {
  max-height: calc(var(--radix-popper-anchor-height, 100vh) - 20px) !important;
}

@media (max-width: 768px) {
  [data-radix-popper-content-wrapper],
  [role="menu"],
  [role="listbox"],
  div[class*="dropdown"],
  div[class*="popover"],
  div[class*="select-content"] {
    max-width: calc(100vw - 16px) !important;
    left: 8px !important;
    right: 8px !important;
    width: calc(100vw - 16px) !important;
    position: fixed !important;
  }
}

/* --- تحسين واجهة الجوال --- */
@media (max-width: 640px) {
  header, nav {
    padding: 0.5rem !important;
  }
  .grid {
    gap: 0.5rem !important;
  }
  h1 { font-size: 1.5rem !important; }
  h2 { font-size: 1.25rem !important; }
  h3 { font-size: 1.1rem !important; }
}

/* --- تحسين عرض الفصول --- */
.chapter-content,
.reading-content,
article[class*="chapter"],
div[class*="chapter-content"],
div[class*="reader"] {
  font-family: 'Noto Sans Arabic', 'Tajawal', 'Cairo', serif !important;
  line-height: 2 !important;
  font-size: 1.1rem !important;
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* --- تحسين اتجاه النص حسب اللغة --- */
[dir="ltr"], .ltr {
  direction: ltr !important;
  text-align: left !important;
}

[dir="rtl"], .rtl {
  direction: rtl !important;
  text-align: right !important;
}

.text-center {
  text-align: center !important;
}

/* --- تحسين الشعار --- */
.logo-img, img[alt*="logo"], img[alt*="Logo"], img[alt*="دواة"], img[alt*="Dawat"] {
  max-height: 48px;
  width: auto;
  object-fit: contain;
}

/* --- تحسين صور البروفايل --- */
img[class*="avatar"], img[class*="profile"] {
  object-fit: cover;
  border-radius: 50%;
}

/* --- تحسين الفوتر --- */
footer {
  direction: rtl;
  text-align: right;
}

footer a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s;
}

footer a:hover {
  color: #a78bfa;
}

/* --- إصلاح شريط التمرير --- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #1a1a2e;
}

::-webkit-scrollbar-thumb {
  background: #4a4a6a;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #6a6a8a;
}

/* --- تحسين البطاقات والأعمال --- */
.work-card, div[class*="card"] {
  overflow: hidden;
  border-radius: 0.75rem;
}

/* --- إصلاح النصوص العربية --- */
input, textarea, select, button {
  font-family: 'Noto Sans Arabic', 'Tajawal', 'Cairo', sans-serif !important;
}

input::placeholder, textarea::placeholder {
  font-family: 'Noto Sans Arabic', 'Tajawal', 'Cairo', sans-serif !important;
  text-align: right;
}

/* --- علامة المشترك --- */
.subscriber-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: linear-gradient(135deg, #FFD700, #FFA500);
  color: #000;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: bold;
  margin-right: 4px;
}

/* --- تحسين التقييم --- */
.rating-stars {
  direction: ltr;
}

/* --- تحسين عرض PDF --- */
.pdf-viewer, .dawat-pdf-viewer iframe {
  width: 100%;
  height: 80vh;
  border: none;
}

/* --- تحسين الإشعارات --- */
.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- تحسين الأيقونات --- */
svg {
  display: inline-block;
  vertical-align: middle;
}

/* --- إصلاح z-index للقوائم --- */
[class*="Dialog"], [class*="dialog"], [class*="Modal"], [class*="modal"] {
  z-index: 10000 !important;
}

[class*="Overlay"], [class*="overlay"] {
  z-index: 9999 !important;
}

/* ============================================================================
   FIX: Mobile Slider Buttons - تصغير أزرار السلايدر على الجوال
   Target: Tailwind classes used by the slider navigation arrows
   ============================================================================ */

/* Slider arrow buttons (left/right) - make smaller and semi-transparent */
button[class*="absolute"][class*="top-1/2"][class*="translate-y"] {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  min-height: 28px !important;
  opacity: 0.4 !important;
  background: rgba(0,0,0,0.4) !important;
  border: none !important;
  border-radius: 50% !important;
  padding: 2px !important;
}

button[class*="absolute"][class*="top-1/2"][class*="translate-y"] svg {
  width: 14px !important;
  height: 14px !important;
}

/* Slider dot buttons - make much smaller */
button[class*="rounded-full"][class*="w-2"][class*="h-2"] {
  width: 8px !important;
  height: 8px !important;
  min-width: 8px !important;
  min-height: 8px !important;
  padding: 0 !important;
  margin: 0 2px !important;
}

/* Active dot */
button[class*="rounded-full"][class*="bg-primary"] {
  width: 16px !important;
  height: 8px !important;
  min-width: 16px !important;
  min-height: 8px !important;
}

@media (max-width: 768px) {
  /* Hide slider arrows on mobile completely */
  button[class*="absolute"][class*="top-1/2"][class*="translate-y"] {
    display: none !important;
  }
  
  /* Make dots even smaller on mobile */
  button[class*="rounded-full"][class*="w-2"] {
    width: 6px !important;
    height: 6px !important;
    min-width: 6px !important;
    min-height: 6px !important;
  }
  
  button[class*="rounded-full"][class*="bg-primary"] {
    width: 12px !important;
    height: 6px !important;
    min-width: 12px !important;
    min-height: 6px !important;
  }
  
  /* Generic slider/carousel button fallback */
  button[class*="swiper"],
  button[class*="slider"],
  button[class*="Slider"],
  button[class*="carousel"],
  button[class*="Carousel"],
  .swiper-button-next,
  .swiper-button-prev {
    display: none !important;
  }
}

/* ============================================================================
   FIX: Rating Section Minimization - تصغير قسم التقييم لأصغر حجم ممكن
   ============================================================================ */

/* Compact rating number buttons - target by title attribute */
button[title*="قيّم"] {
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  min-height: 20px !important;
  font-size: 0.55rem !important;
  padding: 0 !important;
  margin: 1px !important;
  line-height: 20px !important;
  border-radius: 3px !important;
}

/* ============================================================================
   FIX: Remove Placeholder/Random Images
   ============================================================================ */

img[src*="unsplash.com"],
img[src*="picsum.photos"],
img[src*="placeholder.com"],
img[src*="via.placeholder"],
img[src*="randomuser.me"],
img[src*="pravatar.cc"],
img[src*="lorempixel"],
img[src*="placehold.it"],
img[src*="dummyimage.com"] {
  visibility: hidden !important;
  background: #2a2a4a !important;
}

/* Fix broken images */
img:not([src]),
img[src=""],
img[src="undefined"],
img[src="null"] {
  background: #2a2a4a !important;
  min-height: 20px;
}

/* ============================================================================
   FIX: Author Image Removal - إخفاء صورة المؤلف
   ============================================================================ */

[class*="author-image"],
[class*="authorImage"],
[class*="author_image"],
label[for*="author_image"],
label[for*="authorImage"] {
  display: none !important;
}
