/**
 * Elite+ UX Enhancements Styles
 * Keyboard shortcuts, skeletons, celebrations, accessibility
 */

/* ═══════════════════════════════════════════════════════════════════════════
   KEYBOARD SHORTCUTS MODAL
   ═══════════════════════════════════════════════════════════════════════════ */

.shortcuts-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease;
}

.shortcuts-modal {
  background: linear-gradient(135deg, rgba(30, 30, 40, 0.98), rgba(20, 20, 30, 0.98));
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}

.shortcuts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.shortcuts-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: #fff;
}

.shortcuts-header .close-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  transition: all 0.2s;
}

.shortcuts-header .close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.shortcuts-content {
  padding: 20px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
  max-height: 60vh;
  overflow-y: auto;
}

.shortcut-group h3 {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 0 12px;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
}

.shortcut-item kbd {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 0.8rem;
  min-width: 28px;
  text-align: center;
  color: #00f0ff;
}

.shortcut-item span {
  margin-left: auto;
  color: rgba(255, 255, 255, 0.6);
}

/* ═══════════════════════════════════════════════════════════════════════════
   SKELETON LOADING
   ═══════════════════════════════════════════════════════════════════════════ */

.skeleton-loading {
  pointer-events: none;
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.skeleton-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 20px;
  height: 120px;
}

.skeleton-line {
  height: 16px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
  margin-bottom: 12px;
}

.skeleton-line.short {
  width: 60%;
}

.skeleton-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skeleton-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  flex-shrink: 0;
}

.skeleton-avatar.large {
  width: 80px;
  height: 80px;
}

.skeleton-text {
  flex: 1;
}

.skeleton-chart {
  height: 200px;
  display: flex;
  align-items: flex-end;
  padding: 20px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
}

.skeleton-chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  width: 100%;
  height: 100%;
}

.skeleton-bar {
  flex: 1;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px 6px 0 0;
  height: calc(30% + var(--random-height, 40%));
}

.skeleton-bar:nth-child(1) { --random-height: 60%; }
.skeleton-bar:nth-child(2) { --random-height: 30%; }
.skeleton-bar:nth-child(3) { --random-height: 70%; }
.skeleton-bar:nth-child(4) { --random-height: 45%; }
.skeleton-bar:nth-child(5) { --random-height: 55%; }
.skeleton-bar:nth-child(6) { --random-height: 35%; }
.skeleton-bar:nth-child(7) { --random-height: 65%; }

.skeleton-profile {
  text-align: center;
  padding: 30px;
}

.skeleton-profile .skeleton-avatar {
  margin: 0 auto 20px;
}

.skeleton-feed {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.skeleton-post {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 16px;
}

.skeleton-post-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.skeleton-post-body .skeleton-line:last-child {
  margin-bottom: 0;
}

.skeleton-fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   CELEBRATION ANIMATIONS
   ═══════════════════════════════════════════════════════════════════════════ */

.confetti-particle {
  position: fixed;
  width: 10px;
  height: 10px;
  background: var(--color);
  pointer-events: none;
  z-index: 10001;
  animation: confetti 3s ease-out forwards;
  transform-origin: center;
}

@keyframes confetti {
  0% {
    opacity: 1;
    transform: translateY(0) translateX(0) rotate(0deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(var(--y)) translateX(var(--x)) rotate(var(--r)) scale(0);
  }
}

.achievement-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: linear-gradient(135deg, rgba(30, 30, 40, 0.98), rgba(20, 20, 30, 0.98));
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 16px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 10002;
  box-shadow: 
    0 10px 40px rgba(0, 0, 0, 0.4),
    0 0 40px rgba(255, 215, 0, 0.2);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.achievement-toast.show {
  transform: translateX(-50%) translateY(0);
}

.achievement-icon {
  font-size: 2.5rem;
  animation: bounce 0.6s ease-in-out infinite alternate;
}

@keyframes bounce {
  0% { transform: translateY(0); }
  100% { transform: translateY(-5px); }
}

.achievement-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.achievement-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #ffd700;
  font-weight: 600;
}

.achievement-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}

.achievement-desc {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
}

.achievement-shine {
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transform: translateX(-100%);
  animation: shine 2s ease-in-out infinite;
  will-change: transform;
}

@keyframes shine {
  0%, 100% { transform: translateX(-200%); }
  50% { transform: translateX(300%); }
}

