/* ==========================================================================
 * FCC — Add / Edit Event modal redesign (2/3 panel + iOS mobile sheet)
 * Loaded AFTER calendar.css / calendar-event-details.css so it wins on ties.
 * UI/UX only — every field id + handler in main.js is preserved.
 * Scoped to #calendarEventModal.fcc-evm and #calendarEventForm.
 * ========================================================================== */

:root {
  --evm-lav: #7c5cff;
  --evm-lav-2: #9d7bff;
  --evm-grad: linear-gradient(135deg, #7c5cff 0%, #9d7bff 55%, #b07bff 100%);
  --evm-ink: #1f2430;
  --evm-muted: #6b7280;
  --evm-line: rgba(124, 92, 255, 0.16);
  --evm-line-soft: #eceafb;
  --evm-panel: #f7f5ff;
  --evm-surface: #ffffff;
  --evm-radius: 16px;
}

/* ── Shell overrides — turn the single scroll card into a fixed-chrome shell ─ */
#calendarEventModal.fcc-evm .calendar-event-modal-inner {
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  padding: 0 !important;
  background: var(--evm-surface) !important;
  border-radius: 24px !important;
}

/* Widen the desktop card to fit the 3 panels. */
@media (min-width: 769px) {
  body.calendar-modal-open #calendarEventModal.fcc-evm,
  #calendarEventModal.fcc-evm[aria-hidden="false"] {
    width: min(1060px, calc(100vw - 40px)) !important;
    max-width: min(1060px, calc(100vw - 40px)) !important;
  }
}

/* ── Header ─────────────────────────────────────────────────────────────── */
#calendarEventModal.fcc-evm .calendar-event-modal-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--evm-line-soft);
  background: linear-gradient(180deg, #fbfaff 0%, #ffffff 100%);
}
#calendarEventModal.fcc-evm .calendar-event-modal-title {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--evm-ink);
}
#calendarEventModal.fcc-evm .fcc-evm-close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--evm-line-soft);
  background: #fff;
  color: var(--evm-muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
#calendarEventModal.fcc-evm .fcc-evm-close:hover {
  background: var(--evm-panel);
  color: var(--evm-ink);
  transform: scale(1.05);
}
#calendarEventModal.fcc-evm .fcc-evm-close:focus-visible {
  outline: 2px solid var(--evm-lav);
  outline-offset: 2px;
}

/* ── Form shell — flex column so footer stays pinned, body scrolls ─────────── */
#calendarEventForm.fcc-evm-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0;
}

/* ── Body: 3-column grid (nav | main | summary) ────────────────────────────── */
.fcc-evm-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 268px;
  gap: 0;
}

/* ── Left nav (vertical) ───────────────────────────────────────────────────── */
.fcc-evm-nav {
  grid-column: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 12px;
  border-right: 1px solid var(--evm-line-soft);
  background: #fbfaff;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.fcc-evm-navbtn {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--evm-muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.fcc-evm-navbtn:hover {
  background: #f3f0ff;
  color: var(--evm-ink);
}
.fcc-evm-navbtn.is-active {
  background: var(--evm-panel);
  color: var(--evm-lav);
  border-color: var(--evm-line);
}
.fcc-evm-navbtn:focus-visible {
  outline: 2px solid var(--evm-lav);
  outline-offset: 2px;
}
.fcc-evm-navbtn-ic {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid var(--evm-line-soft);
  color: var(--evm-muted);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.fcc-evm-navbtn.is-active .fcc-evm-navbtn-ic {
  background: var(--evm-grad);
  border-color: transparent;
  color: #fff;
}
.fcc-evm-navbtn-tx {
  flex: 1 1 auto;
  min-width: 0;
}
.fcc-evm-lbl-short { display: none; }
.fcc-evm-lbl-full { display: inline; }

/* ── Main active section ───────────────────────────────────────────────────── */
.fcc-evm-main {
  grid-column: 2;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px 24px;
}
.fcc-evm-section {
  animation: fccEvmFade 0.2s ease;
}
.fcc-evm-section[hidden] {
  display: none !important;
}
.fcc-evm-section-head {
  margin: 0 0 16px;
}
.fcc-evm-section-title {
  margin: 0 0 3px;
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--evm-ink);
}
.fcc-evm-section-sub {
  margin: 0;
}
@keyframes fccEvmFade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Consistent field spacing inside sections */
.fcc-evm-main .form-group {
  margin-bottom: 15px;
}
.fcc-evm-main .form-group > label:first-child {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--evm-ink);
  margin-bottom: 6px;
}
.fcc-evm-main .calendar-event-inline-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.fcc-evm-main .input {
  width: 100%;
  border-radius: 12px;
}

/* ── iOS-style switches — every .checkbox-row in the form becomes a switch ──── */
#calendarEventForm .checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  margin: 0 0 9px;
  background: var(--evm-surface);
  border: 1px solid var(--evm-line-soft);
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--evm-ink);
  line-height: 1.3;
}
#calendarEventForm .checkbox-row:hover {
  border-color: var(--evm-line);
}
#calendarEventForm .checkbox-row > span {
  order: 0;
  flex: 1 1 auto;
  min-width: 0;
}
#calendarEventForm .checkbox-row input[type="checkbox"] {
  order: 5;
  margin: 0 0 0 auto;
  flex: 0 0 auto;
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  width: 46px;
  height: 27px;
  border-radius: 999px;
  background: #d9d5ec;
  border: none;
  cursor: pointer;
  transition: background 0.18s ease;
}
#calendarEventForm .checkbox-row input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(20, 12, 50, 0.28);
  transition: transform 0.18s ease;
}
#calendarEventForm .checkbox-row input[type="checkbox"]:checked {
  background: var(--evm-grad);
}
#calendarEventForm .checkbox-row input[type="checkbox"]:checked::after {
  transform: translateX(19px);
}
#calendarEventForm .checkbox-row input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#calendarEventForm .checkbox-row input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--evm-lav);
  outline-offset: 2px;
}

