/* ==========================================================
   ScoutBase - calendar specific styling
   ==========================================================
   Ported from scout_calendar's scoutCal/site/shared/assets/app.css
   (month grid, agenda list, event pills, modal dialog),
   reconciled to use this app's shared tokens.css/base.css
   instead of scout_calendar's own brand tokens and .card/.btn
   rules.
   ========================================================== */

.calendar-app.grid {
  display: grid;
  grid-template-columns: minmax(300px, 2fr) minmax(260px, 1.2fr);
  gap: 16px;
  margin-top: 12px;
}
@media (max-width: 900px) {
  .calendar-app.grid { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.toolbar-left { display: flex; gap: 10px; align-items: center; }
.toolbar-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.title-month { font-size: 20px; }

/* Calendar navigation is used frequently but should not outweigh the month
   itself. Keep its visual footprint below the global primary-action buttons. */
.calendar-app .toolbar .btn {
  min-height: 36px;
  padding: 7px 12px;
  font-size: 14px;
  line-height: 1.2;
}

@media (max-width: 720px) {
  /* The shared mobile rule retains a 44px touch target; only compact the
     visual padding and type inside that target. */
  .calendar-app .toolbar .btn {
    padding: 6px 10px;
    font-size: 13px;
  }
}

/* "+ Termin" carries the group's own accent, same as the month/pill
   highlights, so a leader editing GuSp's calendar sees green and CaEx
   sees blue rather than the generic site-wide accent everywhere. */
#newEventBtn {
  background: var(--group-accent, var(--accent));
}
#newEventBtn:hover {
  filter: brightness(0.9);
}

/* ===== Month grid ===== */
.grid-7 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.dow { text-align: center; font-size: 12px; color: var(--muted); padding: 6px 0; }

.day {
  min-height: clamp(56px, 8vw, 100px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  background: var(--panel);
  position: relative;
  overflow: hidden;
}

/* Keep the seven-day month view usable at 320px.  Event pills retain their
   time/title affordance but truncate inside their own cell instead of forcing
   the whole page to scroll horizontally. */
@media (max-width: 480px) {
  .calendar-app .card { padding: 10px; }
  .grid-7 { gap: 3px; }
  .dow { padding: 4px 0; font-size: 10px; overflow: hidden; }
  .day { min-height: 48px; padding: 4px; border-radius: 7px; }
  .day .num { font-size: 12px; }
  .pill { overflow: hidden; padding: 2px 3px; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
  .toolbar-left, .toolbar-right { gap: 5px; }
  .title-month { font-size: 16px; }
}
.day.other-month { opacity: .5; }

.day.today {
  border-color: var(--group-accent, var(--today-border));
  background: var(--today-bg);
  box-shadow: 0 0 0 2px var(--group-accent, var(--today-border)) inset, 0 0 0 3px var(--today-glow);
}
.day.today .num { color: var(--group-accent, var(--today-border)); font-weight: 700; }

.num { font-size: 12px; color: var(--muted); }

/* Event pills - two-line clamp */
.pill {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  white-space: normal;
  overflow: hidden;

  margin-top: 6px;
  padding: 4px 8px;
  line-height: 1.25;
  font-size: 12px;
  color: var(--text);
  border-radius: 8px;

  border: 1px solid var(--pill-border);
  border-left-width: 6px;
  cursor: pointer;
}

/* Timed event - tinted with the group's own accent when it has one
   (e.g. CaEx blue, GuSp green), falling back to the site accent. */
.pill.red {
  border-left-color: var(--group-accent, var(--accent));
  background: var(--pill-red-bg);
}
/* All-day event */
.pill.blue {
  border-left-color: var(--accent-2);
  background: var(--pill-blue-bg);
}

/* ===== Agenda ===== */
.agenda h3, #agenda h3 { font-size: 14px; margin: 10px 0 6px; }
.item { padding: 8px 4px; border-bottom: 1px solid var(--border); }
.item:last-child { border-bottom: none; }
.when { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); padding: 12px 4px; }

.agenda-toggle { margin-top: 8px; }

details { margin-top: 6px; }
details > summary { cursor: pointer; color: var(--accent-strong); list-style: revert; font-size: 13px; }
details .desc { white-space: pre-wrap; margin-top: 6px; font-size: 14px; }
.past { margin-top: 12px; }

/* ===== Event modal (read + new-event) ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.modal-open { display: flex; }
.modal {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: min(640px, 92vw);
  width: min(640px, 92vw);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.modal h2 { margin: 0 0 6px; font-size: 18px; }
.modal .when { font-size: 14px; margin-bottom: 8px; }
.modal .desc { white-space: pre-wrap; font-size: 14px; }
.modal .actions { display: flex; justify-content: flex-end; margin-top: 12px; }

/* ===== New-event form grid (leader modal) =====
   The original scout_calendar markup used .form-grid/.checkbox-row/
   .time-row/.full classes with no matching CSS anywhere in the source
   app - the modal rendered as unstyled stacked labels. We give them a
   real two-column layout here. */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}
.form-grid label.full { grid-column: 1 / -1; }
.form-grid label.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.form-grid input,
.form-grid textarea,
.form-grid select {
  font-size: 15px;
  color: var(--text);
}
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
}
