/* Themes set these tokens on [data-theme], on <html> and on the swatches
   of the Theme menu (so each swatch previews its own theme). Status
   colours: downloaded, missing (aired, no file), upcoming, premiere
   (upcoming E01), unmonitored. Muximux's themes: themes-muximux.css. */

:root,
[data-theme="organizr"] {
  color-scheme: dark;
  --bg: #141414;
  --surface: #1b1b1b;
  --today: #1f1f1f;
  --line: #2a2a2a;
  --text: #ffffff;
  --text-dim: #e6e6e6;
  --muted: #9aa0a6;
  --accent: #2cabe3;
  --on-accent: #ffffff;
  --btn: #1f2126;
  --btn-hover: #2a2d33;
  /* Organizr's text-success, -danger, -info, -primary */
  --downloaded: #53e69d;
  --missing: #ff7676;
  --upcoming: #2cabe3;
  --premiere: #707cd2;
  --unmonitored: #8d959b;
}

/* Sonarr/Radarr v4+ dark UI */
[data-theme="arr"] {
  color-scheme: dark;
  --bg: #202020;
  --surface: #2a2a2a;
  --today: rgba(53, 197, 244, 0.08);
  --line: #353535;
  --text: #e1e2e3;
  --text-dim: #c6c7c8;
  --muted: #8e8e8e;
  --accent: #35c5f4;
  --on-accent: #202020;
  --btn: #2a2a2a;
  --btn-hover: #383838;
  --downloaded: #27c24c;
  --missing: #f05050;
  --upcoming: #5d9cec;
  --premiere: #a47fd9;
  --unmonitored: #7a7a7a;
}

/* Overseerr / Jellyseerr (Tailwind gray + indigo) */
[data-theme="overseerr"] {
  color-scheme: dark;
  --bg: #111827;
  --surface: #1f2937;
  --today: rgba(99, 102, 241, 0.1);
  --line: #374151;
  --text: #f9fafb;
  --text-dim: #d1d5db;
  --muted: #9ca3af;
  --accent: #6366f1;
  --on-accent: #ffffff;
  --btn: #1f2937;
  --btn-hover: #374151;
  --downloaded: #22c55e;
  --missing: #ef4444;
  --upcoming: #60a5fa;
  --premiere: #c084fc;
  --unmonitored: #6b7280;
}

/* Jellyfin dark */
[data-theme="jellyfin"] {
  color-scheme: dark;
  --bg: #101010;
  --surface: #1c1c1c;
  --today: rgba(0, 164, 220, 0.08);
  --line: #292929;
  --text: #eeeeee;
  --text-dim: #cfcfcf;
  --muted: #999999;
  --accent: #00a4dc;
  --on-accent: #ffffff;
  --btn: #1c1c1c;
  --btn-hover: #2a2a2a;
  --downloaded: #4cc38a;
  --missing: #e5534b;
  --upcoming: #00a4dc;
  --premiere: #aa5cc3;
  --unmonitored: #777777;
}

:root {
  --fc-border-color: var(--line);
  --fc-page-bg-color: var(--bg);
  --fc-neutral-bg-color: var(--surface);
  --fc-today-bg-color: var(--today);
  --fc-list-event-hover-bg-color: var(--btn-hover);
  --fc-event-bg-color: transparent;
  --fc-event-border-color: transparent;
  --fc-event-text-color: var(--text);
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  /* Muximux's font stack: the calendar matches the dashboard framing it */
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  padding: 16px 26px 26px;
}

#warn {
  margin-bottom: 10px;
  padding: 6px 12px;
  border-left: 3px solid var(--missing);
  border-radius: 4px;
  background: var(--surface);
  color: var(--missing);
  font-size: 13px;
}

/* Toolbar: a plain row on the page background */
.fc .fc-toolbar.fc-header-toolbar {
  margin: 0 0 14px;
  gap: 10px;
}

