/* Mobile-Optimized Social Feed Styles */

/* Base mobile class */
.social-feed-mobile {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: pan-y;
}

/* Mobile Tab Bar */
.mobile-tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: #202225;
  display: none;
  justify-content: space-around;
  align-items: center;
  border-top: 1px solid #40444b;
  z-index: 1000;
  padding-bottom: env(safe-area-inset-bottom);
}

.social-feed-mobile .mobile-tab-bar {
  display: flex;
}

.mobile-tab-button {
  flex: 1;
  height: 100%;
  background: none;
  border: none;
  color: #b9bbbe;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  padding: 8px;
}

.mobile-tab-button.active {
  color: #fff;
}

.mobile-tab-button.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 3px;
  background: #5865f2;
  border-radius: 0 0 3px 3px;
}

.mobile-tab-button:active {
  transform: scale(0.95);
}

.tab-icon {
  font-size: 20px;
  line-height: 1;
}

.tab-label {
  font-size: 11px;
  font-weight: 500;
}

/* Touch-friendly sizing */
@media (max-width: 768px) {
  /* Increase touch targets to 44x44 minimum */
  .discord-message {
    min-height: 60px;
    padding: 12px 16px;
  }

  .message-actions button,
  .reaction,
  .add-reaction-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
  }

  .channel-item {
    min-height: 48px;
    padding: 12px 16px;
  }

  .online-user {
    min-height: 52px;
    padding: 8px 12px;
  }

  /* Larger input areas */
  .message-input {
    min-height: 48px;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px 16px;
  }

  /* Bigger buttons */
  .send-btn,
  .emoji-btn {
    width: 48px;
    height: 48px;
  }

  /* Marketplace cards */
  .marketplace-card {
    padding: 16px;
    margin-bottom: 16px;
  }

  .contact-btn {
    min-height: 48px;
    font-size: 16px;
    font-weight: 600;
  }
}

/* Mobile FAB (Floating Action Button) */
.mobile-fab {
  position: fixed;
  bottom: 76px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #5865f2;
  color: white;
  border: none;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(88, 101, 242, 0.4);
  cursor: pointer;
  z-index: 999;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: none;
  padding-bottom: env(safe-area-inset-bottom);
}

.social-feed-mobile .mobile-fab {
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-fab:active {
  transform: scale(0.9);
  box-shadow: 0 2px 8px rgba(88, 101, 242, 0.3);
}

/* Pull to Refresh */
.mobile-refresh-indicator {
  position: absolute;
  top: -60px;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b9bbbe;
  font-size: 14px;
  transition: transform 0.3s ease;
}

.mobile-refresh-indicator.pulling {
  transform: translateY(60px);
}

.mobile-refresh-indicator.refreshing {
  transform: translateY(60px);
}

.refresh-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #5865f2;
  border-top-color: transparent;
  border-radius: 50%;
  margin-right: 8px;
  animation: spin 0.8s linear infinite;
}

/* Swipe hint */
.mobile-swipe-hint {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 16px 24px;
  border-radius: 12px;
  font-size: 16px;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.mobile-swipe-hint.show {
  opacity: 1;
}

.hint-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hint-icon {
  font-size: 24px;
  animation: swipeHint 1s ease-in-out infinite;
}

@keyframes swipeHint {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(10px); }
}

