/**
 * CDC - Event Tickets Modal Mobile Optimization
 * 
 * Customizzazioni responsive per la modale di registrazione attendee
 * su dispositivi mobile, ottimizzata per:
 * - Full-screen experience
 * - Compatibilità con menu Avada bottom mobile
 * - Touch-friendly UI
 * 
 * @version 1.0.0
 * @since 2026-02-02
 */

/* ========================================================================
   BASE: Layout condiviso (mobile + desktop)
   ======================================================================== */

/* Add padding-top to account for admin bar and prevent overlap */
.tribe-modal__wrapper--ar {
  padding-top: 20px !important;
}

/* Format global title as h5-sized heading */
.tribe-modal__title {
  font-size: 18px !important;
  line-height: 1.4 !important;
  margin: 0 0 16px 0 !important;
  font-weight: 600 !important;
  color: #222222 !important;
}

:root {
  --cdc-avada-menu-height: 0px;
}

.cdc-modal-mobile-wrapper {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  box-sizing: border-box;
  position: relative;
  padding: 16px 0 0 0;
}

.cdc-modal-mobile-form {
  /* CSS class on the attendee form div */
}

/* Removed cdc-modal-mobile-header - using absolute close button instead */

.cdc-modal-mobile-content {
  flex: 1 1 auto;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 16px 20px;
  -webkit-overflow-scrolling: touch;
}

.cdc-modal-mobile-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.08);
  border: none;
  border-radius: 50%;
  color: #333333;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  font-size: 24px;
  line-height: 1;
  z-index: 100;
}

.cdc-modal-mobile-close:hover {
  background: rgba(0, 0, 0, 0.15);
}

.cdc-modal-mobile-close:active {
  transform: scale(0.95);
}

.tribe-tickets__item__attendee__fields__title {
  margin-top: 0 !important;
  margin-bottom: 16px !important;
  font-size: 16px !important;
  text-align: left !important;
}

.cdc-modal-mobile-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  background: #ffffff;
  border-top: 1px solid #e5e5e5;
}

.cdc-modal-mobile-footer__progress-text {
  font-size: 12px;
  color: #666666;
  font-weight: 500;
}

/* ========================================================================
   MOBILE: Full-Screen Modal Optimization
   ======================================================================== */

