.cronJobsPage {
  :global {
    .qwenpaw-spark-card-wrapper {
      padding: 0 !important;
    }
    .qwenpaw-table-wrapper
      .qwenpaw-table-container
      .qwenpaw-table-thead
      > tr
      > th {
      background: #f9f8f4 !important;
    }
  }
}

.pageHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  padding: 20px;
  border-bottom: 1px solid #eae9e7;
}

.breadcrumbHeader {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  flex: 1;
}

.breadcrumbParent {
  color: #999;
  font-weight: 400;
}

.breadcrumbSeparator {
  color: #ccc;
  margin: 0 4px;
}

.breadcrumbCurrent {
  color: #333;
  font-weight: 600;
  font-size: 20px;
}

.title {
  font-size: 20px;
  font-weight: 600;
  color: #333;
}

.description {
  color: #999;
  font-size: 14px;
  margin: 0;
  display: none;
}

.tableCard {
  :global(.ant-card-body) {
    padding: 0;
  }
}

.headerActions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.viewToggle {
  display: flex;
  align-items: center;
  gap: 4px;
}

.viewToggleBtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: rgba(20, 20, 19, 0.45);
  cursor: pointer;
  border-radius: 4px;
  font-size: 16px;
  transition: all 0.2s;

  &:hover {
    color: rgba(20, 20, 19, 0.88);
    background: rgba(0, 0, 0, 0.04);
  }

  &.viewToggleBtnActive {
    color: rgba(20, 20, 19, 0.88);
    background: rgba(0, 0, 0, 0.06);
  }
}

.calendarCard {
  :global(.ant-card-body) {
    padding: 0;
  }
}

.calendarHeader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 54px;
  border-bottom: 1px solid #f0f0f0;
}

.calendarTitle {
  min-width: 120px;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: rgba(20, 20, 19, 0.88);
}

.calendarEmptyHint {
  padding: 8px 16px;
  color: rgba(20, 20, 19, 0.45);
  border-bottom: 1px solid #f0f0f0;
  font-size: 12px;
}

.calendarWeekHeader {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid #f0f0f0;
}

.calendarWeekCell {
  padding: 8px;
  text-align: center;
  font-size: 12px;
  color: rgba(20, 20, 19, 0.45);
  border-right: 1px solid #f5f5f5;

  &:last-child {
    border-right: none;
  }
}

.calendarGrid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendarCell {
  min-height: 108px;
  padding: 8px;
  border-right: 1px solid #f5f5f5;
  border-bottom: 1px solid #f5f5f5;
  background: #fff;
}

.calendarCellMuted {
  background: #fafafa;
}

.calendarCellToday {
  box-shadow: inset 0 0 0 1px rgba(24, 144, 255, 0.25);
}

.calendarCellDate {
  font-size: 13px;
  font-weight: 500;
  color: rgba(20, 20, 19, 0.88);
  margin-bottom: 6px;
}

.calendarEvents {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calendarEvent {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
  color: rgba(20, 20, 19, 0.72);

  &:hover {
    color: rgba(20, 20, 19, 0.88);
  }
}

.calendarEventDisabled {
  color: rgba(20, 20, 19, 0.72);

  .calendarEventDot {
    background: #d9d9d9;
  }
}

.calendarEventDot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #52c41a;
  flex-shrink: 0;
}

