/* ============================================================
   Cyandex Callback Widget — Premium Dark Glassmorphism Theme
   ============================================================ */

/* --- Google Fonts (loaded in HTML, declared here for fallback) --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ----------------------------------------------------------------
   1. DESIGN TOKENS (CSS Custom Properties)
   ---------------------------------------------------------------- */
:root {
  /* Surface & Background */
  --bg-primary:       #0a0e1a;
  --bg-card:          rgba(16, 20, 38, 0.65);
  --bg-card-border:   rgba(255, 255, 255, 0.08);
  --bg-input:         rgba(255, 255, 255, 0.04);
  --bg-input-focus:   rgba(255, 255, 255, 0.07);

  /* Accent */
  --accent:           #6c63ff;
  --accent-light:     #8b83ff;
  --accent-glow:      rgba(108, 99, 255, 0.35);
  --accent-gradient:  linear-gradient(135deg, #6c63ff 0%, #48bfe3 100%);
  --accent-gradient-hover: linear-gradient(135deg, #48bfe3 0%, #6c63ff 100%);

  /* Text */
  --text-primary:     #f0f0f5;
  --text-secondary:   rgba(240, 240, 245, 0.6);
  --text-placeholder:  rgba(240, 240, 245, 0.3);
  --text-error:       #ff6b6b;
  --text-success:     #51cf66;

  /* Borders */
  --border-default:   rgba(255, 255, 255, 0.08);
  --border-focus:     rgba(108, 99, 255, 0.6);

  /* Shadows */
  --shadow-card:      0 8px 32px rgba(0, 0, 0, 0.4),
                      0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-glow:      0 0 20px var(--accent-glow),
                      0 0 60px rgba(108, 99, 255, 0.10);
  --shadow-btn:       0 4px 15px rgba(108, 99, 255, 0.3);
  --shadow-btn-hover: 0 8px 25px rgba(108, 99, 255, 0.45);

  /* Glass */
  --glass-blur:       20px;
  --glass-saturation: 180%;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* Timing */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring:   cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 0.2s;
  --duration-med:  0.35s;
  --duration-slow: 0.6s;
}

/* ----------------------------------------------------------------
   2. RESET & BASE
   ---------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ----------------------------------------------------------------
   3. ANIMATED GRADIENT BACKGROUND
   ---------------------------------------------------------------- */
body.full-page {
  background: linear-gradient(135deg, #0a0e1a 0%, #121830 25%, #0d1117 50%, #1a1035 75%, #0a0e1a 100%);
  background-size: 400% 400%;
  animation: gradientShift 20s ease infinite;
}

@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  25%  { background-position: 50% 0%; }
  50%  { background-position: 100% 50%; }
  75%  { background-position: 50% 100%; }
  100% { background-position: 0% 50%; }
}

/* ----------------------------------------------------------------
   4. PARTICLE / DOT BACKGROUND ANIMATION
   ---------------------------------------------------------------- */
.bg-animation {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-animation::before,
.bg-animation::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  opacity: 0.08;
  animation: float 18s ease-in-out infinite;
}

.bg-animation::before {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  top: -10%;
  right: -5%;
  animation-delay: 0s;
}

.bg-animation::after {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #48bfe3 0%, transparent 70%);
  bottom: -10%;
  left: -5%;
  animation-delay: -7s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25%      { transform: translate(30px, -40px) scale(1.05); }
  50%      { transform: translate(-20px, 20px) scale(0.95); }
  75%      { transform: translate(15px, 30px) scale(1.02); }
}

/* Particle dots */
.bg-animation .dot {
  position: absolute;
  width: 3px;
  height: 3px;
  background: rgba(108, 99, 255, 0.25);
  border-radius: 50%;
  animation: particleDrift linear infinite;
}

@keyframes particleDrift {
  0%   { transform: translateY(100vh) scale(0); opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translateY(-10vh) scale(1); opacity: 0; }
}

/* ----------------------------------------------------------------
   5. LAYOUT — CONTAINER
   ---------------------------------------------------------------- */
.container {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-xl) var(--space-md);
}

/* ----------------------------------------------------------------
   6. GLASS CARD
   ---------------------------------------------------------------- */
.glass-card {
  width: 100%;
  max-width: 500px;
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl) var(--space-xl);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
  position: relative;
  overflow: hidden;
  animation: cardEntry var(--duration-slow) var(--ease-out-expo) both;
}

/* Subtle inner highlight along top edge */
.glass-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  pointer-events: none;
}

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

/* ----------------------------------------------------------------
   7. BRANDING AREA
   ---------------------------------------------------------------- */
