/* ===== MOBILE HEADER LAYOUT REORGANIZATION ===== 
   For Android phones, iPhones, and iPads
   Creates a single horizontal header row with Language Selector and Logo/Title
   Tools Blog button remains below in its own row
*/

/* TABLET & MOBILE ADJUSTMENTS (768px and below) */
@media (max-width: 768px) {
  .header {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space--between !important;
    gap: 0.5rem !important;
    padding: 0.5rem 0.75rem !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    height: auto !important;
  }

  /* Header Left: Language selector on the left */
  .header-left {
    flex: 0 0 auto !important;
    order: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: auto !important;
    margin: 0 !important;
  }

  /* Header Center: Logo and Title in the middle */
  .header-center {
    flex: 1 1 auto !important;
    order: 2 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    margin: 0 !important;
    min-width: 0 !important;
  }

  .header-center .logo-container {
    display: flex !important;
    align-items: center !important;
    gap: 0.4rem !important;
    justify-content: center !important;
    white-space: nowrap !important;
    min-width: 0 !important;
  }

  .header-center .logo-img {
    width: 32px !important;
    height: 32px !important;
    flex-shrink: 0 !important;
  }

  .header-center .logo-text {
    font-size: 1.1rem !important;
    font-weight: 800 !important;
    background: var(--gradient) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
    margin: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Header Right: Theme toggle on the right */
  .header-right {
    flex: 0 0 auto !important;
    order: 3 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    width: auto !important;
    gap: 0.35rem !important;
    margin: 0 !important;
  }

  /* Hide bookmark button on mobile */
  .header-bookmark-btn {
    display: none !important;
  }



  /* Language dropdown adjustments */
  .language-dropdown {
    margin: 0 !important;
    flex-shrink: 0 !important;
  }

  .language-btn {
    padding: 0.35rem 0.5rem !important;
    font-size: 0.75rem !important;
    min-height: 36px !important;
    height: 36px !important;
    white-space: nowrap !important;
    gap: 0.3rem !important;
  }

  .language-btn .globe-icon {
    width: 14px !important;
    height: 14px !important;
  }

  .language-btn .dropdown-arrow {
    width: 12px !important;
    height: 12px !important;
  }

  /* Tools Blog button: In horizontal row with proper sizing */
  a.tools-blog-btn {
    position: relative !important;
    flex: 0 0 auto !important;
    order: 1 !important;
    width: auto !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0.4rem 0.75rem !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    margin: 0 !important;
    border-radius: 8px !important;
    background: linear-gradient(135deg, rgba(79, 70, 229, .12), rgba(124, 58, 237, .1), rgba(147, 51, 234, .12), rgba(99, 102, 241, .1)) !important;
    background-size: 400% 400% !important;
    animation: gradientFlow 4s ease infinite !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .07), 0 8px 24px rgba(79, 70, 229, .15) !important;
    color: var(--primary) !important;
    z-index: auto !important;
  }

  a.tools-blog-btn:hover {
    transform: translateY(-2px) scale(1.05) !important;
    box-shadow: 0 0 0 4px rgba(107, 114, 128, 0.3), 0 8px 20px rgba(107, 114, 128, 0.2) !important;
    border-color: #4B5563 !important;
    color: #4B5563 !important;
  }

  /* Header layout: Tools Blog between Language and Logo */
  .header-left {
    order: 0 !important;
  }

  .header-center {
    order: 2 !important;
    flex: 1 1 auto !important;
    position: static !important;
    transform: none !important;
  }

  .header-right {
    order: 3 !important;
  }

  /* Adjust downloader section spacing - no longer need extra margin for Tools Blog */
  .downloader-section {
    margin-top: 80px !important;
    padding: 0.75rem 0.5rem !important;
    padding-top: 1rem !important;
    animation-duration: 20s !important; /* Slower for battery life */
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
  }

  .downloader-buttons {
    padding-top: 0.5rem !important;
    gap: 10px !important;
    padding: 0.5rem 0 !important;
  }
}

/* SMALL TABLETS (640px and below) */
@media (max-width: 640px) {
  .header {
    padding: 0.45rem 0.5rem !important;
    gap: 0.4rem !important;
  }

  .header-left {
    flex: 0 0 auto !important;
  }

  .header-center {
    flex: 1 1 auto !important;
    min-width: 100px !important;
  }

  .header-center .logo-text {
    font-size: 1rem !important;
  }

  .header-center .logo-img {
    width: 28px !important;
    height: 28px !important;
  }

  .header-center .logo-container {
    gap: 0.3rem !important;
  }

  .language-btn {
    padding: 0.3rem 0.4rem !important;
    font-size: 0.7rem !important;
    min-height: 32px !important;
    height: 32px !important;
  }



  a.tools-blog-btn {
    order: 1 !important;
    padding: 0.35rem 0.6rem !important;
    font-size: 0.7rem !important;
  }

  .downloader-section {
    margin-top: 75px !important;
    padding: 0.75rem 0.5rem !important;
  }
}

