/* ============================================
   ACTIONS VIEW - RESPONSIVE LAYOUTS
   iOS-style vertical on mobile, card table on desktop
   ============================================ */

/* ============================================
   BASE - Mobile First (< 768px)
   iOS-style vertical stack
   ============================================ */

#actions-view .view-content {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Mobile: Ensure content isn't cut off at bottom */
@media (max-width: 768px) {
  /* Override app-container grey background when actions view is active */
  #actions-view.active ~ #main-app,
  #actions-view.active,
  #main-app:has(#actions-view.active) {
    background: var(--brokerly-background) !important;
  }
  
  #actions-view {
    padding-bottom: 0 !important;
    background: transparent !important;
  }
  
  #actions-view .view-content {
    padding: 0 !important;
    padding-bottom: 0 !important;
    background: transparent !important;
    min-height: 100vh;
  }
  
  #actions-view .filters-section {
    margin: 0;
    width: 100%;
  }
  
  #actions-view .actions-container {
    padding: 16px;
    padding-bottom: calc(var(--tab-height, 80px) + env(safe-area-inset-bottom, 0px) + 120px) !important;
    min-height: 100vh; /* Fill entire viewport height */
  }
}

#actions-view .filters-section {
  padding: 16px 16px 16px 16px; /* Added top padding for mobile */
  border-bottom: none;
  background: var(--brokerly-background);
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
}

#actions-view .actions-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  padding-bottom: calc(16px + 20px); /* Extra padding at bottom for mobile */
  width: 100%;
  background: var(--brokerly-background); /* Ensure background extends with content */
}

#actions-view .action-card {
  width: 100%;
  min-height: 180px;
  height: 180px; /* Mobile: horizontal card */
  background: var(--modern-card-background);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border: none;
  transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Card Content Layout */
#actions-view .action-card .card-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#actions-view .action-card .card-header {
  flex: 0 0 auto;
}

#actions-view .action-card .card-footer {
  flex: 0 0 auto;
  margin-top: auto;
}

#actions-view .action-card .action-title {
  font-size: 18px;
  font-weight: 600;
  margin: 8px 0 6px 0;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

#actions-view .action-card .action-description {
  font-size: 14px;
  font-weight: 400;
  margin: 0;
  line-height: 1.4;
  opacity: 0.85;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

#actions-view .action-card:active {
  transform: scale(0.98);
  opacity: 0.9;
}

/* Card Colors - Priority Gradients */
#actions-view .action-card.urgent {
  background: linear-gradient(135deg,
    #E66152 0%,
    #FF6F61 25%,
    #F26859 50%,
    #D9594A 100%
  );
  color: white;
  position: relative;
  overflow: hidden;
}

/* Red card shimmer effect (once on hover) */
#actions-view .action-card.urgent::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 70%
  );
  opacity: 0;
  pointer-events: none;
}

#actions-view .action-card.urgent:hover::before {
  animation: shimmerOnce 0.6s ease-out forwards;
}

/* Embossed text for urgent cards */
#actions-view .action-card.urgent .card-title.embossed {
  text-shadow: 
    1px 1px 0 rgba(0, 0, 0, 0.4),
    -1px -1px 0 rgba(255, 255, 255, 0.8);
}

#actions-view .action-card.urgent .card-inner {
  position: relative;
  z-index: 1;
}

#actions-view .action-card.high {
  background: linear-gradient(135deg,
    #D9A621 0%,
    #FFD700 25%,
    #D9A621 50%,
    #B87A0A 100%
  );
  color: white;
  position: relative;
  overflow: hidden;
}

/* Gold card shimmer effect (once on hover) */
#actions-view .action-card.high::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 70%
  );
  opacity: 0;
  pointer-events: none;
}

#actions-view .action-card.high:hover::before {
  animation: shimmerOnce 0.6s ease-out forwards;
}

/* Shimmer animation - plays once on hover with zero latency */
@keyframes shimmerOnce {
  0% {
    opacity: 0;
    transform: translateX(-100%) translateY(-100%) rotate(45deg);
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(100%) translateY(100%) rotate(45deg);
  }
}

/* Ensure content is above shimmer */
#actions-view .action-card.high .card-inner {
  position: relative;
  z-index: 1;
}

/* Embossed text for gold cards */
#actions-view .action-card.high .card-title.embossed {
  text-shadow: 
    1px 1px 0 rgba(0, 0, 0, 0.4),
    -1px -1px 0 rgba(255, 255, 255, 0.8);
}

