/**
 * Voice Support Modal CSS
 * Comprehensive styling for voice support modal system with responsive design and accessibility features
 */

/* ==========================================================================
   ROOT VARIABLES & RESETS
   ========================================================================== */

:root {
  --voice-modal-brand-pink: #B33E96;
  --voice-modal-backdrop: rgba(0, 0, 0, 0.8);
  --voice-modal-white: #ffffff;
  --voice-modal-border-radius: 8px;
  --voice-modal-z-index: 9999;
  --voice-modal-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --voice-modal-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --voice-modal-focus-ring: 0 0 0 3px rgba(179, 62, 150, 0.5);
  --voice-modal-close-size: 44px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  :root {
    --voice-modal-transition: none;
  }
}

/* ==========================================================================
   MODAL BACKDROP & CONTAINER
   ========================================================================== */

.voice-support-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('/wp-content/uploads/2025/07/quote-bg-scaled.jpeg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  z-index: var(--voice-modal-z-index);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  
  /* Initial hidden state */
  opacity: 0;
  visibility: hidden;
  transition: var(--voice-modal-transition);
  
  /* Prevent scrolling behind modal */
  overflow: hidden;
}

/* Modal visible state */
.voice-support-modal.show,
.voice-support-modal.active {
  opacity: 1;
  visibility: visible;
}

/* Modal container sizing */
.modal-container {
  position: relative;
  background-color: var(--voice-modal-white);
  border-radius: var(--voice-modal-border-radius);
  box-shadow: var(--voice-modal-shadow);
  overflow: visible; /* Allow close button to overflow */
  transform: scale(0.9) translateY(20px);
  transition: var(--voice-modal-transition);
  will-change: transform, opacity;
  
  /* Proper sizing to match design mockup */
  width: 600px;
  max-width: 90vw;
  height: 80vh;
  min-height: 500px;
  max-height: 90vh;
}

/* Modal container visible state */
.voice-support-modal.active .modal-container {
  transform: scale(1) translateY(0);
}

/* Modal header */
.modal-header {
  position: relative;
  padding: 10px;
  background-color: var(--voice-modal-white);
  border-bottom: 1px solid #e5e7eb;
}

/* Modal content area */
.modal-content {
  height: calc(100% - 60px); /* Account for header */
  overflow: hidden;
  border-radius: 0 0 var(--voice-modal-border-radius) var(--voice-modal-border-radius);
}

/* Iframe styling */
#voice-support-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* Close button - pink circular design to match mockup */
.modal-close-btn {
  position: absolute;
  top: -20px;
  right: -20px;
  width: 40px;
  height: 40px;
  background-color: var(--voice-modal-brand-pink);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(179, 62, 150, 0.3);
  z-index: 10001; /* Higher than modal z-index */
}

.modal-close-btn:hover {
  background-color: #a0368a;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(179, 62, 150, 0.4);
}

.modal-close-btn svg {
  width: 20px;
  height: 20px;
  color: white;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .voice-support-modal {
    background-color: rgba(0, 0, 0, 0.95);
  }
}

/* ==========================================================================
   MODAL CONTENT CONTAINER
   ========================================================================== */

.voice-support-modal-content {
  position: relative;
  background-color: var(--voice-modal-white);
  border-radius: var(--voice-modal-border-radius);
  box-shadow: var(--voice-modal-shadow);
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  transition: var(--voice-modal-transition);
  will-change: transform, opacity;
  
  /* Default desktop sizing */
  width: 90%;
  max-width: 800px;
  height: 600px;
  max-height: 90vh;
}

/* Modal content visible state */
.voice-support-modal.show .voice-support-modal-content {
  transform: scale(1) translateY(0);
}

/* Focus trap container */
.voice-support-modal-content:focus {
  outline: none;
}

/* ==========================================================================
   MODAL HEADER
   ========================================================================== */

.voice-support-modal-header {
  position: relative;
  background-color: var(--voice-modal-brand-pink);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  box-sizing: border-box;
}

.voice-support-modal-title {
  color: var(--voice-modal-white);
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  line-height: 1.4;
}

/* ==========================================================================
   CLOSE BUTTON
   ========================================================================== */

.voice-support-modal-close {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  width: var(--voice-modal-close-size);
  height: var(--voice-modal-close-size);
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--voice-modal-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--voice-modal-transition);
  font-size: 20px;
  line-height: 1;
  padding: 0;
  margin: 0;
}

.voice-support-modal-close:hover {
  background-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-50%) scale(1.1);
}

.voice-support-modal-close:focus {
  outline: none;
  box-shadow: var(--voice-modal-focus-ring);
  background-color: rgba(255, 255, 255, 0.1);
}

.voice-support-modal-close:active {
  transform: translateY(-50%) scale(0.95);
}

/* Close button icon */
.voice-support-modal-close::before {
  content: "×";
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
}

/* Screen reader text for close button */
.voice-support-modal-close .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;
}

/* ==========================================================================
   MODAL BODY & IFRAME
   ========================================================================== */

.voice-support-modal-body {
  position: relative;
  height: calc(100% - 60px); /* Subtract header height */
  overflow: hidden;
  background-color: var(--voice-modal-white);
}

.voice-support-modal-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background-color: var(--voice-modal-white);
  transition: opacity 0.3s ease;
}

/* ==========================================================================
   LOADING STATES
   ========================================================================== */

.voice-support-modal-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--voice-modal-brand-pink);
}

.voice-support-modal-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(179, 62, 150, 0.2);
  border-top-color: var(--voice-modal-brand-pink);
  border-radius: 50%;
  animation: voice-modal-spin 1s linear infinite;
}

.voice-support-modal-loading-text {
  font-size: 14px;
  color: #666;
  text-align: center;
}