/* Mobile tab container for swipe */
.mobile-tab-container {
  display: flex;
  width: 300%;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.mobile-tab-content {
  width: 33.333%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Scroll indicators */
.mobile-scroll-indicator {
  position: absolute;
  right: 2px;
  top: 0;
  width: 4px;
  background: rgba(88, 101, 242, 0.5);
  border-radius: 2px;
  transition: opacity 0.3s ease;
  opacity: 0;
}

.mobile-scroll-indicator:active {
  opacity: 1;
}

/* Message options menu */
.mobile-message-options {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mobile-message-options.show {
  opacity: 1;
}

.mobile-message-options.show .options-menu {
  transform: translateY(0);
}

.options-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
}

.options-menu {
  position: relative;
  background: #2f3136;
  border-radius: 16px 16px 0 0;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  width: 100%;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.option-item {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 16px;
  background: none;
  border: none;
  color: #dcddde;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.option-item:active {
  background: rgba(79, 84, 92, 0.4);
}

.option-icon {
  font-size: 20px;
}

/* Quick actions grid */
.mobile-quick-actions {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mobile-quick-actions.show {
  opacity: 1;
}

.mobile-quick-actions.show .actions-grid {
  transform: scale(1);
}

.actions-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
}

.actions-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 20px;
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.action-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  background: #2f3136;
  border: none;
  border-radius: 16px;
  color: #dcddde;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-item:active {
  transform: scale(0.95);
  background: #40444b;
}

.action-icon {
  font-size: 32px;
}

.action-label {
  font-size: 14px;
  font-weight: 500;
}

/* Reaction animation */
.mobile-reaction-animation {
  position: fixed;
  font-size: 32px;
  animation: floatUp 1s ease-out forwards;
  pointer-events: none;
  z-index: 10000;
}

@keyframes floatUp {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.2);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -150%) scale(0.8);
    opacity: 0;
  }
}

/* Toast notifications */
.mobile-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 10001;
  opacity: 0;
  transition: all 0.3s ease;
}

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

/* Landscape optimizations */
@media (orientation: landscape) and (max-width: 896px) {
  .discord-container {
    flex-direction: row;
  }

  .discord-sidebar {
    width: 200px;
    max-height: none;
  }

  .mobile-tab-bar {
    left: 200px;
    width: auto;
  }

  .messages-container {
    padding-bottom: 60px;
  }
}

/* Reduced motion */
.reduce-motion * {
  animation-duration: 0.001ms !important;
  transition-duration: 0.001ms !important;
}

/* iOS safe areas */
@supports (padding: max(0px)) {
  .mobile-tab-bar {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .mobile-fab {
    bottom: max(76px, calc(56px + env(safe-area-inset-bottom)));
  }

  .message-input-container {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Improved touch feedback */
@media (hover: none) and (pointer: coarse) {
  .channel-item:active,
  .online-user:active,
  .marketplace-card:active {
    background-color: rgba(79, 84, 92, 0.4);
  }

  /* Remove hover effects on touch devices */
  .discord-message:hover {
    background-color: transparent;
  }

  /* Active states for buttons */
  button:active {
    opacity: 0.8;
  }
}

/* Performance optimizations */
.social-feed-mobile .discord-message {
  will-change: auto;
}

.social-feed-mobile .messages-container {
  contain: layout style paint;
}

/* Skeleton loading for better perceived performance */
.message-skeleton {
  display: flex;
  padding: 12px 16px;
  gap: 12px;
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(90deg, #40444b 25%, #4f545c 50%, #40444b 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.skeleton-content {
  flex: 1;
}

.skeleton-line {
  height: 14px;
  background: linear-gradient(90deg, #40444b 25%, #4f545c 50%, #40444b 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 7px;
  margin-bottom: 8px;
}

.skeleton-line:last-child {
  width: 60%;
}

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

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* Dark mode adjustments for mobile */
@media (prefers-color-scheme: dark) {
  .mobile-fab {
    background: #5865f2;
  }

  .mobile-toast {
    background: rgba(0, 0, 0, 0.9);
  }
}

/* Thumb-friendly positioning */
@media (max-width: 768px) {
  /* Move important actions to bottom */
  .message-input-container {
    padding: 8px;
    background: #40444b;
    border-top: 1px solid #202225;
  }

  /* Ensure content doesn't go under tab bar */
  .discord-main {
    padding-bottom: 56px;
  }

  /* Optimize spacing */
  .discord-message {
    margin-top: 8px;
  }

  /* Larger emoji picker */
  .emoji-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    padding: 12px;
  }

  .emoji-option {
    font-size: 24px;
    padding: 8px;
  }
}