/* =====================================================================
   XSUNT Contact Form Modal Styles
   ===================================================================== */

/* Lock body scrolling when modal is open */
body.xsunt-modal-open {
  overflow: hidden !important;
}

/* Modal Wrapper / Backdrop */
.xsunt-contact-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  justify-content: center;
  padding: 24px 16px;
  box-sizing: border-box;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s;
}

.xsunt-contact-modal.is-active {
  opacity: 1;
  visibility: visible;
}

.xsunt-modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(10, 18, 48, 0.6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  cursor: pointer;
}

/* Modal Card */
.xsunt-modal-card {
  position: relative;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 24px 60px -15px rgba(10, 18, 48, 0.35), 0 0 1px rgba(10, 18, 48, 0.1);
  width: 100%;
  max-width: 550px;
  height: auto;
  max-height: calc(100vh - 30px);
  max-height: calc(100dvh - 30px);
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  margin: auto;
  padding: 24px 32px 22px;
  box-sizing: border-box;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2;
  scrollbar-width: thin;
  scrollbar-color: #CBD5E1 transparent;
}

.xsunt-contact-modal.is-active .xsunt-modal-card {
  transform: translateY(0) scale(1);
}

/* Custom scrollbar for modal card */
.xsunt-modal-card::-webkit-scrollbar {
  width: 6px;
}
.xsunt-modal-card::-webkit-scrollbar-track {
  background: transparent;
}
.xsunt-modal-card::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 999px;
}

/* Close Button - sticky so it stays accessible when scrolled */
.xsunt-modal-close {
  position: sticky;
  top: 10px;
  float: right;
  margin-top: -6px;
  margin-right: -14px;
  margin-bottom: -32px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #64748B;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(10, 18, 48, 0.08);
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.xsunt-modal-close:hover,
.xsunt-modal-close:focus-visible {
  background-color: #F1F5F9;
  color: #0A1230;
  transform: scale(1.05);
  outline: none;
}

/* Modal Header */
.xsunt-modal-header {
  margin-bottom: 14px;
}

.xsunt-modal-badge {
  display: inline-block;
  background-color: #E6F7F2;
  color: #0E8373;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.xsunt-modal-title {
  font-family: 'Schibsted Grotesk', 'Inter', system-ui, sans-serif;
  font-size: 1.65rem;
  font-weight: 800;
  color: #0A1230;
  line-height: 1.15;
  letter-spacing: -0.025em;
  margin: 0 0 10px 0;
}

.xsunt-modal-subtitle {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.88rem;
  line-height: 1.42;
  color: #4A5875;
  margin: 0;
  max-width: 480px;
}

/* Form Styles */
.xsunt-contact-form {
  display: flex;
  flex-direction: column;
  gap: 10px
}

.xsunt-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 10px;
}

.xsunt-form-group {
  display: flex;
  flex-direction: column;
}

.xsunt-form-group-full {
  margin-bottom: 10px;
}

.xsunt-form-group label {
  display: block;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: #0A1230;
  margin-bottom: 4px;
}

.xsunt-form-group .req {
  color: #E11D48;
  font-weight: 700;
  margin-left: 2px;
}

