/*
  ============================================================
  Edupidia — Profile Menu Styles (Optimized for Zero Lag)
  File: profile-menu.css
  ------------------------------------------------------------
  - Fixed scroll lag by reducing heavy blur and adding GPU hints.
  - Cleaned up conflicting mobile media queries.
  - Smooth, lag-free scrolling on all devices (especially mobile).
  ============================================================
*/

/* 1. DESIGN TOKENS */
:root {
  --ep-accent: #6d5dfc;
  --ep-accent-2: #22d3ee;
  --ep-accent-soft: rgba(109, 93, 252, 0.12);

  --ep-bg: #ffffff;
  --ep-surface: rgba(255, 255, 255, 0.85); /* Slightly opaque for better performance */
  --ep-surface-solid: #ffffff;
  --ep-border: rgba(15, 23, 42, 0.08);
  --ep-divider: rgba(15, 23, 42, 0.08);

  --ep-text: #0f172a;
  --ep-text-muted: #64748b;
  --ep-text-soft: #94a3b8;

  --ep-shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --ep-shadow-md: 0 10px 30px rgba(15, 23, 42, 0.10), 0 4px 10px rgba(15, 23, 42, 0.05);
  --ep-shadow-lg: 0 20px 60px rgba(15, 23, 42, 0.15), 0 8px 20px rgba(15, 23, 42, 0.06);
  --ep-glow: 0 0 0 4px rgba(109, 93, 252, 0.18);

  --ep-radius-sm: 10px;
  --ep-radius-md: 14px;
  --ep-radius-lg: 20px;
  --ep-radius-full: 999px;

  --ep-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ep-duration: 200ms; /* Faster for snappier feel */

  --ep-font: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Dark mode tokens */
@media (prefers-color-scheme: dark) {
  :root:not([data-ep-theme="light"]) {
    --ep-bg: #0b0d12;
    --ep-surface: rgba(22, 25, 34, 0.85);
    --ep-surface-solid: #141722;
    --ep-border: rgba(255, 255, 255, 0.08);
    --ep-divider: rgba(255, 255, 255, 0.08);
    --ep-text: #f1f5f9;
    --ep-text-muted: #94a3b8;
    --ep-text-soft: #64748b;
    --ep-shadow-md: 0 10px 30px rgba(0, 0, 0, 0.45), 0 4px 10px rgba(0, 0, 0, 0.30);
    --ep-shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.50), 0 8px 20px rgba(0, 0, 0, 0.35);
    --ep-accent-soft: rgba(109, 93, 252, 0.22);
  }
}

[data-ep-theme="dark"] {
  --ep-bg: #0b0d12;
  --ep-surface: rgba(22, 25, 34, 0.85);
  --ep-surface-solid: #141722;
  --ep-border: rgba(255, 255, 255, 0.08);
  --ep-divider: rgba(255, 255, 255, 0.08);
  --ep-text: #f1f5f9;
  --ep-text-muted: #94a3b8;
  --ep-text-soft: #64748b;
  --ep-shadow-md: 0 10px 30px rgba(0, 0, 0, 0.45), 0 4px 10px rgba(0, 0, 0, 0.30);
  --ep-shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.50), 0 8px 20px rgba(0, 0, 0, 0.35);
  --ep-accent-soft: rgba(109, 93, 252, 0.22);
}

/* 2. ROOT CONTAINER */
.ep-profile-menu {
  position: relative;
  font-family: var(--ep-font);
  color: var(--ep-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

/* 3. TRIGGER BUTTON */
.ep-profile-trigger {
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--ep-border);
  border-radius: var(--ep-radius-full);
  background: var(--ep-surface-solid);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--ep-duration) var(--ep-ease), box-shadow var(--ep-duration) var(--ep-ease), border-color var(--ep-duration) var(--ep-ease);
  box-shadow: var(--ep-shadow-sm);
  will-change: transform; /* GPU Hint */
}

.ep-profile-trigger:hover {
  transform: scale(1.06);
  box-shadow: var(--ep-glow), var(--ep-shadow-md);
  border-color: rgba(109, 93, 252, 0.35);
}

.ep-profile-trigger:focus-visible {
  outline: none;
  box-shadow: var(--ep-glow), 0 0 0 2px var(--ep-accent);
}

.ep-profile-trigger:active { transform: scale(0.97); }

/* 4. AVATARS */
.ep-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--ep-radius-full);
  overflow: hidden;
  flex-shrink: 0;
}
.ep-avatar svg { width: 100%; height: 100%; display: block; }
.ep-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.ep-avatar--sm { width: 40px; height: 40px; }
.ep-avatar--lg {
  width: 56px;
  height: 56px;
  box-shadow: 0 6px 18px rgba(109, 93, 252, 0.35);
}

