/* Edge Browser Aggressive Layout Fixes */
/* Created by Cuserob - Visual Creation & Interface Design 🎨✨ */
/* More specific fixes for persistent Edge issues */

/* ========================================
   FORCE EDGE TO RESPECT GRID LAYOUTS
   ======================================== */

/* Target Edge specifically with multiple detection methods */
@supports (-ms-ime-align: auto) {
  /* Force proper grid behavior */
  .token-grid,
  .tokens-grid,
  .token-packages-grid,
  #token-packages-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    grid-auto-rows: minmax(400px, auto) !important;
    gap: 2rem !important;
    width: 100% !important;
    max-width: 1400px !important;
    margin: 0 auto !important;
    padding: 0 1rem !important;
    justify-items: stretch !important;
    align-items: start !important;
  }
  
  @media (max-width: 1200px) {
    .token-grid,
    .tokens-grid,
    .token-packages-grid,
    #token-packages-grid {
      grid-template-columns: repeat(2, 1fr) !important;
    }
  }
  
  @media (max-width: 768px) {
    .token-grid,
    .tokens-grid,
    .token-packages-grid,
    #token-packages-grid {
      grid-template-columns: 1fr !important;
    }
  }
}

/* Edge-specific card fixes with -ms- prefixes */
_:-ms-fullscreen, :root .token-card,
_:-ms-fullscreen, :root .token-price-card,
_:-ms-fullscreen, :root .package-card {
  display: -ms-flexbox !important;
  display: flex !important;
  -ms-flex-direction: column !important;
  flex-direction: column !important;
  width: 100% !important;
  min-width: 300px !important;
  max-width: 380px !important;
  height: auto !important;
  min-height: 450px !important;
  max-height: 550px !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  overflow: visible !important;
}

/* Force Edge to respect card content layout */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
  .token-card,
  .token-price-card,
  .package-card {
    /* Reset any conflicting styles */
    position: relative !important;
    float: none !important;
    clear: both !important;
    
    /* Force proper dimensions */
    width: calc(100% - 2rem) !important;
    max-width: 360px !important;
    min-height: 480px !important;
    
    /* Ensure proper spacing */
    padding: 1.5rem !important;
    margin: 1rem !important;
    
    /* Fix flexbox issues */
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
  }
  
  /* Fix card header */
  .token-card .card-header,
  .package-card .card-header {
    flex: 0 0 auto !important;
    margin-bottom: 1rem !important;
  }
  
  /* Fix card body */
  .token-card .card-body,
  .token-card .card-content,
  .package-card .card-content {
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
  }
  
  /* Fix price section */
  .token-card .price-section,
  .package-card .price-section {
    flex: 0 0 auto !important;
    margin-top: auto !important;
    padding-top: 1rem !important;
  }
  
  /* Fix button container */
  .token-card .action-buttons,
  .package-card .purchase-section {
    flex: 0 0 auto !important;
    margin-top: 1rem !important;
  }
}

/* ========================================
   EDGE FLEXBOX FIXES
   ======================================== */

/* Use -ms- prefixes for better Edge support */
@supports (-ms-ime-align: auto) {
  .token-card > * {
    -ms-flex-negative: 0 !important;
    flex-shrink: 0 !important;
  }
  
  .card-content,
  .card-body {
    -ms-flex: 1 1 auto !important;
    flex: 1 1 auto !important;
  }
  
  .price-section {
    -ms-flex-item-align: end !important;
    align-self: flex-end !important;
    width: 100% !important;
  }
}

/* ========================================
   EDGE BADGE POSITIONING FIXES
   ======================================== */

@supports (-ms-ime-align: auto) {
  /* Ensure badges don't affect card dimensions */
  .rarity-badge,
  .discount-badge,
  .benefit-badge {
    position: absolute !important;
    z-index: 20 !important;
  }
  
  .rarity-badge {
    top: -15px !important;
    right: 15px !important;
  }
  
  .discount-badge {
    bottom: 120px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
  }
}

/* ========================================
   EDGE TEXT RENDERING FIXES
   ======================================== */

@supports (-ms-ime-align: auto) {
  /* Fix text overflow in Edge */
  .token-card h3,
  .token-card h4,
  .package-card h3 {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    max-width: 100% !important;
  }
  
  .token-card p,
  .package-card p {
    overflow: hidden !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 3 !important;
    -webkit-box-orient: vertical !important;
    line-height: 1.4 !important;
  }
}

/* ========================================
   EDGE CONTAINER FIXES
   ======================================== */

/* Ensure main container doesn't constrain cards */
@supports (-ms-ime-align: auto) {
  #token-sales-enhanced,
  .tab-content {
    overflow: visible !important;
    min-height: 100vh !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  
  .container,
  .content-wrapper {
    max-width: 100% !important;
    padding: 0 2rem !important;
  }
}

/* ========================================
   NUCLEAR OPTION - EDGE ONLY
   ======================================== */

/* If all else fails, use table layout for Edge */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
  .token-grid.edge-fallback {
    display: table !important;
    width: 100% !important;
    table-layout: fixed !important;
  }
  
  .token-grid.edge-fallback .token-card {
    display: table-cell !important;
    width: 33.333% !important;
    padding: 1rem !important;
    vertical-align: top !important;
  }
}

/* ========================================
   DEBUG HELPERS FOR EDGE
   ======================================== */

/* Add visual indicators in Edge for debugging */
@supports (-ms-ime-align: auto) {
  .edge-debug .token-grid {
    border: 3px solid red !important;
  }
  
  .edge-debug .token-card {
    border: 2px solid blue !important;
  }
  
  .edge-debug .price-section {
    border: 2px solid green !important;
  }
}