#actions-view .action-card.medium {
  background: linear-gradient(135deg,
    #3DB063 0%,
    #50C878 25%,
    #47BD6E 50%,
    #33A358 100%
  );
  color: white;
  position: relative;
  overflow: hidden;
}

/* Green card shimmer effect (once on hover) */
#actions-view .action-card.medium::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 70%
  );
  opacity: 0;
  pointer-events: none;
}

#actions-view .action-card.medium:hover::before {
  animation: shimmerOnce 0.6s ease-out forwards;
}

/* Embossed text for medium cards */
#actions-view .action-card.medium .card-title.embossed {
  text-shadow: 
    1px 1px 0 rgba(0, 0, 0, 0.4),
    -1px -1px 0 rgba(255, 255, 255, 0.8);
}

#actions-view .action-card.medium .card-inner {
  position: relative;
  z-index: 1;
}

#actions-view .action-card.mediumLow {
  background: linear-gradient(135deg,
    #0099D8 0%,
    #00B4D8 25%,
    #00A8CC 50%,
    #0088BB 100%
  );
  color: white;
  position: relative;
  overflow: hidden;
}

/* Blue card shimmer effect (once on hover) */
#actions-view .action-card.mediumLow::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 70%
  );
  opacity: 0;
  pointer-events: none;
}

#actions-view .action-card.mediumLow:hover::before {
  animation: shimmerOnce 0.6s ease-out forwards;
}

#actions-view .action-card.mediumLow .card-inner {
  position: relative;
  z-index: 1;
}

#actions-view .action-card.low {
  background: linear-gradient(135deg,
    #F5F5F7 0%,
    #FFFFFF 25%,
    #FAFAFA 50%,
    #F0F0F2 100%
  );
  color: var(--brokerly-text-primary);
  position: relative;
  overflow: hidden;
  border: 1px solid #E5E7EB;
  box-shadow: 
    0 8px 15px rgba(0, 0, 0, 0.08),
    0 4px 6px rgba(0, 0, 0, 0.04);
}

/* White card shimmer effect (more subtle, once on hover) */
#actions-view .action-card.low::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(0, 0, 0, 0.03) 50%,
    transparent 70%
  );
  opacity: 0;
  pointer-events: none;
}

#actions-view .action-card.low:hover::before {
  animation: shimmerOnce 0.6s ease-out forwards;
}

#actions-view .action-card.low .card-inner {
  position: relative;
  z-index: 1;
}

/* Card Inner Styling - matching discover view */
#actions-view .card-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 20px;
  color: white; /* Default text color for colored cards */
  background: transparent !important; /* ALWAYS transparent - gradient on parent only */
  box-shadow: none !important; /* Remove inner shadow */
  border: none !important; /* No border on inner */
}

/* Override ALL text colors for low priority (white) cards */
#actions-view .action-card.low .card-inner {
  color: #2C3E50 !important; /* Stylish dark gray instead of black */
}

/* Ensure all text elements on white cards are dark grey - override everything except badges and savings */
#actions-view .action-card.low .card-inner *:not(.category-badge):not(.savings-amount):not(.currency):not(.amount) {
  color: #2C3E50 !important;
}

/* Force white text only for category badge on white cards */
#actions-view .action-card.low .category-badge {
  color: white !important;
}

/* Override the priority badge specifically */
#actions-view .action-card.low .priority-badge,
#actions-view .action-card.low .priority-badge * {
  color: #2C3E50 !important;
}

#actions-view .card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

#actions-view .category-badge {
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: white;
  background: linear-gradient(135deg, #737376, #8C8C8E);
  padding: 6px 12px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(115, 115, 118, 0.3);
}

/* Dark category badge background for white cards */
#actions-view .action-card.low .category-badge {
  background: linear-gradient(135deg, #5A6C7D, #738491);
}

#actions-view .priority-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 12px;
  backdrop-filter: blur(10px);
  color: white;
}

/* Darker priority badge text for white cards */
#actions-view .action-card.low .priority-badge {
  color: #2C3E50 !important;
}

#actions-view .action-card.low .priority-badge span {
  color: #2C3E50 !important;
}

#actions-view .savings-display {
  text-align: right;
  margin: 12px 0;
}

#actions-view .savings-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  color: rgba(255, 255, 255, 0.8);
}

#actions-view .savings-amount {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  font-size: 32px;
  font-weight: 900;
  color: white;
  text-shadow: 
    1px 1px 0 rgba(0, 0, 0, 0.4),
    -1px -1px 0 rgba(255, 255, 255, 0.8);
}

