/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-weight: 600;
  transition: all 0.2s;
  cursor: pointer;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-error {
  background-color: var(--error);
  color: white;
}

.btn-error:hover {
  background-color: var(--error-hover);
}

.btn-outline {
  border: 1px solid var(--border-light);
  background-color: var(--bg-card-light);
}

.btn-outline:hover {
  background-color: var(--primary-light);
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.btn-pastel-green {
  background-color: #86efac;
}

.btn-pastel-green:hover {
  background-color: #4ade80;
}

.btn-error-outline {
  border: 1px solid var(--error);
  background-color: var(--bg-card-light);
  color: var(--error);
}

.btn-error-outline:hover {
  background-color: var(--error-light);
}

.btn-success {
  background-color: #16a34a;
  /* green-600 */
  color: white;
}

.btn-success:hover {
  background-color: #15803d;
  /* green-700 */
}

input[type=submit] {
  border-width: 0;
}

.flow-card-image {
  height: 160px;
  width: calc(100% + 4rem);
  /* Full width + padding compensation */
  border-top-left-radius: 1rem;
  border-top-right-radius: 1rem;
  margin: -2rem -2rem 2rem -2rem;
  /* Negative margin to cover 2rem padding */
}

.flow-title {
  font-size: 1.25rem;
  font-weight: 600;
}

/* Cards */
.card {
  background-color: var(--bg-card-light);
  border: 1px solid var(--border-light);
  border-radius: 1rem;
  padding: var(--spacing-lg);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Forms */
.form-group {
  margin-bottom: var(--spacing-md);
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.form-input {
  display: block;
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-light);
  background-color: var(--bg-light);
  border: 1px solid var(--border-light);
  border-radius: 0.5rem;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-check-input {
  width: 1rem;
  height: 1rem;
  border-radius: 0.25rem;
  border: 1px solid var(--border-light);
  color: var(--primary);
}

.form-check-label {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-bottom: 0;
}

/* Alerts */
.alert {
  padding: var(--spacing-md);
  border-radius: 0.5rem;
  margin-bottom: var(--spacing-md);
  font-size: 0.875rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.alert-danger {
  background-color: #fef2f2;
  /* Red 50 */
  border: 1px solid #fecaca;
  /* Red 200 */
  color: #991b1b;
  /* Red 800 */
}

.alert-success {
  background-color: #f0fdf4;
  /* Green 50 */
  border: 1px solid #bbf7d0;
  /* Green 200 */
  color: #166534;
  /* Green 800 */
}

.alert-info {
  background-color: #eff6ff;
  /* Blue 50 */
  border: 1px solid #bfdbfe;
  /* Blue 200 */
  color: #1e40af;
  /* Blue 800 */
}

.alert-icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

.alert-danger .alert-icon {
  color: #ef4444;
  /* Red 500 */
}

.alert-success .alert-icon {
  color: #22c55e;
  /* Green 500 */
}

.alert-info .alert-icon {
  color: #3b82f6;
  /* Blue 500 */
}

.alert-content {
  flex-grow: 1;
}

.alert-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.alert-list {
  list-style-type: disc;
  list-style-position: inside;
  margin-top: 0.25rem;
}

/* Segmented Control */
.segmented-control {
  background-color: #f3f4f6;
  /* Gray 100 */
  border-radius: 0.5rem;
  padding: 0.25rem;
  display: inline-flex;
  position: relative;
  cursor: pointer;
  user-select: none;
}

.segmented-item {
  padding: 0.375rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary-light);
  border-radius: 0.375rem;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  z-index: 1;
}

.segmented-item.active {
  background-color: white;
  color: var(--text-light);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.discount-badge {
  color: #10b981;
  /* Emerald 500 */
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 0.25rem;
}

/* Pricing Cards */
.pricing-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--spacing-lg);
  width: 100%;
}

@media (min-width: 768px) {
  .pricing-grid {
    grid-template-columns: repeat(3, 1fr);
    align-items: start;
  }
}

.pricing-card {
  background-color: white;
  border: 1px solid var(--border-light);
  border-radius: 1rem;
  padding: 2rem;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.pricing-card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.pricing-card.current-plan-card {
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
  /* Indigo ring */
}

.current-plan-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--primary);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  text-transform: uppercase;
}

.pricing-card h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-light);
}