.branding {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.org-logo {
  max-height: 56px;
  max-width: 200px;
  object-fit: contain;
  margin-bottom: var(--space-md);
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity var(--duration-med) ease;
}

.org-logo.loaded {
  opacity: 1;
}

.org-logo.hidden {
  display: none;
}

.org-name {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.3;
}

.org-name .subtitle {
  display: block;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: var(--space-xs);
  letter-spacing: 0.02em;
}

/* ----------------------------------------------------------------
   8. FORM FIELDS
   ---------------------------------------------------------------- */
.form-group {
  margin-bottom: var(--space-lg);
  position: relative;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  transition: color var(--duration-fast) ease;
}

.form-group:focus-within label {
  color: var(--accent-light);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.8125rem 1rem;
  background: var(--bg-input);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 400;
  outline: none;
  transition:
    border-color var(--duration-med) var(--ease-out-expo),
    background var(--duration-med) ease,
    box-shadow var(--duration-med) var(--ease-out-expo);
  -webkit-appearance: none;
  appearance: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-placeholder);
}

/* --- Focus glow --- */
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  background: var(--bg-input-focus);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow), 0 0 20px rgba(108, 99, 255, 0.08);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
}

/* Select custom arrow */
.select-wrapper {
  position: relative;
}

.select-wrapper::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--text-secondary);
  pointer-events: none;
  transition: border-color var(--duration-fast) ease;
}

.select-wrapper:focus-within::after {
  border-top-color: var(--accent-light);
}

.form-select {
  cursor: pointer;
  padding-right: 2.5rem;
}

.form-select option {
  background: #1a1e2e;
  color: var(--text-primary);
}

/* ----------------------------------------------------------------
   9. FIELD VALIDATION STATES
   ---------------------------------------------------------------- */
.form-group.error .form-input,
.form-group.error .form-select,
.form-group.error .form-textarea {
  border-color: var(--text-error);
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.15);
}

.form-group.error label {
  color: var(--text-error);
}

.field-error {
  font-size: 0.75rem;
  color: var(--text-error);
  margin-top: var(--space-xs);
  opacity: 0;
  transform: translateY(-4px);
  transition: all var(--duration-fast) var(--ease-out-expo);
  display: none;
}

.form-group.error .field-error {
  opacity: 1;
  transform: translateY(0);
  display: block;
}

/* ----------------------------------------------------------------
   10. HONEYPOT (hidden from humans, visible to bots)
   ---------------------------------------------------------------- */
.hp-field {
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
  tabindex: -1;
}

/* ----------------------------------------------------------------
   11. SUBMIT BUTTON
   ---------------------------------------------------------------- */
.submit-btn {
  width: 100%;
  padding: 0.9375rem 1.5rem;
  background: var(--accent-gradient);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-btn);
  transition:
    box-shadow var(--duration-med) var(--ease-out-expo),
    transform var(--duration-med) var(--ease-spring);
}

.submit-btn:hover:not(:disabled) {
  background: var(--accent-gradient-hover);
  box-shadow: var(--shadow-btn-hover);
  transform: translateY(-2px);
}

.submit-btn:active:not(:disabled) {
  transform: translateY(0px) scale(0.98);
  box-shadow: var(--shadow-btn);
}

.submit-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Shimmer sweep on hover */
.submit-btn::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -60%;
  width: 50%;
  height: 200%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.12),
    transparent
  );
  transform: skewX(-20deg);
  transition: left 0.6s var(--ease-out-expo);
  pointer-events: none;
}

.submit-btn:hover::after {
  left: 130%;
}

/* Button text & spinner */
.btn-text {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  transition: opacity var(--duration-fast) ease;
}

.submit-btn.loading .btn-text {
  opacity: 0;
}

.btn-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--duration-fast) ease;
}

.submit-btn.loading .btn-spinner {
  opacity: 1;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ----------------------------------------------------------------
   12. SUCCESS SCREEN
   ---------------------------------------------------------------- */
.success-screen {
  text-align: center;
  padding: var(--space-xl) 0;
}

.success-screen.hidden {
  display: none;
}

.success-screen h2 {
  font-size: 1.375rem;
  font-weight: 700;
  margin-top: var(--space-lg);
  color: var(--text-primary);
  animation: fadeUp var(--duration-med) var(--ease-out-expo) 0.4s both;
}

.success-screen p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-top: var(--space-sm);
  animation: fadeUp var(--duration-med) var(--ease-out-expo) 0.55s both;
}

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

/* --- Animated Checkmark --- */
.checkmark-circle {
  width: 72px;
  height: 72px;
  margin: 0 auto;
  position: relative;
}

.checkmark-svg {
  width: 72px;
  height: 72px;
  display: block;
}

