/**
 * WhatsApp Button Plugin Styles
 * Version: 1.1
 */

/* CSS Custom Properties for dynamic theming */
:root {
  --whatsapp-primary-color: #25d366;
  --whatsapp-primary-hover: #22b358;
  --whatsapp-primary-shadow: #1da049;
  --whatsapp-primary-light: rgba(37, 211, 102, 0.3);
}

/* WhatsApp Button Styles */
#whatsapp-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: linear-gradient(
    135deg,
    var(--whatsapp-primary-color) 0%,
    var(--whatsapp-primary-hover) 100%
  );
  color: white;
  border-radius: 50px;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 4px 20px var(--whatsapp-primary-light);
  transition: all 0.3s ease;
  border: none;
  outline: none;
}

#whatsapp-button:hover,
#whatsapp-button:focus {
  background: linear-gradient(
    135deg,
    var(--whatsapp-primary-hover) 0%,
    var(--whatsapp-primary-shadow) 100%
  );
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 25px var(--whatsapp-primary-light);
}

#whatsapp-button img {
  width: 30px;
  height: 30px;
  pointer-events: none;
}

/* Custom icon styles for smart logo feature */
#whatsapp-button .whatsapp-custom-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  pointer-events: none;
}

#whatsapp-button .whatsapp-custom-icon img {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  object-fit: cover;
}

#whatsapp-button .whatsapp-text-icon {
  font-size: 16px;
  font-weight: bold;
  color: white;
  text-transform: uppercase;
  text-align: center;
  line-height: 1;
}

/* Position variants */
#whatsapp-button.whatsapp-bottom-left {
  bottom: 20px;
  left: 20px;
  right: auto;
}
#whatsapp-button.whatsapp-top-right {
  top: 20px;
  right: 20px;
  bottom: auto;
}
#whatsapp-button.whatsapp-top-left {
  top: 20px;
  left: 20px;
  bottom: auto;
  right: auto;
}
#whatsapp-button.whatsapp-bottom-right {
  bottom: 20px;
  right: 20px;
}

/* WhatsApp Form Overlay */
/* WhatsApp Form Modal Styles */
.whatsapp-form-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.whatsapp-form-overlay.active {
  display: flex;
  opacity: 1;
}

.whatsapp-form {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  position: relative;
  transform: translateY(20px);
  transition: transform 0.3s ease;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  max-height: 90vh;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
}

.whatsapp-form-overlay.active .whatsapp-form {
  transform: translateY(0);
}

/* Header with branding */
/* Form header */
.whatsapp-form-header {
  background: linear-gradient(
    135deg,
    var(--whatsapp-primary-color) 0%,
    var(--whatsapp-primary-hover) 100%
  );
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 8px 8px 0 0;
}

.whatsapp-brand-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.whatsapp-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.whatsapp-company-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.whatsapp-default-avatar {
  background: var(--whatsapp-primary-color);
  color: white;
  font-weight: bold;
  font-size: 18px;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}

.whatsapp-brand-text {
  flex: 1;
}

.whatsapp-company-name {
  color: white;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}

.whatsapp-status {
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  display: block;
  margin-top: 1px;
}

/* Welcome message */
.whatsapp-welcome-message {
  padding: 20px 24px 24px;
  background: #f8f9fa;
  border-radius: 8px;
  margin: 16px 24px 0;
  border: 1px solid #e9ecef;
}

.whatsapp-welcome-message p {
  margin: 0;
  color: #495057;
  font-size: 14px;
  line-height: 1.5;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#whatsapp-form h2 {
  margin-top: 0;
  color: #333;
  font-size: 1.5em;
  text-align: center;
}

/* Form Container */
.whatsapp-contact-form {
  padding: 20px;
  background: white;
}

/* Form Field Styles */
.whatsapp-field-group {
  margin-bottom: 12px;
}

.whatsapp-label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 500;
  color: #495057;
}