/* 5. DROPDOWN (Optimized for Zero Lag) */
.ep-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  left: auto;
  right: 0;
  width: min(340px, calc(100vw - 24px));
  max-height: calc(100vh - 120px);
  background: var(--ep-surface);
  /* REDUCED BLUR: 22px -> 12px (Massive performance gain on mobile) */
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid var(--ep-border);
  border-radius: var(--ep-radius-lg);
  box-shadow: var(--ep-shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  opacity: 0;
  transform: translateY(10px) scale(.96);
  transform-origin: top right;
  pointer-events: none;
  visibility: hidden;

  transition:
      opacity .28s ease,
      transform .28s cubic-bezier(.22,1,.36,1),
      visibility 0s linear .28s;
  z-index: 9999;
  
  /* GPU Acceleration to prevent scroll lag */
  will-change: opacity, transform;
  transform: translateY(10px) scale(.96);
  -webkit-transform: translateY(10px) scale(.96);
}

.ep-dropdown.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
  transition: opacity var(--ep-duration) var(--ep-ease), transform var(--ep-duration) var(--ep-ease), visibility 0s linear 0s;
}

.ep-dropdown.is-closing {
  transition: opacity 150ms ease-in, transform 150ms ease-in, visibility 0s linear 150ms;
  opacity: 0;
  transform: translateY(10px) scale(.96);
}

/* 6. HEADER */
.ep-dropdown__header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 18px 16px;
  background: linear-gradient(135deg, var(--ep-accent-soft) 0%, transparent 60%);
  border-bottom: 1px solid var(--ep-divider);
  flex-shrink: 0; /* Prevent header from shrinking during scroll */
}

.ep-dropdown__identity { min-width: 0; flex: 1; }
.ep-dropdown__name { margin: 0; font-size: 15px; font-weight: 600; color: var(--ep-text); letter-spacing: -0.01em; }
.ep-dropdown__greeting { margin: 2px 0 0; font-size: 12.5px; font-weight: 500; color: var(--ep-accent); }
.ep-dropdown__subtitle { margin: 4px 0 0; font-size: 12px; color: var(--ep-text-muted); line-height: 1.45; }

/* 7. BODY (Scrollable area - Optimized) */
.ep-dropdown__body {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
  /* Native smooth scrolling for iOS */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--ep-text-soft) transparent;
  /* GPU Acceleration for smooth scrolling */
  will-change: scroll-position;
  transform: translateZ(0);
}

.ep-dropdown__body::-webkit-scrollbar { width: 6px; }
.ep-dropdown__body::-webkit-scrollbar-thumb { background: var(--ep-text-soft); border-radius: 10px; }
.ep-dropdown__body::-webkit-scrollbar-track { background: transparent; }

/* 8. MENU LIST & ITEMS */
.ep-menu { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.ep-menu__item {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: var(--ep-radius-md);
  color: var(--ep-text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  /* Simplified transitions for better performance (no layout thrashing) */
  transition: background-color 150ms ease, color 150ms ease;
  will-change: background-color;
}

.ep-menu__item::before {
  content: "";
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--ep-accent), var(--ep-accent-2));
  transform: scaleY(0);
  transform-origin: center;
  transition: transform 150ms ease;
}

.ep-menu__icon {
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ep-text-muted);
  flex-shrink: 0;
  transition: color 150ms ease;
}
.ep-menu__icon svg { width: 100%; height: 100%; }
.ep-menu__label { flex: 1; }

.ep-menu__meta {
  font-size: 11.5px; color: var(--ep-accent);
  padding: 2px 8px; border-radius: var(--ep-radius-full);
  background: var(--ep-accent-soft); font-weight: 600;
}

