/* app/assets/stylesheets/calendar.css */
.apple-cal,
.apple-week {
  --bg: #ffffff;
  --surface-muted: #f2f2f7;
  --border: #e5e5ea;
  --text: #1c1c1e;
  --text-secondary: #3a3a3c;
  --text-muted: #8e8e93;
  --accent-red: #ff3b30;
  --accent-green: #34c759;
  --event-bg: transparent;
  --event-text: #1c1c1e;

  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  color: var(--text);
  background: var(--bg);
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 24px 0;
  overflow-x: clip;
}

.apple-cal__header,
.apple-week__topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.apple-cal__title-group {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.apple-cal__month {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.apple-cal__year {
  font-size: 24px;
  font-weight: 300;
  color: var(--text-muted);
}

.apple-week__nav {
  display: flex;
  gap: 6px;
}

.apple-cal__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  min-width: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

.apple-cal__btn:hover {
  background: var(--surface-muted);
}

/* Full-width navigation bar directly below month grid */
.apple-cal__nav-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.apple-cal__nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.apple-cal__nav-btn:hover {
  background: var(--surface-muted);
}

.apple-cal__weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.apple-cal__weekday {
  text-align: right;
  padding-right: 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.apple-cal__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-left: 1px solid var(--border);
}

.apple-cal__cell {
  display: flex;
  flex-direction: column;
  min-height: 112px;
  padding: 6px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  color: inherit;
  text-decoration: none;
}

.apple-cal__cell:hover {
  background: #fafafa;
}

.apple-cal__cell.is-outside {
  background: var(--surface-muted);
  color: var(--text-muted);
}

.apple-cal__cell.is-outside:hover {
  background: #ececef;
}

.apple-cal__cell-top {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  margin-bottom: 4px;
}

.apple-cal__day-number {
  font-size: 13px;
  font-weight: 500;
}

.apple-cal__cell.is-today .apple-cal__day-number span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--accent-red);
  color: #ffffff;
  font-weight: 600;
}

.apple-cal__mobile-badge-wrap {
  display: none;
}

.apple-cal__events {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.apple-cal__event {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  border-radius: 4px;
  background: var(--event-bg);
  color: var(--event-text);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.apple-cal__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.apple-cal__event-time {
  font-weight: 600;
  flex-shrink: 0;
}

.apple-cal__event-title {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Full-bleed gray Upcoming Events section below month view */
.apple-cal__agenda {
  display: flex;
  flex-direction: column;
  margin-top: 24px;
  padding: 24px 0 48px;
  background: var(--surface-muted);
  border-top: 1px solid var(--border);
  box-shadow: 0 0 0 100vmax var(--surface-muted);
  clip-path: inset(0 -100vmax);
}

.apple-cal__agenda-heading {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-muted);
  margin: 0 0 16px;
}

.apple-cal__agenda-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.apple-cal__agenda-card {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.apple-cal__agenda-date-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 44px;
  flex-shrink: 0;
  padding-top: 2px;
  text-decoration: none;
  color: var(--text);
}

.apple-cal__agenda-day-num {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.15;
}

.apple-cal__agenda-weekday {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.apple-cal__agenda-items {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.apple-cal__agenda-item {
  padding-left: 12px;
  border-left: 2px solid var(--text-secondary);
}

.apple-cal__agenda-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.apple-cal__agenda-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.apple-cal__agenda-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.apple-cal__agenda-time {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.35;
}

.apple-cal__empty {
  color: var(--text-muted);
  font-size: 14px;
}

/* Week view */
.apple-week {
  max-width: 1280px;
  padding-bottom: 0;
}

.apple-week__heading {
  margin-bottom: 18px;
}

.apple-week__full-date {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.apple-week__sublabel {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-red);
  margin-top: 2px;
}

.apple-week__strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  max-width: 640px;
  margin-bottom: 28px;
}

.apple-week__day-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  border-radius: 12px;
  background: var(--surface-muted);
  color: var(--text);
  text-decoration: none;
  gap: 4px;
}

.apple-week__day-pill.is-selected {
  background: var(--accent-red);
  color: #ffffff;
}

.apple-week__day-abbr {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.75;
}

.apple-week__day-num {
  font-size: 16px;
  font-weight: 700;
}

.apple-week__day-dots {
  display: flex;
  gap: 3px;
  min-height: 6px;
}

.apple-week__mini-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
}

.apple-week__day-pill.is-selected .apple-week__mini-dot {
  background: #ffffff;
}

/* Full-bleed gray events band on week view */
.apple-week__agenda {
  display: flex;
  flex-direction: column;
  padding: 24px 0 48px;
  background: var(--surface-muted);
  border-top: 1px solid var(--border);
  box-shadow: 0 0 0 100vmax var(--surface-muted);
  clip-path: inset(0 -100vmax);
}

.apple-week__agenda-heading {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-muted);
  margin: 0 0 16px;
}

.apple-week__agenda-card {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.apple-week__agenda-date-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 44px;
  flex-shrink: 0;
  padding-top: 2px;
  color: var(--text);
}

.apple-week__agenda-day-num {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.15;
}

.apple-week__agenda-weekday {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.apple-week__agenda-items {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.apple-week__agenda-item {
  padding-left: 12px;
  border-left: 2px solid var(--text-secondary);
}

.apple-week__agenda-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.apple-week__agenda-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.apple-week__agenda-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.apple-week__agenda-time {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Green plus button centered at the end of the gray section */
.apple-cal__fab {
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-top: 28px;
  border-radius: 999px;
  background: var(--accent-green);
  color: #ffffff;
  font-size: 32px;
  font-weight: 300;
  line-height: 1;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(52, 199, 89, 0.35);
}

.apple-cal__fab:hover {
  background: #2db84d;
}

.apple-cal__fab:active {
  transform: scale(0.96);
}

/* New event form */
.apple-event-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 520px;
  padding-bottom: 48px;
}

.apple-event-form__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.apple-event-form__label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.apple-event-form__input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}

.apple-event-form__checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.apple-event-form__submit {
  height: 46px;
  border: none;
  border-radius: 999px;
  background: var(--accent-green);
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.apple-event-form__submit:hover {
  background: #2db84d;
}

.apple-event-form__errors {
  padding: 10px 12px;
  border-radius: 10px;
  background: #ffeceb;
  color: var(--accent-red);
  font-size: 13px;
}

/* Mobile rules */
@media (max-width: 767px) {
  .apple-cal {
    padding: 14px 12px 0;
  }

  .apple-cal__cell {
    min-height: 64px;
    padding: 4px;
  }

  .apple-cal__events {
    display: none;
  }

  .apple-cal__mobile-badge-wrap {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    width: 100%;
  }

  .apple-cal__mobile-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--accent-red);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
  }

  .apple-cal__nav-bar {
    gap: 8px;
    margin-top: 12px;
  }

  .apple-cal__nav-btn {
    height: 44px;
    font-size: 14px;
    border-radius: 10px;
  }

  .apple-cal__agenda {
    padding: 20px 0 40px;
  }

  .apple-cal__agenda-card {
    padding: 14px;
    gap: 14px;
  }

  .apple-week__agenda {
    padding: 20px 0 40px;
  }

  .apple-week__agenda-card {
    padding: 14px;
    gap: 14px;
  }
}