/**
 * Leads Manager - Modal Styles
 * Version: 2.1.0
 *
 * Modal system for displaying forms in popups
 * Works with MicroModal.js library
 */

/* ============================================================================
   MODAL OVERLAY (Backdrop)
   ============================================================================ */

.lm-modal {
  display: none;
}

.lm-modal.is-open {
  display: block;
}

.lm-modal__overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999999;
}

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

.lm-modal__container {
  background-color: #ffffff;
  padding: 0;
  max-width: 600px;
  /* Default: medium */
  max-height: 90vh;
  border-radius: 8px;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  position: relative;
  margin: 20px;
}

/* Width Modifiers */
.lm-modal--small .lm-modal__container {
  max-width: 400px;
}

.lm-modal--medium .lm-modal__container {
  max-width: 600px;
}

.lm-modal--large .lm-modal__container {
  max-width: 800px;
}

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

.lm-modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 30px;
  border-bottom: 1px solid #e5e5e5;
  background-color: #f9f9f9;
  border-radius: 8px 8px 0 0;
}

.lm-modal__title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: #333;
  line-height: 1.2;
}

.lm-modal__close {
  background: transparent;
  border: none;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  transition: color 0.2s ease;
  border-radius: 4px;
}

.lm-modal__close:hover,
.lm-modal__close:focus {
  color: #333;
  background-color: rgba(0, 0, 0, 0.05);
  outline: none;
}

.lm-modal__close:active {
  background-color: rgba(0, 0, 0, 0.1);
}

/* ============================================================================
   MODAL CONTENT (Body)
   ============================================================================ */

.lm-modal__content {
  padding: 30px;
}

/* Ensure form inside modal has proper spacing */
.lm-modal__content .lm-form {
  margin: 0;
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

/* Fade Animation (Default) */
@keyframes lm-modal-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes lm-modal-fade-out {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

.lm-modal__overlay {
  animation: lm-modal-fade-in 0.3s cubic-bezier(0.0, 0.0, 0.2, 1);
}

.lm-modal.is-closing .lm-modal__overlay {
  animation: lm-modal-fade-out 0.3s cubic-bezier(0.4, 0.0, 1, 1);
}

/* Slide Animation */
@keyframes lm-modal-slide-in {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes lm-modal-slide-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(30px);
  }
}

.lm-modal--slide .lm-modal__container {
  animation: lm-modal-slide-in 0.3s cubic-bezier(0.0, 0.0, 0.2, 1);
}

.lm-modal--slide.is-closing .lm-modal__container {
  animation: lm-modal-slide-out 0.3s cubic-bezier(0.4, 0.0, 1, 1);
}

/* No Animation */
.lm-modal--no-animation .lm-modal__overlay,
.lm-modal--no-animation .lm-modal__container {
  animation: none !important;
}

/* ============================================================================
   RESPONSIVE BREAKPOINTS
   ============================================================================ */

/* Tablet (768px and below) */
@media screen and (max-width: 768px) {
  .lm-modal__container {
    max-width: 90%;
    margin: 15px;
  }

  .lm-modal__header {
    padding: 15px 20px;
  }

  .lm-modal__title {
    font-size: 1.3rem;
  }

  .lm-modal__content {
    padding: 20px;
  }
}

/* Mobile (480px and below) */
@media screen and (max-width: 480px) {
  .lm-modal__overlay {
    align-items: flex-start;
    padding-top: 20px;
  }

  .lm-modal__container {
    max-width: 95%;
    max-height: calc(100vh - 40px);
    margin: 0 10px;
    border-radius: 6px;
  }

  .lm-modal__header {
    padding: 12px 15px;
  }

  .lm-modal__title {
    font-size: 1.1rem;
  }

  .lm-modal__close {
    font-size: 1.5rem;
    width: 28px;
    height: 28px;
  }

  .lm-modal__content {
    padding: 15px;
  }
}

/* Small mobile (320px and below) */
@media screen and (max-width: 320px) {
  .lm-modal__container {
    max-width: 100%;
    margin: 0 5px;
  }

  .lm-modal__header {
    padding: 10px 12px;
  }

  .lm-modal__title {
    font-size: 1rem;
  }

  .lm-modal__content {
    padding: 12px;
  }
}

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

/* Focus visible styles for keyboard navigation */
.lm-modal__close:focus-visible {
  outline: 2px solid #0073aa;
  outline-offset: 2px;
}

/* Screen reader only text */
.lm-modal__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ============================================================================
   LOADING STATE
   ============================================================================ */

.lm-modal__loading {
  text-align: center;
  padding: 40px 20px;
  color: #666;
}

.lm-modal__loading::before {
  content: "";
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #0073aa;
  border-radius: 50%;
  animation: lm-modal-spin 1s linear infinite;
  margin-bottom: 15px;
}

@keyframes lm-modal-spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* ============================================================================
   ERROR STATE
   ============================================================================ */

.lm-modal__error {
  padding: 20px;
  background-color: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 4px;
  color: #856404;
  margin: 15px 0;
}

.lm-modal__error-title {
  font-weight: 600;
  margin: 0 0 5px 0;
}

.lm-modal__error-message {
  margin: 0;
}

/* ============================================================================
   Z-INDEX MANAGEMENT
   ============================================================================ */

/* Ensure modal appears above WordPress admin bar and other common elements */
.lm-modal__overlay {
  z-index: 999999;
  /* Above WP admin bar (z-index: 99999) */
}

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

@media print {

  .lm-modal,
  .lm-modal__overlay {
    display: none !important;
  }
}
