/* =====================================================
   Planning Center Events Sync
   All rules scoped under .pco-app to prevent theme bleed
   ===================================================== */

.pco-app {
  --pco-primary:       #2aa1af;
  --pco-primary-dark:  #1f7d89;
  --pco-primary-light: #e6f6f8;
  --pco-accent:        #f59e0b;
  --pco-text:          #1e293b;
  --pco-muted:         #64748b;
  --pco-border:        #e2e8f0;
  --pco-bg:            #ffffff;
  --pco-bg-sidebar:    #f8f9fa;
  --pco-radius:        8px;
  --pco-shadow:        0 2px 8px rgba(0,0,0,.07);

  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--pco-text);
  max-width: 100%;
  position: relative;
  box-sizing: border-box;
}

/* Reset box-sizing for all children */
.pco-app *,
.pco-app *::before,
.pco-app *::after {
  box-sizing: border-box;
}

/* ── Top bar ─────────────────────────────────────────── */
.pco-app .pco-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1.5rem;
}

/* ── Tabs — fully reset to avoid theme a/button hover bleed ── */
.pco-app .pco-tabs {
  display: flex;
  gap: .5rem;
}

.pco-app .pco-tab {
  all: unset;
  display: inline-block;
  padding: .45rem 1.1rem;
  border-radius: 6px;
  border: 2px solid transparent;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--pco-muted);
  background: transparent;
  text-decoration: none;
  transition: color .15s;
  line-height: 1.4;
}

.pco-app .pco-tab--active {
  background: var(--pco-primary) !important;
  color: #fff !important;
  border-color: var(--pco-primary) !important;
  text-decoration: none !important;
}

.pco-app .pco-tab:not(.pco-tab--active):hover {
  color: var(--pco-primary) !important;
  background: transparent !important;
  text-decoration: none !important;
  border-color: transparent !important;
}

/* ── Top actions ─────────────────────────────────────── */
.pco-app .pco-topbar__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ── Searchable filter ───────────────────────────────── */
.pco-app .pco-filter-wrap {
  position: relative;
}

.pco-app .pco-filter-select {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: .42rem .9rem;
  border: 1px solid var(--pco-border);
  border-radius: 6px;
  background: #fff;
  font-size: .87rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--pco-text);
  transition: border-color .15s, color .15s;
  user-select: none;
}
.pco-app .pco-filter-select:hover {
  border-color: var(--pco-primary);
  color: var(--pco-primary);
}

.pco-app .pco-filter-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid var(--pco-border);
  border-radius: var(--pco-radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.13);
  min-width: 220px;
  max-width: 280px;
  z-index: 9999;
  overflow: hidden;
}

.pco-app .pco-filter-search-wrap {
  padding: .5rem .6rem;
  border-bottom: 1px solid var(--pco-border);
}

.pco-app .pco-filter-search {
  all: unset;
  display: block;
  width: 100%;
  padding: .38rem .6rem;
  font-size: .84rem;
  color: var(--pco-text);
  background: var(--pco-bg-sidebar);
  border: 1px solid var(--pco-border);
  border-radius: 5px;
  outline: none;
}
.pco-app .pco-filter-search:focus {
  border-color: var(--pco-primary);
}

.pco-app .pco-filter-options {
  max-height: 220px;
  overflow-y: auto;
  padding: .3rem 0;
}