.plan-description {
  font-size: 0.875rem;
  color: var(--text-secondary-light);
  margin-bottom: 1.5rem;
}

.price-container {
  margin-bottom: 1.5rem;
  margin-top: auto;
  /* Push to bottom if content varies */
}

.price {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-light);
  display: flex;
  align-items: baseline;
}

.price span {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-secondary-light);
  margin-left: 0.25rem;
}

/* Credit Packs */
.credit-packs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 640px) {
  .credit-packs {
    grid-template-columns: repeat(3, 1fr);
  }
}

.credit-pack-card {
  background-color: white;
  border: 1px solid var(--border-light);
  border-radius: 1rem;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: border-color 0.2s;
  cursor: pointer;
  text-align: left;
  width: 100%;
  height: 100%;
}

.credit-pack-card:hover {
  border-color: var(--primary);
}

.pack-info h3 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 0.25rem;
}

.pack-info p {
  font-size: 0.875rem;
  color: var(--text-secondary-light);
  margin-bottom: 1rem;
}

.pack-price {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-light);
}

.pack-action {
  width: 2rem;
  height: 2rem;
  background-color: #f3f4f6;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  transition: background-color 0.2s;
}

.credit-pack-card:hover .pack-action {
  background-color: #e5e7eb;
}

.credit-packs form {
  height: 100%;
}

.credit-pack-link {
  width: 100%;
  height: 100%;
  display: block;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  text-align: inherit;
}

/* Execution History */
.execution-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.execution-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md);
  background-color: white;
  border: 1px solid var(--border-light);
  border-radius: 1rem;
  transition: box-shadow 0.2s;
}

.execution-item:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.execution-status-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  margin-right: var(--spacing-md);
  flex-shrink: 0;
}

.execution-status-icon.success {
  background-color: #dcfce7;
  /* green-100 */
  color: #16a34a;
  /* green-600 */
}

.execution-status-icon.running {
  background-color: #dbeafe;
  /* blue-100 */
  color: #2563eb;
  /* blue-600 */
}

.execution-status-icon.failed {
  background-color: #fee2e2;
  /* red-100 */
  color: #dc2626;
  /* red-600 */
}

.execution-status-icon.pending {
  background-color: #fff59e;
  /* yellow-100 */
  color: #f59e0b;
  /* yellow-600 */
}

.execution-details {
  display: flex;
  align-items: center;
  flex-grow: 1;
}

.execution-text {
  font-size: 1rem;
  color: var(--text-light);
}

.execution-arrow {
  color: var(--text-secondary-light);
}

/* Execution Details */
.execution-detail-card {
  background-color: white;
  border: 1px solid var(--border-light);
  border-radius: 1rem;
  overflow: hidden;
  margin-bottom: var(--spacing-lg);
}

.execution-header {
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--border-light);
  background-color: #f9fafb;
  /* gray-50 */
}

.execution-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-light);
}

.execution-section {
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--border-light);
}

.execution-section:last-child {
  border-bottom: none;
}

.execution-section:nth-child(odd) {
  background-color: #f9fafb;
}

.execution-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--spacing-sm);
}

@media (min-width: 640px) {
  .execution-row {
    grid-template-columns: 1fr 3fr;
    gap: var(--spacing-md);
  }
}

.execution-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary-light);
}

.execution-value {
  font-size: 0.875rem;
  color: var(--text-light);
}

.execution-value ul {
  list-style-type: disc;
  padding-left: 1.5rem;
}

.execution-value li {
  margin-bottom: var(--spacing-sm);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.status-badge.succeeded {
  background-color: #dcfce7;
  color: #166534;
}

.status-badge.running,
.status-badge.pending {
  background-color: #dbeafe;
  color: #1e40af;
}

.status-badge.failed {
  background-color: #fee2e2;
  color: #991b1b;
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .5;
  }
}

/* Execution Footer Navigation */
.execution-footer-nav {
  display: flex;
  flex-direction: column-reverse;
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
}