.ep-badge { font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: var(--ep-radius-full); letter-spacing: 0.02em; }
.ep-badge--soon { background: rgba(234, 179, 8, 0.12); color: #b45309; }
[data-ep-theme="dark"] .ep-badge--soon, .ep-profile-menu .ep-badge--soon { background: rgba(234, 179, 8, 0.16); color: #fbbf24; }
@media (prefers-color-scheme: dark) {
  :root:not([data-ep-theme="light"]) .ep-badge--soon { background: rgba(234, 179, 8, 0.16); color: #fbbf24; }
}

/* Hover states - simplified to prevent lag during scroll */
.ep-menu__item:hover {
  background: var(--ep-accent-soft);
  color: var(--ep-text);
  box-shadow: 0 0 0 1px var(--ep-accent-soft);
}
.ep-menu__item:hover::before { transform: scaleY(1); }
.ep-menu__item:hover .ep-menu__icon { color: var(--ep-accent); }

.ep-menu__item:focus-visible { outline: none; background: var(--ep-accent-soft); box-shadow: inset 0 0 0 2px var(--ep-accent); }
.ep-menu__item:focus-visible::before { transform: scaleY(1); }
.ep-menu__item:active { background: var(--ep-accent-soft); }

/* 9. THEME TOGGLE SWITCH */
.ep-switch {
  position: relative; width: 34px; height: 20px;
  border-radius: var(--ep-radius-full);
  background: rgba(148, 163, 184, 0.35);
  transition: background var(--ep-duration) var(--ep-ease);
  flex-shrink: 0;
}
.ep-switch__thumb {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform var(--ep-duration) var(--ep-ease);
}
.ep-profile-menu.is-dark .ep-switch { background: var(--ep-accent); }
.ep-profile-menu.is-dark .ep-switch__thumb { transform: translateX(14px); }

.ep-icon--moon { display: none; }
.ep-icon--sun  { display: inline-flex; }
.ep-profile-menu.is-dark .ep-icon--moon { display: inline-flex; }
.ep-profile-menu.is-dark .ep-icon--sun  { display: none; }

/* 10. DIVIDER & FOOTER */
.ep-divider { height: 1px; background: var(--ep-divider); margin: 6px 4px; flex-shrink: 0; }

.ep-dropdown__footer {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; font-size: 11.5px; color: var(--ep-text-soft);
  border-top: 1px solid var(--ep-divider); background: var(--ep-surface);
  flex-shrink: 0;
}
.ep-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--ep-text-soft); opacity: 0.6; }
.ep-brand { font-weight: 600; color: var(--ep-text-muted); }

/* 11. TOAST (Optimized) */
.ep-toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 10000; pointer-events: none;
}
.ep-toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px;
  min-width: 260px; max-width: 360px; padding: 12px 16px;
  background: var(--ep-surface);
  backdrop-filter: blur(10px) saturate(140%); /* Reduced blur */
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  border: 1px solid var(--ep-border); border-radius: var(--ep-radius-md);
  box-shadow: var(--ep-shadow-md); color: var(--ep-text);
  font-size: 13px; font-weight: 500;
  animation: epToastIn 320ms var(--ep-ease) both;
  will-change: transform, opacity;
}
.ep-toast.is-leaving { animation: epToastOut 240ms var(--ep-ease) both; }
.ep-toast__icon {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--ep-accent), var(--ep-accent-2));
  color: #fff; flex-shrink: 0;
}
.ep-toast__icon svg { width: 16px; height: 16px; }
.ep-toast__text { flex: 1; line-height: 1.4; }
.ep-toast__progress {
  position: absolute; left: 12px; right: 12px; bottom: 6px;
  height: 2px; background: var(--ep-divider); border-radius: 2px; overflow: hidden;
}
.ep-toast__progress::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--ep-accent), var(--ep-accent-2));
  transform-origin: left; animation: epToastProgress 3s linear forwards;
}

@keyframes epToastIn { 0% { opacity: 0; transform: translateX(20px) scale(0.95); } 100% { opacity: 1; transform: translateX(0) scale(1); } }
@keyframes epToastOut { 0% { opacity: 1; transform: translateX(0) scale(1); } 100% { opacity: 0; transform: translateX(20px) scale(0.95); } }
@keyframes epToastProgress { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* 12. OVERLAY (Optimized) 
.ep-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.25);
  backdrop-filter: none; /* Removed heavy blur for massive performance gain 
  -webkit-backdrop-filter: none;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 200ms ease-out, visibility 0s linear 200ms;
  z-index: 9998; will-change: opacity; transform: translateZ(0);
}
.ep-overlay.is-visible { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 200ms ease-out, visibility 0s linear 0s; } */
.ep-overlay.is-leaving { transition: opacity 150ms ease-in, visibility 0s linear 150ms; opacity: 0; }