/* Inputs, Select, Textarea */
.xsunt-form-group input[type="text"],
.xsunt-form-group input[type="email"],
.xsunt-form-group select,
.xsunt-form-group textarea {
  width: 100%;
  box-sizing: border-box;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.88rem;
  color: #0A1230;
  background-color: #FFFFFF;
  border: 1.5px solid #D8E0ED;
  border-radius: 8px;
  padding: 8px 12px;
  line-height: 1.4;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.xsunt-form-group input[type="text"]::placeholder,
.xsunt-form-group input[type="email"]::placeholder,
.xsunt-form-group textarea::placeholder {
  color: #94A3B8;
}

.xsunt-form-group input:hover,
.xsunt-form-group select:hover,
.xsunt-form-group textarea:hover {
  border-color: #CBD5E1;
}

.xsunt-form-group input:focus,
.xsunt-form-group select:focus,
.xsunt-form-group textarea:focus {
  outline: none;
  border-color: #00c2a8;
  box-shadow: 0 0 0 3px rgba(0, 194, 168, 0.16);
}

.xsunt-form-group.has-error input,
.xsunt-form-group.has-error select,
.xsunt-form-group.has-error textarea {
  border-color: #EF4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.14);
}

.xsunt-field-error {
  display: none;
  font-size: 0.78rem;
  color: #DC2626;
  font-weight: 500;
  margin-top: 5px;
}

.xsunt-form-group.has-error .xsunt-field-error {
  display: block;
}

/* Custom Select Dropdown matching Mockup */
.xsunt-custom-select {
  position: relative;
  width: 100%;
}

.xsunt-custom-select-trigger {
  width: 100%;
  box-sizing: border-box;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.88rem;
  color: #0A1230;
  background-color: #FFFFFF;
  border: 1.5px solid #D8E0ED;
  border-radius: 8px;
  padding: 8px 36px 8px 12px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  position: relative;
}

.xsunt-custom-select.is-open .xsunt-custom-select-trigger,
.xsunt-custom-select-trigger:focus-visible {
  outline: none;
  border-color: #00c2a8;
  box-shadow: 0 0 0 3px rgba(0, 194, 168, 0.16);
}

.xsunt-custom-select-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #0A1230;
}

.xsunt-custom-select .xsunt-select-chevron {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: #00c2a8;
  pointer-events: none;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.xsunt-custom-select.is-open .xsunt-select-chevron {
  transform: translateY(-50%) rotate(180deg);
}

/* Custom Select Menu (Dropdown Panel) */
.xsunt-custom-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 100;
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  box-shadow: 0 12px 28px -6px rgba(10, 18, 48, 0.14), 0 4px 10px -2px rgba(10, 18, 48, 0.05);
  padding: 6px;
  margin: 0;
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  box-sizing: border-box;
}

/* Custom scrollbar for dropdown menu */
.xsunt-custom-select-menu::-webkit-scrollbar {
  width: 5px;
}
.xsunt-custom-select-menu::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 999px;
}

/* Option Items */
.xsunt-custom-select-option {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.88rem;
  color: #0A1230;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  user-select: none;
}

.xsunt-custom-select-option:hover,
.xsunt-custom-select-option.is-highlighted {
  background-color: #EDF2FE;
  color: #101B42;
}

.xsunt-custom-select-option.is-selected {
  background-color: #EDF2FE;
  color: #16255C;
  font-weight: 500;
}

/* Textarea */
.xsunt-form-group textarea {
  min-height: 70px;
  resize: vertical;
}

/* Footer / Submit Button */
.xsunt-form-footer {
  margin-top: 4px;
  display: flex;
  align-items: center;
}

.xsunt-submit-btn {
  background: linear-gradient(120deg, #3D59A7 0%, #00c2a8 100%);
  background-size: 160% 100%;
  color: #ffffff;
  border: 0;
  border-radius: 8px;
  padding: 10px 22px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.22s ease, transform 0.1s ease;
}

.xsunt-submit-btn:hover {
  background-position: 100% 0;
  transform: translateY(-1px);
  box-shadow: 0 10px 24px -10px rgba(31, 78, 216, 0.55);
}

.xsunt-submit-btn:active {
  transform: scale(0.98);
}

.xsunt-submit-btn .arrow {
  transition: transform 0.22s ease;
}

.xsunt-submit-btn:hover .arrow {
  transform: translateX(3px);
}

/* Loading Spinner */
.xsunt-submit-btn .btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: xsuntSpin 0.7s linear infinite;
  margin-left: 2px;
}

.xsunt-submit-btn.is-loading {
  pointer-events: none;
  opacity: 0.85;
}

.xsunt-submit-btn.is-loading .arrow {
  display: none;
}

.xsunt-submit-btn.is-loading .btn-spinner {
  display: inline-block;
}

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

/* Feedback Notifications */
.xsunt-form-feedback {
  margin-top: 18px;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 0.92rem;
  line-height: 1.5;
  font-family: 'Inter', system-ui, sans-serif;
}

