/**
 * Quick Contact Widget Styles
 * Mobile-first, accessible, and conversion-optimized
 */

/* CSS Variables for Quick Contact */
:root {
  --qc-primary: #1f6feb;
  --qc-primary-hover: #1861d1;
  --qc-primary-light: #58a6ff;
  --qc-secondary: #6B7280;
  --qc-success: #10B981;
  --qc-error: #EF4444;
  --qc-warning: #F59E0B;
  --qc-bg: #FFFFFF;
  --qc-text: #1F2937;
  --qc-text-light: #6B7280;
  --qc-border: #E5E7EB;
  --qc-shadow: 0 20px 40px rgba(31, 111, 235, 0.15), 0 10px 20px rgba(0, 0, 0, 0.1);
  --qc-shadow-hover: 0 30px 60px rgba(31, 111, 235, 0.25), 0 15px 30px rgba(0, 0, 0, 0.15);
  --qc-animation-duration: 0.3s;
  --qc-z-index: 1000;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --qc-bg: #161b22;
    --qc-text: #f0f6fc;
    --qc-text-light: #8b949e;
    --qc-border: #30363d;
    --qc-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(88, 166, 255, 0.2);
    --qc-shadow-hover: 0 30px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(88, 166, 255, 0.4);
  }
}

/* Base container */
.quick-contact {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--qc-z-index);
  font-family: system-ui, -apple-system, sans-serif;
}

/* Mobile positioning */
@media (max-width: 640px) {
  .quick-contact {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }
}

/* Floating toggle button */
.quick-contact-toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--qc-primary) 0%, var(--qc-primary-hover) 100%);
  color: white;
  border: none;
  border-radius: 28px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  box-shadow: var(--qc-shadow);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.quick-contact-toggle::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.quick-contact-toggle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s ease, height 0.6s ease;
}

.quick-contact-toggle:hover::before {
  opacity: 1;
}

.quick-contact-toggle:hover::after {
  width: 300px;
  height: 300px;
}

.quick-contact-toggle:hover {
  background: linear-gradient(135deg, var(--qc-primary-hover) 0%, #1451a7 100%);
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--qc-shadow-hover);
}

.quick-contact-toggle:active {
  transform: translateY(-2px) scale(1);
}

.quick-contact-toggle:focus {
  outline: 3px solid rgba(88, 166, 255, 0.5);
  outline-offset: 2px;
}

.quick-contact-toggle[aria-expanded="true"] .quick-contact-label {
  display: none;
}

.quick-contact-toggle[aria-expanded="true"] .quick-contact-close {
  display: block;
}

.quick-contact-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  transition: all 0.3s ease;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.3));
  z-index: 1;
}

.quick-contact-toggle:hover .quick-contact-icon {
  transform: scale(1.1) rotate(-5deg);
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.5));
}

.quick-contact-label {
  z-index: 1;
  position: relative;
}

.quick-contact-close {
  display: none;
  font-size: 24px;
  line-height: 1;
}

/* Pulse animation for attention */
.quick-contact-pulse {
  position: absolute;
  top: -8px;
  left: -8px;
  right: -8px;
  bottom: -8px;
  border-radius: 36px;
  background: linear-gradient(135deg, var(--qc-primary-light) 0%, var(--qc-primary) 100%);
  opacity: 0;
  pointer-events: none;
  animation: pulse-glow 2.5s infinite;
  z-index: -1;
  display: none;
}

@keyframes pulse-glow {
  0% {
    transform: scale(1);
    opacity: 0.7;
    box-shadow: 0 0 0 0 rgba(88, 166, 255, 0.7);
  }
  50% {
    transform: scale(1.15);
    opacity: 0;
    box-shadow: 0 0 20px 10px rgba(88, 166, 255, 0);
  }
  100% {
    transform: scale(1);
    opacity: 0.7;
    box-shadow: 0 0 0 0 rgba(88, 166, 255, 0.7);
  }
}

/* Form container */
.quick-contact-form {
  position: absolute;
  bottom: calc(100% + 16px);
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  background: var(--qc-bg);
  border-radius: 20px;
  box-shadow: var(--qc-shadow);
  border: 2px solid rgba(88, 166, 255, 0.1);
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.quick-contact-form::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--qc-primary), var(--qc-primary-light), var(--qc-primary));
  background-size: 200% 100%;
  animation: shimmer-bar 3s linear infinite;
}

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

.quick-contact-form[aria-hidden="false"] {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Mobile full-width */
@media (max-width: 640px) {
  .quick-contact-form {
    position: fixed;
    bottom: 80px;
    right: 16px;
    left: 16px;
    width: auto;
  }
}

/* Form header */
.quick-contact-header {
  padding: 24px 28px 20px;
  border-bottom: 2px solid var(--qc-border);
  background: linear-gradient(135deg, rgba(88, 166, 255, 0.03) 0%, transparent 100%);
  position: relative;
}

.quick-contact-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--qc-text) 0%, var(--qc-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.quick-contact-subtitle {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--qc-text-light);
  font-weight: 500;
}

