:root {
  --fc-border-color: #dddddd;
  --fc-daygrid-event-dot-width: 6px;
  --fc-today-bg-color: transparent;
  --fc-page-bg-color: transparent;
}

.fc {
  position: relative !important;
  // Neutralise theme-injected table defaults (e.g. Divi's `.entry-content tr td`)
  // that leak padding/borders/backgrounds into FullCalendar cells. Scoped to the
  // interior grid cells only so our own header padding / event padding survives.
  &.fc table {
    border: 0;
    margin: 0;
  }
  &.fc .fc-daygrid-day,
  &.fc .fc-timegrid-slot,
  &.fc .fc-timegrid-slot-label,
  &.fc .fc-timegrid-col,
  &.fc .fc-timegrid-axis,
  &.fc .fc-daygrid-body td,
  &.fc .fc-daygrid-body th {
    padding: 0;
    border-top-color: var(--fc-border-color);
    color: inherit;
    font-weight: inherit;
  }
  // Week view: drop redundant cell borders that stack with neighbours.
  &.fc .fc-timegrid-axis.fc-scrollgrid-shrink {
    border-bottom: 0;
  }
  &.fc .fc-scrollgrid-section-liquid > td {
    border-right: 0;
  }
  &.fc tr.fc-scrollgrid-section-body:not(.fc-scrollgrid-section-liquid) td.fc-day {
    border-bottom: 0;
  }
  table {
    margin-bottom: 0;
  }
  a {
    color: inherit;
  }
  .fc-daygrid-event {
    border-radius: 0;
    border-top-width: 0;
    border-right-width: 0;
    border-bottom-width: 0;
    border-left-width: 0;
    outline: 0;
    font-size: 13px;
    box-shadow: none !important;
    margin-top: 3px;
    cursor: pointer;
    .fc-event-main {
      color: inherit !important;
    }
    &.fc-daygrid-dot-event {
      background-color: transparent !important;
      .fc-event-title {
        text-align: left;
      }
    }
    // Block-bar events (all-day / multi-day) already paint their full
    // background with the calendar color, so the colored dot is redundant
    // — and being display:block it pushes the title onto a second line.
    &.fc-h-event .fc-daygrid-event-dot,
    &.fc-daygrid-block-event .fc-daygrid-event-dot {
      display: none;
    }
    // All-day / multi-day chip in the week-view all-day row and in
    // month-view cells: rounded card matching the timegrid event style.
    &.fc-h-event {
      color: #fff !important;
      border-radius: 8px !important;
      padding: 3px 8px;
      min-height: 22px;
      font-weight: 500;
      box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.18) !important;
      .fc-event-title,
      .fc-event-title-container {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }
  }
  .fc-event-selected::after,
  .fc-event:focus::after {
    background-color: transparent !important;
  }
  .fc-scrollgrid {
    border: 0;
  }
  .fc-daygrid-day.fc-day-today {
    background-color: var(--fc-today-bg-color);
  }
  .fc-daygrid-day-top {
    flex-direction: row;
    padding: 4px 6px 0;
  }
  .fc-daygrid-day-frame {
    min-height: 120px;
  }
  .fc-daygrid-day-events {
    margin: 6px 4px 4px;
  }
  .fc-daygrid-day-events .fc-daygrid-event-harness {
    margin-top: 2px;
  }
  .fc-daygrid-day-number {
    text-decoration: none !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75rem;
    height: 1.75rem;
    padding: 0 0.5rem;
    border-radius: 9999px;
    font-weight: 500;
    font-size: 15px;
    color: #2d2d2d;
    background: transparent;
  }
  .fc-day-today .fc-daygrid-day-number {
    background: var(--ek-calendar-accent, var(--wp-admin-theme-color, #2563eb));
    font-weight: 600;
    color: #fff !important;
  }
  .fc-scrollgrid-section th {
    border: 0;
  }
  .fc-event-main {
    font-size: 13px;
    padding-left: 4px;
  }
  .fc-daygrid-dot-event .fc-event-title {
    font-weight: 500;
    line-height: 1.25;
  }
  .fc-daygrid-more-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 4px 0 0;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    text-decoration: none !important;
    color: #475569;
    background: #f1f5f9;
    transition: background-color 0.15s ease, color 0.15s ease;
  }
  .fc-daygrid-more-link:hover,
  .fc-daygrid-more-link:focus {
    color: #1e293b;
    background: #e2e8f0;
  }
  .fc-col-header {
    border: none;
    th {
      border: 0;
    }
  }
  .fc-col-header-cell {
    padding-top: 10px;
    padding-bottom: 20px;
    font-size: 0.9em;
    text-align: left;
  }
  .fc-col-header-cell-cushion {
    text-decoration: none;
    font-weight: 500;
    text-transform: uppercase;
    padding: 0 0 0 6px;
    font-size: 14px;
  }
  .fc-toolbar.fc-header-toolbar {
    margin-bottom: 0;
    .fc-toolbar-chunk {
      display: flex;
      align-items: center;
      gap: 10px;
      &:last-child {
        .fc-button-group {
          gap: 0px;
          background: #f5f5f5;
          border: 1px solid #eee;
          border-radius: 8px;
          padding: 0px;
        }
        .fc-button {
          font-size: 14px;
          background-color: transparent !important;
          box-shadow: none !important;
          color: #666 !important;
          border: 0 !important;
          padding: 4px 14px !important;
          text-transform: capitalize;
          height: 32px !important;
          &.fc-button-active {
            color: #333 !important;
            background-color: #fff !important;
            border-radius: 8px;
            border: 0 !important;
            box-shadow: 0 1px #eee !important;
            font-weight: 500;
          }
        }
      }
    }
    .fc-toolbar-title {
      display: inline-flex;
      font-family: Helvetica, sans-serif;
      margin: 0 !important;
    }
    .fc-button-group {
      gap: 6px;
      font-size: 11px;
      min-height: 32px;
    }
  }
  .fc-button.fc-prev-button,
  .fc-button.fc-next-button {
    background-color: transparent !important;
    border-color: transparent !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    color: #393838 !important;
    border: none;
    padding: 0;
    &:hover,
    &:focus,
    &:active {
      background-color: transparent !important;
      border-color: transparent !important;
      border-radius: 0 !important;
      box-shadow: none !important;
      color: #111111 !important;
    }
  }
  .fc-today-button {
    background-color: transparent;
    border: 1px solid #aaa;
    font-size: 14px;
    border-radius: 4px;
    color: #666;
    height: 32px;
    line-height: 32px;
    display: flex;
    align-items: center;
    margin: 0 !important;
    &:disabled {
      background-color: transparent;
      color: #888;
      border-color: #bbb;
    }
  }
  .fc-scrollgrid-section-header {
    .fc-scroller {
      overflow: hidden !important;
    }
  }
  .fc-event-title {
    padding: 0;
  }
  .fc-event-time {
    flex-shrink: 0;
    padding: 0;
  }
  .fc-timegrid {
    tbody
      > tr.fc-scrollgrid-section.fc-scrollgrid-section-body:nth-of-type(3)
      > td {
      border-top: 0 !important;
    }
  }
  .fc-timegrid .fc-event-main {
    font-size: 13px;
  }
  .fc-timegrid-slot {
    font-size: 14px;
  }
  .fc-timegrid-slot-minor {
    border-top: 0;
  }
  .fc-timegrid-axis-cushion {
    font-size: 15px;
  }
  .fc-timegrid-col .fc-event-main {
    padding: 4px 6px;
    .fc-event-time,
    .fc-event-title {
      display: block;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 100%;
    }
    // Multi-day continuation bars (Sat/Sun of a Fri-Sun event) span the
    // whole column from 00:00, so the title would scroll off-screen as
    // soon as the user scrolls to business hours. Sticky-pinning the
    // title keeps it visible at the top of the bar's visible portion —
    // matching Google Calendar's behavior.
    .fc-event-title {
      font-weight: 500;
      position: sticky;
      top: 4px;
    }
  }
  // Google-Calendar-style cards for timegrid events. Cascade indent +
  // z-index are set inline by cascadeTimegridColumn().
  // NOTE: NO overflow on this element — any overflow (hidden / clip /
  // auto) traps `position: sticky` on the title, defeating the keep-
  // visible-on-scroll behavior for multi-day continuation bars.
  // The .fc-event-time/.fc-event-title spans inside already clip via
  // `text-overflow: ellipsis`, so text never escapes the card visually.
  .fc-timegrid-event {
    border-radius: 8px;
    border: 0;
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.18);
  }
  // Subtle warm-grey tint for days NOT in the user's configured
  // working_days setting (Settings → Working days). Matches Google's
  // weekend tint pattern but respects custom work-week schedules.
  td.ek-non-working-day,
  .ek-non-working-day .fc-timegrid-col-frame {
    background-color: rgb(0 0 0 / 0.024);
  }
  // Google-Calendar-style "now" indicator: thin red line across all
  // timegrid columns at the current time, with a circular dot pinned
  // to the time-axis on the left edge.
  .fc-timegrid-now-indicator-line {
    border-top: 2px solid #ea4335;
    border-color: #ea4335;
  }
  .fc-timegrid-now-indicator-arrow {
    border: 0;
    margin-top: -5px;
    margin-left: -5px;
    width: 10px;
    height: 10px;
    background: #ea4335;
    border-radius: 50%;
  }
  // The overlapping (level > 0) event gets a strong card edge — a white
  // ring against its underlying neighbor plus a soft drop-shadow so it
  // visibly floats on top.
  .fc-timegrid-event-harness.ek-cascade-overlap .fc-timegrid-event {
    box-shadow: 0 0 0 2px #fff, 0 6px 14px rgb(0 0 0 / 0.22);
  }
  .fc-timegrid-axis-cushion::first-letter {
    text-transform: uppercase;
  }
  .fc-scrollgrid-sync-inner {
    text-align: center;
  }
  .fc-daygrid-body-natural .fc-daygrid-day-events {
    margin-bottom: 0;
  }
  [class="fc-scrollgrid-section"] {
    display: none;
  }
  .fc-timegrid-all-day {
    font-weight: bold;
  }
  .fc-timegrid
    .fc-scrollgrid-section-body:not(.fc-scrollgrid-section-liquid)
    .fc-scroller {
    overflow: hidden !important;
  }
  .fc-timegrid .fc-scroller {
    scrollbar-width: thin;
  }
  .fc-timegrid .fc-scroller::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }
  .fc-timegrid .fc-scroller::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.25);
    border-radius: 999px;
  }
  .fc-timegrid .fc-scroller::-webkit-scrollbar-track {
    background: transparent;
  }
  .fc-scrollgrid-section-sticky > * {
    background-color: white;
  }
  .fc-popover {
    z-index: 70;
    background-color: #fff;
    border: 1px solid #ddd;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  }
  .fc-popover-header {
    background-color: #fff;
    border-bottom: 1px solid #eee;
  }
  .fc-popover-body {
    background-color: #fff;
  }
  .fc-popover .fc-daygrid-event-harness {
    margin: 4px 6px;
  }
  .fc-popover .fc-daygrid-event {
    border-radius: 6px !important;
    padding: 4px 6px !important;
  }
}

