/* Ad Card Styling - matches base card styling */
.ad-card {
  background: linear-gradient(145deg, #1a1a2e, #16213e);
  border: 2px solid rgba(0, 210, 255, 0.3);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  margin-bottom: 20px;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.35s cubic-bezier(0.2, 1, 0.3, 1);
  height: auto;
  min-height: 200px;
  position: relative;
  padding: 0;
  animation: fadeIn 0.5s ease-in-out;
}

/* History tab ad styling - matches history card styling */
#history-list .ad-card {
  background: linear-gradient(145deg, #3d2f1f 0%, #2a1810 50%, #1f1207 100%);
  border: 3px solid #8b6914;
  box-shadow: 
    0 4px 15px rgba(0, 0, 0, 0.4),
    0 0 20px rgba(139, 105, 20, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

#history-list .ad-card:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 8px 25px rgba(0, 0, 0, 0.5),
    0 0 30px rgba(139, 105, 20, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* History ad label styling */
#history-list .ad-label {
  color: #8b6914;
}

.ad-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 255, 255, 0.1), 0 0 15px rgba(0, 210, 255, 0.2);
}

.ad-content {
  padding: 15px;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.ad-label {
  color: #888;
  font-size: 0.8em;
  text-align: center;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.7;
}

/* AdSense container styling */
.ad-card .adsbygoogle {
  display: block !important;
  min-height: 150px;
  flex: 1;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Mobile Responsive adjustments - match mobile card layout */
@media screen and (max-width: 768px) and (orientation: portrait) {
  .ad-card {
    /* Match mobile card layout exactly */
    margin: 5px auto !important;
    width: 98% !important;
    min-width: 98% !important;
    max-width: 98% !important;
    padding: 7px 8px !important;
    border-radius: 5px !important;
    min-height: 140px !important;
    max-height: none !important; /* Allow ads to expand naturally */
    height: auto !important; /* Changed from fixed 140px to auto */
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important; /* Changed from center to stretch */
    box-sizing: border-box !important;
    position: relative !important; /* Add position context */
    contain: layout !important; /* Improve rendering performance */
    
    /* Keep ad-specific styling */
    background: linear-gradient(145deg, #1a1a2e, #16213e);
    border: 2px solid rgba(0, 210, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  }
  
  /* History list ads on mobile match history card styling */
  #history-list .ad-card {
    background: linear-gradient(145deg, #3d2f1f 0%, #2a1810 50%, #1f1207 100%) !important;
    border: 3px solid #8b6914 !important;
    box-shadow: 
      0 4px 15px rgba(0, 0, 0, 0.4),
      0 0 20px rgba(139, 105, 20, 0.2),
      inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
  }
  
  /* History ad label on mobile */
  #history-list .ad-label {
    color: rgba(139, 105, 20, 0.8) !important;
    background: rgba(139, 105, 20, 0.1) !important;
    border: 1px solid rgba(139, 105, 20, 0.2) !important;
  }
  
  .ad-content {
    padding: 0 !important;
    height: auto !important; /* Changed from 100% to auto */
    min-height: 120px !important; /* Add minimum height */
    width: 100% !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important; /* Changed from center to stretch */
    gap: 12px !important;
    box-sizing: border-box !important;
    position: relative !important;
  }
  
  .ad-label {
    /* Create a side label that matches mobile card image area */
    writing-mode: vertical-rl;
    text-orientation: mixed;
    width: 60px !important;
    min-height: 120px !important; /* Changed from fixed height to min-height */
    height: auto !important; /* Allow to grow with content */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(0, 210, 255, 0.1) !important;
    border-radius: 3px !important;
    border: 1px solid rgba(0, 210, 255, 0.2) !important;
    font-size: 10px !important;
    letter-spacing: 1px !important;
    text-transform: uppercase !important;
    color: rgba(0, 210, 255, 0.8) !important;
    flex-shrink: 0 !important;
    margin-bottom: 0 !important;
    margin-right: 12px !important;
  }
  
  /* AdSense container - takes remaining space like mobile card content */
  .ad-card .adsbygoogle {
    flex: 1 !important;
    min-height: 120px !important;
    max-height: none !important; /* Remove max-height constraint */
    height: auto !important; /* Changed from fixed 120px to auto */
    background: rgba(255, 255, 255, 0.02) !important;
    border-radius: 8px !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    overflow: hidden !important;
    display: block !important;
    position: relative !important;
    contain: layout !important; /* Improve rendering */
    width: 100% !important; /* Ensure full width within flex container */
  }
}

/* Additional mobile-mode class support */
body.mobile-mode .ad-card {
  /* Match mobile card layout exactly when mobile-mode class is active */
  margin: 5px auto !important;
  width: 98% !important;
  min-width: 98% !important;
  max-width: 98% !important;
  padding: 7px 8px !important;
  border-radius: 5px !important;
  min-height: 140px !important;
  max-height: none !important; /* Allow ads to expand naturally */
  height: auto !important; /* Changed from fixed 140px to auto */
  display: flex !important;
  flex-direction: row !important;
  align-items: stretch !important; /* Changed from center to stretch */
  box-sizing: border-box !important;
  position: relative !important;
  contain: layout !important; /* Improve rendering performance */
  
  /* Keep ad-specific styling */
  background: linear-gradient(145deg, #1a1a2e, #16213e);
  border: 2px solid rgba(0, 210, 255, 0.3);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* History list ads with mobile-mode class */
body.mobile-mode #history-list .ad-card {
  background: linear-gradient(145deg, #3d2f1f 0%, #2a1810 50%, #1f1207 100%) !important;
  border: 3px solid #8b6914 !important;
  box-shadow: 
    0 4px 15px rgba(0, 0, 0, 0.4),
    0 0 20px rgba(139, 105, 20, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
}

/* History ad label with mobile-mode class */
body.mobile-mode #history-list .ad-label {
  color: rgba(139, 105, 20, 0.8) !important;
  background: rgba(139, 105, 20, 0.1) !important;
  border: 1px solid rgba(139, 105, 20, 0.2) !important;
}

body.mobile-mode .ad-content {
  padding: 0 !important;
  height: auto !important; /* Changed from 100% to auto */
  min-height: 120px !important;
  width: 100% !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: stretch !important; /* Changed from center to stretch */
  gap: 12px !important;
  box-sizing: border-box !important;
  position: relative !important;
}

body.mobile-mode .ad-label {
  /* Create a side label that matches mobile card image area */
  writing-mode: vertical-rl;
  text-orientation: mixed;
  width: 60px !important;
  min-height: 120px !important; /* Changed from fixed height to min-height */
  height: auto !important; /* Allow to grow with content */
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: rgba(0, 210, 255, 0.1) !important;
  border-radius: 3px !important;
  border: 1px solid rgba(0, 210, 255, 0.2) !important;
  font-size: 10px !important;
  letter-spacing: 1px !important;
  text-transform: uppercase !important;
  color: rgba(0, 210, 255, 0.8) !important;
  flex-shrink: 0 !important;
  margin-bottom: 0 !important;
  margin-right: 12px !important;
}

body.mobile-mode .ad-card .adsbygoogle {
  flex: 1 !important;
  min-height: 120px !important;
  max-height: none !important; /* Remove max-height constraint */
  height: auto !important; /* Changed from fixed 120px to auto */
  background: rgba(255, 255, 255, 0.02) !important;
  border-radius: 8px !important;
  border: 1px solid rgba(255, 255, 255, 0.05) !important;
  overflow: hidden !important;
  display: block !important;
  position: relative !important;
  contain: layout !important; /* Improve rendering */
  width: 100% !important; /* Ensure full width within flex container */
}

/* Ensure ads are properly sized and visible */
.ad-card .adsbygoogle[data-adsbygoogle-status="filled"] {
  min-height: auto;
}

/* Prevent ads from using fixed positioning on mobile */
@media screen and (max-width: 768px) and (orientation: portrait) {
  .ad-card .adsbygoogle,
  .ad-card .adsbygoogle * {
    position: relative !important; /* Force relative positioning */
    transform: none !important; /* Prevent any transforms */
  }
}

body.mobile-mode .ad-card .adsbygoogle,
body.mobile-mode .ad-card .adsbygoogle * {
  position: relative !important; /* Force relative positioning */
  transform: none !important; /* Prevent any transforms */
}

/* Style for when ads are loading */
.ad-card .adsbygoogle:not([data-adsbygoogle-status]) {
  position: relative;
  min-height: 150px;
}

.ad-card .adsbygoogle:not([data-adsbygoogle-status])::before {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #666;
  font-size: 0.9em;
}

/* Style for unfilled ads */
.ad-card .adsbygoogle[data-adsbygoogle-status="unfilled"] {
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  position: relative;
  min-height: 150px;
}

.ad-card .adsbygoogle[data-adsbygoogle-status="unfilled"]::before {
  content: 'No ad available';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #666;
  font-size: 0.9em;
}

/* Mobile loading and unfilled states */
@media screen and (max-width: 768px) and (orientation: portrait) {
  .ad-card .adsbygoogle:not([data-adsbygoogle-status])::before,
  .ad-card .adsbygoogle[data-adsbygoogle-status="unfilled"]::before {
    font-size: 12px !important;
    color: #888 !important;
  }
}

body.mobile-mode .ad-card .adsbygoogle:not([data-adsbygoogle-status])::before,
body.mobile-mode .ad-card .adsbygoogle[data-adsbygoogle-status="unfilled"]::before {
  font-size: 12px !important;
  color: #888 !important;
}

/* Animation for fade in */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}