/* ==========================================================================
 * FCC — Event Details card v2
 * Modern, iOS-style Event Details modal with a Source Information panel.
 * Loaded after calendar.css so its rules win on ties.
 * ========================================================================== */

:root {
  --fcc-evd-lavender: #7c5cff;
  --fcc-evd-lavender-soft: #efeaff;
  --fcc-evd-lavender-line: rgba(124, 92, 255, 0.22);
  --fcc-evd-panel: #f7f5ff;
  --fcc-evd-card-radius: 22px;
  --fcc-evd-ink: #1f2430;
  --fcc-evd-muted: #6b7280;
  --fcc-evd-shadow: 0 24px 60px rgba(53, 40, 120, 0.24);
}

/* ── Overlay host + backdrop ─────────────────────────────────────────────── */
.fcc-evd-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 24, 60, 0.42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 4200;
}
.fcc-evd-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

#calendarEventDetailsHost.fcc-evd-host-open {
  position: fixed;
  inset: 0;
  z-index: 4300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

/* ── Card shell ──────────────────────────────────────────────────────────── */
.fcc-evd-card {
  width: 100%;
  max-width: 780px;
  background: #ffffff;
  border: 1px solid var(--fcc-evd-lavender-line);
  border-radius: var(--fcc-evd-card-radius);
  box-shadow: var(--fcc-evd-shadow);
  color: var(--fcc-evd-ink);
  overflow: hidden;
  animation: fccEvdPop 0.18s ease;
}
.fcc-evd-card--overlay {
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}
.fcc-evd-card--synced {
  max-width: min(980px, calc(100vw - 48px));
}
@keyframes fccEvdPop {
  from { transform: translateY(8px) scale(0.985); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* Left color stripe keyed to the source. */
.fcc-evd-card { position: relative; }
.fcc-evd-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: var(--fcc-evd-lavender);
}
.fcc-evd-card[data-source="google"]::before    { background: #2563eb; }
.fcc-evd-card[data-source="microsoft"]::before  { background: #4f52d6; }
.fcc-evd-card[data-source="fcc"]::before        { background: var(--fcc-evd-lavender); }
.fcc-evd-card[data-source="school"]::before     { background: #0d9488; }
.fcc-evd-card[data-source="holiday"]::before    { background: #16a34a; }
.fcc-evd-card[data-source="feed"]::before       { background: #ea8a1e; }

/* ── Header ──────────────────────────────────────────────────────────────── */
.fcc-evd-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 22px 14px 26px;
  border-bottom: 1px solid rgba(124, 92, 255, 0.1);
}
.fcc-evd-header-lead {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.fcc-evd-heading { min-width: 0; }
.fcc-evd-title {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 750;
  line-height: 1.25;
  color: var(--fcc-evd-ink);
  word-break: break-word;
}
.fcc-evd-eyebrow {
  margin-top: 2px;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fcc-evd-muted);
}
.fcc-evd-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

/* Source glyph (square provider badge). */
.fcc-evd-source-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: var(--fcc-evd-lavender);
  flex: 0 0 auto;
  box-shadow: 0 4px 10px rgba(53, 40, 120, 0.18);
}
.fcc-evd-source-glyph--google    { background: #2563eb; }
.fcc-evd-source-glyph--microsoft { background: #4f52d6; }
.fcc-evd-source-glyph--fcc       { background: var(--fcc-evd-lavender); }
.fcc-evd-source-glyph--school    { background: #0d9488; }
.fcc-evd-source-glyph--holiday   { background: #16a34a; }
.fcc-evd-source-glyph--feed      { background: #ea8a1e; }

/* Branded provider badge — real Google / Microsoft mark on a white rounded
   square with soft border + shadow (iOS-premium). Overrides the flat colour. */
.fcc-evd-source-glyph--brand {
  background: #ffffff;
  padding: 0;
  border: 1px solid rgba(20, 12, 50, 0.10);
  box-shadow: 0 4px 12px rgba(53, 40, 120, 0.14);
}
.fcc-evd-source-glyph--brand svg {
  display: block;
}

/* Buttons. */
.fcc-evd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}
.fcc-evd-btn--primary {
  background: var(--fcc-evd-lavender);
  color: #fff;
  border-color: var(--fcc-evd-lavender);
}
.fcc-evd-btn--primary:hover { filter: brightness(1.05); }
.fcc-evd-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(31, 36, 48, 0.12);
  background: #fff;
  color: var(--fcc-evd-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.fcc-evd-close:hover { background: #f3f4f6; color: var(--fcc-evd-ink); }

/* ── Body: two-column layout ─────────────────────────────────────────────── */
.fcc-evd-body {
  display: grid;
  grid-template-columns: 1fr 288px;
  gap: 20px;
  padding: 18px 22px 24px 26px;
  overflow-y: auto;
  overflow-x: hidden;
}
.fcc-evd-card--synced .fcc-evd-body {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
  align-items: start;
}
.fcc-evd-main {
  min-width: 0;
  max-width: 100%;
}
.fcc-evd-main *,
.fcc-evd-source-panel * {
  box-sizing: border-box;
}
.fcc-evd-main > *,
.fcc-evd-source-panel > * {
  min-width: 0;
  max-width: 100%;
}

.fcc-evd-catbadges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.fcc-evd-facts {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}
.fcc-evd-fact {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.92rem;
  color: var(--fcc-evd-ink);
}
.fcc-evd-fact-icon {
  flex: 0 0 auto;
  width: 20px;
  text-align: center;
  opacity: 0.85;
}
.fcc-evd-fact-text {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: normal;
}

.fcc-evd-description {
  margin: 4px 0 14px;
  padding: 12px 14px;
  background: #f7f7fb;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #374151;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
}

.fcc-evd-section { margin-top: 10px; }

/* ── Source Information panel ─────────────────────────────────────────────── */
.fcc-evd-source-panel {
  background: var(--fcc-evd-panel);
  border: 1px solid var(--fcc-evd-lavender-line);
  border-radius: 16px;
  padding: 16px;
  align-self: start;
  display: grid;
  gap: 12px;
  width: 100%;
  max-width: 340px;
  overflow: hidden;
  box-sizing: border-box;
}
.fcc-evd-source-panel-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fcc-evd-lavender);
}
.fcc-evd-provider {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.fcc-evd-provider-label {
  font-size: 0.9rem;
  font-weight: 650;
  color: var(--fcc-evd-ink);
  overflow-wrap: anywhere;
  word-break: normal;
}
.fcc-evd-account {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: #fff;
  border: 1px solid rgba(124, 92, 255, 0.12);
  border-radius: 12px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.fcc-evd-account-text { min-width: 0; flex: 1 1 auto; }
.fcc-evd-account-email {
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--fcc-evd-ink);
  overflow-wrap: anywhere;
  word-break: normal;
  white-space: normal;
}
.fcc-evd-account-name {
  font-size: 0.72rem;
  color: var(--fcc-evd-muted);
  overflow-wrap: anywhere;
  word-break: normal;
  white-space: normal;
}
.fcc-evd-account-check {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #22c55e;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

/* Avatar (photo w/ initials fallback). */
.fcc-evd-avatar {
  position: relative;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--fcc-evd-lavender-soft) 0%, #f3ecff 100%);
  border: 1px solid rgba(124, 92, 255, 0.20);
  box-shadow: 0 3px 9px rgba(53, 40, 120, 0.12);
}
.fcc-evd-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.fcc-evd-avatar-fallback {
  font-size: 14px;
  font-weight: 800;
  color: var(--fcc-evd-lavender);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.fcc-evd-avatar-fallback--glyph { color: var(--fcc-evd-lavender); }

/* ── Disabled source open button (link unavailable) ──────────────────────── */
.fcc-evd-btn[disabled],
.fcc-evd-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  filter: grayscale(0.2);
}

/* ── Family visibility controls (imported/synced events) ─────────────────── */
.fcc-evd-visibility {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--fcc-evd-lavender-line);
  width: 100%;
  overflow: hidden;
}
.fcc-evd-vis-help {
  margin: 4px 0 10px;
  font-size: 0.76rem;
  line-height: 1.4;
  color: var(--fcc-evd-muted);
}
.fcc-evd-vis-seg-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: #f0ecfb;
  border-radius: 12px;
  border: 1px solid var(--fcc-evd-lavender-line);
}
.fcc-evd-vis-seg {
  flex: 1 1 0;
  min-width: 0;
  padding: 7px 6px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--fcc-evd-muted);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.15;
}
.fcc-evd-vis-seg:hover { color: var(--fcc-evd-ink); }
.fcc-evd-vis-seg.is-active {
  background: #ffffff;
  color: var(--fcc-evd-lavender);
  box-shadow: 0 2px 6px rgba(53, 40, 120, 0.14);
}
.fcc-evd-vis-seg:focus-visible {
  outline: 2px solid var(--fcc-evd-lavender);
  outline-offset: 1px;
}
.fcc-evd-vis-members {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}
.fcc-evd-vis-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--fcc-evd-lavender-line);
  background: #fff;
  color: var(--fcc-evd-ink);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  max-width: 100%;
}
.fcc-evd-vis-chip:hover { border-color: var(--fcc-evd-lavender); }
.fcc-evd-vis-chip.is-selected {
  background: var(--fcc-evd-lavender-soft);
  border-color: var(--fcc-evd-lavender);
  box-shadow: 0 2px 8px rgba(124, 92, 255, 0.18);
}
.fcc-evd-vis-chip-av {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--fcc-evd-lavender-soft);
}
.fcc-evd-vis-chip-av--fallback {
  font-size: 11px;
  font-weight: 800;
  color: var(--fcc-evd-lavender);
}
.fcc-evd-vis-chip.is-selected .fcc-evd-vis-chip-av--fallback {
  background: #fff;
}
.fcc-evd-vis-chip-label {
  overflow-wrap: anywhere;
  word-break: normal;
  white-space: normal;
}
.fcc-evd-vis-msg {
  margin-top: 9px;
  font-size: 0.76rem;
  font-weight: 600;
}
.fcc-evd-vis-msg--ok { color: #1a8a4d; }
.fcc-evd-vis-msg--err { color: #c0392b; }
.fcc-evd-vis-save {
  margin-top: 11px;
  width: 100%;
  max-width: 100%;
}
.fcc-evd-avatar.has-image .fcc-evd-avatar-fallback { opacity: 0; }
.fcc-evd-avatar.image-failed img { display: none; }
.fcc-evd-avatar.image-failed .fcc-evd-avatar-fallback { opacity: 1; }

.fcc-evd-source-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.fcc-evd-source-field-key {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fcc-evd-muted);
}
.fcc-evd-source-field-val {
  font-size: 0.85rem;
  color: var(--fcc-evd-ink);
  overflow-wrap: anywhere;
  word-break: normal;
}
.fcc-evd-readonly-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #eef0f4;
  color: #475569;
  font-size: 0.76rem;
  font-weight: 650;
}
.fcc-evd-source-note {
  padding: 10px 12px;
  background: #eef2ff;
  border-radius: 10px;
  font-size: 0.76rem;
  line-height: 1.45;
  color: #4338ca;
  overflow-wrap: anywhere;
  word-break: normal;
}

/* ── Pill source badges: fill in provider colors not covered elsewhere ────── */
#calendar .fcc-event-source-microsoft,
.fcc-event-source-microsoft {
  color: #4f52d6;
  background: #eceafe;
  border-color: rgba(79, 82, 214, 0.22);
}
#calendar .fcc-event-source-feed,
.fcc-event-source-feed {
  color: #854d0e;
  background: #fef3c7;
  border-color: rgba(133, 77, 14, 0.2);
}

/* ── Source legend/filter (compact dropdown pill in the calendar toolbar) ─── */
.fcc-calendar-source-legend-host { margin: 0; display: inline-flex; }

/* The whole control is a single pill; the summary is the button, the body is a
   popover anchored below it (collapsed by default). No card, no heavy shadow. */
.fcc-src-legend {
  position: relative;
  background: transparent;
  border: 0;
  border-radius: 999px;
  box-shadow: none;
  overflow: visible;
}
.fcc-src-legend-summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--fcc-evd-lavender-line);
  background: rgba(124, 92, 255, 0.06);
  font-weight: 650;
  color: var(--fcc-evd-ink);
  user-select: none;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.fcc-src-legend-summary:hover { background: rgba(124, 92, 255, 0.12); }
.fcc-src-legend[open] .fcc-src-legend-summary { background: rgba(124, 92, 255, 0.12); }
.fcc-src-legend-summary::-webkit-details-marker { display: none; }
.fcc-src-legend-summary::after {
  content: "▾";
  margin-left: 1px;
  color: var(--fcc-evd-muted);
  font-size: 0.72rem;
  transition: transform 0.15s ease;
}
.fcc-src-legend[open] .fcc-src-legend-summary::after { transform: rotate(180deg); }
.fcc-src-legend-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--fcc-evd-ink);
}
.fcc-src-legend-sub {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--fcc-evd-lavender);
}
.fcc-src-legend-body {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 9999;
  min-width: 230px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--fcc-evd-lavender-line);
  border-radius: 14px;
  box-shadow: 0 14px 34px rgba(53, 40, 120, 0.16);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fcc-src-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.fcc-src-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  border: 1px solid rgba(31, 36, 48, 0.12);
  background: #f3f4f6;
  color: #64748b;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, opacity 0.12s ease;
  opacity: 0.62;
}
.fcc-src-chip.is-on {
  background: var(--fcc-evd-lavender-soft);
  border-color: var(--fcc-evd-lavender-line);
  color: var(--fcc-evd-ink);
  opacity: 1;
}
.fcc-src-chip-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}
.fcc-src-chip-count {
  min-width: 18px;
  text-align: center;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(31, 36, 48, 0.08);
  font-size: 0.7rem;
  font-weight: 700;
  color: #475569;
}
.fcc-src-chip-tick {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--fcc-evd-lavender);
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: opacity 0.12s ease;
}
.fcc-src-chip.is-on .fcc-src-chip-tick { opacity: 1; width: auto; }
.fcc-src-legend-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.fcc-src-showall {
  border: none;
  background: none;
  padding: 0;
  color: var(--fcc-evd-lavender);
  font-size: 0.8rem;
  font-weight: 650;
  cursor: pointer;
}
.fcc-src-showall:disabled { color: #b6bcc7; cursor: default; }
.fcc-src-empty-note {
  font-size: 0.78rem;
  color: #b45309;
  font-weight: 600;
}

/* Mobile: keep the popover on-screen and let chips wrap inside it. */
@media (max-width: 760px) {
  .fcc-src-legend-body {
    right: auto;
    left: 0;
    min-width: min(240px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
  }
  .fcc-src-chips { flex-wrap: wrap; }
  .fcc-src-chip { flex: 0 0 auto; }
}

/* ── Mobile: single column, source panel stacks below ────────────────────── */
@media (max-width: 760px) {
  #calendarEventDetailsHost.fcc-evd-host-open { padding: 0; align-items: flex-end; }
  .fcc-evd-card {
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
  }
  .fcc-evd-body {
    grid-template-columns: 1fr;
    padding: 16px 18px 22px 20px;
  }
  .fcc-evd-title { font-size: 1.06rem; }
}

/* Tablet: synced source panel stacks below details before columns get tight. */
@media (max-width: 900px) {
  .fcc-evd-card--synced {
    max-width: min(100%, calc(100vw - 32px));
  }
  .fcc-evd-card--synced .fcc-evd-body {
    grid-template-columns: minmax(0, 1fr);
  }
  .fcc-evd-card--synced .fcc-evd-source-panel {
    max-width: none;
  }
}

@media (max-width: 760px) {
  .fcc-evd-source-panel { max-width: none; }
}

/* Prevent background scroll while the overlay is open. */
body.fcc-evd-open { overflow: hidden; }