@media (max-width: 768px) {
  .fc .fc-col-header-cell {
    text-align: center !important;
    padding-left: 0 !important;
    padding-bottom: 10px !important;
    padding-top: 5px !important;
  }

  .fc .fc-col-header-cell-cushion {
    padding-left: 0 !important;
    display: inline-block;
    width: 100%;
    text-align: center;
  }

  [data-event-popover] {
    left: 0 !important;
    width: 100% !important;
    max-width: none !important;
  }

  .fc .fc-event-main,
  .fc .fc-daygrid-dot-event {
    font-size: 10px;
  }

  .fc-timegrid th.fc-day .fc-scrollgrid-sync-inner {
    margin: 0 10px;
  }

  .fc .fc-timegrid .fc-event-main {
    font-size: 13px;
    padding: 2px;
  }
}

// Scoped under `.eventkoi-front` for the same reason as the utilities in
// global.scss: themes ship button resets that strip borders and backgrounds,
// and at equal specificity they win on source order, leaving the retry
// control looking like plain text. The longhand border properties keep a
// theme shorthand from zeroing the width.
.eventkoi-front {
  .ek-calendar-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px 16px;
    text-align: center;

    p {
      margin: 0;
      color: #6b7280;
      font-size: 14px;
    }

    // Tailwind's scoped preflight zeroes button borders and padding at
    // `.eventkoi-front :is(button,...):not(...):not(...)`, which is 0,3,1.
    // This selector is 0,4,1 so the retry control keeps looking like a
    // button instead of plain text.
    button.ek-calendar-error__retry:not(.wp-element-button) {
      padding: 8px 16px;
      border-width: 1px;
      border-style: solid;
      border-color: #d1d5db;
      border-radius: 6px;
      background: transparent;
      color: inherit;
      font-size: 14px;
      line-height: 1.4;
      cursor: pointer;

      &:hover {
        background: #f3f4f6;
      }
    }
  }
}