/* Loading spinner animation */
@keyframes voice-modal-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Hide loading when iframe is loaded */
.voice-support-modal-iframe.loaded + .voice-support-modal-loading {
  display: none;
}

/* ==========================================================================
   ERROR STATES
   ========================================================================== */

.voice-support-modal-error {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  padding: 40px 20px;
  max-width: 80%;
}

.voice-support-modal-error-icon {
  font-size: 48px;
  color: #dc3545;
  margin-bottom: 16px;
}

.voice-support-modal-error-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin: 0 0 8px 0;
}

.voice-support-modal-error-message {
  font-size: 14px;
  color: #666;
  margin: 0 0 20px 0;
  line-height: 1.5;
}

.voice-support-modal-retry-btn {
  background-color: var(--voice-modal-brand-pink);
  color: var(--voice-modal-white);
  border: none;
  padding: 12px 24px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--voice-modal-transition);
}

.voice-support-modal-retry-btn:hover {
  background-color: #9a3580;
  transform: translateY(-1px);
}

.voice-support-modal-retry-btn:focus {
  outline: none;
  box-shadow: var(--voice-modal-focus-ring);
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

/* Mobile devices (≤767px) */
@media screen and (max-width: 767px) {
  .voice-support-modal {
    padding: 5%;
  }
  
  .voice-support-modal-content {
    width: 90%;
    height: 90%;
    max-width: none;
    max-height: 90vh;
  }
  
  .voice-support-modal-header {
    padding: 12px 16px;
    min-height: 50px;
  }
  
  .voice-support-modal-title {
    font-size: 16px;
    padding-right: 50px; /* Make room for close button */
  }
  
  .voice-support-modal-close {
    right: 12px;
    width: 40px;
    height: 40px;
  }
  
  .voice-support-modal-close::before {
    font-size: 20px;
  }
  
  .voice-support-modal-body {
    height: calc(100% - 50px);
  }
  
  .voice-support-modal-error {
    padding: 20px 16px;
    max-width: 90%;
  }
  
  .voice-support-modal-error-icon {
    font-size: 36px;
  }
  
  .voice-support-modal-error-title {
    font-size: 16px;
  }
}

/* Tablet devices (768px - 1199px) */
@media screen and (min-width: 768px) and (max-width: 1199px) {
  .voice-support-modal-content {
    width: 85%;
    height: 80%;
    max-width: 700px;
  }
}

/* Large desktop (≥1200px) */
@media screen and (min-width: 1200px) {
  .voice-support-modal-content {
    width: 90%;
    max-width: 800px;
    height: 600px;
  }
}

/* Very small screens (≤480px) */
@media screen and (max-width: 480px) {
  .voice-support-modal {
    padding: 2%;
  }
  
  .voice-support-modal-content {
    width: 96%;
    height: 96%;
    border-radius: 4px;
  }
  
  .voice-support-modal-header {
    padding: 10px 12px;
    min-height: 44px;
  }
  
  .voice-support-modal-title {
    font-size: 14px;
  }
  
  .voice-support-modal-close {
    right: 8px;
    width: 36px;
    height: 36px;
  }
  
  .voice-support-modal-body {
    height: calc(100% - 44px);
  }
}

/* ==========================================================================
   ACCESSIBILITY ENHANCEMENTS
   ========================================================================== */

/* Focus management */
.voice-support-modal[aria-hidden="true"] {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.voice-support-modal[aria-hidden="false"] {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Keyboard navigation indicators */
.voice-support-modal-content:focus-within {
  box-shadow: var(--voice-modal-shadow), var(--voice-modal-focus-ring);
}

/* Screen reader improvements */
.voice-support-modal[role="dialog"] {
  /* Ensures proper semantics */
}

.voice-support-modal-content[aria-labelledby] {
  /* Ensures proper labeling */
}

/* High contrast mode adjustments */
@media (prefers-contrast: high) {
  .voice-support-modal-header {
    border-bottom: 2px solid var(--voice-modal-white);
  }
  
  .voice-support-modal-close {
    border: 2px solid var(--voice-modal-white);
  }
  
  .voice-support-modal-content {
    border: 2px solid #000;
  }
}

/* ==========================================================================
   PERFORMANCE OPTIMIZATIONS
   ========================================================================== */

/* GPU acceleration for smooth animations */
.voice-support-modal-content,
.voice-support-modal-close {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Prevent layout shifts during animations */
.voice-support-modal-spinner {
  contain: layout style paint;
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
  .voice-support-modal {
    display: none !important;
  }
}

/* ==========================================================================
   BROWSER-SPECIFIC FIXES
   ========================================================================== */

/* Safari-specific fixes */
@supports (-webkit-appearance: none) {
  .voice-support-modal-iframe {
    -webkit-transform: translateZ(0);
  }
}

/* Firefox-specific fixes */
@-moz-document url-prefix() {
  .voice-support-modal-close {
    -moz-appearance: none;
  }
}

/* Edge-specific fixes */
@supports (-ms-ime-align: auto) {
  .voice-support-modal-content {
    -ms-overflow-style: none;
  }
}

/* ==========================================================================
   VOICE SUPPORT PAGE SPECIFIC STYLES
   ========================================================================== */

/* Voice Support Button - Override width to prevent text wrapping */
#voice-support-modal-trigger.btn {
  width: auto;
  min-width: 240px;
  white-space: nowrap;
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */

/* Hidden state for screen readers */
.voice-support-modal .sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Focus-visible polyfill support */
.voice-support-modal .focus-visible {
  outline: none;
  box-shadow: var(--voice-modal-focus-ring);
}

/* No-scroll class for body when modal is open */
body.voice-support-modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

/* Prevent text selection on modal backdrop */
.voice-support-modal::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  user-select: none;
  pointer-events: none;
}