/* MOBILE PHONES (480px and below) */
@media (max-width: 480px) {
  .header {
    padding: 0.35rem 0.4rem !important;
    justify-content: space-between !important;
    gap: 0.25rem !important;
    height: auto !important;
  }

  .header-left {
    flex: 0 0 auto !important;
    min-width: 0 !important;
  }

  .header-center {
    flex: 1 1 auto !important;
    min-width: 80px !important;
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .header-center .logo-text {
    font-size: 0.9rem !important;
  }

  .header-center .logo-img {
    width: 24px !important;
    height: 24px !important;
  }

  .header-center .logo-container {
    gap: 0.25rem !important;
  }

  .language-btn {
    padding: 0.25rem 0.3rem !important;
    font-size: 0.65rem !important;
    min-height: 30px !important;
    height: 30px !important;
    gap: 0.2rem !important;
  }

  .language-btn .globe-icon {
    width: 12px !important;
    height: 12px !important;
  }

  .language-btn .dropdown-arrow {
    display: none !important;
  }

  .header-right {
    gap: 0.2rem !important;
  }



  a.tools-blog-btn {
    order: 1 !important;
    padding: 0.3rem 0.5rem !important;
    font-size: 0.65rem !important;
    font-weight: 600 !important;
  }

  .downloader-section {
    margin-top: 70px !important;
    padding: 0.5rem 0.4rem !important;
  }
}

/* ===== RTL (ARABIC) LANGUAGE SUPPORT ===== 
   Ensures proper display of buttons and dropdown in right-to-left languages
*/

@media (max-width: 768px) {
  /* RTL Header adjustments */
  [dir="rtl"] .header {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
  }

  [dir="rtl"] a.tools-blog-btn {
    order: 0 !important;
  }

  [dir="rtl"] .header-left {
    order: 3 !important;
    justify-content: flex-end !important;
  }

  [dir="rtl"] .header-center {
    order: 1 !important;
    flex: 1 1 auto !important;
  }

  [dir="rtl"] .header-right {
    order: 2 !important;
    justify-content: flex-start !important;
  }

  /* RTL Language dropdown - centered and visible */
  [dir="rtl"] .language-dropdown {
    z-index: 9999 !important;
    position: relative !important;
    overflow: visible !important;
    margin: 0 auto !important;
  }

  [dir="rtl"] .language-btn {
    z-index: 9999 !important;
    position: relative !important;
    overflow: visible !important;
  }

  [dir="rtl"] .language-menu {
    z-index: 10000 !important;
    position: absolute !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    overflow: visible !important;
    min-width: 200px !important;
  }

  /* RTL Downloader section */
  [dir="rtl"] .downloader-section {
    direction: rtl !important;
    width: 100% !important;
    overflow: visible !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 auto !important;
  }

  [dir="rtl"] .downloader-container {
    direction: rtl !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    overflow: visible !important;
  }

  /* RTL Downloader buttons - ensure visibility */
  [dir="rtl"] .downloader-buttons {
    direction: rtl !important;
    width: 100% !important;
    max-width: 100% !important;
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 10px !important;
    margin: 0 !important;
    overflow: visible !important;
    align-items: center !important;
    text-align: center !important;
    padding: 0.5rem 0 !important;
  }

  [dir="rtl"] .downloader-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    visibility: visible !important;
    overflow: visible !important;
    word-break: break-word !important;
    white-space: normal !important;
    flex: 1 1 auto !important;
    min-width: 180px !important;
    max-width: 100% !important;
    direction: ltr !important;
    position: relative !important;
  }

  /* Ensure all platform buttons are visible in RTL */
  [dir="rtl"] .facebook-btn,
  [dir="rtl"] .instagram-btn,
  [dir="rtl"] .twitter-btn,
  [dir="rtl"] .mp3-btn {
    visibility: visible !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
  }

  [dir="rtl"] .facebook-btn {
    background: #1877f2 !important;
    background: linear-gradient(45deg, #1877f2, #165fcf) !important;
  }

  [dir="rtl"] .instagram-btn {
    background: linear-gradient(45deg, #f58529, #e1306c, #c13584) !important;
  }

  [dir="rtl"] .twitter-btn {
    background: #000 !important;
  }

  [dir="rtl"] .mp3-btn {
    background: linear-gradient(45deg, #5e36eb, #6c34cd, #4f46e5) !important;
  }

  /* Logo positioning in RTL */
  [dir="rtl"] .header-center .logo-container {
    justify-content: center !important;
  }

  /* RTL header-right positioning */
  [dir="rtl"] .header-right {
    gap: 0.35rem !important;
  }

  [dir="rtl"] .header-right .language-dropdown {
    order: 2 !important;
  }
}

/* Small tablets and mobile - RTL adjustments */
@media (max-width: 640px) {
  [dir="rtl"] .language-menu {
    min-width: calc(100% - 2rem) !important;
    max-width: 90vw !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
  }

  [dir="rtl"] .downloader-btn {
    min-width: 140px !important;
    font-size: 0.9rem !important;
  }
}

/* Mobile phones - RTL adjustments */
@media (max-width: 480px) {
  [dir="rtl"] .header {
    padding: 0.35rem 0.4rem !important;
    flex-direction: row !important;
  }

  [dir="rtl"] .header-left {
    order: 3 !important;
  }

  [dir="rtl"] .header-center {
    order: 2 !important;
    flex: 1 1 auto !important;
  }

  [dir="rtl"] .header-right {
    order: 1 !important;
  }

  [dir="rtl"] .language-dropdown {
    z-index: 9999 !important;
    position: relative !important;
    overflow: visible !important;
  }

  [dir="rtl"] .language-btn {
    z-index: 9999 !important;
    padding: 0.25rem 0.3rem !important;
  }

  [dir="rtl"] .language-menu {
    z-index: 10000 !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    top: 56px !important;
    min-width: calc(100% - 2rem) !important;
    max-width: 90vw !important;
  }

  [dir="rtl"] .downloader-btn {
    min-width: 140px !important;
    max-width: 100% !important;
    font-size: 0.85rem !important;
    padding: 10px 12px !important;
  }

  [dir="rtl"] a.tools-blog-btn {
    order: 0 !important;
    position: relative !important;
    top: auto !important;
    width: auto !important;
  }
}

/* ===== MOBILE RTL FIX: Kill Animations & Force Visibility =====
   This fixes the Facebook button being hidden/cut off on Arabic mobile view
*/
@media (max-width: 768px) {
  /* Disable entry/transform animations for the 4 action buttons on mobile RTL
     BUT preserve the lightweight gradient background animation */
  [dir="rtl"] .downloader-btn,
  [dir="rtl"] .facebook-btn,
  [dir="rtl"] .instagram-btn,
  [dir="rtl"] .twitter-btn,
  [dir="rtl"] .mp3-btn,
  [dir="rtl"] .downloader-buttons {
    animation: none !important;
    -webkit-animation: none !important;
    -moz-animation: none !important;
    -o-animation: none !important;
    transition: none !important;
    -webkit-transition: none !important;
    opacity: 1 !important;
    transform: none !important;
    -webkit-transform: none !important;
  }

  /* Keep gradient background animation for downloader-section */
  [dir="rtl"] .downloader-section {
    animation: gradientShift 20s ease infinite !important;
    opacity: 1 !important;
    transform: none !important;
    -webkit-transform: none !important;
  }

  /* Force immediate visibility - no fade/slide delays */
  [dir="rtl"] .facebook-btn,
  [dir="rtl"] .instagram-btn,
  [dir="rtl"] .twitter-btn,
  [dir="rtl"] .mp3-btn {
    opacity: 1 !important;
    visibility: visible !important;
    display: flex !important;
    transform: none !important;
    -webkit-transform: none !important;
    animation: none !important;
    -webkit-animation: none !important;
  }

  /* Fix document flow - ensure static positioning, no overlap */
  [dir="rtl"] .downloader-section {
    position: relative !important;
    margin-top: 300px !important;
    padding-top: 30px !important;
    overflow: visible !important;
    display: block !important;
    width: 100% !important;
  }

  [dir="rtl"] .downloader-container {
    position: relative !important;
    overflow: visible !important;
    display: block !important;
    width: 100% !important;
    margin: 0 auto !important;
  }

  [dir="rtl"] .downloader-buttons {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    width: 100% !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 1rem 0 !important;
  }

  /* Ensure buttons push content below - proper stacking */
  [dir="rtl"] .downloader-btn {
    position: relative !important;
    flex: none !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 56px !important;
    margin: 0 !important;
  }

  /* Tools blog button - horizontal in RTL too */
  [dir="rtl"] a.tools-blog-btn {
    order: 0 !important;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    width: auto !important;
    margin: 0 !important;
    animation: gradientFlow 4s ease infinite !important;
    -webkit-animation: gradientFlow 4s ease infinite !important;
  }

  /* Hero section - proper spacing */
  [dir="rtl"] .hero {
    margin-top: 0 !important;
    padding-top: 1rem !important;
  }

  [dir="rtl"] main {
    margin-top: 75px !important;
    padding-top: 0 !important;
  }
}

/* Small mobile screens - RTL specific */
@media (max-width: 480px) {
  [dir="rtl"] .downloader-section {
    margin-top: 120px !important;
  }

  [dir="rtl"] .downloader-buttons {
    gap: 10px !important;
  }

  [dir="rtl"] .downloader-btn {
    min-height: 52px !important;
    font-size: 0.9rem !important;
  }

  [dir="rtl"] a.tools-blog-btn {
    order: 0 !important;
    margin: 0 !important;
    padding: 0.3rem 0.5rem !important;
    font-size: 0.65rem !important;
  }
}