.xsunt-form-feedback.is-success {
  background-color: #E8F8F4;
  border: 1px solid #A2E8DC;
  color: #0E6C5E;
}

.xsunt-form-feedback.is-error {
  background-color: #FEF2F2;
  border: 1px solid #FECACA;
  color: #991B1B;
}

/* Result View (Success / Failure Screen) */
.xsunt-modal-result-view {
  min-height: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  text-align: center;
  box-sizing: border-box;
}

.xsunt-result-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: auto 0;
}

.xsunt-result-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  animation: xsuntPopIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.xsunt-result-icon-success {
  background-color: #E6F7F2;
  color: #0E8373;
}

.xsunt-result-icon-error {
  background-color: #FEE2E2;
  color: #DC2626;
}

.xsunt-result-title {
  font-family: 'Schibsted Grotesk', 'Inter', system-ui, sans-serif;
  font-size: 1.65rem;
  font-weight: 800;
  color: #0A1230;
  margin: 0 0 8px 0;
  line-height: 1.2;
}

.xsunt-result-text {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.92rem;
  line-height: 1.5;
  color: #4A5875;
  margin: 0 0 24px 0;
  max-width: 440px;
}

.xsunt-result-btn,
.xsunt-retry-btn {
  padding: 10px 28px;
  border-radius: 8px;
}

@keyframes xsuntPopIn {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Responsive Breakpoint for Mobile */
@media (max-width: 640px) {
  .xsunt-contact-modal {
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .xsunt-modal-card {
    padding: 18px 18px calc(16px + env(safe-area-inset-bottom, 0px));
    border-radius: 16px;
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
  }

  .xsunt-modal-close {
    top: 8px;
    margin-right: -6px;
    margin-top: -4px;
  }

  .xsunt-modal-header {
    margin-bottom: 12px;
  }

  .xsunt-modal-badge {
    margin-bottom: 6px;
  }

  .xsunt-modal-title {
    font-size: 1.45rem;
    margin-bottom: 6px;
  }

  .xsunt-modal-subtitle {
    font-size: 0.85rem;
    line-height: 1.38;
  }

  .xsunt-form-row {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 10px;
  }

  .xsunt-form-group-full {
    margin-bottom: 10px;
  }

  .xsunt-form-group textarea {
    min-height: 65px;
  }

  .xsunt-form-footer {
    margin-top: 8px;
    padding-bottom: 2px;
  }

  .xsunt-submit-btn {
    width: 100%;
    justify-content: center;
    padding: 12px 20px;
  }
}

/* Compact rules for short screens, landscape mode, or active virtual keyboard */
@media (max-height: 580px) {
  .xsunt-contact-modal {
    padding: 8px;
  }

  .xsunt-modal-card {
    padding: 14px 16px 14px;
    border-radius: 12px;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }

  .xsunt-modal-header {
    margin-bottom: 8px;
  }

  .xsunt-modal-badge {
    margin-bottom: 4px;
    padding: 2px 8px;
    font-size: 0.68rem;
  }

  .xsunt-modal-title {
    font-size: 1.25rem;
    margin-bottom: 4px;
  }

  .xsunt-modal-subtitle {
    display: none; /* Hide subtitle to preserve vital vertical space */
  }

  .xsunt-form-row {
    gap: 8px;
    margin-bottom: 8px;
  }

  .xsunt-form-group-full {
    margin-bottom: 8px;
  }

  .xsunt-form-group label {
    font-size: 0.78rem;
    margin-bottom: 2px;
  }

  .xsunt-form-group input[type="text"],
  .xsunt-form-group input[type="email"],
  .xsunt-form-group select,
  .xsunt-form-group textarea,
  .xsunt-custom-select-trigger {
    padding: 6px 10px;
    font-size: 0.84rem;
  }

  .xsunt-form-group textarea {
    min-height: 50px;
  }

  .xsunt-submit-btn {
    padding: 9px 18px;
    font-size: 0.85rem;
  }
}