.calendarEventText {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendarMoreBtn {
  border: none;
  background: transparent;
  color: #1677ff;
  padding: 0;
  font-size: 12px;
  text-align: left;
  cursor: pointer;

  &:hover {
    color: #4096ff;
  }
}

.dayJobList {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.dayJobPopover {
  width: 380px;
}

.dayJobPopoverOverlay {
  :global(.ant-popover-inner) {
    border-radius: 14px;
    padding: 14px 16px;
  }
}

.dayJobPopoverHeader {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.dayJobPopoverDay {
  font-size: 54px;
  line-height: 1;
  font-weight: 600;
  color: #3b65f5;
}

.dayJobPopoverWeek {
  font-size: 28px;
  line-height: 1;
  color: #3b65f5;
  font-weight: 600;
}

.dayJobItem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  background: #fafafa;
  transition: background 0.2s;

  &:hover {
    background: #f0f5ff;
  }
}

.dayJobItemDisabled {
  opacity: 1;

  .dayJobItemTime,
  .dayJobItemName {
    color: rgba(20, 20, 19, 0.88);
  }
}

.dayJobItemTime {
  font-size: 12px;
  color: rgba(20, 20, 19, 0.6);
  min-width: 42px;
}

.dayJobItemName {
  font-size: 13px;
  color: rgba(20, 20, 19, 0.88);
}

.templateModalHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.templateModalDesc {
  color: rgba(20, 20, 19, 0.6);
  font-size: 13px;
}

.templateGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.templateCard {
  border: 1px solid #eaeaea;
  border-radius: 10px;
  padding: 14px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.templateTitle {
  font-size: 14px;
  font-weight: 600;
  color: rgba(20, 20, 19, 0.88);
}

.templateDesc {
  font-size: 12px;
  color: rgba(20, 20, 19, 0.65);
}

.templateMeta {
  font-size: 12px;
  color: rgba(20, 20, 19, 0.45);
}

.templateTags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.templateTag {
  font-size: 11px;
  color: rgba(20, 20, 19, 0.65);
  background: #f2f4f7;
  border-radius: 999px;
  padding: 2px 8px;
}

.templateTagRecommended {
  font-size: 11px;
  color: #1677ff;
  background: #e6f4ff;
  border-radius: 999px;
  padding: 2px 8px;
}

.templateActions {
  margin-top: 4px;
}

.historyList {
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.historyEmpty {
  padding: 20px 0;
  text-align: center;
  color: rgba(20, 20, 19, 0.45);
}

.historyItem {
  border: 1px solid #f0f0f0;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fafafa;
}

.historyItemMain {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.historyItemTime {
  font-size: 13px;
  color: rgba(20, 20, 19, 0.88);
}

.historyItemStatus {
  font-size: 12px;
  font-weight: 500;
}

.historyItemStatusSuccess {
  color: #389e0d;
}

.historyItemStatusError {
  color: #cf1322;
}

.historyItemMeta {
  margin-top: 4px;
  font-size: 12px;
  color: rgba(20, 20, 19, 0.45);
}

.historyItemError {
  margin-top: 6px;
  font-size: 12px;
  color: #cf1322;
  white-space: pre-wrap;
  word-break: break-word;
}

.historyItemErrorCollapsed {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  overflow: hidden;
}

.historyItemErrorToggle {
  margin-top: 6px;
  padding: 0;
  border: none;
  background: transparent;
  color: #1677ff;
  font-size: 12px;
  cursor: pointer;

  &:hover {
    color: #4096ff;
  }
}

.formActions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Status indicator styling */
.statusIndicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.statusDot {
  width: 6px;
  height: 6px;
  border-radius: 50%;

  &.enabled {
    background-color: #52c41a;
  }

  &.disabled {
    background-color: #d9d9d9;
  }
}

/* Table text styles */
.tableText {
  font-size: 12px;
}

.cronText {
  font-size: 12px;
  cursor: help;
}

.codeText {
  font-size: 12px;
}

.codeLink {
  font-size: 12px;
  cursor: help;
  text-decoration: underline dotted;
}

/* Tooltip content */
.tooltipContent {
  position: relative;
}

.tooltipJsonContent {
  max-width: 400px;
  max-height: 300px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 12px;
  font-family: monospace;
  padding-right: 30px;
}

.copyButton {
  position: absolute;
  top: 0;
  right: 0;
  color: #1890ff;
  z-index: 10;
}

/* Form extra text */
.formExtraText {
  font-size: 12px;
  color: #8c8c8c;
}

.formHelperLink {
  color: #1890ff;
}

/* Action column */
.actionColumn {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Mobile card list */
.mobileCardList {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.mobileJobCard {
  border-radius: var(--border-radius, 8px);
  background: #ffffff;
  border: 1px solid #eae8e7;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease-in-out;

  &:hover {
    border-color: #d9d9d9;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  }
}

.mobileJobHeader {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
  gap: 12px;
}

.mobileJobName {
  font-weight: 600;
  font-size: 17px;
  color: rgba(20, 20, 19, 0.88);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
  line-height: 26px;
}

.mobileJobStatus {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: rgba(20, 20, 19, 0.45);
  flex-shrink: 0;
  line-height: 26px;

  &.enabled {
    color: rgba(20, 184, 166, 1);
  }
}

.mobileJobSchedule {
  font-size: 14px;
  color: rgba(20, 20, 19, 0.55);
  margin-bottom: 22px;
  line-height: 22px;
}

.mobileJobActions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #f0f0f0;

  .mobileActionBtn {
    font-size: 13px;
    height: 28px;
    padding: 0 10px;
    color: #666;
    background: transparent;
    border: 1px solid #d9d9d9;
    border-radius: 7px;

    &:hover:not(:disabled) {
      color: #333;
      border-color: #bfbfbf;
    }

    &:disabled {
      color: #d9d9d9;
      cursor: not-allowed;
    }
  }

  .mobileMoreBtn {
    font-size: 13px;
    width: 28px;
    height: 28px;
    color: #666;
    background: transparent;
    border: 1px solid #d9d9d9;
    border-radius: 7px;

    &:hover:not(:disabled) {
      color: #333;
      border-color: #bfbfbf;
      background: rgba(0, 0, 0, 0.04);
    }
  }
}

@media (max-width: 768px) {
  .cronJobsPage {
    padding: 0 16px 16px;
  }

  .headerActions {
    gap: 6px;
    flex-wrap: wrap;

    :global(.ant-select) {
      flex: 1;
      min-width: 120px;
      max-width: 150px;
    }

    :global(.ant-btn) {
      flex-shrink: 0;
    }
  }

  .viewToggleBtn {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  .cronJobsPage {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .tableCard,
  .calendarCard {
    flex: 1;
    overflow: hidden;

    :global(.ant-card-body) {
      height: 100%;
    }
  }

  .calendarCard {
    overflow: auto;
  }
}

/* ─── Dark mode ─────────────────────────────────────────────────────────────── */
:global(.dark-mode) {
  .pageHeader {
    border-bottom-color: rgba(255, 255, 255, 0.12);
  }

  /* Override the light-mode table header background */
  .cronJobsPage {
    :global {
      .qwenpaw-table-wrapper
        .qwenpaw-table-container
        .qwenpaw-table-thead
        > tr
        > th {
        background: #2a2a2a !important;
      }
    }
  }

  .breadcrumbParent {
    color: rgba(255, 255, 255, 0.35);
  }

  .breadcrumbSeparator {
    color: rgba(255, 255, 255, 0.2);
  }

  .breadcrumbCurrent {
    color: rgba(255, 255, 255, 0.85);
  }

  .title {
    color: rgba(255, 255, 255, 0.85);
  }

  .description {
    color: rgba(255, 255, 255, 0.35);
  }

  .statusDot {
    &.enabled {
      background-color: #73d13d;
    }

    &.disabled {
      background-color: #5a5a5a;
    }
  }

  /* Form extra text */
  .formExtraText {
    color: rgba(255, 255, 255, 0.45);
  }

  .formHelperLink {
    color: #69b1ff !important;
  }

  .viewToggleBtn {
    color: rgba(255, 255, 255, 0.45);

    &:hover {
      color: rgba(255, 255, 255, 0.85);
      background: rgba(255, 255, 255, 0.08);
    }

    &.viewToggleBtnActive {
      color: rgba(255, 255, 255, 0.85);
      background: rgba(255, 255, 255, 0.12);
    }
  }

  .calendarHeader,
  .calendarEmptyHint,
  .calendarWeekHeader {
    border-bottom-color: rgba(255, 255, 255, 0.12);
  }

  .calendarWeekHeader {
    border-bottom-color: rgba(255, 255, 255, 0.12);
  }

  .calendarTitle,
  .calendarCellDate {
    color: rgba(255, 255, 255, 0.85);
  }

  .calendarWeekCell,
  .calendarEmptyHint {
    color: rgba(255, 255, 255, 0.45);
  }

  .calendarCell {
    background: #1f1f1f;
    border-right-color: rgba(255, 255, 255, 0.08);
    border-bottom-color: rgba(255, 255, 255, 0.08);
  }

  .calendarCellMuted {
    background: #181818;
  }

  .calendarCellToday {
    box-shadow: inset 0 0 0 1px rgba(105, 177, 255, 0.45);
  }

  .calendarEvent {
    color: rgba(255, 255, 255, 0.75);

    &:hover {
      color: rgba(255, 255, 255, 0.92);
    }
  }

  .calendarEventDisabled {
    color: rgba(255, 255, 255, 0.75);

    .calendarEventDot {
      background: #6b7280;
    }
  }

  .calendarEventDot {
    background: #73d13d;
  }

  .calendarMoreBtn {
    color: #69b1ff;

    &:hover {
      color: #91caff;
    }
  }

  .dayJobItem {
    background: #262626;

    &:hover {
      background: #303030;
    }
  }

  .dayJobItemTime {
    color: rgba(255, 255, 255, 0.45);
  }

  .dayJobItemName {
    color: rgba(255, 255, 255, 0.88);
  }

  .historyEmpty,
  .historyItemMeta {
    color: rgba(255, 255, 255, 0.45);
  }

  .historyItem {
    background: #262626;
    border-color: rgba(255, 255, 255, 0.12);
  }

  .historyItemTime {
    color: rgba(255, 255, 255, 0.88);
  }

  .historyItemStatusSuccess {
    color: #95de64;
  }

  .historyItemStatusError,
  .historyItemError {
    color: #ff7875;
  }

  .templateModalDesc,
  .templateDesc,
  .templateMeta,
  .templateTag {
    color: rgba(255, 255, 255, 0.6);
  }

  .templateCard {
    background: #262626;
    border-color: rgba(255, 255, 255, 0.12);
  }

  .templateTitle {
    color: rgba(255, 255, 255, 0.88);
  }

  .templateTag {
    background: #303030;
  }

  .templateTagRecommended {
    color: #69b1ff;
    background: rgba(105, 177, 255, 0.16);
  }

  .historyItemErrorToggle {
    color: #69b1ff;

    &:hover {
      color: #91caff;
    }
  }

  .dayJobPopoverOverlay {
    :global(.ant-popover-inner) {
      background: #1f1f1f;
    }
  }

  .dayJobPopoverDay,
  .dayJobPopoverWeek {
    color: #7ea5ff;
  }

  .mobileJobCard {
    background: #2d2d2d;
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);

    &:hover {
      border-color: rgba(255, 255, 255, 0.2);
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    }
  }

  .mobileJobName {
    color: rgba(255, 255, 255, 0.85);
  }

  .mobileJobStatus {
    color: rgba(255, 255, 255, 0.45);

    &.enabled {
      color: rgba(20, 184, 166, 1);
    }
  }

  .mobileJobSchedule {
    color: rgba(255, 255, 255, 0.45);
  }

  .mobileJobActions {
    border-top-color: rgba(255, 255, 255, 0.08);

    .mobileActionBtn {
      color: rgba(255, 255, 255, 0.65);
      background: transparent;
      border-color: rgba(255, 255, 255, 0.2);

      &:hover:not(:disabled) {
        color: rgba(255, 255, 255, 0.85);
        border-color: rgba(255, 255, 255, 0.35);
      }

      &:disabled {
        color: rgba(255, 255, 255, 0.25);
        border-color: rgba(255, 255, 255, 0.1);
      }
    }

    .mobileMoreBtn {
      color: rgba(255, 255, 255, 0.65);
      background: transparent;
      border-color: rgba(255, 255, 255, 0.2);

      &:hover:not(:disabled) {
        color: rgba(255, 255, 255, 0.85);
        border-color: rgba(255, 255, 255, 0.35);
        background: rgba(255, 255, 255, 0.08);
      }
    }
  }
}
