/* 
 * KN Popup Frontend Styles
 * Following Tailwind philosophy with pure CSS
 * Color scheme from variables.css
 * Typography scale: 2.5rem, 1.5rem, 1rem
 * Spacing: 8px grid (1rem, 1.5rem, 2rem, 2.5rem)
 * Border radius: 1rem for large elements, 0.5rem for small
 */

/* ===== POPUP OVERLAY ===== */
.kn-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.kn-popup.kn-popup-active {
  opacity: 1 !important;
  visibility: visible !important;
  display: flex !important;
}

.kn-popup-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 20, 45, 0.8);
  backdrop-filter: blur(2px);
  transition: all 0.3s ease;
}

/* ===== POPUP MODAL ===== */
.kn-popup-modal {
  position: relative;
  background: #ffffff;
  border-radius: var(--border-radius-md);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  transition: all 0.3s ease;
  z-index: 1;
}

.kn-popup.kn-popup-active .kn-popup-modal {
  transform: scale(1) translateY(0);
}

/* ===== CLOSE BUTTON ===== */
.kn-popup-close {
  all: unset;
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.kn-popup-close:hover {
  background: var(--bg-secondary);
  border-color: var(--primary-color);
  transform: scale(1.1);
}

.kn-popup-close svg {
  width: 1rem;
  height: 1rem;
  color: var(--text-color);
  transition: all 0.3s ease;
}

.kn-popup-close:hover svg {
  color: var(--primary-color);
}

/* ===== POPUP CONTENT ===== */
.kn-popup-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 400px;
  overflow: hidden;
}

.kn-popup-form {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #ffffff;
  order: 1;
}

.kn-popup-image {
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  order: 2;
  position: relative;
}

.kn-popup-image::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    rgba(5, 20, 45, 0.1) 0%,
    rgba(26, 147, 202, 0.1) 100%
  );
  z-index: 1;
}

.kn-popup-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: all 0.3s ease;
}

/* ===== FORM STYLING ===== */
.kn-popup-form h2,
.kn-popup-form h3 {
  color: var(--primary-color);
  margin-bottom: 1rem;
  font-family: var(--font-primary);
  line-height: var(--line-height-tight);
}

.kn-popup-form h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

.kn-popup-form h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.kn-popup-form p {
  color: var(--text-color);
  line-height: var(--line-height-relaxed);
  margin-bottom: 1.5rem;
}

/* Formidable Form Overrides */
.kn-popup-form .frm_forms {
  margin: 0;
}

.kn-popup-form .frm_form_fields {
  padding: 0;
  background: transparent;
  border: none;
}

.kn-popup-form .frm_form_field {
  margin-bottom: 10px !important;
}

.kn-popup-form .frm_primary_label {
  font-weight: 600;
  color: var(--text-color);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  font-family: var(--font-primary);
}

.kn-popup-form input[type="text"],
.kn-popup-form input[type="email"],
.kn-popup-form input[type="tel"],
.kn-popup-form input[type="url"],
.kn-popup-form input[type="number"],
.kn-popup-form textarea,
.kn-popup-form select {
  background: #ffffff;
  min-height: auto !important;
  line-height: normal;
}

.kn-popup-form input:focus,
.kn-popup-form textarea:focus,
.kn-popup-form select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(5, 20, 45, 0.1);
}

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

.kn-popup-form textarea {
  resize: vertical;
  min-height: 100px;
}

/* Form Validation */
.kn-popup-form .frm_error_style {
  border-color: #dc3545;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.kn-popup-form .frm_error {
  color: #dc3545;
  font-size: 0.75rem;
  margin-top: 0.25rem;
  font-family: var(--font-primary);
}

/* Success Message */
.kn-popup-form .frm_message {
  background: #d4edda;
  color: #155724;
  padding: 1rem;
  border-radius: 0.5rem;
  border: 1px solid #c3e6cb;
  margin-bottom: 1rem;
  font-family: var(--font-primary);
}

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

/* Tablet: ≤ 1024px */
@media (max-width: 1024px) {
  .kn-popup-modal {
    max-width: 700px;
  }

  .kn-popup-content {
    min-height: 350px;
  }
}

/* Mobile: ≤ 768px */
@media (max-width: 768px) {
  .kn-popup {
    padding: 0.5rem;
    align-items: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .kn-popup-modal {
    max-width: 100%;
    max-height: none;
    border-radius: var(--border-radius-md);
    margin: 1rem auto;
    overflow: visible;
  }

  .kn-popup-content {
    grid-template-columns: 1fr;
    min-height: auto;
    overflow: visible;
  }

  .kn-popup-form {
    order: 2;
    overflow-y: auto;
    max-height: none;
  }

  .kn-popup-image {
    order: 1;
    min-height: 200px;
    max-height: 250px;
    overflow: hidden;
  }

  .kn-popup-close {
    top: 0.75rem;
    right: 0.75rem;
    width: 2rem;
    height: 2rem;
  }

  .kn-popup-close svg {
    width: 0.875rem;
    height: 0.875rem;
  }

  .kn-popup-form h2 {
    font-size: 1.25rem;
  }

  .kn-popup-form h3 {
    font-size: 1.125rem;
  }
}

/* Mobile Small: ≤ 480px */
@media (max-width: 480px) {
  .kn-popup {
    padding: 0.25rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .kn-popup-modal {
    border-radius: var(--border-radius-md);
    margin: 0.5rem auto;
  }

  .kn-popup-image {
    min-height: 150px;
    max-height: 200px;
    border-top-left-radius: var(--border-radius-md);
    border-top-right-radius: var(--border-radius-md);
  }

  .kn-popup-form h2 {
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
  }

  .kn-popup-form h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
  }

  .kn-popup-form p {
    font-size: 0.875rem;
    margin-bottom: 1rem;
  }

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

/* ===== ANIMATIONS ===== */
@keyframes kn-popup-fadeIn {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(30px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes kn-popup-slideIn {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Animation variants */
.kn-popup.kn-popup-animate-fade .kn-popup-modal {
  animation: kn-popup-fadeIn 0.4s ease-out;
}

.kn-popup.kn-popup-animate-slide .kn-popup-form {
  animation: kn-popup-slideIn 0.5s ease-out 0.2s both;
}

/* ===== ACCESSIBILITY ===== */
.kn-popup-modal:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .kn-popup-overlay {
    background: rgba(0, 0, 0, 0.9);
  }

  .kn-popup-modal {
    border: 2px solid var(--text-color);
  }

  .kn-popup-close {
    border: 2px solid var(--text-color);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .kn-popup,
  .kn-popup-modal,
  .kn-popup-close,
  .kn-popup-image img,
  .kn-popup-form .frm_submit,
  .kn-popup-form input,
  .kn-popup-form textarea {
    transition: none;
  }

  .kn-popup.kn-popup-animate-fade .kn-popup-modal,
  .kn-popup.kn-popup-animate-slide .kn-popup-form {
    animation: none;
  }
}

/* ===== NO-JS FALLBACK ===== */
.no-js .kn-popup {
  position: static;
  opacity: 1;
  visibility: visible;
  z-index: auto;
  padding: 2rem 0;
}

.no-js .kn-popup-overlay {
  display: none;
}

.no-js .kn-popup-modal {
  transform: none;
  max-width: 800px;
  margin: 0 auto;
  position: relative;
}

.no-js .kn-popup-close {
  display: none;
}