.pco-app .pco-filter-option {
  padding: .48rem .9rem;
  font-size: .86rem;
  cursor: pointer;
  color: var(--pco-text);
  transition: background .1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pco-app .pco-filter-option:hover {
  background: var(--pco-primary-light);
  color: var(--pco-primary);
}
.pco-app .pco-filter-option--active {
  color: var(--pco-primary);
  font-weight: 600;
}

/* ── Subscribe button ────────────────────────────────── */
.pco-app .pco-subscribe-btn {
  all: unset;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .87rem;
  font-weight: 500;
  color: var(--pco-primary) !important;
  cursor: pointer;
  text-decoration: none !important;
  transition: color .15s;
}
.pco-app .pco-subscribe-btn:hover {
  color: var(--pco-primary-dark) !important;
  text-decoration: none !important;
}

/* ── Views ───────────────────────────────────────────── */
.pco-app .pco-view          { display: none; }
.pco-app .pco-view--active  { display: flex; gap: 1.5rem; align-items: flex-start; }
.pco-app .pco-view--calendar.pco-view--active { display: block; }

/* ══════════════════════════════════════════════════════
   LIST VIEW
══════════════════════════════════════════════════════ */

.pco-app .pco-list-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.pco-app .pco-event-row {
  display: flex;
  gap: 1.25rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--pco-border);
  align-items: flex-start;
  text-decoration: none !important;
  color: var(--pco-text) !important;
}
.pco-app .pco-event-row:first-of-type {
  border-top: 1px solid var(--pco-border);
}

.pco-app .pco-event-row__img {
  flex-shrink: 0;
  width: 200px;
  height: 140px;
  border-radius: var(--pco-radius);
  overflow: hidden;
  background: var(--pco-bg-sidebar);
}
.pco-app .pco-event-row__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pco-app .pco-event-row__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .28rem;
}

.pco-app .pco-event-row__title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--pco-primary);
  margin: 0;
  line-height: 1.3;
  text-decoration: none;
}

.pco-app .pco-event-row__date {
  font-size: .88rem;
  font-weight: 700;
  color: var(--pco-text);
  margin: 0;
}

.pco-app .pco-event-row__time,
.pco-app .pco-event-row__loc {
  font-size: .87rem;
  color: var(--pco-text);
  margin: 0;
}

.pco-app .pco-event-row__desc {
  font-size: .85rem;
  color: var(--pco-muted);
  margin: .2rem 0 0;
  line-height: 1.55;
}

/* ── Register button — isolated from theme ───────────── */
.pco-app .pco-reg-btn {
  all: unset;
  display: inline-block;
  margin-top: .45rem;
  padding: .4rem .9rem;
  background: var(--pco-primary);
  /* color: #fff !important; */
  font-size: .8rem;
  font-weight: 600;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none !important;
  transition: background .15s;
  width: fit-content;
}
.pco-app .pco-reg-btn:hover {
  background: var(--pco-primary-dark) !important;
  color: #fff !important;
  text-decoration: none !important;
}
.pco-app .pco-reg-btn--sm {
  padding: .28rem .65rem;
  font-size: .75rem;
  margin-top: .3rem;
}

/* ── Pagination ──────────────────────────────────────── */
.pco-app .pco-pagination {
  margin-top: 1.25rem;
}
.pco-app .pco-pages {
  display: flex;
  align-items: center;
  gap: .35rem;
  flex-wrap: wrap;
}
.pco-app .pco-page-btn {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 .55rem;
  border: 1px solid var(--pco-border);
  border-radius: 6px;
  font-size: .84rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--pco-text);
  background: #fff;
  transition: all .15s;
}
.pco-app .pco-page-btn:hover:not([disabled]) {
  border-color: var(--pco-primary);
  color: var(--pco-primary);
  background: var(--pco-primary-light);
}
.pco-app .pco-page-btn--active {
  background: var(--pco-primary) !important;
  color: #fff !important;
  border-color: var(--pco-primary) !important;
}
.pco-app .pco-page-btn[disabled] {
  opacity: .4;
  cursor: default;
}
.pco-app .pco-page-prev,
.pco-app .pco-page-next {
  font-size: .82rem;
  padding: 0 .7rem;
}

