/* =====================================================
   PI Events for SeatGeek — Frontend Styles v1.6.4
   Uses CSS custom properties so admin style settings
   cascade without extra specificity or !important.
   ===================================================== */

/* ── CSS variable defaults (overridden by inline style on wrapper) ── */
.pisg-events-wrap {
  --pisg-card-bg:       #ffffff;
  --pisg-card-border:   #e8e8e8;
  --pisg-card-radius:   10px;
  --pisg-card-shadow:   0 2px 8px rgba(0,0,0,0.07);
  --pisg-title-color:   #1a1a2e;
  --pisg-title-size:    16px;
  --pisg-meta-color:    #555555;
  --pisg-meta-size:     13px;
  --pisg-btn-bg:        #0073aa;
  --pisg-btn-color:     #ffffff;
  --pisg-btn-radius:    5px;
  --pisg-thumb-height:  190px;
  --pisg-gap:           22px;
  --pisg-cols-desktop:  3;
  --pisg-cols-tablet:   2;
  margin: 20px 0;
  max-width: 100%;
}

/* =====================================================
   GRID LAYOUTS — CSS Grid
   ===================================================== */
.pisg-events {
  display: grid;
  gap: var(--pisg-gap);
  width: 100%;
  box-sizing: border-box;
}

/* 3-col default */
.pisg-events.grid-3 {
  grid-template-columns: repeat(var(--pisg-cols-desktop, 3), minmax(0, 1fr));
}

/* 2-col */
.pisg-events.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* 4-col */
.pisg-events.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* List — single column, horizontal cards */
.pisg-events.list {
  display: grid;
  grid-template-columns: 1fr;
}

/* =====================================================
   MASONRY — CSS columns (no JS, no reflow bugs)
   ===================================================== */
.pisg-events.masonry {
  display: block;
  grid-template-columns: none;
  column-count: var(--pisg-cols-desktop, 3);
  column-gap: var(--pisg-gap);
}

.pisg-events.masonry .pisg-event-item {
  break-inside: avoid;
  display: inline-block; /* required for column break-inside to work */
  width: 100%;
  margin-bottom: var(--pisg-gap);
}

/* =====================================================
   CARD BASE
   ===================================================== */
.pisg-event-item {
  background: var(--pisg-card-bg);
  border: 1px solid var(--pisg-card-border);
  border-radius: var(--pisg-card-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--pisg-card-shadow);
  transition: box-shadow 0.25s ease, transform 0.25s ease;
  min-width: 0;
  box-sizing: border-box;
}

.pisg-event-item:hover {
  box-shadow: 0 8px 28px rgba(0,0,0,0.14);
  transform: translateY(-4px);
}

/* List view: horizontal card */
.pisg-events.list .pisg-event-item {
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

/* =====================================================
   THUMBNAIL — real image
   ===================================================== */
.pisg-event-thumb {
  flex-shrink: 0;
  overflow: hidden;
  position: relative; /* for badge positioning */
}

.pisg-thumb-real img {
  width: 100%;
  height: var(--pisg-thumb-height);
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.pisg-event-item:hover .pisg-thumb-real img {
  transform: scale(1.05);
}

/* List view thumb */
.pisg-events.list .pisg-event-thumb {
  flex: 0 0 200px;
  max-width: 200px;
}

.pisg-events.list .pisg-thumb-real img {
  height: 100%;
  min-height: 130px;
}

/* Masonry: let height be natural */
.pisg-events.masonry .pisg-thumb-real img {
  height: auto;
  min-height: 140px;
  max-height: 320px;
}

/* =====================================================
   THUMBNAIL — gradient fallback with icon
   ===================================================== */
.pisg-thumb-fallback {
  height: var(--pisg-thumb-height);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.pisg-thumb-fallback-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  text-decoration: none;
}

.pisg-cat-icon {
  font-size: 3.2rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
  transition: transform 0.3s ease;
  display: block;
}

.pisg-event-item:hover .pisg-cat-icon {
  transform: scale(1.12);
}

/* List view fallback */
.pisg-events.list .pisg-thumb-fallback {
  height: 100%;
  min-height: 130px;
  flex: 0 0 200px;
  max-width: 200px;
}

/* =====================================================
   CATEGORY BADGE — overlaid on thumbnail
   ===================================================== */
.pisg-cat-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 10px;
  letter-spacing: 0.3px;
  line-height: 1.4;
  pointer-events: none;
}

/* =====================================================
   CARD CONTENT
   ===================================================== */
.pisg-event-info {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 5px;
}

/* ── Title (h3) ── */
.pisg-event-title {
  font-size: var(--pisg-title-size);
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 4px;
}

.pisg-event-title a {
  color: var(--pisg-title-color);
  text-decoration: none;
}

.pisg-event-title a:hover {
  color: var(--pisg-btn-bg);
}

/* ── Meta ── */
.pisg-event-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: var(--pisg-meta-size);
  color: var(--pisg-meta-color);
  line-height: 1.5;
  flex: 1;
}

