/*
 * ╔═══════════════════════════════════════════════════════════╗
 * ║  GALAPPXY — Extensions                                    ║
 * ║  v2.1 · Febrero 2026                                      ║
 * ║                                                          ║
 * ║  Extensiones del framework core:                          ║
 * ║  - Smart child sidebar menu (chevrons + direct nav)       ║
 * ║  - Right trigger mobile toggle                            ║
 * ║  - Mobile dropdown overrides (full-width)                 ║
 * ║  - Impersonation banner                                   ║
 * ║  - Profile switcher                                       ║
 * ║  - Topbar profile ID                                      ║
 * ║  - Embed mode                                             ║
 * ╚═══════════════════════════════════════════════════════════╝
 */


/* ─── SMART MENU (Chevron + Direct Navigate) ─────────────── */

.gx-childsidebar__chevron {
  width: 14px;
  height: 14px;
  margin-left: auto;
  opacity: 0.4;
  transition: transform var(--gx-duration-base) var(--gx-ease-default),
              opacity var(--gx-duration-base) var(--gx-ease-default);
  flex-shrink: 0;
}

.gx-childsidebar__group-title:hover .gx-childsidebar__chevron {
  opacity: 0.7;
}

.gx-childsidebar__group--expandable.is-expanded .gx-childsidebar__chevron {
  transform: rotate(90deg);
  opacity: 0.8;
}

.gx-childsidebar__group--direct .gx-childsidebar__chevron {
  display: none;
}

.gx-childsidebar__group.is-active > .gx-childsidebar__group-title {
  background: var(--gx-childsidebar-hover);
  color: var(--gx-sidebar-text-active);
}

.gx-childsidebar__group-title {
  position: relative;
}

.gx-childsidebar__group.is-active > .gx-childsidebar__group-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--gx-sidebar-accent);
  border-radius: 0 var(--gx-radius-full) var(--gx-radius-full) 0;
}

.gx-childsidebar__subitem.is-active {
  background: var(--gx-childsidebar-hover);
  color: var(--gx-sidebar-text-active);
  font-weight: var(--gx-weight-medium);
}


/* ─── RIGHT TRIGGER: Mobile toggle button ────────────────── */

.gx-right-trigger__toggle {
  display: none;
}

@media (max-width: 768px) {
  .gx-right-trigger__toggle {
    display: flex;
  }

  .gx-right-trigger__toggle .gx-icon {
    transition: transform var(--gx-duration-base) var(--gx-ease-default);
  }

  .gx-right-trigger.is-mobile-expanded .gx-right-trigger__toggle .gx-icon {
    transform: rotate(180deg);
  }
}


/* ─── MOBILE: Full-width dropdowns override (final) ──────── 
   These must come AFTER component-level dropdown widths
   to win the CSS specificity battle on mobile.
   ─────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .gx-dropdown--notifications .gx-dropdown__menu,
  .gx-dropdown--modules .gx-dropdown__menu,
  .gx-dropdown--profile .gx-dropdown__menu {
    position: fixed;
    top: var(--gx-topbar-height);
    left: var(--gx-sp-3);
    right: var(--gx-sp-3);
    width: auto;
    min-width: unset;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .gx-dropdown--notifications .gx-dropdown__menu,
  .gx-dropdown--modules .gx-dropdown__menu,
  .gx-dropdown--profile .gx-dropdown__menu {
    left: var(--gx-sp-2);
    right: var(--gx-sp-2);
  }
}


/* ─── IMPERSONATION BANNER ───────────────────────────────── */

.gx-impersonate {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gx-sp-3);
  background: linear-gradient(135deg, #F59E0B, #D97706);
  color: #FFF;
  font-size: var(--gx-text-sm);
  font-weight: var(--gx-weight-medium);
  z-index: calc(var(--gx-z-toast) + 10);
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.3);
  padding: 0 var(--gx-sp-4);
}