#actions-view .savings-amount .currency {
  font-size: 0.8em;
}

/* Low priority card savings (stylish dark gray) */
#actions-view .action-card.low .savings-label {
  color: #5A6C7D !important;
  opacity: 0.85;
}

#actions-view .action-card.low .savings-amount {
  color: #50C878 !important;
  text-shadow: none;
}

#actions-view .action-card.low .savings-amount .currency,
#actions-view .action-card.low .savings-amount .amount {
  color: #50C878 !important;
}

#actions-view .card-divider {
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3) 10%,
    rgba(255, 255, 255, 0.4) 50%,
    rgba(255, 255, 255, 0.3) 90%,
    transparent
  );
  margin: 16px 0;
}

#actions-view .action-card.low .card-divider {
  background: linear-gradient(
    90deg,
    transparent,
    rgba(44, 62, 80, 0.15) 10%,
    rgba(44, 62, 80, 0.2) 50%,
    rgba(44, 62, 80, 0.15) 90%,
    transparent
  );
}

#actions-view .card-title {
  font-size: 18px;
  font-weight: 700;
  color: white;
  margin: 12px 0;
  line-height: 1.3;
}

#actions-view .action-card.low .card-title {
  color: #2C3E50 !important; /* Stylish dark gray */
}

#actions-view .card-description-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#actions-view .card-description {
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.5;
}

#actions-view .action-card.low .card-description {
  color: #445566 !important; /* Stylish medium-dark gray */
}

#actions-view .time-to-complete {
  text-align: right;
}

#actions-view .time-label {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 1.0px;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 2px;
}

#actions-view .action-card.low .time-label {
  color: #5A6C7D !important; /* Stylish gray for labels */
  opacity: 0.85;
}

#actions-view .time-value {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.95);
}

#actions-view .action-card.low .time-value {
  color: #2C3E50 !important; /* Stylish dark gray */
}

#actions-view .card-spacer {
  flex: 1;
}

/* Removed obsolete .colored class rules - now using priority classes directly */

/* ============================================
   TABLET (768px - 1023px)
   2-column card grid
   ============================================ */
@media (min-width: 768px) and (max-width: 1023px) {
  #actions-view .view-content {
    max-width: 100%;
    padding: 0;
  }

  /* Match Overview header layout */
  #actions-view .view-header {
    max-width: 800px;
    margin: 0 auto;
    padding: 16px 24px;
  }
  
  #actions-view .filters-section {
    padding: 0 24px 16px 24px;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
  }

  #actions-view .actions-container {
    display: grid;
    grid-template-columns: repeat(3, 240px); /* Fixed 3-column layout */
    gap: 20px;
    padding: 24px;
    max-width: 800px;
    margin: 0 auto;
    justify-content: center; /* Center cards */
  }

  #actions-view .action-card {
    width: 240px; /* Fixed Pokémon card width */
    height: 336px; /* Pokémon ratio 1.4 (240 × 1.4 = 336) */
    min-height: 336px;
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  }

  #actions-view .action-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 5;
  }
}

/* ============================================
   DESKTOP (1024px - 1439px)
   Card table layout - Masonry grid
   ============================================ */
@media (min-width: 1024px) and (max-width: 1439px) {
  #actions-view .view-content {
    max-width: 100%;
    padding: 0;
  }

  #actions-view .filters-section {
    padding: 0 32px 20px 32px;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
  }

  /* Match Overview header layout */
  #actions-view .view-header {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 32px;
  }
  
  #actions-view .filters-section {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
  }
  
  #actions-view .actions-container {
    display: grid;
    grid-template-columns: repeat(3, 260px); /* Fixed 3-column layout */
    gap: 24px;
    padding: 32px;
    max-width: 900px;
    margin: 0 auto;
    align-items: start;
    justify-content: center;
  }

  #actions-view .action-card {
    width: 260px; /* Fixed Pokémon card width */
    height: 364px; /* Pokémon ratio 1.4 (260 × 1.4 = 364) */
    min-height: 364px;
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    /* Slightly randomized positioning for card table effect */
  }

  #actions-view .action-card:hover {
    transform: translateY(-6px) scale(1.03) rotate(0.5deg);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
    z-index: 10;
  }

  /* Alternating slight rotations for card table effect */
  #actions-view .action-card:nth-child(3n+1) {
    transform: rotate(-0.5deg);
  }

  #actions-view .action-card:nth-child(3n+2) {
    transform: rotate(0.3deg);
  }

  #actions-view .action-card:nth-child(3n+3) {
    transform: rotate(-0.3deg);
  }

  #actions-view .action-card:hover {
    transform: translateY(-6px) scale(1.03) rotate(0deg) !important;
  }
}