/* Level Up Overlay */
.level-up-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10003;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.level-up-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.level-up-content {
  text-align: center;
  transform: scale(0.5);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.level-up-overlay.show .level-up-content {
  transform: scale(1);
}

.level-up-badge {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd700, #ff8c00);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  box-shadow: 
    0 0 60px rgba(255, 215, 0, 0.5),
    0 0 120px rgba(255, 140, 0, 0.3);
  animation: levelPulse 1s ease-in-out infinite;
}

@keyframes levelPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 60px rgba(255, 215, 0, 0.5); }
  50% { transform: scale(1.05); box-shadow: 0 0 80px rgba(255, 215, 0, 0.7); }
}

.level-up-number {
  font-size: 4rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
}

.level-up-text {
  font-size: 2rem;
  font-weight: 700;
  color: #ffd700;
  text-transform: uppercase;
  letter-spacing: 4px;
  animation: textGlow 1s ease-in-out infinite alternate;
}

@keyframes textGlow {
  0% { text-shadow: 0 0 20px rgba(255, 215, 0, 0.5); }
  100% { text-shadow: 0 0 40px rgba(255, 215, 0, 0.8); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ENHANCED TOOLTIPS
   ═══════════════════════════════════════════════════════════════════════════ */

.elite-tooltip {
  position: fixed;
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10000;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s, transform 0.15s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.elite-tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

.elite-tooltip::after {
  content: '';
  position: absolute;
  border: 6px solid transparent;
}

.elite-tooltip.top::after {
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-top-color: rgba(0, 0, 0, 0.9);
}

.elite-tooltip.bottom::after {
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-bottom-color: rgba(0, 0, 0, 0.9);
}

.elite-tooltip.left::after {
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  border-left-color: rgba(0, 0, 0, 0.9);
}

.elite-tooltip.right::after {
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border-right-color: rgba(0, 0, 0, 0.9);
}

/* ═══════════════════════════════════════════════════════════════════════════
   ACCESSIBILITY
   ═══════════════════════════════════════════════════════════════════════════ */

.skip-link {
  position: fixed;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: #00f0ff;
  color: #000;
  padding: 12px 24px;
  border-radius: 0 0 8px 8px;
  font-weight: 600;
  z-index: 100000;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus visible styles */
:focus-visible {
  outline: 2px solid #00f0ff;
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #00f0ff;
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .confetti-particle,
  .achievement-toast,
  .level-up-overlay {
    animation: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ERROR TOASTS
   ═══════════════════════════════════════════════════════════════════════════ */

.error-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(30, 30, 40, 0.98);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 10000;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 90%;
}

.error-toast.show {
  transform: translateX(-50%) translateY(0);
}

.error-toast.error {
  border-color: rgba(239, 68, 68, 0.3);
}

.error-toast.warning {
  border-color: rgba(245, 158, 11, 0.3);
}

.error-toast.info {
  border-color: rgba(59, 130, 246, 0.3);
}

.error-toast.success {
  border-color: rgba(34, 197, 94, 0.3);
}

.error-icon {
  font-size: 1.25rem;
}

.error-message {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9rem;
}

.error-action {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.error-action:hover {
  background: rgba(255, 255, 255, 0.2);
}

.error-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0 0 0 8px;
  line-height: 1;
}

.error-close:hover {
  color: #fff;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PAGE TRANSITIONS
   ═══════════════════════════════════════════════════════════════════════════ */

.page-enter {
  opacity: 0;
  transform: translateY(10px);
}

.page-enter-active {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.3s, transform 0.3s;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PULL TO REFRESH
   ═══════════════════════════════════════════════════════════════════════════ */

.pull-refresh-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-60px);
  width: 40px;
  height: 40px;
  background: rgba(30, 30, 40, 0.95);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.2s;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.pull-refresh-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #00f0ff;
  border-radius: 50%;
}

.pull-refresh-indicator.ready .pull-refresh-spinner {
  border-top-color: #22c55e;
}

.pull-refresh-indicator.refreshing .pull-refresh-spinner {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   UTILITY ANIMATIONS
   ═══════════════════════════════════════════════════════════════════════════ */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { 
    opacity: 0;
    transform: translateY(20px);
  }
  to { 
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideDown {
  from { 
    opacity: 0;
    transform: translateY(-20px);
  }
  to { 
    opacity: 1;
    transform: translateY(0);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   LAZY LOADING
   ═══════════════════════════════════════════════════════════════════════════ */

img[data-src] {
  opacity: 0;
  transition: opacity 0.3s;
}

img.loaded {
  opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SMOOTH SCROLLBAR (Webkit)
   ═══════════════════════════════════════════════════════════════════════════ */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) rgba(255, 255, 255, 0.05);
}