/* ── Member checklist → chip-like rows ─────────────────────────────────────── */
#calendarEventAssignedProfiles.calendar-profile-checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Right summary panel ───────────────────────────────────────────────────── */
.fcc-evm-summary {
  grid-column: 3;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 18px;
  border-left: 1px solid var(--evm-line-soft);
  background: var(--evm-panel);
}
.fcc-evm-summary-title {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--evm-muted);
  margin-bottom: 14px;
}
.fcc-evm-summary-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.fcc-evm-sum-row {
  display: flex;
  gap: 11px;
  align-items: flex-start;
}
.fcc-evm-sum-ic {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: #fff;
  border: 1px solid var(--evm-line-soft);
  color: var(--evm-lav);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.fcc-evm-sum-tx {
  min-width: 0;
  flex: 1 1 auto;
}
.fcc-evm-sum-label {
  display: block;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--evm-muted);
  margin-bottom: 2px;
}
.fcc-evm-sum-value {
  display: block;
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.35;
  color: var(--evm-ink);
  word-break: break-word;
}
.fcc-evm-sum-value.is-empty {
  color: #a5a1b8;
  font-weight: 500;
}
.fcc-evm-sum-value .fcc-evm-sum-badge {
  display: inline-block;
  margin-top: 3px;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: #e9fbf0;
  color: #1a8a4d;
}
.fcc-evm-sum-value .fcc-evm-sum-badge.is-off {
  background: #f0eef8;
  color: #7a7690;
}

/* ── Progress dots (mobile only) ───────────────────────────────────────────── */
.fcc-evm-dots {
  display: none;
}
.fcc-evm-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d7d3e8;
  transition: width 0.2s ease, background 0.2s ease;
}
.fcc-evm-dots span.is-active {
  width: 20px;
  border-radius: 4px;
  background: var(--evm-grad);
}

/* ── Footer actions ────────────────────────────────────────────────────────── */
#calendarEventForm .calendar-event-form-actions.fcc-evm-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--evm-line-soft);
  background: #fff;
  margin: 0;
}
#calendarEventForm .fcc-evm-footer #calendarEventCancelBtn {
  margin-right: auto;
}
#calendarEventForm .fcc-evm-footer .btn-primary {
  background: var(--evm-grad);
  border: none;
  color: #fff;
  font-weight: 700;
  border-radius: 12px;
  padding: 11px 22px;
  box-shadow: 0 8px 22px rgba(124, 92, 255, 0.32);
}
#calendarEventForm .fcc-evm-footer .btn-primary:hover {
  filter: brightness(1.03);
}
#calendarEventForm .fcc-evm-footer .btn-secondary {
  border-radius: 12px;
  padding: 11px 18px;
  font-weight: 650;
}
#calendarEventForm .fcc-evm-footer .btn-danger {
  border-radius: 12px;
  padding: 11px 16px;
}

#calendarEventForm .calendar-event-form-message {
  flex: 0 0 auto;
  padding: 0 22px;
  margin: 8px 0 0;
}
#calendarEventForm .calendar-event-form-message:empty {
  display: none;
}

/* ── Mobile: premium bottom-sheet with top pill nav + dots ─────────────────── */
@media (max-width: 768px) {
  .fcc-evm-body {
    display: block;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Pill nav — circular icons, horizontally scrollable, sticky under header */
  .fcc-evm-nav {
    grid-column: auto;
    position: sticky;
    top: 0;
    z-index: 3;
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    overflow-y: visible;
    padding: 12px 14px;
    border-right: none;
    border-bottom: 1px solid var(--evm-line-soft);
    background: rgba(251, 250, 255, 0.94);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    scrollbar-width: none;
  }
  .fcc-evm-nav::-webkit-scrollbar { display: none; }
  .fcc-evm-navbtn {
    flex: 0 0 auto;
    flex-direction: column;
    gap: 5px;
    width: 66px;
    padding: 4px 2px;
    border: none;
    background: transparent;
    font-size: 0.66rem;
    text-align: center;
  }
  .fcc-evm-navbtn:hover { background: transparent; }
  .fcc-evm-navbtn.is-active {
    background: transparent;
    border: none;
  }
  .fcc-evm-navbtn-ic {
    width: 50px;
    height: 50px;
    border-radius: 16px;
  }
  .fcc-evm-navbtn-tx {
    flex: 0 0 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 66px;
  }
  .fcc-evm-lbl-full { display: none; }
  .fcc-evm-lbl-short { display: inline; }

  .fcc-evm-main {
    grid-column: auto;
    overflow: visible;
    padding: 18px 18px 8px;
  }
  .fcc-evm-main .calendar-event-inline-row {
    grid-template-columns: 1fr 1fr;
  }

  /* Summary panel is hidden on mobile (space handled by section flow) */
  .fcc-evm-summary {
    display: none;
  }

  .fcc-evm-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    flex: 0 0 auto;
    padding: 10px 0 4px;
  }

  #calendarEventForm .calendar-event-form-actions.fcc-evm-footer {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    gap: 8px;
  }
  #calendarEventForm .fcc-evm-footer .fcc-evm-next-btn,
  #calendarEventForm .fcc-evm-footer #calendarEventSaveBtn {
    flex: 1 1 auto;
    justify-content: center;
    text-align: center;
  }
  #calendarEventForm .fcc-evm-footer #calendarEventDeleteBtn {
    flex: 0 0 auto;
  }
}