/* Form styles */
.quick-form {
  padding: 24px 28px 28px;
  background: linear-gradient(180deg, transparent 0%, rgba(88, 166, 255, 0.01) 100%);
}

.quick-form-stage {
  display: none;
}

.quick-form-stage[data-stage="1"] {
  display: block;
}

.quick-form-stage[aria-hidden="false"] {
  display: block;
  animation: stageSlideIn var(--qc-animation-duration) ease;
}

@keyframes stageSlideIn {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.quick-form-group {
  margin-bottom: 16px;
}

.quick-form-input,
.quick-form-textarea {
  width: 100%;
  padding: 14px 18px;
  font-size: 16px;
  color: var(--qc-text);
  background: var(--qc-bg);
  border: 2px solid var(--qc-border);
  border-radius: 12px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 500;
}

.quick-form-input:hover,
.quick-form-textarea:hover {
  border-color: rgba(88, 166, 255, 0.3);
}

.quick-form-input:focus,
.quick-form-textarea:focus {
  outline: none;
  border-color: var(--qc-primary-light);
  box-shadow: 0 0 0 4px rgba(88, 166, 255, 0.15);
  background: rgba(88, 166, 255, 0.02);
  transform: translateY(-1px);
}

.quick-form-input.error,
.quick-form-textarea.error {
  border-color: var(--qc-error);
}

.quick-form-textarea {
  resize: vertical;
  min-height: 80px;
}

/* Email display */
.quick-email-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(88, 166, 255, 0.08) 0%, rgba(31, 111, 235, 0.03) 100%);
  border: 2px solid rgba(88, 166, 255, 0.2);
  border-radius: 10px;
  margin-bottom: 16px;
  transition: all 0.3s ease;
}

.quick-email-display:hover {
  border-color: rgba(88, 166, 255, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(88, 166, 255, 0.1);
}

.quick-email-display span {
  font-size: 14px;
  color: var(--qc-text);
  font-weight: 600;
}

.quick-edit-email {
  padding: 6px;
  background: rgba(88, 166, 255, 0.1);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--qc-primary);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quick-edit-email:hover {
  background: rgba(88, 166, 255, 0.2);
  transform: scale(1.1);
}

/* Form options */
.quick-form-options {
  margin: 16px 0;
}

.quick-form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--qc-text);
}

