/**
 * Agent Cards - Flip Effect & Styling
 * Modern glassmorphism with 3D transforms
 */

/* Grid Container */
.agents-grid-dynamic {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 2rem;
  padding: 2rem 1rem;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

/* Force white text on all agent cards regardless of theme */
.agent-card-wrapper,
.agent-card-wrapper *,
.agent-card-front,
.agent-card-front *,
.agent-card-back,
.agent-card-back * {
  color: white !important;
}

/* Card Wrapper - Perspective Container */
.agent-card-wrapper {
  perspective: 1000px;
  height: 480px;
  cursor: pointer;
}

/* Card Inner - Rotating Element */
.agent-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.agent-card-wrapper.flipped .agent-card-inner {
  transform: rotateY(180deg);
}

/* Card Faces - Front & Back */
.agent-card-front,
.agent-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.agent-card-front {
  background: linear-gradient(135deg, rgba(17, 24, 39, 0.95) 0%, rgba(31, 41, 55, 0.9) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  padding: 2rem 1.5rem;
  color: white !important;
}

.agent-card-front * {
  color: inherit;
}

.agent-card-back {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, rgba(17, 24, 39, 0.98) 0%, rgba(31, 41, 55, 0.95) 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  flex-direction: column;
  padding: 2rem;
}

/* Front Side Elements */
.agent-card-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1.5rem;
  padding: 1rem;
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.agent-card-icon::before {
  content: '';
  position: absolute;
  inset: 0;
  background: inherit;
  opacity: 0.2;
  filter: blur(20px);
}

.agent-card-icon svg {
  position: relative;
  z-index: 1;
  color: white;
}

.agent-card-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: white !important;
  margin-bottom: 0.75rem;
  text-align: center;
}

.agent-card-description {
  color: rgba(255, 255, 255, 0.7) !important;
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 2rem;
  padding: 0 1rem;
}

.agent-card-features {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.agent-feature-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0 1rem;
}

.agent-feature-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  color: #10b981;
  margin-top: 2px;
}

.agent-feature-text {
  flex: 1;
}

.agent-feature-title {
  font-weight: 600;
  color: white !important;
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
}

.agent-feature-desc {
  color: rgba(255, 255, 255, 0.6) !important;
  font-size: 0.85rem;
  line-height: 1.4;
}

.agent-card-flip-hint {
  margin-top: auto;
  padding-top: 1.5rem;
  text-align: center;
  color: rgba(255, 255, 255, 0.5) !important;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.agent-card-flip-hint span {
  color: rgba(255, 255, 255, 0.5) !important;
}

.agent-card-flip-hint svg {
  animation: flip-hint 2s ease-in-out infinite;
}

@keyframes flip-hint {
  0%, 100% { transform: rotateY(0deg); }
  50% { transform: rotateY(180deg); }
}

/* Back Side Elements */
.agent-card-back-header {
  text-align: center;
  margin-bottom: 2rem;
}

.agent-card-back-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
  margin-bottom: 0.5rem;
}

.agent-card-back-subtitle {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.9rem;
}

.agent-deployment-flow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  position: relative;
  padding: 1.5rem 0;
}

.agent-deployment-flow::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 15%;
  right: 15%;
  height: 2px;
  background: linear-gradient(90deg, 
    rgba(99, 102, 241, 0.3) 0%, 
    rgba(99, 102, 241, 0.8) 50%, 
    rgba(99, 102, 241, 0.3) 100%);
  transform: translateY(-50%);
  z-index: 0;
}

.agent-flow-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  z-index: 1;
}

.agent-flow-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.2);
  border: 2px solid rgba(99, 102, 241, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #818cf8;
}

.agent-flow-icon svg {
  width: 24px;
  height: 24px;
}

.agent-flow-label {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
  max-width: 80px;
  text-align: center;
}

.agent-deploy-btn {
  width: 100%;
  padding: 1rem 1.5rem;
  border-radius: 0.5rem;
  border: none;
  font-weight: 600;
  font-size: 1rem;
  color: white;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
  margin-top: auto;
}

.agent-deploy-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
}

.agent-deploy-btn:active {
  transform: translateY(0);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .agents-grid-dynamic {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 1.5rem 1rem;
  }

  .agent-card-wrapper {
    height: 500px;
  }

  .agent-card-back {
    padding: 1.5rem;
  }

  .agent-deployment-flow {
    flex-direction: column;
    gap: 1rem;
  }

  .agent-deployment-flow::before {
    left: 50%;
    right: auto;
    top: 10%;
    bottom: 10%;
    width: 2px;
    height: auto;
    background: linear-gradient(180deg, 
      rgba(99, 102, 241, 0.3) 0%, 
      rgba(99, 102, 241, 0.8) 50%, 
      rgba(99, 102, 241, 0.3) 100%);
  }

  .agent-flow-label {
    max-width: 120px;
  }
}

/* Hover Effects on Desktop */
@media (hover: hover) {
  .agent-card-wrapper:hover .agent-card-inner {
    transform: scale(1.02);
  }

  .agent-card-wrapper.flipped:hover .agent-card-inner {
    transform: rotateY(180deg) scale(1.02);
  }

  .agent-card-wrapper:not(.flipped) .agent-card-front {
    transition: border-color 0.3s ease;
  }

  .agent-card-wrapper:hover:not(.flipped) .agent-card-front {
    border-color: rgba(255, 255, 255, 0.2);
  }
}

/* Accessibility */
.agent-card-wrapper:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 4px;
  border-radius: 1rem;
}

/* Loading State */
.agents-grid-dynamic.loading {
  opacity: 0.5;
  pointer-events: none;
}

/* Animation on Page Load */
.agent-card-wrapper {
  animation: fadeInUp 0.6s ease-out backwards;
}

.agent-card-wrapper:nth-child(1) { animation-delay: 0.1s; }
.agent-card-wrapper:nth-child(2) { animation-delay: 0.2s; }
.agent-card-wrapper:nth-child(3) { animation-delay: 0.3s; }
.agent-card-wrapper:nth-child(4) { animation-delay: 0.4s; }
.agent-card-wrapper:nth-child(5) { animation-delay: 0.5s; }
.agent-card-wrapper:nth-child(6) { animation-delay: 0.6s; }

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