.checkmark-svg .circle {
  fill: none;
  stroke: var(--text-success);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  animation: drawCircle 0.6s var(--ease-out-expo) forwards;
  transform-origin: center;
}

.checkmark-svg .check {
  fill: none;
  stroke: var(--text-success);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 50;
  stroke-dashoffset: 50;
  animation: drawCheck 0.4s var(--ease-out-expo) 0.45s forwards;
}

/* Glow ring behind checkmark */
.checkmark-circle::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(81, 207, 102, 0.15) 0%, transparent 70%);
  animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes drawCircle {
  to { stroke-dashoffset: 0; }
}

@keyframes drawCheck {
  to { stroke-dashoffset: 0; }
}

@keyframes pulseGlow {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50%      { opacity: 1; transform: scale(1.15); }
}

/* ----------------------------------------------------------------
   13. INLINE ERROR MESSAGE
   ---------------------------------------------------------------- */
.form-error-message {
  background: rgba(255, 107, 107, 0.08);
  border: 1px solid rgba(255, 107, 107, 0.2);
  border-radius: var(--radius-sm);
  color: var(--text-error);
  font-size: 0.875rem;
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-lg);
  text-align: center;
  display: none;
  animation: fadeUp var(--duration-fast) var(--ease-out-expo);
}

.form-error-message.visible {
  display: block;
}

/* ----------------------------------------------------------------
   14. FOOTER
   ---------------------------------------------------------------- */
.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: var(--space-lg) var(--space-md) var(--space-xl);
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.6;
}

.footer a {
  color: var(--accent-light);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--duration-fast) ease;
}

.footer a:hover {
  color: #fff;
}

/* ----------------------------------------------------------------
   15. WIDGET MODE (compact iframe styling)
   ---------------------------------------------------------------- */
body.widget-mode {
  background: transparent;
  min-height: auto;
}

body.widget-mode .bg-animation {
  display: none;
}

body.widget-mode .container {
  min-height: auto;
  padding: var(--space-sm);
  align-items: flex-start;
}

body.widget-mode .glass-card {
  max-width: 100%;
  padding: var(--space-lg) var(--space-md);
  border-radius: var(--radius-md);
  background: rgba(16, 20, 38, 0.85);
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

body.widget-mode .org-logo {
  max-height: 40px;
}

body.widget-mode .org-name {
  font-size: 1.2rem;
}

body.widget-mode .branding {
  margin-bottom: var(--space-md);
}

body.widget-mode .form-group {
  margin-bottom: var(--space-md);
}

body.widget-mode .form-input,
body.widget-mode .form-select,
body.widget-mode .form-textarea {
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
}

body.widget-mode .form-textarea {
  min-height: 70px;
}

body.widget-mode .form-group label {
  font-size: 0.6875rem;
  margin-bottom: 0.3rem;
}

body.widget-mode .submit-btn {
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
}

body.widget-mode .success-screen {
  padding: var(--space-md) 0;
}

body.widget-mode .checkmark-circle {
  width: 56px;
  height: 56px;
}

body.widget-mode .checkmark-svg {
  width: 56px;
  height: 56px;
}

body.widget-mode .success-screen h2 {
  font-size: 1.125rem;
}

body.widget-mode .footer {
  display: none;
}

/* ----------------------------------------------------------------
   16. RESPONSIVE BREAKPOINTS
   ---------------------------------------------------------------- */

/* Tablet (768px) */
@media (max-width: 768px) {
  .glass-card {
    padding: var(--space-xl) var(--space-lg);
    border-radius: var(--radius-md);
  }

  .org-name {
    font-size: 1.375rem;
  }
}

/* Mobile (375px-width devices) */
@media (max-width: 480px) {
  html {
    font-size: 15px;
  }

  .container {
    padding: var(--space-md) var(--space-sm);
  }

  .glass-card {
    padding: var(--space-lg) var(--space-md);
    border-radius: var(--radius-md);
  }

  .org-name {
    font-size: 1.25rem;
  }

  .form-input,
  .form-select,
  .form-textarea {
    padding: 0.75rem 0.875rem;
    font-size: 0.875rem;
  }

  .submit-btn {
    padding: 0.875rem 1rem;
  }
}

/* Very small screens */
@media (max-width: 375px) {
  html {
    font-size: 14px;
  }

  .glass-card {
    padding: var(--space-md) var(--space-sm);
  }
}

/* ----------------------------------------------------------------
   17. ACCESSIBILITY — REDUCED MOTION
   ---------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ----------------------------------------------------------------
   18. SCROLLBAR STYLING
   ---------------------------------------------------------------- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ----------------------------------------------------------------
   19. LOADING SKELETON (while fetching branding)
   ---------------------------------------------------------------- */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 25%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.04) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