.pisg-event-meta span { display: block; }
.pisg-date    { font-weight: 600; }
.pisg-venue   { }
.pisg-address { opacity: 0.85; }
.pisg-city    { opacity: 0.8; }
.pisg-cat     { font-size: 0.88em; opacity: 0.7; }
.pisg-price   { font-weight: 700; }

/* ── Ticket button — full width, centered ── */
.pisg-event-ticket {
  margin-top: 14px;
  padding-top: 0;
}

.pisg-ticket-btn {
  display: block;
  width: 100%;
  text-align: center;
  background: var(--pisg-btn-bg);
  color: var(--pisg-btn-color);
  padding: 9px 12px;
  border-radius: var(--pisg-btn-radius);
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
  transition: filter 0.2s ease, transform 0.15s ease;
  box-sizing: border-box;
}

.pisg-ticket-btn:hover {
  filter: brightness(0.88);
  color: var(--pisg-btn-color);
  transform: translateY(-1px);
}

/* List view: button not full-width */
.pisg-events.list .pisg-ticket-btn {
  display: inline-block;
  width: auto;
}

/* =====================================================
   PAGINATION
   ===================================================== */
.pisg-pagination {
  margin-top: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.pisg-pagination a {
  display: inline-block;
  background: var(--pisg-btn-bg);
  color: var(--pisg-btn-color);
  padding: 8px 20px;
  border-radius: var(--pisg-btn-radius);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  transition: filter 0.2s ease;
}

.pisg-pagination .pisg-page-number,
.pisg-pagination .pisg-page-ellipsis {
  min-width: 38px;
  padding-left: 10px;
  padding-right: 10px;
  text-align: center;
  box-sizing: border-box;
}

.pisg-pagination .pisg-current {
  display: inline-block;
  background: var(--pisg-title-color);
  color: #fff;
  padding: 8px 10px;
  border-radius: var(--pisg-btn-radius);
  font-size: 0.9rem;
  font-weight: 700;
}

.pisg-pagination .pisg-page-ellipsis {
  color: var(--pisg-meta-color);
}

.pisg-pagination a:hover {
  filter: brightness(0.85);
  color: var(--pisg-btn-color);
}

.pisg-pagination .pisg-page-info {
  font-size: 0.9rem;
  color: var(--pisg-meta-color);
}

/* =====================================================
   MESSAGES
   ===================================================== */
.pisg-error,
.pisg-no-events {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 0.95rem;
}

.pisg-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

.pisg-no-events {
  background: #f0f9ff;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

/* =====================================================
   RESPONSIVE BREAKPOINTS
   ===================================================== */

/* Tablet: 3-col → 2-col */
@media (max-width: 1024px) {
  .pisg-events.grid-3 {
    grid-template-columns: repeat(var(--pisg-cols-tablet, 2), 1fr);
  }
  .pisg-events.grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .pisg-events.masonry {
    column-count: var(--pisg-cols-tablet, 2);
  }
}

/* Mobile: everything → 1 col */
@media (max-width: 680px) {
  .pisg-events.grid-3,
  .pisg-events.grid-2,
  .pisg-events.grid-4 {
    grid-template-columns: 1fr;
  }

  .pisg-events.masonry {
    column-count: 1;
  }

  /* List: collapse to vertical */
  .pisg-events.list .pisg-event-item {
    flex-direction: column;
  }
  .pisg-events.list .pisg-event-thumb {
    flex: unset;
    max-width: 100%;
  }
  .pisg-events.list .pisg-event-thumb img {
    height: var(--pisg-thumb-height);
  }
}

/* =====================================================
   VIRTUAL EVENT DETAIL PAGE
   ===================================================== */
.pisg-event-detail {
  max-width: 900px;
  margin: 40px auto;
  padding: 0 20px;
  font-size: 1rem;
  line-height: 1.6;
}

.pisg-detail-hero {
  width: 100%;
  border-radius: 10px;
  margin-bottom: 24px;
  display: block;
  object-fit: cover;
  max-height: 420px;
}

.pisg-detail-title {
  font-size: 2rem;
  font-weight: 800;
  margin: 0 0 20px;
  line-height: 1.2;
  color: #1a1a2e;
}

.pisg-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin: 0 0 28px;
  padding: 20px;
  background: #f9f9f9;
  border-radius: 8px;
  border: 1px solid #eee;
}

.pisg-detail-meta-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 180px;
  flex: 1 1 200px;
}