.whatsapp-input,
.whatsapp-phone-number {
  width: 100%;
  padding: 16px;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.2s ease;
  box-sizing: border-box;
  font-family: inherit;
  background: #ffffff;
  color: #495057;
}

.whatsapp-input:focus,
.whatsapp-phone-number:focus {
  outline: none;
  border-color: var(--whatsapp-primary-color);
  background: #ffffff;
  box-shadow: 0 0 0 3px var(--whatsapp-primary-light);
}

.whatsapp-input::placeholder,
.whatsapp-phone-number::placeholder {
  color: #6c757d;
  font-size: 14px;
}

/* Error States for Input Fields */
.whatsapp-input.error,
.whatsapp-phone-number.error {
  border-color: #dc3545;
  background-color: #fff5f5;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.whatsapp-input.error:focus,
.whatsapp-phone-number.error:focus {
  border-color: #dc3545;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.2);
}

/* Error Messages */
.whatsapp-error-message {
  display: none;
  margin-top: 6px;
  padding: 8px 12px 8px 36px;
  font-size: 12px;
  color: #dc3545;
  font-weight: 500;
  line-height: 1.4;
  background-color: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: 6px;
  position: relative;
  animation: fadeInError 0.3s ease-in-out;
}

.whatsapp-error-message.show {
  display: block;
}

.whatsapp-error-message::before {
  content: '⚠';
  position: absolute;
  left: 12px;
  top: 8px;
  font-size: 12px;
  color: #dc3545;
  font-weight: bold;
}

.field-error {
  margin-top: 6px;
  padding: 8px 12px 8px 36px;
  font-size: 12px;
  color: #dc3545;
  font-weight: 500;
  line-height: 1.4;
  background-color: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: 6px;
  position: relative;
  animation: fadeInError 0.3s ease-in-out;
}

.field-error::before {
  content: '⚠';
  position: absolute;
  left: 12px;
  top: 8px;
  font-size: 12px;
  color: #dc3545;
  font-weight: bold;
}

@keyframes fadeInError {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Phone input with country selector */
.whatsapp-phone-group {
  position: relative;
}

.whatsapp-phone-input {
  display: flex;
  gap: 0;
}

.flag-icon {
  width: 20px;
  height: 15px;
  border-radius: 2px;
}

.country-code {
  font-size: 14px;
  color: #495057;
  font-weight: 500;
}

.dropdown-arrow {
  width: 12px;
  height: 12px;
  color: #6c757d;
}

.whatsapp-phone-number {
  border-radius: 0 8px 8px 0;
  border-left: none;
  flex: 1;
}

/* Checkbox styles */
.whatsapp-consent-group {
  margin: 16px 0 12px;
}

.whatsapp-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.4;
}

.whatsapp-checkbox {
  display: none;
}

.whatsapp-checkbox-custom {
  width: 18px;
  height: 18px;
  border: 2px solid #dee2e6;
  border-radius: 4px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  margin-top: 2px;
}

.whatsapp-checkbox:checked + .whatsapp-checkbox-custom {
  background: var(--whatsapp-primary-color);
  border-color: var(--whatsapp-primary-color);
}

.whatsapp-checkbox:checked + .whatsapp-checkbox-custom::after {
  content: '✓';
  color: white;
  font-size: 12px;
  font-weight: bold;
}

.whatsapp-checkbox-text {
  color: #495057;
  flex: 1;
}

/* Checkbox Error State */
.whatsapp-consent-group .whatsapp-checkbox-custom.error,
.whatsapp-consent-group:has(.whatsapp-error-message.show)
  .whatsapp-checkbox-custom {
  border-color: #dc3545;
  background-color: #fff5f5;
}

.whatsapp-consent-group .whatsapp-checkbox-text.error,
.whatsapp-consent-group:has(.whatsapp-error-message.show)
  .whatsapp-checkbox-text {
  color: #dc3545;
}

/* Privacy notice */
.whatsapp-privacy-notice {
  margin: 12px 0 20px;
}

.whatsapp-privacy-notice p {
  font-size: 12px;
  line-height: 1.4;
  color: #6c757d;
  margin: 0;
}

/* Legacy form elements for compatibility */
#whatsapp-form input,
#whatsapp-form textarea {
  width: 100%;
  padding: 12px;
  margin: 8px 0;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  box-sizing: border-box;
  transition: border-color 0.3s ease;
}