.quick-form-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Buttons */
.quick-form-btn {
  width: 100%;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.quick-form-btn-primary {
  background: linear-gradient(135deg, var(--qc-primary) 0%, var(--qc-primary-hover) 100%);
  color: white;
  box-shadow: 0 4px 16px rgba(31, 111, 235, 0.3);
}

.quick-form-btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.quick-form-btn-primary:hover::before {
  opacity: 1;
}

.quick-form-btn-primary:hover {
  background: linear-gradient(135deg, var(--qc-primary-hover) 0%, #1451a7 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(31, 111, 235, 0.4);
}

.quick-form-btn-primary:active {
  transform: translateY(0);
}

.quick-form-btn-primary:focus {
  outline: 3px solid rgba(88, 166, 255, 0.5);
  outline-offset: 2px;
}

.quick-form-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.quick-form-btn-secondary {
  background: transparent;
  color: var(--qc-primary);
  border: 2px solid var(--qc-primary);
  box-shadow: none;
}

.quick-form-btn-secondary:hover {
  background: rgba(88, 166, 255, 0.1);
  border-color: var(--qc-primary-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(31, 111, 235, 0.2);
}

/* Button loader */
.btn-loader {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.quick-form-btn.loading .btn-text {
  visibility: hidden;
}

.quick-form-btn.loading .btn-loader {
  display: block;
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Error messages */
.quick-form-error {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--qc-error);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.quick-form-error:not(:empty) {
  opacity: 1;
}

/* Form footer */
.quick-form-footer {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px solid var(--qc-border);
  text-align: center;
}

.quick-form-footer p {
  margin: 0;
  font-size: 14px;
  color: var(--qc-text-light);
}

.quick-form-link {
  color: var(--qc-primary);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.3s ease;
  position: relative;
}

.quick-form-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--qc-primary), var(--qc-primary-light));
  transition: width 0.3s ease;
}

.quick-form-link:hover {
  color: var(--qc-primary-light);
}

.quick-form-link:hover::after {
  width: 100%;
}

/* Success state */
.quick-form-success {
  display: none;
  text-align: center;
  padding: 40px 28px;
}

.quick-form-success[aria-hidden="false"] {
  display: block;
  animation: successFadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes successFadeIn {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.success-icon {
  margin-bottom: 20px;
  color: var(--qc-success);
  animation: successPulse 0.6s ease;
  display: inline-flex;
  padding: 16px;
  background: rgba(16, 185, 129, 0.1);
  border-radius: 50%;
  box-shadow: 0 0 0 8px rgba(16, 185, 129, 0.05);
}

@keyframes successPulse {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.quick-form-success h4 {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--qc-text) 0%, var(--qc-success) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.quick-form-success p {
  margin: 0 0 24px;
  color: var(--qc-text-light);
  font-size: 15px;
  line-height: 1.5;
}

/* Error state */
.quick-form-error-state {
  display: none;
  padding: 18px;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.12) 0%, rgba(239, 68, 68, 0.06) 100%);
  border: 2px solid rgba(239, 68, 68, 0.3);
  border-radius: 12px;
  margin-top: 16px;
  animation: errorShake 0.5s ease;
}

@keyframes errorShake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.quick-form-error-state[aria-hidden="false"] {
  display: block;
}

.quick-form-error-state p {
  margin: 0;
  font-size: 14px;
  color: var(--qc-error);
  font-weight: 600;
}

.quick-form-error-state a {
  color: var(--qc-error);
  font-weight: 700;
  text-decoration: underline;
}

.quick-form-error-state a:hover {
  color: #dc2626;
}

/* Accessibility */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .quick-contact-toggle,
  .quick-contact-form,
  .quick-form-input,
  .quick-form-textarea,
  .quick-form-btn,
  .quick-form-error,
  .quick-contact-pulse {
    transition: none;
    animation: none;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .quick-contact-toggle,
  .quick-form-btn-primary {
    background: #000;
    color: #fff;
  }
  
  .quick-form-input,
  .quick-form-textarea {
    border-width: 2px;
  }
}

/* Enhanced interaction styles */
.quick-form-hint {
  display: block;
  font-size: 0.875rem;
  color: var(--qc-text-light);
  margin-top: 0.25rem;
  transition: opacity var(--qc-animation-duration) ease;
}

.quick-form-hint.hidden {
  opacity: 0;
  height: 0;
  margin: 0;
}

/* Character counter */
.quick-form-footer-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.quick-character-counter {
  font-size: 0.75rem;
  color: var(--qc-text-light);
  transition: all var(--qc-animation-duration) ease;
  font-weight: 500;
  padding: 4px 8px;
  background: rgba(88, 166, 255, 0.05);
  border-radius: 6px;
}

.quick-character-counter.warning {
  color: var(--qc-warning);
  font-weight: 700;
  background: rgba(245, 158, 11, 0.1);
  animation: pulse-warning 1s ease infinite;
}

@keyframes pulse-warning {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Enhanced error states */
.quick-form-error {
  display: block;
  color: var(--qc-error);
  font-size: 0.875rem;
  margin-top: 0.25rem;
  opacity: 0;
  transform: translateY(-10px);
  transition: all var(--qc-animation-duration) ease;
}

.quick-form-error.show {
  opacity: 1;
  transform: translateY(0);
}

/* Input states */
.quick-form-input.has-value,
.quick-form-textarea.has-value {
  background: linear-gradient(135deg, rgba(88, 166, 255, 0.03) 0%, transparent 100%);
  border-color: rgba(88, 166, 255, 0.3);
}

.quick-form-input.success,
.quick-form-textarea.success {
  border-color: var(--qc-success);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, transparent 100%);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.quick-form-input.error,
.quick-form-textarea.error {
  border-color: var(--qc-error);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.05) 0%, transparent 100%);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
  animation: errorShake 0.5s ease;
}

/* Shake animation for errors */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
  20%, 40%, 60%, 80% { transform: translateX(2px); }
}

.shake {
  animation: shake 0.5s ease-in-out;
}

/* Success icon */
.field-success-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--qc-success);
  font-size: 1.25rem;
  animation: fadeInScale 0.3s ease;
}

@keyframes fadeInScale {
  0% {
    opacity: 0;
    transform: translateY(-50%) scale(0.5);
  }
  100% {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }
}

/* Loading states */
.quick-form-btn.loading {
  position: relative;
  color: transparent;
}

.quick-form-btn.loading .btn-loader {
  display: inline-block;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.btn-loader {
  display: none;
}

/* Accessibility improvements */
.quick-form-input:focus-visible,
.quick-form-textarea:focus-visible {
  outline: 2px solid var(--qc-primary);
  outline-offset: 2px;
}

/* Form group spacing */
.quick-form-group {
  position: relative;
  margin-bottom: 1rem;
}

/* Print styles */
@media print {
  .quick-contact {
    display: none;
  }
}