.pisg-meta-icon {
  font-size: 1.3rem;
  line-height: 1;
  margin-top: 2px;
  flex-shrink: 0;
}

.pisg-detail-info {
  background: #f0f9ff;
  border-left: 4px solid #0073aa;
  padding: 14px 18px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 18px;
}

.pisg-please-note {
  background: #fff8e1;
  border-left: 4px solid #f9a825;
  padding: 12px 16px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 18px;
}

.pisg-detail-seatmap { margin-bottom: 20px; }
.pisg-detail-seatmap img {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 8px;
  border: 1px solid #ddd;
}

.pisg-detail-ticket { margin: 28px 0 40px; }

.pisg-ticket-btn--large {
  font-size: 1.1rem;
  padding: 14px 36px;
}

@media (max-width: 680px) {
  .pisg-detail-title  { font-size: 1.4rem; }
  .pisg-detail-meta   { gap: 12px; }
  .pisg-detail-meta-item { flex: 1 1 100%; }
}

/* =====================================================
   iCAL BUTTON
   ===================================================== */
.pisg-ical-btn {
  display: inline-block;
  margin-left: 10px;
  padding: 8px 14px;
  background: #f0f9ff;
  color: #0073aa;
  border: 1px solid #bae6fd;
  border-radius: 5px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease;
  vertical-align: middle;
}
.pisg-ical-btn:hover {
  background: #0073aa;
  color: #fff;
  border-color: #0073aa;
}

/* =====================================================
   GOOGLE MAPS
   ===================================================== */
.pisg-map-wrap { margin-top: 20px; }
.pisg-map-wrap iframe {
  width: 100%;
  height: 400px;
  border: 0;
  border-radius: 8px;
  display: block;
}

/* =====================================================
   EVENTS HEADING (Display on Pages inject)
   ===================================================== */
.pisg-events-heading {
  margin: 32px 0 16px;
  font-size: 1.5rem;
  font-weight: 700;
  color: #1a1a2e;
}

/* =====================================================
   ADMIN LOG TABLE
   ===================================================== */
#pisg-log-wrap .wp-list-table th.column-id    { width: 8%; }
#pisg-log-wrap .wp-list-table th.column-title { width: 40%; }
#pisg-log-wrap .wp-list-table th.column-sg_id { width: 20%; }
#pisg-log-wrap .wp-list-table th.column-date  { width: 14%; }
#pisg-log-wrap { margin-top: 0; }