/* ── Sidebar ─────────────────────────────────────────── */
.pco-app .pco-sidebar {
  flex-shrink: 0;
  width: 250px;
}
.pco-app .pco-sidebar__box {
  background: var(--pco-bg-sidebar);
  border-radius: var(--pco-radius);
  padding: 1.1rem 1.25rem;
}
.pco-app .pco-sidebar__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--pco-text);
  margin: 0 0 1rem;
}
.pco-app .pco-sidebar__day { margin-bottom: .85rem; }
.pco-app .pco-sidebar__day-label {
  display: block;
  font-size: .82rem;
  font-weight: 700;
  color: var(--pco-text);
  margin-bottom: .3rem;
}
.pco-app .pco-sidebar__event {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .4rem;
  padding: .22rem 0;
}
.pco-app .pco-sidebar__event-name {
  font-size: .84rem;
  color: var(--pco-primary);
  font-weight: 500;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pco-app .pco-sidebar__event-time {
  font-size: .8rem;
  color: var(--pco-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.pco-app .pco-sidebar__empty {
  font-size: .84rem;
  color: var(--pco-muted);
  font-style: italic;
  margin: 0;
}

/* ══════════════════════════════════════════════════════
   CALENDAR VIEW
══════════════════════════════════════════════════════ */

.pco-app .pco-cal-wrap { position: relative; }

.pco-app .pco-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.pco-app .pco-cal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--pco-text);
}
.pco-app .pco-cal-nav {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--pco-border);
  border-radius: 6px;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--pco-muted);
  background: #fff;
  transition: all .15s;
}
.pco-app .pco-cal-nav:hover {
  background: var(--pco-primary-light) !important;
  color: var(--pco-primary) !important;
  border-color: var(--pco-primary) !important;
}

.pco-app .pco-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--pco-border);
  border: 1px solid var(--pco-border);
  border-radius: var(--pco-radius);
  overflow: hidden;
}
.pco-app .pco-cal-dow {
  background: var(--pco-bg-sidebar);
  text-align: center;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--pco-muted);
  padding: .5rem 0;
}
.pco-app .pco-cal-cell,
.pco-app .pco-cal-empty {
  background: var(--pco-bg);
  min-height: 88px;
  padding: .4rem .45rem;
  vertical-align: top;
}
.pco-app .pco-cal-empty { background: #fafafa; }

.pco-app .pco-cal-num {
  display: block;
  font-size: .8rem;
  color: var(--pco-muted);
  font-weight: 500;
  margin-bottom: .22rem;
  line-height: 1.5;
}
.pco-app .pco-cal-cell--today { background: var(--pco-primary-light); }
.pco-app .pco-cal-cell--today .pco-cal-num {
  background: var(--pco-primary);
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .78rem;
}
.pco-app .pco-cal-cell--has { cursor: pointer; }
.pco-app .pco-cal-cell--has:hover { background: var(--pco-primary-light); }

.pco-app .pco-cal-pill {
  display: block;
  background: var(--pco-primary);
  color: #fff;
  font-size: .67rem;
  font-weight: 600;
  border-radius: 3px;
  padding: 2px 5px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
}
.pco-app .pco-cal-more {
  font-size: .67rem;
  color: var(--pco-muted);
  padding: 1px 4px;
}

/* Popover */
.pco-app .pco-cal-popover {
  position: absolute;
  background: #fff;
  border: 1px solid var(--pco-border);
  border-radius: var(--pco-radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
  z-index: 9999;
  width: 280px;
  padding: .85rem 1rem;
}
.pco-app .pco-pop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .7rem;
  font-size: .9rem;
}
.pco-app .pco-pop-close {
  all: unset;
  cursor: pointer;
  font-size: 1.15rem;
  color: var(--pco-muted);
  line-height: 1;
  padding: 2px 4px;
}
.pco-app .pco-pop-close:hover { color: var(--pco-text); }
.pco-app .pco-pop-event {
  display: flex;
  gap: .6rem;
  padding: .5rem 0;
  border-top: 1px solid var(--pco-border);
  align-items: flex-start;
}
.pco-app .pco-pop-img {
  width: 48px;
  height: 48px;
  border-radius: 5px;
  object-fit: cover;
  flex-shrink: 0;
}
.pco-app .pco-pop-info {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  font-size: .82rem;
  min-width: 0;
}
.pco-app .pco-pop-info strong { color: var(--pco-text); font-size: .88rem; display: block; }
.pco-app .pco-pop-info span   { color: var(--pco-muted); display: block; }

/* ── Misc ────────────────────────────────────────────── */
.pco-app .pco-empty {
  color: var(--pco-muted);
  font-style: italic;
  padding: 2rem 0;
  text-align: center;
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .pco-app .pco-sidebar                    { display: none; }
  .pco-app .pco-tab[data-tab="calendar"]   { display: none; }
  .pco-app .pco-view--list.pco-view--active { flex-direction: column; }
  .pco-app .pco-event-row                  { flex-direction: column; gap: .75rem; }
  .pco-app .pco-event-row__img             { width: 100%; height: 180px; }
  .pco-app .pco-topbar                     { flex-direction: column; align-items: flex-start; }
  .pco-app .pco-filter-dropdown            { right: auto; left: 0; }
}
@media (max-width: 480px) {
  .pco-app .pco-event-row__img { height: 140px; }
}

/* ══════════════════════════════════════════════════════
   GRID LAYOUT
══════════════════════════════════════════════════════ */

.pco-app.pco-events--grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.pco-app .pco-event-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
  display: flex;
  flex-direction: column;
  transition: transform .2s, box-shadow .2s;
  border: 1px solid var(--pco-border);
}
.pco-app .pco-event-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(42,161,175,.13);
}