/* ============================================
   LARGE DESKTOP (≥ 1440px)
   Expanded card table layout
   ============================================ */
@media (min-width: 1440px) {
  #actions-view .view-content {
    max-width: 100%;
    padding: 0;
  }

  /* Match Overview header layout */
  #actions-view .view-header {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px 48px;
  }
  
  #actions-view .filters-section {
    padding: 0 48px 24px 48px;
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
  }

  #actions-view .actions-container {
    display: grid;
    grid-template-columns: repeat(3, 280px); /* Fixed 3-column layout */
    gap: 28px;
    padding: 48px;
    max-width: 1000px;
    margin: 0 auto;
    align-items: start;
    justify-content: center;
  }

  #actions-view .action-card {
    width: 280px; /* Fixed Pokémon card width */
    height: 392px; /* Pokémon ratio 1.4 (280 × 1.4 = 392) */
    min-height: 392px;
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  }

  #actions-view .action-card:hover {
    transform: translateY(-8px) scale(1.04) rotate(0deg);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
    z-index: 10;
  }

  /* More pronounced card table effect */
  #actions-view .action-card:nth-child(5n+1) {
    transform: rotate(-0.7deg);
  }

  #actions-view .action-card:nth-child(5n+2) {
    transform: rotate(0.5deg);
  }

  #actions-view .action-card:nth-child(5n+3) {
    transform: rotate(-0.4deg);
  }

  #actions-view .action-card:nth-child(5n+4) {
    transform: rotate(0.6deg);
  }

  #actions-view .action-card:nth-child(5n+5) {
    transform: rotate(-0.3deg);
  }

  #actions-view .action-card:hover {
    transform: translateY(-8px) scale(1.04) rotate(0deg) !important;
  }
}

/* ============================================
   ULTRA-WIDE (≥ 1920px)
   Maximum card table spread
   ============================================ */
@media (min-width: 1920px) {
  /* Match Overview header layout */
  #actions-view .view-header {
    max-width: 1100px;
    margin: 0 auto;
  }
  
  #actions-view .filters-section {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
  }

  #actions-view .actions-container {
    grid-template-columns: repeat(3, 300px); /* Fixed 3-column layout */
    gap: 32px;
    padding: 60px;
    max-width: 1100px;
    margin: 0 auto;
    justify-content: center;
  }

  #actions-view .action-card {
    width: 300px; /* Fixed Pokémon card width */
    height: 420px; /* Pokémon ratio 1.4 (300 × 1.4 = 420) */
    min-height: 420px;
  }
}

/* ============================================
   MOBILE DEVICE DETECTION
   Force iOS-style on actual mobile browsers
   ============================================ */
html[data-device="mobile"] #actions-view .actions-container {
  display: flex !important;
  flex-direction: column !important;
  gap: 16px !important;
  padding: 16px !important;
  grid-template-columns: unset !important;
}

html[data-device="mobile"] #actions-view .action-card {
  width: 100% !important;
  transform: none !important;
}

html[data-device="mobile"] #actions-view .action-card:active {
  transform: scale(0.98) !important;
}

/* ============================================
   ACCESSIBILITY & TOUCH
   ============================================ */

/* Larger tap targets on mobile */
@media (max-width: 767px) {
  #actions-view .action-card {
    min-height: 180px;
    height: 180px; /* Uniform height */
    padding: 20px;
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  #actions-view .action-card {
    transform: none !important;
    transition: box-shadow 0.2s, opacity 0.2s !important;
  }

  #actions-view .action-card:hover {
    transform: none !important;
  }
}

/* ============================================
   EMPTY STATE
   ============================================ */
#actions-view .actions-container:empty::after {
  content: 'No actions yet. Tap Discover to find opportunities!';
  display: block;
  text-align: center;
  padding: 48px 24px;
  color: var(--brokerly-text-secondary);
  font-size: 16px;
  grid-column: 1 / -1;
}

/* ============================================
   LOADING STATE
   ============================================ */
#actions-view .actions-container.loading {
  opacity: 0.6;
  pointer-events: none;
}

#actions-view .actions-container.loading .action-card {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