.gx-impersonate__badge {
  background: rgba(255,255,255,0.2);
  padding: 1px 8px;
  border-radius: var(--gx-radius-full);
  font-size: 10px;
  font-weight: var(--gx-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.gx-impersonate__btn {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  color: #FFF;
  padding: 2px 12px;
  border-radius: var(--gx-radius-full);
  font-size: var(--gx-text-xs);
  font-weight: var(--gx-weight-semibold);
  cursor: pointer;
  transition: all var(--gx-duration-fast) var(--gx-ease-default);
}

.gx-impersonate__btn:hover {
  background: rgba(255,255,255,0.35);
}

/* Push everything down when impersonating */
body.gx-impersonating .gx-sidebar,
body.gx-impersonating .gx-topbar,
body.gx-impersonating .gx-childsidebar,
body.gx-impersonating .gx-right-trigger,
body.gx-impersonating .gx-panel {
  top: 36px;
}

@media (max-width: 768px) {
  .gx-impersonate {
    height: 60px;
    flex-wrap: wrap;
    gap: var(--gx-sp-2);
    padding: var(--gx-sp-2) var(--gx-sp-3);
    font-size: var(--gx-text-xs);
  }

  body.gx-impersonating .gx-sidebar,
  body.gx-impersonating .gx-topbar,
  body.gx-impersonating .gx-childsidebar,
  body.gx-impersonating .gx-right-trigger,
  body.gx-impersonating .gx-panel {
    top: 60px;
  }
}


/* ─── PROFILE SWITCHER ───────────────────────────────────── */

.gx-profile-switch {
  padding: var(--gx-sp-2) var(--gx-sp-3);
}

.gx-profile-switch__label {
  display: flex;
  align-items: center;
  gap: var(--gx-sp-2);
  font-size: var(--gx-text-xs);
  font-weight: var(--gx-weight-semibold);
  color: var(--gx-text-muted);
  text-transform: uppercase;
  letter-spacing: var(--gx-tracking-wide);
  padding: var(--gx-sp-2);
  border-radius: var(--gx-radius-md);
  cursor: pointer;
  transition: all var(--gx-duration-fast) var(--gx-ease-default);
  user-select: none;
}

.gx-profile-switch__label:hover {
  background: var(--gx-bg-surface-hover);
  color: var(--gx-text-primary);
}

.gx-profile-switch__arrow {
  transition: transform var(--gx-duration-base) var(--gx-ease-default);
}

.gx-profile-switch.is-expanded .gx-profile-switch__arrow {
  transform: rotate(180deg);
}

/* Collapsible list */
.gx-profile-switch__list {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--gx-duration-medium) var(--gx-ease-default);
}

.gx-profile-switch.is-expanded .gx-profile-switch__list {
  max-height: 300px;
}

.gx-profile-switch__item {
  display: flex;
  align-items: center;
  gap: var(--gx-sp-3);
  padding: var(--gx-sp-2) var(--gx-sp-2);
  border-radius: var(--gx-radius-md);
  cursor: pointer;
  transition: all var(--gx-duration-fast) var(--gx-ease-default);
}

.gx-profile-switch__item:hover {
  background: var(--gx-bg-surface-hover);
}

.gx-profile-switch__item.is-active {
  background: rgba(var(--gx-primary-rgb), 0.06);
}

.gx-profile-switch__info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.gx-profile-switch__name {
  font-size: var(--gx-text-sm);
  font-weight: var(--gx-weight-medium);
  color: var(--gx-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gx-profile-switch__role {
  font-size: var(--gx-text-xs);
  color: var(--gx-text-muted);
}

.gx-profile-switch__check {
  visibility: hidden;
  flex-shrink: 0;
}

.gx-profile-switch__item.is-active .gx-profile-switch__check {
  visibility: visible;
}


/* ─── TOPBAR PROFILE ID ──────────────────────────────────── */

.gx-topbar__profile-id {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--gx-bg-surface);
  border: 1px solid var(--gx-border-light);
  border-radius: var(--gx-radius-full);
  font-size: 11px;
  font-weight: var(--gx-weight-bold);
  color: var(--gx-text-primary);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  letter-spacing: 0.02em;
  cursor: default;
  user-select: all;
  white-space: nowrap;
}

.gx-topbar__profile-id:hover {
  background: var(--gx-bg-surface-hover);
}


/* ─── EMBED MODE ─────────────────────────────────────────── */

.gx-app.gx-app--embed {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  grid-template-areas: "content";
}

.gx-app.gx-app--embed .gx-sidebar,
.gx-app.gx-app--embed .gx-childsidebar,
.gx-app.gx-app--embed .gx-topbar {
  display: none !important;
}

body.gx-embed .gx-right-trigger,
body.gx-embed .gx-impersonate {
  display: none !important;
}

.gx-app.gx-app--embed .gx-content {
  grid-area: content;
  padding: var(--gx-sp-4);
  max-height: 100vh;
  overflow-y: auto;
}