/* ── Image with overlaid date badge ─────────────────── */
.pco-app .pco-event-card__image {
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.pco-app .pco-event-card__image img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}
.pco-app .pco-event-card__image-placeholder {
  width: 100%;
  height: 180px;
  background: var(--pco-primary-light);
  display: block;
}

/* Featured badge */
.pco-app .pco-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--pco-accent);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* Date badge — overlaid bottom-left of image */
.pco-app .pco-event-card__date {
  position: absolute;
  bottom: 10px;
  left: 12px;
  width: 50px;
  height: 50px;
  border-radius: 8px;
  background: var(--pco-primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  flex-shrink: 0;
}
.pco-app .pco-event-card__month {
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  line-height: 1;
  color: rgba(255,255,255,.85);
}
.pco-app .pco-event-card__day {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.1;
  color: #fff;
}

/* ── Card body ───────────────────────────────────────── */
.pco-app .pco-event-card__body {
  padding: 1rem 1.15rem 1.15rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: .75rem;
  flex: 1;
}

.pco-app .pco-event-card__info {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  width: 100%;
}

.pco-app .pco-event-card__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--pco-text);
  margin: 0 0 .15rem;
  text-decoration: none;
  line-height: 1.3;
}

.pco-app .pco-event-card__time,
.pco-app .pco-event-card__location {
  font-size: .82rem;
  color: var(--pco-muted);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
}
.pco-app .pco-event-card__time svg,
.pco-app .pco-event-card__location svg {
  flex-shrink: 0;
  color: var(--pco-primary);
}

.pco-app .pco-event-card__desc {
  font-size: .82rem;
  color: var(--pco-muted);
  margin: .2rem 0 0;
  line-height: 1.55;
}

/* ── Buttons ─────────────────────────────────────────── */
.pco-app .pco-btn {
  all: unset;
  display: inline-block;
  padding: .45rem 1rem;
  background: var(--pco-primary);
  color: #fff !important;
  font-size: .82rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none !important;
  transition: background .15s;
  width: fit-content;
  margin-top: .1rem;
}
.pco-app .pco-btn:hover {
  background: var(--pco-primary-dark) !important;
  color: #fff !important;
  text-decoration: none !important;
}

.pco-app .pco-btn--outline {
  background: transparent !important;
  color: var(--pco-primary) !important;
  border: 1.5px solid var(--pco-primary) !important;
}
.pco-app .pco-btn--outline:hover {
  background: var(--pco-primary-light) !important;
  color: var(--pco-primary-dark) !important;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .pco-app.pco-events--grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 480px) {
  .pco-app.pco-events--grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}