.fc .fc-toolbar-chunk {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fc .fc-toolbar-title {
  margin-left: 6px;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}

.fc .fc-button {
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  text-transform: none;
  padding: 6px 12px;
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  box-shadow: none !important;
}

.fc .fc-button:hover {
  background: var(--btn-hover);
  border-color: var(--line);
  color: var(--text);
}

.fc .fc-button:disabled {
  background: var(--btn);
  border-color: var(--line);
  color: var(--muted);
  opacity: 1;
}

.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.fc .fc-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.fc .fc-button-group > .fc-button {
  margin-left: 0;
}

.fc .fc-button-group > .fc-button + .fc-button {
  margin-left: -1px;
}

.fc .fc-back-button,
.fc .fc-forward-button {
  padding: 6px 9px;
}

.fc .fc-toolbar-chunk .fc-button-group,
.fc .fc-toolbar-chunk > .fc-button {
  margin-left: 0 !important;
}

/* Filter and Theme open a menu: a caret says so */
.fc .fc-filter-button::after,
.fc .fc-theme-button::after {
  content: "";
  display: inline-block;
  margin-left: 7px;
  vertical-align: 3px;
  border: 4px solid transparent;
  border-top-color: currentColor;
  border-bottom: 0;
}

body.busy .fc-refresh-button {
  opacity: 0.6;
}

/* Grid */
.fc .fc-scrollgrid {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.fc .fc-col-header-cell {
  background: var(--surface);
  padding: 9px 0;
}

.fc .fc-col-header-cell-cushion {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
}

.fc .fc-daygrid-day-top {
  flex-direction: row;
}

.fc .fc-daygrid-day-number {
  padding: 12px 14px 16px;
  color: var(--accent);
  font-size: 17px;
  text-decoration: none;
}

.fc .fc-day-other .fc-daygrid-day-top {
  opacity: 0.55;
}

.fc .fc-daygrid-day-frame {
  min-height: 120px;
}

/* Events: no box, three lines. Sizes scale with --ev-scale, set from
   config.yaml fontScale (1 = the Organizr sizes). */
:root {
  --ev-scale: 1;
}

.fc .fc-daygrid-event,
.fc .fc-daygrid-block-event {
  margin: 0 6px calc(14px * var(--ev-scale)) 10px !important;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 4px;
  white-space: nowrap;
}

.fc .fc-daygrid-event:hover {
  background: var(--btn-hover);
}

.fc .fc-event:focus::after,
.fc .fc-event-selected::after {
  display: none;
}

.ev-inner {
  overflow: hidden;
  line-height: 1.25;
  cursor: pointer;
}

.ev-meta {
  display: flex;
  align-items: center;
  gap: calc(5px * var(--ev-scale));
  height: calc(22px * var(--ev-scale));
}

.ev-meta svg {
  width: calc(17px * var(--ev-scale));
  height: calc(17px * var(--ev-scale));
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ev-time {
  font-size: calc(17px * var(--ev-scale));
  font-weight: 600;
}

.ev-title {
  overflow: hidden;
  color: var(--text);
  font-size: calc(16.5px * var(--ev-scale));
  font-weight: 500;
  line-height: calc(22px * var(--ev-scale));
}

.ev-sub {
  overflow: hidden;
  color: var(--text-dim);
  font-size: calc(13.5px * var(--ev-scale));
  font-weight: 500;
  line-height: calc(20px * var(--ev-scale));
}

.ev-downloaded .ev-meta { color: var(--downloaded); }
.ev-missing .ev-meta { color: var(--missing); }
.ev-upcoming .ev-meta { color: var(--upcoming); }
.ev-unmonitored .ev-meta,
.ev-unmonitored .ev-title,
.ev-unmonitored .ev-sub { color: var(--unmonitored); }

/* Upcoming E01 (series or season premiere): flashes once on load like
   Organizr's "animated flash" */
.ev-upcoming.ev-premiere .ev-meta {
  color: var(--premiere);
}

body:not(.settled) .ev-upcoming.ev-premiere .ev-meta {
  animation: flash 1s both;
}

@keyframes flash {
  0%, 50%, 100% { opacity: 1; }
  25%, 75% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  body:not(.settled) .ev-upcoming.ev-premiere .ev-meta {
    animation: none;
  }
}

/* Now line (app.js updateNowLine): the current time, then a line, between
   today's last started event and the first upcoming one. */
.fc-daygrid-event-harness.now-before::before,
.fc-daygrid-event-harness.now-after::after {
  content: attr(data-now);
  display: block;
  margin: 0 6px calc(12px * var(--ev-scale)) 10px;
  color: var(--accent);
  font-size: calc(11.5px * var(--ev-scale));
  font-weight: 600;
  line-height: calc(14px * var(--ev-scale));
  background: linear-gradient(var(--accent), var(--accent)) no-repeat right center /
    calc(100% - 3.4em) 2px;
}

.fc-daygrid-event-harness.now-after::after {
  margin-top: calc(-2px * var(--ev-scale));
}

.fc-list-event.now-before > td {
  box-shadow: inset 0 2px 0 var(--accent);
}

.fc-list-event.now-after > td {
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* List view: icon, title and subtitle on one line */
.fc .fc-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.fc .fc-list-day-cushion {
  background: var(--surface);
  color: var(--text);
}

.fc .fc-list-day-text,
.fc .fc-list-day-side-text {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.fc .fc-list-event-dot {
  display: none;
}

.fc-list-event .ev-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fc-list-event .ev-body {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.fc-list-event.ev-downloaded .fc-list-event-time { color: var(--downloaded); }
.fc-list-event.ev-missing .fc-list-event-time { color: var(--missing); }
.fc-list-event.ev-upcoming .fc-list-event-time { color: var(--upcoming); }
.fc-list-event.ev-upcoming.ev-premiere .fc-list-event-time { color: var(--premiere); }
.fc-list-event.ev-unmonitored .fc-list-event-time { color: var(--unmonitored); }

.fc .fc-list-empty {
  background: var(--bg);
}

/* Drop-down menus (Filter, Theme) */
.menu {
  position: absolute;
  z-index: 10;
  min-width: 220px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  padding: 6px 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  font-size: 14.5px;
  color: var(--text);
}

.menu-head {
  padding: 8px 14px 4px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.menu-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  box-sizing: border-box;
  padding: 6px 14px;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.menu-row:hover,
.menu-row:focus-visible {
  background: var(--btn-hover);
  outline: none;
}

.menu-row input {
  accent-color: var(--accent);
}

.menu-row[aria-checked="true"] {
  color: var(--accent);
  font-weight: 600;
}

.menu-row .note {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.menu-row .dot::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 7px;
  border-radius: 50%;
  background: currentColor;
}

.menu-row .dot { color: var(--text); }
.menu-row .dot.ev-downloaded::before { background: var(--downloaded); }
.menu-row .dot.ev-missing::before { background: var(--missing); }
.menu-row .dot.ev-upcoming::before { background: var(--upcoming); }
.menu-row .dot.ev-unmonitored::before { background: var(--unmonitored); }

/* Dark / Light / System */
.segmented {
  display: flex;
  margin: 4px 14px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.segmented button {
  flex: 1;
  padding: 5px 8px;
  border: none;
  background: var(--btn);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}

.segmented button + button {
  border-left: 1px solid var(--line);
}

.segmented button:hover {
  background: var(--btn-hover);
}

.segmented button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

/* Theme swatch: the theme's background with its status colours */
.swatch {
  display: inline-flex;
  flex: none;
  gap: 3px;
  padding: 4px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
}

.swatch i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.swatch i:nth-child(1) { background: var(--downloaded); }
.swatch i:nth-child(2) { background: var(--missing); }
.swatch i:nth-child(3) { background: var(--upcoming); }
.swatch i:nth-child(4) { background: var(--premiere); }

@media (max-width: 760px) {
  body {
    padding: 10px 16px 16px;
  }
  .fc .fc-toolbar.fc-header-toolbar {
    flex-wrap: wrap;
  }
  .fc .fc-button {
    font-size: 13.5px;
    padding: 5px 8px;
  }
  .fc .fc-toolbar-title {
    font-size: 18px;
  }
}
