/* =========================================================
   NG AI Widget — Front-end Styles
   ========================================================= */

.ngai-widget-wrapper {
  width: 100%;
  position: relative;
  z-index: 10;
  margin-top: 16px;
  margin-bottom: 24px;
  padding: 0 20px;
  box-sizing: border-box;
}

/* Floating orbs background (disabled in hero) */
.ngai-widget-wrapper::before,
.ngai-widget-wrapper::after {
  display: none;
}

/* ── Inner container ── */
.ngai-widget-inner {
  max-width: 780px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

/* ── Site title headline ── */
.ngai-widget-site-title {
  font-family: 'Manrope', 'Inter', sans-serif;
  font-size: clamp(1.5rem, 4vw, 2.3rem);
  font-weight: 800;
  color: #fff;
  text-align: center;
  margin: 0 0 32px;
  letter-spacing: -.02em;
  line-height: 1.25;
  text-shadow: 0 2px 20px rgba(0,0,0,.4);
  background: linear-gradient(135deg, #fff 30%, #c4b5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Widget box ── */
.ngai-widget-box {
  position: relative;
  background: #ffffff;
  border-radius: 20px;
  padding: 20px 20px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  transition: all .3s;
}

.ngai-widget-box::before {
  content: '';
  position: absolute;
  inset: -1.5px;
  border-radius: 21px;
  background: linear-gradient(135deg, #7c3aed 0%, #2563eb 50%, #10b981 100%);
  z-index: -1;
  opacity: 0.85;
  transition: opacity 0.3s, box-shadow 0.3s;
}

.ngai-widget-box:focus-within::before {
  opacity: 1;
  box-shadow: 0 0 15px rgba(124, 58, 237, 0.35);
}

/* ── Animated beam ring (circulating lights) ── */
.ngai-beam-ring {
  position: absolute;
  inset: -2px;
  border-radius: 22px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  transition: opacity .4s;
  z-index: 1;
}

.ngai-beam-ring::before {
  content: '';
  position: absolute;
  inset: -50%;
  width: 200%; height: 200%;
  background: conic-gradient(
    from 0deg,
    transparent 0%,
    transparent 30%,
    #7c3aed 40%,
    #06b6d4 50%,
    #a855f7 60%,
    transparent 70%,
    transparent 100%
  );
  animation: ngai-beam-rotate 1.6s linear infinite;
}

.ngai-beam-ring::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 20px;
  background: #ffffff;
}

@keyframes ngai-beam-rotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* When loading is active */
.ngai-widget-box.ngai-loading .ngai-beam-ring { opacity: 1; }
.ngai-widget-box.ngai-loading {
  border-color: transparent;
}

/* ── Textarea prompt ── */
.ngai-prompt {
  width: 100%;
  box-sizing: border-box;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  resize: none;
  font-family: 'Inter', 'Manrope', sans-serif;
  font-size: 1rem;
  color: #1f2937 !important;
  line-height: 1.6;
  padding: 8px 4px 4px !important;
  position: relative;
  z-index: 2;
}
.ngai-prompt::placeholder { color: #9ca3af; }
.ngai-prompt:focus { box-shadow: none !important; border: none !important; }

/* ── Widget footer (char count + button) ── */
.ngai-widget-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  gap: 12px;
  position: relative;
  z-index: 2;
}

.ngai-char-count {
  font-size: .78rem;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
}

/* ── Generate button ── */
.ngai-generate-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 24px;
  background: linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .2s, opacity .2s, box-shadow .2s;
  box-shadow: 0 4px 20px rgba(124,58,237,.5);
  white-space: nowrap;
  letter-spacing: .01em;
}
.ngai-generate-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(124,58,237,.65);
  opacity: .95;
}
.ngai-generate-btn:active { transform: translateY(0); }
.ngai-generate-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

.ngai-btn-icon { flex-shrink: 0; }

/* ── Spinner overlay on button ── */
.ngai-generate-btn.ngai-spinning .ngai-btn-icon {
  animation: ngai-spin .7s linear infinite;
}
@keyframes ngai-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ── Error ── */
.ngai-error {
  display: none;
  margin-top: 14px;
  padding: 12px 16px;
  background: rgba(239, 68, 68, 0.05);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 10px;
  color: #b91c1c;
  font-size: .875rem;
  text-align: center;
}
.ngai-error.ngai-error--visible { display: block; }

/* ── Results ── */
.ngai-results {
  margin-top: 16px;
  display: none;
  flex-direction: column;
  gap: 0;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
}
.ngai-results.ngai-results--visible { display: flex; }

.ngai-results-header {
  padding: 14px 18px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ngai-results-label {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #4b5563;
}

.ngai-copy-all-btn {
  font-size: .78rem;
  padding: 5px 12px;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: #374151;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  transition: background .15s, color .15s;
}
.ngai-copy-all-btn:hover { background: #f3f4f6; color: #111827; border-color: #9ca3af; }

/* Name items */
.ngai-name-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  border-bottom: 1px solid #f3f4f6;
  animation: ngai-slide-in .3s ease both;
  gap: 12px;
}
.ngai-name-item:last-child { border-bottom: none; }

@keyframes ngai-slide-in {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}

.ngai-name-num {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(124,58,237,.1);
  color: #7c3aed;
  font-size: .72rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.ngai-name-text {
  flex: 1;
  font-size: 1rem;
  font-weight: 600;
  color: #111827;
  font-family: 'Manrope', 'Inter', sans-serif;
  letter-spacing: -.01em;
}

.ngai-copy-btn {
  padding: 5px 10px;
  background: transparent;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: #4b5563;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: .75rem;
  font-weight: 600;
  transition: all .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.ngai-copy-btn:hover {
  background: #f3f4f6;
  color: #111827;
  border-color: #9ca3af;
}
.ngai-copy-btn.ngai-copied {
  background: #d1fae5;
  border-color: #34d399;
  color: #065f46;
}

.ngai-provider-tag {
  text-align: center;
  padding: 10px;
  font-size: .7rem;
  color: #9ca3af;
  letter-spacing: .04em;
  border-top: 1px solid #f3f4f6;
}

/* ── Reset Button ── */
.ngai-reset-btn {
  display: inline-flex;
  align-items: center;
  padding: 11px 24px;
  background: #ffffff;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.ngai-reset-btn:hover {
  background: #f3f4f6;
  color: #111827;
  border-color: #9ca3af;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .ngai-widget-wrapper {
    margin-top: 8px;
    margin-bottom: 16px;
    padding: 0;
  }
  .ngai-widget-footer { flex-direction: column; align-items: stretch; gap: 16px; }
  .ngai-widget-actions { flex-direction: column; width: 100%; gap: 10px; }
  .ngai-generate-btn, .ngai-reset-btn { width: 100%; justify-content: center; }
  .ngai-api-toggle-group { grid-template-columns: 1fr; }
}

/* ── Skeleton Loader Shimmer ── */
.ngai-skeleton-text {
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.12) 37%, rgba(255,255,255,0.05) 63%);
  background-size: 400% 100%;
  animation: ngai-skeleton-pulse 1.4s ease infinite;
  border-radius: 4px;
  display: inline-block;
}
.ngai-skeleton-num {
  background: rgba(255, 255, 255, 0.05) !important;
  color: transparent !important;
}
.ngai-skeleton-btn {
  width: 50px;
  height: 26px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
}
.ngai-skeleton-item {
  pointer-events: none;
}
@keyframes ngai-skeleton-pulse {
  0% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ── Screen Reader Utility ── */
.ngai-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Accessibility: Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  .ngai-beam-ring::before {
    animation: none !important;
  }
  .ngai-name-item {
    animation: none !important;
  }
  .ngai-generate-btn.ngai-spinning .ngai-btn-icon {
    animation: none !important;
  }
  .ngai-skeleton-text {
    animation: none !important;
    background: rgba(255, 255, 255, 0.08);
  }
}