@media (min-width: 640px) {
  .execution-footer-nav {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

/* Flow Graph Container */
.flow-graph-container {
  position: relative;
  width: 100%;
  height: 700px;
  border: 1px solid var(--border-light);
  border-radius: 1rem;
  background-color: #f8fafc;
  /* slate-50 */
  background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M 20 0 L 0 0 0 20' fill='none' stroke='%23e2e8f0' stroke-width='0.5'/%3E%3C/svg%3E");
  overflow: hidden;
  cursor: grab;
}

.edges-svg {
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.edges-svg line {
  pointer-events: stroke;
  cursor: pointer;
}

.flow-graph-container.panning {
  cursor: grabbing;
}

.zoom-target {
  transform-origin: 0 0;
  width: 100%;
  height: 100%;
  transition: transform 0.1s ease-out;
}

.zoom-controls {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: white;
  padding: 0.5rem;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  z-index: 30;
  border: 1px solid var(--border-light);
}

.zoom-level {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary-light);
  min-width: 3rem;
  text-align: center;
}

.btn-zoom {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.375rem;
  color: var(--text-secondary-light);
  transition: all 0.2s;
}

.btn-zoom:hover {
  background-color: #f3f4f6;
  /* gray-100 */
  color: var(--text-light);
}

.flow-graph-toolbar {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--spacing-md);
  width: 100%;
}

/* Node Styles */
.node {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid #e2e8f0;
  /* slate-200 */
  border-radius: 0.5rem;
  background-color: rgba(241, 245, 249, 0.8);
  /* slate-100/80 */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #0f172a;
  /* slate-900 */
  min-width: 220px;
  max-width: 300px;
  z-index: 10;
  cursor: move;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.node:last-child {
  margin-bottom: 0;
}

.node-title {
  font-weight: 700;
  font-size: 1.125rem;
  color: #0f172a;
  /* slate-900 */
  margin-bottom: 0.25rem;
  display: block;
}

.node-subtitle {
  font-size: 0.875rem;
  color: #64748b;
  /* slate-500 */
  margin-bottom: 0.5rem;
}

.pin-container {
  position: relative;
  display: flex;
  align-items: center;
  border: 1px dashed #94a3b8;
  /* slate-400 */
  border-radius: 0.375rem;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background-color: transparent;
  transition: all 0.2s;
}

.pin-container:last-child {
  margin-bottom: 0;
}

.pin-text {
  font-size: 0.875rem;
  color: #64748b;
  /* slate-500 */
  width: 100%;
}

.pin-text-scroll {
  white-space: normal;
  max-height: 8rem;
  overflow-y: auto;
}

/* Pins */
.pin {
  position: absolute;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background-color: #f8fafc;
  /* slate-50 */
  cursor: pointer;
  transition: transform 0.2s;
  z-index: 20;
}

.pin:hover {
  transform: scale(1.2);
}

.pin-output {
  right: -0.6rem;
  /* Half width + border adjustment */
  top: 50%;
  transform: translateY(-50%);
}

.pin-input {
  left: -0.6rem;
  top: 50%;
  transform: translateY(-50%);
}

/* Connected state for pins (optional, if we want to fill them) */
.pin.connected {
  background-color: #10b981;
  border-color: #10b981;
}

.pin.active {
  border-color: #10b981;
}

.pin.highlight {
  border-color: #10b981;
}

.pin.dim {
  border-color: #ff0000;
}

.valid-connection {
  stroke: #10b981;
}

.node-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.btn-warning {
  background-color: #d97706;
  /* amber-600 */
  color: white;
}

.btn-warning:hover {
  background-color: #b45309;
  /* amber-700 */
}

.btn-error {
  background-color: #f43f5e;
  /* rose-500 */
  color: white;
}

.btn-error:hover {
  background-color: #e11d48;
  /* rose-600 */
}

/* Edges */
div#edges-container {
  height: 100%;
  position: relative;
  pointer-events: none;
  /* Allow clicking through to grid */
}

svg.edges-svg {
  height: 100%;
  width: 100%;
  z-index: 5;
  /* Below nodes */
  pointer-events: visibleStroke;
  /* Only capture events on lines */
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.modal-dialog {
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  width: 100%;
  max-width: 28rem;
  /* max-w-md */
  margin: 0 1rem;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  color: var(--text-secondary-light);
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text-light);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  border-top: 1px solid var(--border-light);
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Tabs */
.tab-container {
  display: flex;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 1rem;
}

.tab-button {
  padding: 0.5rem 1rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  color: var(--text-secondary-light);
}

.tab-button:hover {
  color: var(--text-light);
}

.tab-button.active {
  border-bottom-color: var(--primary);
  color: var(--primary);
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
}