/* ============================================================
 * לחצן "קבצים ופרויקטים" - לחצן מפוצל (split button):
 *   [ אייקון + תווית  |  חץ ]
 * ה-wrapper הוא ה"פיל" הממוסגר; הגוף הראשי עושה toggle לגרסת ברירת המחדל,
 * והחץ פותח תפריט בחירת גרסת-מודל (סונטה/אופוס/ג׳ימיני/ג׳י פי טי).
 * ============================================================ */

.files-projects-pin-wrapper {
  direction: rtl !important;
  display: inline-flex !important;
  align-items: stretch !important;
  position: relative !important;
  /* קריטי: לא להתכווץ. אחרת ה-wrapper "סופג" את הכיווץ של ה-flex כשהכותרת
     צרה — הטקסט והחץ נחתכים (overflow:hidden), ובמקביל בורר המודל מפסיק
     להתכווץ ונשאר ברוחב מלא (w-full + text-left). flex:0 0 auto משחזר את
     התנהגות הלחצן הישן ומחזיר לבורר המודל את גודלו לפי התוכן. */
  flex: 0 0 auto !important;
  /* 36px = h-9, גובה כל לחצני הכותרת (בורר המודל, "שיחה חדשה" וכו'). היה 40px
     וגרם ללחצן להיות גבוה משאר הלחצנים. */
  height: 36px !important;
  box-sizing: border-box !important;
  border: 1.5px solid var(--brand-medium, #25408f) !important;
  border-radius: 0.5rem !important;
  /* רקע אטום (לא transparent): הכותרת של LibreChat היא gradient שדועך לשקוף,
     והודעות הצ'אט גוללות מאחורי הלחצנים. var(--presentation) לבן ב-light וגריי
     כהה ב-dark - תואם לרקע הכותרת. */
  background: var(--presentation, #fff) !important;
  overflow: hidden !important;
}

.files-projects-pin-button,
.files-projects-pin-caret {
  direction: rtl !important;
  height: 100% !important;
  box-sizing: border-box !important;
  flex: 0 0 auto !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--brand-medium, #25408f) !important;
  box-shadow: none !important;
  font-weight: 600 !important;
  line-height: 1.2 !important;
  white-space: nowrap !important;
  cursor: pointer !important;
  transition: background 0.15s ease, color 0.15s ease !important;
}

.files-projects-pin-button {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.5rem !important;
  padding: 0.4rem 0.8rem !important;
}

.files-projects-pin-caret {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 0.4rem !important;
  min-width: 28px !important;
  /* קו מפריד בין הגוף הראשי לחץ */
  border-inline-start: 1.5px solid var(--brand-medium, #25408f) !important;
}

.files-projects-pin-button svg {
  width: 17px !important;
  height: 17px !important;
  color: currentColor !important;
  stroke: currentColor !important;
  flex-shrink: 0 !important;
}

.files-projects-pin-caret svg {
  width: 16px !important;
  height: 16px !important;
  color: currentColor !important;
  stroke: currentColor !important;
  flex-shrink: 0 !important;
  transition: transform 0.15s ease !important;
}

.files-projects-pin-caret[aria-expanded="true"] svg {
  transform: rotate(180deg) !important;
}

@media (hover: hover) and (pointer: fine) {
  .files-projects-pin-button:hover:not(:disabled),
  .files-projects-pin-caret:hover:not(:disabled) {
    background: var(--brand-medium, #25408f) !important;
    color: #fff !important;
  }
}

/* מצב פעיל - הפיל כולו צבוע במותג */
.files-projects-pin-wrapper.is-active {
  background: var(--brand-medium, #25408f) !important;
  box-shadow: 0 4px 12px rgba(37, 64, 143, 0.22) !important;
}

.files-projects-pin-wrapper.is-active .files-projects-pin-button,
.files-projects-pin-wrapper.is-active .files-projects-pin-caret {
  color: #fff !important;
}

.files-projects-pin-wrapper.is-active .files-projects-pin-caret {
  border-inline-start-color: rgba(255, 255, 255, 0.4) !important;
}

@media (hover: hover) and (pointer: fine) {
  .files-projects-pin-wrapper.is-active .files-projects-pin-button:hover:not(:disabled),
  .files-projects-pin-wrapper.is-active .files-projects-pin-caret:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.16) !important;
    color: #fff !important;
  }
}

/* ===== Dark mode ===== */
html[data-theme="dark"] .files-projects-pin-wrapper {
  background: var(--presentation, #2f2f2f) !important;
  border-color: var(--brand-light, #7dd2ef) !important;
}

html[data-theme="dark"] .files-projects-pin-button,
html[data-theme="dark"] .files-projects-pin-caret {
  color: var(--brand-light, #7dd2ef) !important;
}

html[data-theme="dark"] .files-projects-pin-caret {
  border-inline-start-color: var(--brand-light, #7dd2ef) !important;
}

@media (hover: hover) and (pointer: fine) {
  html[data-theme="dark"] .files-projects-pin-button:hover:not(:disabled),
  html[data-theme="dark"] .files-projects-pin-caret:hover:not(:disabled) {
    background: var(--brand-light, #7dd2ef) !important;
    color: var(--brand-dark, #16213f) !important;
  }
}

html[data-theme="dark"] .files-projects-pin-wrapper.is-active {
  background: var(--brand-light, #7dd2ef) !important;
}

html[data-theme="dark"] .files-projects-pin-wrapper.is-active .files-projects-pin-button,
html[data-theme="dark"] .files-projects-pin-wrapper.is-active .files-projects-pin-caret {
  color: var(--brand-dark, #16213f) !important;
}

html[data-theme="dark"] .files-projects-pin-wrapper.is-active .files-projects-pin-caret {
  border-inline-start-color: rgba(22, 33, 63, 0.35) !important;
}

@media (hover: hover) and (pointer: fine) {
  html[data-theme="dark"] .files-projects-pin-wrapper.is-active .files-projects-pin-button:hover:not(:disabled),
  html[data-theme="dark"] .files-projects-pin-wrapper.is-active .files-projects-pin-caret:hover:not(:disabled) {
    background: rgba(22, 33, 63, 0.18) !important;
    color: var(--brand-dark, #16213f) !important;
  }
}

/* ===== מובייל: מסתירים את התווית, משאירים אייקון + חץ ===== */
@media (max-width: 640px) {
  .files-projects-pin-wrapper {
    height: 36px !important;
  }

  .files-projects-pin-button {
    padding: 0.5rem !important;
  }

  .files-projects-pin-button span {
    display: none !important;
  }

  .files-projects-pin-caret {
    min-width: 24px !important;
    padding: 0 0.3rem !important;
  }
}

/* ============================================================
 * תפריט בחירת גרסת-מודל (נפתח מהחץ; מוצמד ל-body עם position: fixed)
 * עיצוב זהה לשאר התפריטים הממותגים בממשק (tools-dropdown-style.css):
 * רקע לבן / #1a1a2e בכהה, מסגרת כחולה 2px, פינות 12px, צל מותג,
 * ופריטים בצבעי המותג עם hover עדין.
 * ============================================================ */

.files-projects-pin-menu {
  position: fixed !important;
  z-index: 9999 !important;
  direction: rtl !important;
  min-width: 220px !important;
  max-width: 300px !important;
  padding: 8px !important;
  background: #fff !important;
  border: 2px solid var(--brand-medium, #25408f) !important;
  border-radius: 12px !important;
  box-shadow: 0 8px 24px rgba(37, 64, 143, 0.15) !important;
  font-family: inherit !important;
  animation: files-projects-pin-menu-fade 0.18s ease !important;
}

@keyframes files-projects-pin-menu-fade {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.files-projects-pin-menu-title {
  padding: 8px 10px 6px !important;
  font-size: 0.85rem !important;
  font-weight: 700 !important;
  color: var(--brand-dark, #16213f) !important;
  border-bottom: 1px solid rgba(37, 64, 143, 0.2) !important;
  margin-bottom: 4px !important;
}

/* הסלקטורים של ה-items מקוננים תחת .files-projects-pin-menu בכוונה: header-buttons-style.css
   כולל כלל `[role="menu"] button { background/border/...: revert !important }` (ספציפיות 0,1,1)
   שמנטרל עיצוב כפתורי-כותרת בתוך תפריטים. ה-items שלנו הם <button> בתוך role="menu", ולכן
   הכלל ההוא תפס אותם והחזיר אותם לעיצוב דפדפן (אפור/outset). קינון תחת מחלקת המיכל מעלה
   את הספציפיות ל-(0,2,0) ומנצח את ה-revert. */
.files-projects-pin-menu .files-projects-pin-menu-item {
  /* קריטי: ה-items הם <button>; ללא appearance:none דפדפנים מציירים רקע
     אפור (ButtonFace #efefef) ומסגרת outset נייטיביים. איפוס ה-appearance
     מאפשר לעיצוב הממותג לחול. */
  appearance: none !important;
  -webkit-appearance: none !important;
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  width: 100% !important;
  padding: 6px 10px !important;
  margin: 2px 0 !important;
  border: 1px solid transparent !important;
  background: transparent !important;
  border-radius: 8px !important;
  text-align: right !important;
  font-size: 0.9rem !important;
  /* משקל רגיל כמו פריטי שאר התפריטים (בבורר המודלים font-weight:400); רק
     הכותרת מודגשת. */
  font-weight: 400 !important;
  color: var(--brand-dark, #16213f) !important;
  cursor: pointer !important;
  white-space: nowrap !important;
  transition: all 0.2s ease !important;
}

/* קו עדין מפריד בין פריטים - זהה לתפריטי הבחירה האחרים (rgba מותג, 1px, יושב
   ב-gap של ה-margin בין הפריטים). לא מצויר אחרי הפריט האחרון. */
.files-projects-pin-menu .files-projects-pin-menu-item:not(:last-child)::after {
  content: '' !important;
  position: absolute !important;
  left: 8% !important;
  right: 8% !important;
  bottom: -3px !important;
  height: 1px !important;
  background: rgba(37, 64, 143, 0.12) !important;
  pointer-events: none !important;
}

.files-projects-pin-menu .files-projects-pin-menu-item:hover,
.files-projects-pin-menu .files-projects-pin-menu-item.is-active {
  background: rgba(37, 64, 143, 0.08) !important;
  border-color: var(--brand-medium, #25408f) !important;
  color: var(--brand-medium, #25408f) !important;
}

.files-projects-pin-menu-check {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 16px !important;
  height: 16px !important;
  flex-shrink: 0 !important;
  color: var(--brand-medium, #25408f) !important;
}

.files-projects-pin-menu-check svg {
  width: 15px !important;
  height: 15px !important;
  stroke: currentColor !important;
}

/* אייקון הספק לפני שם הגרסה - אותם קבצים שמשמשים את האווטרים בתפריט המודלים.
   anthropic/openai הם SVG שחורים (currentColor) ונראים במצב בהיר; ב-dark הם
   נצבעים לבן (img לא יורש currentColor). gemini הוא webp צבעוני - נשאר כמות שהוא. */
.files-projects-pin-menu-icon {
  display: inline-block !important;
  width: 18px !important;
  height: 18px !important;
  flex-shrink: 0 !important;
  object-fit: contain !important;
}

html[data-theme="dark"] .files-projects-pin-menu-icon.is-mono {
  filter: brightness(0) invert(1) !important;
}

.files-projects-pin-menu-label {
  flex: 1 1 auto !important;
}

.files-projects-pin-menu-empty {
  padding: 10px !important;
  font-size: 0.85rem !important;
  color: var(--brand-dark, #16213f) !important;
  opacity: 0.7 !important;
}

/* Dark mode - תואם tools-dropdown-style.css (#1a1a2e + brand-light) */
html[data-theme="dark"] .files-projects-pin-menu {
  background: #1a1a2e !important;
  border-color: var(--brand-light, #7dd2ef) !important;
  box-shadow: 0 8px 24px rgba(125, 210, 239, 0.2) !important;
}

html[data-theme="dark"] .files-projects-pin-menu-title {
  color: var(--brand-light, #7dd2ef) !important;
  border-bottom-color: rgba(125, 210, 239, 0.25) !important;
}

html[data-theme="dark"] .files-projects-pin-menu .files-projects-pin-menu-item {
  color: var(--brand-light, #7dd2ef) !important;
}

html[data-theme="dark"] .files-projects-pin-menu .files-projects-pin-menu-item:hover,
html[data-theme="dark"] .files-projects-pin-menu .files-projects-pin-menu-item.is-active {
  background: rgba(125, 210, 239, 0.12) !important;
  border-color: var(--brand-light, #7dd2ef) !important;
  color: var(--brand-light, #7dd2ef) !important;
}

html[data-theme="dark"] .files-projects-pin-menu .files-projects-pin-menu-item:not(:last-child)::after {
  background: rgba(125, 210, 239, 0.18) !important;
}

html[data-theme="dark"] .files-projects-pin-menu-check {
  color: var(--brand-light, #7dd2ef) !important;
}

html[data-theme="dark"] .files-projects-pin-menu-empty {
  color: var(--brand-light, #7dd2ef) !important;
}
