/* Event Planner – consolidated overrides
   Scope: Special Event flow components
   Load AFTER event-planner/styles.css
   Notes:
   - Color tokens to keep values consistent
   - One definitive calendar rule (works in popover/portal)
*/

:root {
  --pe-red-500: #ef4444;
  --pe-red-600: #dc2626;
  --pe-red-700: #b91c1c;
  --pe-gray-200: #e5e7eb;
  --pe-gray-300: #d1d5db;
  --pe-gray-400: #9ca3af;
}

/* 1) Title helper: (Select One) */
.pe-select-one {
  color: var(--pe-red-600);
  font-weight: 600;
}

/* 2) Radios (menus/facility) — attention styling */
.pe-stage.pe-attn #facilityList input[type="radio"],
.pe-stage.pe-attn #menuList input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 9999px;
  border: 2px solid var(--pe-red-500);
  background: #fff;
  vertical-align: middle;
  outline: 0 !important;
  box-shadow: none !important;
}
.pe-stage.pe-attn #facilityList input[type="radio"]:checked,
.pe-stage.pe-attn #menuList input[type="radio"]:checked {
  background: radial-gradient(circle at 50% 50%, var(--pe-red-500) 0 45%, transparent 46% 100%);
}
#facilityList input[type="radio"]:focus-visible,
#menuList input[type="radio"]:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

/* 3) Drinks checkboxes — base and attention states (robust selectors) */

/* Base: red checkmark when selected (desktop + mobile, always) */
.pe-stage :where(
  #drinksList,
  [id*="drink" i],
  [class*="drinks" i],
  [data-section="drinks"],
  [aria-labelledby*="drinks" i]
) input[type="checkbox"] {
  accent-color: var(--pe-red-500);
}

/* Attention: show crisp red stroke even when unchecked */
.pe-stage.pe-attn :where(
  #drinksList,
  [id*="drink" i],
  [class*="drinks" i],
  [data-section="drinks"],
  [aria-labelledby*="drinks" i]
) input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 2px solid var(--pe-red-500) !important;
  background: #fff;
  vertical-align: middle;
  outline: 0 !important;
  box-shadow: none !important;
}

/* Checked state: red fill + white checkmark */
.pe-stage.pe-attn :where(
  #drinksList,
  [id*="drink" i],
  [class*="drinks" i],
  [data-section="drinks"],
  [aria-labelledby*="drinks" i]
) input[type="checkbox"]:checked {
  background-color: var(--pe-red-500) !important;
  border-color: var(--pe-red-500) !important;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 20 20' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='4 10 8 14 16 6'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px 12px;
}

/* 3A) Hors/Desserts checkboxes — base and attention states (like Drinks) */
.pe-stage :where(
  #horsList,
  #dessertList,
  [id*="hors" i],
  [id*="dessert" i],
  [class*="hors" i],
  [class*="dessert" i],
  [data-section="hors"],
  [data-section="dessert"],
  [aria-labelledby*="hors" i],
  [aria-labelledby*="dessert" i]
) input[type="checkbox"] {
  accent-color: var(--pe-red-500);
}

/* Attention: show crisp red stroke even when unchecked */
.pe-stage.pe-attn :where(
  #horsList,
  #dessertList,
  [id*="hors" i],
  [id*="dessert" i],
  [class*="hors" i],
  [class*="dessert" i],
  [data-section="hors"],
  [data-section="dessert"],
  [aria-labelledby*="hors" i],
  [aria-labelledby*="dessert" i]
) input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 2px solid var(--pe-red-500) !important;
  background: #fff;
  vertical-align: middle;
  outline: 0 !important;
  box-shadow: none !important;
}

/* Checked state: red fill + white checkmark */
.pe-stage.pe-attn :where(
  #horsList,
  #dessertList,
  [id*="hors" i],
  [id*="dessert" i],
  [class*="hors" i],
  [class*="dessert" i]
) input[type="checkbox"]:checked {
  background-color: var(--pe-red-500) !important;
  border-color: var(--pe-red-500) !important;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 20 20' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='4 10 8 14 16 6'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px 12px;
}

/* Keyboard focus */
.pe-stage :where(
  #drinksList,
  [id*="drink" i],
  [class*="drinks" i],
  [data-section="drinks"],
  [aria-labelledby*="drinks" i],
  #horsList,
  #dessertList,
  [id*="hors" i],
  [id*="dessert" i],
  [class*="hors" i],
  [class*="dessert" i],
  [data-section="hors"],
  [data-section="dessert"],
  [aria-labelledby*="hors" i],
  [aria-labelledby*="dessert" i]
) input[type="checkbox"]:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

