/*! 
 * yAccessibility v5.5 - Arabic Accessibility Widget 
 * Designed by Tareq Abuhajjaj
 * Contact: tzhajjaj@gmail.com
 * www.tareqdesign.com
 */

:root {
  --y-blue: #006DD5;
  --y-blue-hover: #0056b3;
  --y-font-scale: 1;
  --y-panel-bg: rgba(255, 255, 255, 0.92);
  --y-text-main: #2d3748;
}

/* الزر الرئيسي */
#y-access-btn {
  position: fixed;
  left: 20px;
  bottom: 20px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--y-blue), var(--y-blue-hover));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  cursor: pointer;
  z-index: 99999;
  border: none;
  box-shadow: 0 8px 25px rgba(0, 109, 213, 0.4);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: y-pulse 3s infinite;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
@keyframes y-pulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 109, 213, 0.4); }
  70% { box-shadow: 0 0 0 15px rgba(0, 109, 213, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 109, 213, 0); }
}
#y-access-btn:hover {
  transform: scale(1.15) rotate(10deg);
  animation: none;
}

/* اللوحة */
#y-panel {
  position: fixed;
  left: 20px;
  bottom: 90px; /* تظهر اللوحة فوق الزر */
  z-index: 99999;
  width: 300px;
  padding: 20px;
  background: var(--y-panel-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.15), 0 0 0 1px rgba(255,255,255,0.5) inset;
  display: block;
  visibility: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: 'Tajawal', sans-serif;
  user-select: none;
}
#y-panel.active {
  visibility: visible;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* الشبكة */
#y-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

/* عناصر الأزرار */
.y-item {
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 16px;
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
  background: rgba(255, 255, 255, 0.6);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.y-item i {
  font-size: 22px;
  color: var(--y-blue);
  margin-bottom: 8px;
  transition: transform 0.2s ease;
}
.y-item span {
  font-size: 12px;
  font-weight: 600;
  color: var(--y-text-main);
  text-align: center;
}
.y-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 25px rgba(0,0,0,0.08);
  background: #fff;
  border-color: var(--y-blue);
}
.y-item.active {
  background: var(--y-blue);
  border-color: var(--y-blue);
  color: #fff;
  box-shadow: 0 8px 20px rgba(0, 109, 213, 0.3);
  transform: translateY(-2px);
}
.y-item.active:hover {
  background: var(--y-blue-hover);
  border-color: var(--y-blue-hover);
  transform: translateY(-4px);
}
.y-item.active i,
.y-item.active span {
  color: #fff;
}

.shortcut {
  font-size: 11px;
  color: #666;
  margin-top: 2px;
}

/* تذييل اللوحة */
#y-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(0,0,0,0.05);
  gap: 12px;
}
#y-reset,
#y-close {
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
}
#y-reset {
  background: rgba(220, 53, 69, 0.1);
  color: #dc3545;
}
#y-reset:hover {
  background: rgba(220, 53, 69, 0.2);
  transform: translateY(-1px);
}

/* إعدادات الوصول */
.y-simple-font {
  font-family: "Arial", sans-serif !important;
  line-height: 1.6 !important;
}
.y-stop-anim * {
  animation: none !important;
  transition: none !important;
}

/* وضع التركيز */
#focus-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 99998;
  background: rgba(0, 0, 0, 0.6);
  transition: all 0.2s ease;
  display: none;
}

/* التباين والألوان */
/* تم تحديث المحددات لتعمل مع أي عنصر رئيسي */
.y-highlight a,
.y-highlight button,
.y-highlight input,
.y-highlight select,
.y-highlight textarea {
  outline: 3px dashed var(--highlight-color, var(--y-blue));
  outline-offset: 3px;
}

/* الوضع الليلي - استثناء الصور والفيديو من الفلتر */
.y-night-mode-active img,
.y-night-mode-active video,
.y-night-mode-active iframe {
  filter: invert(1) hue-rotate(180deg);
}

/* إخفاء الصور */
.y-remove-images img,
.y-remove-images video,
.y-remove-images svg,
.y-remove-images [role="img"] {
  opacity: 0 !important;
  visibility: hidden !important;
}

.btn-download {
    padding: 10px;
    background-color: #515151;
    color: white;
    border-radius: 8px;
    display: block;
    text-align: center;
}

.btn-download:hover {
    padding: 10px;
    background-color: #323232;
    color: white;
    transition: .5s;

}
#y-close {
    background-color: rgba(0,0,0,0.05);
    color: var(--y-text-main);
}
#y-close:hover {
    background-color: rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

/* Custom Tooltip */
#y-tooltip {
  position: fixed;
  background: rgba(30, 41, 59, 0.95); /* لون خلفية داكن */
  backdrop-filter: blur(4px);
  color: #fff; /* لون نص أبيض */
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Tajawal', sans-serif;
  z-index: 100000; /* فوق كل شيء */
  pointer-events: none; /* لمنعه من اعتراض نقرات الماوس */
  opacity: 0;
  transform: translate(-50%, -100%) translateY(-10px) scale(0.95);
  transition: opacity 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  white-space: nowrap; /* لمنع النص من الانقسام لعدة أسطر */
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

#y-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -6px;
  border-width: 6px;
  border-style: solid;
  border-color: rgba(30, 41, 59, 0.95) transparent transparent transparent;
}

#y-tooltip.active {
  opacity: 1;
  transform: translate(-50%, -100%) translateY(-5px) scale(1);
}

body.y-panel-open {
  overflow: hidden;
}

@media (hover: none) {
  #y-access-btn:hover,
  .y-item:hover,
  .y-item.active:hover,
  #y-reset:hover,
  #y-close:hover {
    transform: none;
    box-shadow: none;
    animation: none;
  }
}

@media (max-width: 768px) {
  #y-access-btn {
    left: auto !important;
    right: 16px !important;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
    width: 56px;
    height: 56px;
    font-size: 24px;
    animation: none;
  }

  #y-panel {
    left: 50% !important;
    right: auto !important;
    bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important;
    width: min(94vw, 420px);
    max-height: calc(100dvh - 120px - env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    padding: 16px;
    border-radius: 20px;
    transform: translate(-50%, 20px) scale(0.96);
  }

  #y-panel.active {
    transform: translate(-50%, 0) scale(1);
  }

  #y-grid {
    gap: 10px;
  }

  .y-item {
    min-height: 86px;
    padding: 12px 8px;
  }

  .y-item i {
    font-size: 20px;
    margin-bottom: 6px;
  }

  .y-item span {
    font-size: 11px;
  }

  .shortcut {
    display: none;
  }

  #y-footer {
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,0.92) 26%);
    padding-top: 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    margin-bottom: 0;
  }

  #y-tooltip {
    display: none !important;
  }

  .y-item.y-desktop-only {
    display: none !important;
  }
}
