/* AI Team Builder Custom Styles */

:root {
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
  --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.builder-container {
  font-family: 'Inter', sans-serif;
  min-height: 80vh;
}

/* Glassmorphism Cards */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 1rem;
}

/* Drag and Drop Zones */
.agent-catalog {
  max-height: 700px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.team-workspace {
  min-height: 400px;
  border: 2px dashed #cbd5e1;
  border-radius: 1rem;
  transition: all 0.3s ease;
  background-color: rgba(248, 250, 252, 0.5);
  position: relative;
}

.team-workspace.drag-over {
  background-color: rgba(59, 130, 246, 0.1);
  border-color: #3b82f6;
  transform: scale(1.01);
}

/* Agent Cards */
.agent-card {
  position: relative;
  /* Ensure X is positioned relative to card */
  cursor: grab;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.agent-card:active {
  cursor: grabbing;
}

.agent-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.agent-card.in-team {
  cursor: default;
  margin-bottom: 1rem;
  /* Ensure spacing on Mobile where gap might fail or be insufficient */
  overflow: hidden;
  /* Prevent content overflow */
  max-width: 100%;
  /* Don't exceed parent width */
  word-wrap: break-word;
  /* Wrap long words */
  overflow-wrap: break-word;
}

.agent-card .remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  opacity: 0;
  transition: opacity 0.2s;
  background: white;
  /* Prevent transparent text overlap */
  border-radius: 50%;
}

.agent-card:hover .remove-btn {
  opacity: 1;
}

/* Ghost element during drag */
.sortable-ghost {
  opacity: 0.4;
  background: #f1f5f9;
}

/* Stats Counter Animation */
.stat-value {
  font-variant-numeric: tabular-nums;
  transition: color 0.3s ease;
}

.stat-value.up {
  color: #10b981;
}

/* Custom Scrollbar */
.agent-catalog::-webkit-scrollbar {
  width: 6px;
}

.agent-catalog::-webkit-scrollbar-track {
  background: transparent;
}

.agent-catalog::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 20px;
}

/* Mobile optimizations */
@media (max-width: 768px) {
  .team-workspace {
    min-height: 250px;
  }

  .agent-card .remove-btn {
    opacity: 1;
    /* Always visible on mobile */
  }

  /* Fix card layout for mobile */
  .agent-card.in-team {
    flex-wrap: wrap;
  }

  .agent-card.in-team>div:last-of-type {
    /* Content container */
    flex: 1 1 0;
    min-width: 0;
    /* Allow shrinking below content size */
  }

  .agent-card.in-team h3,
  .agent-card.in-team p {
    word-break: break-word;
    white-space: normal;
  }

  /* Stack parameter rows vertically on mobile */
  .agent-card.in-team .mt-3.grid {
    gap: 0.75rem;
  }

  .agent-card.in-team .mt-3.grid>div {
    flex-direction: column;
    align-items: stretch;
  }

  .agent-card.in-team .mt-3.grid label {
    margin-bottom: 0.25rem;
    margin-right: 0;
  }

  /* Hide Catalog on Mobile */
  .agent-catalog {
    display: none;
  }

  /* Mobile Agent Modal */
  .mobile-agent-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: flex;
    align-items: flex-end;
    /* Bottom sheet feel */
  }

  .mobile-agent-modal.hidden {
    display: none;
  }

  .mobile-agent-content {
    background: white;
    width: 100%;
    max-height: 80vh;
    border-radius: 20px 20px 0 0;
    padding: 1.5rem;
    overflow-y: auto;
    animation: slideUpModal 0.3s ease-out;
  }

  @keyframes slideUpModal {
    from {
      transform: translateY(100%);
    }

    to {
      transform: translateY(0);
    }
  }
}

/* End Mobile Query */

/* CONFIG MODAL - Global Styles */
.config-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: none;
  /* JS toggles flex */
  align-items: flex-end;
  /* Mobile default: Bottom sheet */
  justify-content: center;
}

.config-modal.active {
  display: flex;
}

.config-sheet {
  background: white;
  width: 100%;
  max-width: 600px;
  /* Limit width on desktop */
  border-radius: 20px 20px 0 0;
  padding: 1.5rem;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideUpModal 0.3s ease-out;
}

/* Desktop Overrides for Config Modal */
@media (min-width: 768px) {
  .config-modal {
    align-items: center;
    /* Center on Desktop */
  }

  .config-sheet {
    border-radius: 12px;
    width: 400px;
    animation: fadeIn 0.2s ease-out;
    /* Fade in instead of slide up on desktop */
  }
}

.config-option-btn {
  width: 100%;
  text-align: left;
  padding: 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin-bottom: 0.5rem;
  transition: all 0.2s;
  background: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.config-option-btn:hover,
.config-option-btn.selected {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #1d4ed8;
}

/* Sticky Stats Footer (Mobile Only for now, ensuring media query context or global?) */
/* It seems sticky stats are also inside mobile query logic in JS handling, but CSS needs to be right */
@media (max-width: 768px) {
  .stats-container-mobile-sticky {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: white;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
    padding: 0.75rem;
    border-top: 1px solid #e2e8f0;
    animation: slideUp 0.3s ease-out;
  }
}


/* Add padding to body to prevent content being hidden behind sticky footer */
body {
  padding-bottom: 80px;
}


/* Floating Agent Animation */
@keyframes float {
  0% {
    transform: translateY(0px);
  }

  50% {
    transform: translateY(-5px);
  }

  100% {
    transform: translateY(0px);
  }
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

/* FAQ Styles matching ai-services.php */
.faq-item {
  border: 1px solid transparent;
  transition: all 0.3s ease;
}

.faq-item:hover {
  border-color: rgba(59, 130, 246, 0.2);
}

.faq-question {
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.faq-question:hover {
  background-color: rgba(59, 130, 246, 0.05);
}

.faq-question[aria-expanded="true"] .faq-icon {
  transform: rotate(180deg);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), padding 0.4s ease;
}

.faq-answer.open {
  max-height: 1000px;
  padding-top: 0.5rem;
}