/* 4) Dining Room group: neutralize red box on the whole group in attention */
.pe-stage.pe-attn #facilityList.pe-group-invalid {
  outline: 0 !important;
  box-shadow: none !important;
  border-color: var(--pe-gray-200) !important;
  --tw-ring-color: transparent !important;
  --tw-ring-offset-shadow: 0 0 #0000 !important;
  --tw-ring-shadow: 0 0 #0000 !important;
}
.pe-stage.pe-attn #facilityList.pe-group-invalid .border,
.pe-stage.pe-attn #facilityList.pe-group-invalid > div[class*="border"] {
  border-color: var(--pe-gray-200) !important;
  box-shadow: none !important;
}

/* 5) Event Name: remove red invalid outline in attention state */
.pe-stage.pe-attn #eventName.pe-invalid,
.pe-stage.pe-attn #event_name.pe-invalid,
.pe-stage.pe-attn input[name="event_name"].pe-invalid {
  box-shadow: none !important;
  border-color: var(--pe-gray-200) !important;
}

/* 7) “Review & Complete Section” badge: red border + red text, no fill */
.pe-status-badge.is-pending,
.pe-stage.pe-attn .pe-status-badge.is-pending {
  background: transparent !important;
  border-color: var(--pe-red-500) !important;
  color: var(--pe-red-700) !important;
}

/* 8) Calendar — disabled/inactive days in popover/portal */
body .flatpickr-calendar .flatpickr-day.disabled,
body .flatpickr-calendar .flatpickr-day.flatpickr-disabled,
body .rdp .rdp-day[aria-disabled="true"],
body .rdp .rdp-button:disabled,
body [role="dialog"] .datepicker-cell.disabled,
body [role="dialog"] .datepicker-cell[aria-disabled="true"],
body [role="dialog"] button[disabled],
body [role="dialog"] [aria-disabled="true"] {
  opacity: 1 !important;                 /* cancel library fade */
  filter: none !important;
  color: var(--pe-gray-400) !important;  /* visible but muted */
  -webkit-text-fill-color: var(--pe-gray-400) !important;
  background: transparent !important;    /* remove chip/fill */
  border: 0 !important;
  border-color: transparent !important;  /* remove thin box */
  box-shadow: none !important;
  outline: 0 !important;
  pointer-events: none;                  /* keep unclickable */
  cursor: not-allowed;
}
/* Prevent hover/focus from reintroducing styles */
body .flatpickr-calendar .flatpickr-day.disabled:hover,
body .flatpickr-calendar .flatpickr-day.flatpickr-disabled:hover,
body .rdp .rdp-day[aria-disabled="true"]:hover,
body .rdp .rdp-button:disabled:hover,
body [role="dialog"] .datepicker-cell.disabled:hover,
body [role="dialog"] .datepicker-cell[aria-disabled="true"]:hover,
body [role="dialog"] button[disabled]:hover,
body [role="dialog"] [aria-disabled="true"]:hover,
body .flatpickr-calendar .flatpickr-day.disabled:focus,
body .flatpickr-calendar .flatpickr-day.flatpickr-disabled:focus,
body .rdp .rdp-day[aria-disabled="true"]:focus,
body .rdp .rdp-button:disabled:focus,
body [role="dialog"] .datepicker-cell.disabled:focus,
body [role="dialog"] .datepicker-cell[aria-disabled="true"]:focus,
body [role="dialog"] button[disabled]:focus,
body [role="dialog"] [aria-disabled="true"]:focus {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  outline: 0 !important;
}

/* 9) Mobile: keep our custom calendar visible (JS suppresses native sheet) */
@media (pointer: coarse), (hover: none) {
  .flatpickr-calendar,
  .rdp,
  .datepicker,
  [role="dialog"] .rdp,
  [role="dialog"] .flatpickr-calendar {
    display: block !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }
}

/* 10) iOS focus zoom prevention (>=16px) */
@media (pointer: coarse), (hover: none) {
  #quoteForm input[type="text"],
  #quoteForm input[type="email"],
  #quoteForm input[type="tel"],
  #quoteForm input[type="number"],
  #quoteForm input[type="search"],
  #quoteForm select,
  #quoteForm textarea,
  #quoteForm .pe-control,
  #quoteForm .pe-select {
    font-size: 16px !important;
  }
}