/* 13. NOTIFICATION BADGE */
.ep-notification-badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--ep-radius-full);
  background: linear-gradient(135deg, #ef4444, #f97316);
  color: #fff; font-size: 10.5px; font-weight: 700;
  line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--ep-surface-solid), 0 4px 10px rgba(239, 68, 68, 0.45);
  display: none; align-items: center; justify-content: center;
  letter-spacing: 0.02em; animation: epBadgePop 360ms var(--ep-ease) both; z-index: 2;
}
.ep-notification-badge.is-visible { display: inline-flex; }
.ep-notification-badge.is-dot { min-width: 10px; height: 10px; padding: 0; top: 2px; right: 2px; }
@keyframes epBadgePop { 0% { transform: scale(0); opacity: 0; } 60% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

/* 14. RIPPLE EFFECT (Optimized) */
.ep-profile-trigger, .ep-menu__item { position: relative; overflow: hidden; }
.ep-ripple {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(109, 93, 252, 0.25) 0%, rgba(109, 93, 252, 0.10) 40%, transparent 70%);
  transform: translateZ(0) scale(0); opacity: 0.6;
  animation: epRippleExpand 400ms ease-out forwards;
  will-change: transform, opacity;
}
[data-ep-theme="dark"] .ep-ripple, .ep-profile-menu.is-dark .ep-ripple {
  background: radial-gradient(circle, rgba(167, 139, 250, 0.45) 0%, rgba(109, 93, 252, 0.20) 40%, transparent 70%);
}
@keyframes epRippleExpand { 0% { transform: translateZ(0) scale(0); opacity: 0.6; } 60% { opacity: 0.3; } 100% { transform: translateZ(0) scale(2.4); opacity: 0; } }

/* 15. RESPONSIVE (Cleaned & Consolidated to prevent conflicts) */
@media (max-width: 1024px) {
  .nav-actions { display: flex; align-items: center; gap: 10px; }
  .ep-profile-menu { order: 1; }
  .hamburger { order: 2; }
  .ep-dropdown { width: 320px; }
}

@media (max-width: 768px) {
  .nav-actions { display: flex; align-items: center; gap: 8px; }
  .ep-profile-trigger { width: 40px; height: 40px; }
  .ep-avatar--sm { width: 34px; height: 34px; }
  .ep-notification-badge { top: -1px; right: -1px; min-width: 16px; height: 16px; font-size: 9.5px; line-height: 16px; }

  /* Fixed positioning for mobile to prevent layout shift during scroll */
  .ep-dropdown {
    position: fixed;
    top: 65px; /* Adjust based on your header height */
    right: 12px; left: 12px;
    width: auto; max-width: none;
    max-height: calc(100vh - 80px);
    border-radius: 18px;
    transform-origin: top center;
  }
  .ep-dropdown.is-open { animation: epMobileSlideUp 250ms var(--ep-ease) both; }
  .ep-dropdown.is-closing { animation: epMobileSlideDown 180ms ease-in both; }

  @keyframes epMobileSlideUp { 0% { opacity: 0; transform: translateZ(0) translateY(-12px) scale(0.96); } 100% { opacity: 1; transform: translateZ(0) translateY(0) scale(1); } }
  @keyframes epMobileSlideDown { 0% { opacity: 1; transform: translateZ(0) translateY(0) scale(1); } 100% { opacity: 0; transform: translateZ(0) translateY(-8px) scale(0.96); } }

  .ep-dropdown__header { padding: 14px 14px 12px; gap: 12px; }
  .ep-avatar--lg { width: 48px; height: 48px; }
  .ep-dropdown__name { font-size: 14px; }
  .ep-dropdown__greeting { font-size: 11.5px; }
  .ep-dropdown__subtitle { font-size: 11px; }
  .ep-menu__item { padding: 9px 10px; font-size: 13px; gap: 10px; }
  .ep-menu__icon { width: 16px; height: 16px; }
  .ep-badge { font-size: 9.5px; padding: 2px 6px; }

  .ep-toast-container { left: 12px; right: 12px; bottom: 16px; }
  .ep-toast { min-width: 0; width: 100%; max-width: none; padding: 10px 14px; font-size: 12.5px; }
}

@media (max-width: 360px) {
  .ep-profile-trigger { width: 36px; height: 36px; }
  .ep-avatar--sm { width: 30px; height: 30px; }
  .ep-dropdown { right: 8px; left: 8px; top: 60px; }
}

@supports (padding: env(safe-area-inset-right)) {
  @media (max-width: 768px) {
    .ep-dropdown { right: calc(12px + env(safe-area-inset-right)); left: calc(12px + env(safe-area-inset-left)); }
    .ep-toast-container { left: calc(12px + env(safe-area-inset-left)); right: calc(12px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); }
  }
}

/* 16. REDUCED MOTION & SCROLL LOCK */
@media (prefers-reduced-motion: reduce) {
  .ep-dropdown, .ep-menu__item, .ep-menu__icon, .ep-menu__label, .ep-profile-trigger, .ep-toast, .ep-overlay {
    transition-duration: 0.01ms !important; animation-duration: 0.01ms !important;
  }
}
body.ep-scroll-locked {
    overflow: hidden;
}