@media (max-width: 782px) {
  :root {
    --cdc-avada-menu-height: 64px;
  }
  /* ----------------------------------------------------------------
	   Modal Wrapper - Full Screen
	   ---------------------------------------------------------------- */

  .tribe-modal__wrapper--ar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    transform: none !important;
    /* Z-index sotto il menu Avada bottom mobile (che di solito è 10000+) */
    z-index: 9999 !important;
  }

  .tribe-modal__overlay--ar {
    /* Overlay dietro la modale */
    z-index: 9998 !important;
    background: rgba(0, 0, 0, 0.7) !important;
  }

  .tribe-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    max-width: 100% !important;
    max-height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  /* ----------------------------------------------------------------
	   Main Container - Flexbox Layout
	   ---------------------------------------------------------------- */

  .cdc-modal-mobile-wrapper {
    display: flex !important;
    flex-direction: column !important;
    height: 100vh !important;
    height: 100dvh !important;
    overflow: hidden !important;
    background: #ffffff !important;
    padding-bottom: calc(
      var(--cdc-avada-menu-height) + env(safe-area-inset-bottom)
    );
    box-sizing: border-box;
  }

  /* ----------------------------------------------------------------
	   Mobile Title - Top of Content
	   ---------------------------------------------------------------- */

  .tribe-modal__title {
    padding: 0 20px 0 20px !important;
    font-size: 16px !important;
    padding-right: 50px !important; /* Space for close button */
  }

  .cdc-modal-mobile-close {
    top: 8px;
    right: 8px;
    width: 40px;
    height: 40px;
    background: rgba(149, 12, 69, 0.1);
    color: #222222;
  }

  .cdc-modal-mobile-close:hover {
    background: rgba(149, 12, 69, 0.15);
  }

  /* ----------------------------------------------------------------
	   Mobile Content - Scrollable with Padding
	   ---------------------------------------------------------------- */

  .cdc-modal-mobile-content {
    padding: 20px 20px 24px 20px !important;
  }

  .tribe-tickets__item__attendee__fields__title {
    font-size: 15px !important;
    text-align: left !important;
  }

  /* ----------------------------------------------------------------
	   Mobile Footer - Fixed Bottom
	   ---------------------------------------------------------------- */

  .cdc-modal-mobile-footer {
    padding: 8px 16px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
  }

  /* Footer Buttons - Enhanced Styling */
  .tribe-modal__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 16px !important;
    background: #ffffff;
    border-top: 1px solid #e5e5e5;
  }

  .tribe-modal__actions .tribe-common-c-btn {
    width: 100% !important;
    min-height: 48px !important;
    padding: 12px 16px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    text-align: center !important;
    transition: all 0.2s ease !important;
    border-radius: 8px !important;
  }

  .tribe-modal__actions .tribe-common-c-btn--secondary {
    background: #f5f5f5 !important;
    color: #333333 !important;
    border: 1px solid #e0e0e0 !important;
  }

  .tribe-modal__actions .tribe-common-c-btn--secondary:hover {
    background: #ebebeb !important;
  }

  .tribe-modal__actions .tribe-common-c-btn--primary,
  .tribe-modal__actions .tribe-common-c-btn[type="submit"] {
    background: #950c45 !important;
    color: #ffffff !important;
    border: none !important;
  }

  .tribe-modal__actions .tribe-common-c-btn--primary:hover,
  .tribe-modal__actions .tribe-common-c-btn[type="submit"]:hover {
    background: #7a0a38 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(149, 12, 69, 0.25) !important;
  }

  /* ----------------------------------------------------------------
	   Cart Section - Ticket Selection
	   ---------------------------------------------------------------- */

  .tribe-modal__cart {
    margin-bottom: 20px !important;
    padding: 16px !important;
    background: #f9f9f9 !important;
    border-radius: 8px !important;
    border: 1px solid #e8e8e8 !important;
  }

  .tribe-modal__cart-item {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 12px 0 !important;
    border-bottom: 1px solid #e0e0e0 !important;
  }

  .tribe-modal__cart-item:last-child {
    border-bottom: none !important;
  }

  .tribe-modal__cart-item-name {
    font-size: 14px !important;
    font-weight: 500 !important;
    color: #222222 !important;
    flex: 1;
  }

  .tribe-modal__cart-item-price {
    font-size: 15px !important;
    font-weight: 600 !important;
    color: #950c45 !important;
    margin-right: 12px;
  }

  /* ----------------------------------------------------------------
	   Attendee Items - Accordion Style
	   ---------------------------------------------------------------- */

  .tribe-tickets__attendee-tickets-item {
    margin-bottom: 16px !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    background: #ffffff !important;
    padding: 16px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
  }

  .tribe-tickets__attendee-tickets-item__title {
    font-size: 15px !important;
    font-weight: 600 !important;
    margin: 0 0 16px 0 !important;
    padding: 0 !important;
    border-bottom: none !important;
    color: #950c45 !important; /* Brand color */
  }

  /* Attendee Container Section */
  .tribe-tickets__attendee-tickets-container {
    margin-bottom: 20px !important;
    padding-bottom: 20px !important;
    border-bottom: 2px solid #f0f0f0 !important;
  }

  .tribe-tickets__attendee-tickets-container:last-child {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
    border-bottom: none !important;
  }

  .tribe-tickets__attendee-tickets-container h3 {
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #950c45 !important;
    margin: 0 0 16px 0 !important;
  }

  /* ----------------------------------------------------------------
	   Form Fields - Touch-Optimized
	   ---------------------------------------------------------------- */

  .tribe-tickets__attendee-tickets-item label {
    display: block !important;
    margin-bottom: 6px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: #333333 !important;
  }

  .tribe-tickets__attendee-tickets-item input[type="text"],
  .tribe-tickets__attendee-tickets-item input[type="email"],
  .tribe-tickets__attendee-tickets-item input[type="tel"],
  .tribe-tickets__attendee-tickets-item select,
  .tribe-tickets__attendee-tickets-item textarea {
    width: 100% !important;
    min-height: 44px !important; /* Touch-friendly */
    padding: 12px 14px !important;
    font-size: 16px !important; /* Previene zoom su iOS */
    border: 1px solid #cccccc !important;
    border-radius: 6px !important;
    background: #ffffff !important;
    box-sizing: border-box !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
  }

  .tribe-tickets__attendee-tickets-item input:focus,
  .tribe-tickets__attendee-tickets-item select:focus,
  .tribe-tickets__attendee-tickets-item textarea:focus {
    border-color: #950c45 !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(149, 12, 69, 0.1) !important;
  }

  /* ----------------------------------------------------------------
	   Form Spacing
	   ---------------------------------------------------------------- */

  .tribe-field {
    margin-bottom: 16px !important;
  }

  .tribe-field:last-child {
    margin-bottom: 0 !important;
  }

  /* ----------------------------------------------------------------
	   Hide Original Desktop Elements
	   ---------------------------------------------------------------- */

  /* Nascondi titolo originale (già presente nell'header mobile) */
  .tribe-tickets__item__attendee__fields
    > .tribe-tickets__item__attendee__fields__title {
    display: none !important;
  }

  /* ----------------------------------------------------------------
	   Scroll Smooth & Safe Area
	   ---------------------------------------------------------------- */

  .cdc-modal-mobile-content {
    scroll-behavior: smooth;
  }

  /* ----------------------------------------------------------------
	   Accessibility - Focus Visible
	   ---------------------------------------------------------------- */

  .cdc-modal-mobile-close:focus-visible {
    outline: 2px solid #950c45;
    outline-offset: 2px;
  }

  /* ----------------------------------------------------------------
	   Validation Errors - Mobile Optimized
	   ---------------------------------------------------------------- */

  .tribe-tickets-notice {
    margin: 16px 0 !important;
    padding: 12px 16px !important;
    border-radius: 6px !important;
    font-size: 14px !important;
  }

  .tribe-tickets-notice--error {
    background: #fee !important;
    border-left: 4px solid #c00 !important;
    color: #c00 !important;
  }

  /* ----------------------------------------------------------------
	   Performance Optimization
	   ---------------------------------------------------------------- */

  /* GPU acceleration per animazioni smooth */
  .cdc-modal-mobile-footer,
  .cdc-modal-mobile-content {
    will-change: transform;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }
}

/* ========================================================================
   LANDSCAPE MODE - Ottimizzazioni aggiuntive
   ======================================================================== */

@media (max-width: 782px) and (orientation: landscape) {
  .tribe-modal__title {
    padding: 0 20px 0 20px !important;
    font-size: 15px !important;
  }

  .cdc-modal-mobile-content {
    padding: 16px 12px;
  }

  .tribe-tickets__attendee-tickets-item {
    padding: 12px !important;
  }
}