/* 11) Facility radios — do NOT show red when disabled (guest-count logic) */
.pe-stage.pe-attn #facilityList input[type="radio"]:disabled,
.pe-stage.pe-attn #facilityList [aria-disabled="true"] input[type="radio"],
.pe-stage.pe-attn #facilityList [data-disabled="true"] input[type="radio"],
.pe-stage.pe-attn #facilityList .is-disabled input[type="radio"] {
  appearance: none !important;
  -webkit-appearance: none !important;
  width: 16px;
  height: 16px;
  border-radius: 9999px;
  border: 2px solid var(--pe-gray-300) !important;
  background: #fff !important;
  background-image: none !important;
  outline: 0 !important;
  box-shadow: none !important;
  cursor: not-allowed;
}
.pe-stage.pe-attn #facilityList input[type="radio"]:disabled:checked,
.pe-stage.pe-attn #facilityList [aria-disabled="true"] input[type="radio"]:checked,
.pe-stage.pe-attn #facilityList [data-disabled="true"] input[type="radio"]:checked,
.pe-stage.pe-attn #facilityList .is-disabled input[type="radio"]:checked {
  background: #fff !important;
  background-image: none !important;
}
.pe-stage.pe-attn #facilityList input[type="radio"]:not(:disabled) {
  border-color: var(--pe-red-500) !important;
}
.pe-stage.pe-attn #facilityList input[type="radio"]:not(:disabled):checked {
  background: radial-gradient(circle at 50% 50%, var(--pe-red-500) 0 45%, transparent 46% 100%) !important;
}

/* 12) Desktop: align section status badges flush-right (Menus, Drinks, Equip/Services)
      Final, consolidated approach (no duplicate positioning blocks). */
@media (min-width: 768px) {
  section.order-2 .pe-legend,
  section.order-3 .pe-legend,
  section.order-4 .pe-legend {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    min-height: 32px;
    gap: 0.75rem;
    position: relative; /* sticky still works if present */
  }
  section.order-2 .pe-legend > .pe-attn-badge,
  section.order-3 .pe-legend > .pe-attn-badge,
  section.order-4 .pe-legend > .pe-attn-badge,
  section.order-2 .pe-legend > .pe-section-badge,
  section.order-3 .pe-legend > .pe-section-badge,
  section.order-4 .pe-legend > .pe-section-badge,
  section.order-2 .pe-legend > .pe-status-badge,
  section.order-3 .pe-legend > .pe-status-badge,
  section.order-4 .pe-legend > .pe-status-badge,
  section.order-2 .pe-legend > [data-pe-badge],
  section.order-3 .pe-legend > [data-pe-badge],
  section.order-4 .pe-legend > [data-pe-badge] {
    margin-left: auto !important;  /* push pill to far right */
    white-space: nowrap !important;
  }
}

/* 13) Facility list bottom spacing */
#facilityList { margin-bottom: 0 !important; }
#facilityList > :last-child { margin-bottom: 0 !important; padding-bottom: 0 !important; }

/* 14) Shared Hors/Dessert relocation helpers
   - Hide any Hors/Dessert groups that remain inside the Menus section after we move them
   - Normalize spacing for moved groups in the shared section */
#menuList .hd-hidden { display: none !important; }
#hdSection .hd-moved-group {
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

/* 15) FIX: When section is complete, checked checkboxes (drinks/hors/dessert) are gray */
.pe-stage.pe-done :where(
  #drinksList,
  [id*="drink" i],
  [class*="drinks" i],
  [data-section="drinks"],
  [aria-labelledby*="drinks" i],
  #horsList,
  #dessertList,
  [id*="hors" i],
  [id*="dessert" i],
  [class*="hors" i],
  [class*="dessert" i],
  [data-section="hors"],
  [data-section="dessert"],
  [aria-labelledby*="hors" i],
  [aria-labelledby*="dessert" i]
) input[type="checkbox"]:checked {
  background-color: var(--pe-gray-400) !important;
  border-color: var(--pe-gray-400) !important;
  accent-color: var(--pe-gray-400);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 20 20' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='4 10 8 14 16 6'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px 12px;
}

/* 16) FIX: Disabled checkboxes gray in completed sections */
.pe-stage.pe-done :where(#horsList, #dessertList, #drinksList) input[type="checkbox"]:disabled {
  border-color: var(--pe-gray-300) !important;
  background: #fff !important;
  accent-color: var(--pe-gray-300) !important;
  cursor: not-allowed;
}

/* 17) Only show green border on parent .pe-stage, not on indented submenus */
.pe-done:not(.pe-stage) {
  border: none !important;
  box-shadow: none !important;
}

/* 18) FIX: Force red attention styling off when the parent is complete (.pe-done) */
.pe-stage.pe-done input[type="checkbox"].pe-invalid {
  border-color: var(--pe-gray-200) !important;
}
.pe-stage.pe-done input[type="checkbox"].pe-invalid:not(:checked) {
  background-color: #fff !important;
}