#whatsapp-form input:focus,
#whatsapp-form textarea:focus {
  outline: none;
  border-color: var(--whatsapp-primary-color);
  box-shadow: 0 0 5px var(--whatsapp-primary-shadow);
}

#whatsapp-form textarea {
  resize: vertical;
  min-height: 80px;
}

/* Submit Button */
.whatsapp-submit-btn {
  background: linear-gradient(
    135deg,
    var(--whatsapp-primary-color) 0%,
    var(--whatsapp-primary-hover) 100%
  );
  color: white;
  border: none;
  padding: 16px 24px;
  border-radius: 25px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.whatsapp-submit-btn:hover:not(:disabled) {
  background: linear-gradient(
    135deg,
    var(--whatsapp-primary-hover) 0%,
    var(--whatsapp-primary-shadow) 100%
  );
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--whatsapp-primary-light);
}

.whatsapp-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Legacy submit button for compatibility */
#whatsapp-form button[type='submit'] {
  background-color: var(--whatsapp-primary-color);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  width: 100%;
  transition: background-color 0.3s ease;
  font-weight: bold;
}

#whatsapp-form button[type='submit']:hover:not(:disabled) {
  background-color: var(--whatsapp-primary-hover);
}

#whatsapp-form button[type='submit']:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Close Button */
.whatsapp-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  color: white;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
  line-height: 1;
}

.whatsapp-close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

/* Legacy close button for compatibility */
#whatsapp-form .close-btn {
  position: absolute;
  top: 10px;
  right: 15px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.3s ease;
}

#whatsapp-form .close-btn:hover {
  color: #333;
}

/* Loading State */
#whatsapp-form.loading {
  pointer-events: none;
}

#whatsapp-form.loading button[type='submit'] {
  position: relative;
  color: transparent;
}

#whatsapp-form.loading button[type='submit']::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #ffffff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Messages */
.whatsapp-message {
  padding: 10px;
  margin: 10px;
  border-radius: 4px;
  font-size: 14px;
}

.whatsapp-error {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.whatsapp-success {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

/* Modern Responsive Design */
@media (max-width: 768px) {
  .whatsapp-form {
    width: 95%;
    max-width: none;
    margin: 10px;
    border-radius: 12px;
  }

  .whatsapp-form-header {
    padding: 16px 20px 12px;
  }

  .whatsapp-welcome-message {
    margin: 12px 20px 0;
    padding: 16px 20px 20px;
  }

  .whatsapp-contact-form {
    padding: 20px;
  }

  .whatsapp-phone-input {
    flex-direction: column;
    gap: 8px;
  }

  .whatsapp-phone-number {
    border-radius: 8px;
    border-left: 1px solid #e0e0e0;
  }
}

@media (max-width: 480px) {
  .whatsapp-form {
    width: 100%;
    height: 100vh;
    max-height: none;
    border-radius: 0;
  }

  .whatsapp-form-overlay {
    align-items: flex-start;
  }

  /* Legacy responsive */
  #whatsapp-form {
    width: 95%;
    margin: 0 10px;
    padding: 15px;
  }

  #whatsapp-button {
    width: 50px;
    height: 50px;
  }

  #whatsapp-button img {
    width: 25px;
    height: 25px;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  #whatsapp-button,
  #whatsapp-form input,
  #whatsapp-form textarea,
  #whatsapp-form button {
    transition: none;
  }

  @keyframes slideIn {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  #whatsapp-button {
    border: 2px solid currentColor;
  }

  #whatsapp-form {
    border: 2px solid #333;
  }

  #whatsapp-form input,
  #whatsapp-form textarea {
    border: 2px solid #333;
  }
}
