/* ===================================================================
   Cron Page — Glassmorphism cards with collapsible progress
   All classes prefixed cr-
   =================================================================== */

/* --- Page Layout --- */
.cr-page {
  max-width: 1200px;
  margin: 0 auto;
}

/* --- Create Form --- */
.cr-form-card {
  position: relative;
  background: rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-xl);
  padding: 24px;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2),
              inset 0 1px 0 rgba(255, 255, 255, 0.04);
  animation: agSlideUp 0.3s ease-out;
}

.cr-form-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: linear-gradient(90deg, var(--color-accent) 0%, #38bdf8 50%, rgba(0, 112, 243, 0.3) 100%);
}

.cr-form-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-strong);
  margin: 0 0 1rem;
  letter-spacing: -0.01em;
}

.cr-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.cr-form-full {
  grid-column: 1 / -1;
}

.cr-form-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cr-form-hint {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--color-muted);
  flex-shrink: 0;
}

.cr-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.cr-error {
  padding: 10px 14px;
  background: var(--color-danger-subtle);
  border: 1px solid rgba(255, 68, 68, 0.25);
  border-radius: var(--radius-md);
  color: var(--color-danger);
  font-size: 0.82rem;
  margin-bottom: 1rem;
}

/* --- Job Cards Grid --- */
.cr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 12px;
}

/* --- Job Card --- */
.cr-card {
  position: relative;
  background: rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-xl);
  padding: 0;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2),
              inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: transform 0.2s ease-out,
              box-shadow 0.2s ease-out,
              border-color 0.2s ease-out;
  animation: agCardIn 0.4s ease-out backwards;
}

.cr-card:nth-child(1) { animation-delay: 0ms; }
.cr-card:nth-child(2) { animation-delay: 50ms; }
.cr-card:nth-child(3) { animation-delay: 100ms; }
.cr-card:nth-child(4) { animation-delay: 150ms; }
.cr-card:nth-child(5) { animation-delay: 200ms; }
.cr-card:nth-child(6) { animation-delay: 250ms; }

/* Top accent bar */
.cr-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  z-index: 1;
}

.cr-card.cr-enabled::before {
  background: linear-gradient(90deg, #2dd4bf 0%, #5eead4 50%, rgba(45, 212, 191, 0.3) 100%);
}

.cr-card.cr-disabled::before {
  background: linear-gradient(90deg, var(--color-muted) 0%, var(--color-muted) 50%, rgba(136, 136, 136, 0.3) 100%);
}

.cr-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3),
              inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.cr-card.cr-disabled {
  opacity: 0.55;
}

/* --- Card Header --- */
.cr-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 0 20px;
  gap: 12px;
}

.cr-card-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.cr-card-name {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-strong);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-align: left;
  transition: color 0.15s;
}

.cr-card-name:hover {
  color: var(--color-accent);
}

.cr-card-badges {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.cr-badge-oneshot {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--color-accent-subtle);
  color: var(--color-accent);
}

/* --- Card Body --- */
.cr-card-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 16px 20px 0 20px;
}

.cr-detail {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
}

.cr-detail-label {
  font-family: var(--font-heading);
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
}

.cr-detail-value {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-foreground);
}

.cr-message-preview {
  grid-column: 1 / -1;
}

.cr-message-text {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--color-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

/* --- Card Actions --- */
.cr-card-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  padding: 16px 20px 20px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin-top: 16px;
}

/* --- Live Progress Panel (collapsible) --- */
.cr-progress {
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.15);
}

.cr-progress-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-foreground);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-align: left;
  transition: background 0.15s;
}

.cr-progress-toggle:hover {
  background: rgba(255, 255, 255, 0.03);
}

.cr-progress-toggle-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.cr-progress-label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-accent);
  font-size: 0.65rem;
}

.cr-progress-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  font-size: 0.62rem;
  font-weight: 700;
}

.cr-progress-preview {
  flex: 1;
  min-width: 0;
  color: var(--color-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.68rem;
}

.cr-progress-chevron {
  flex-shrink: 0;
  color: var(--color-faint);
  transition: transform 0.2s;
  font-size: 0.8rem;
}

.cr-progress-chevron[data-expanded="true"] {
  transform: rotate(180deg);
}

.cr-progress-body {
  max-height: 160px;
  overflow-y: auto;
  padding: 4px 12px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.cr-progress-body::-webkit-scrollbar {
  width: 4px;
}

.cr-progress-body::-webkit-scrollbar-track {
  background: transparent;
}

.cr-progress-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
}

.cr-progress-empty {
  padding: 8px 0;
  color: var(--color-faint);
  font-size: 0.72rem;
}

.cr-progress-entry {
  display: flex;
  gap: 6px;
  padding: 2px 0;
  font-size: 0.68rem;
  line-height: 1.5;
}

.cr-progress-time {
  color: var(--color-faint);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.cr-progress-icon {
  color: var(--color-accent);
  flex-shrink: 0;
  width: 10px;
  text-align: center;
}

.cr-progress-type {
  color: var(--color-muted);
  flex-shrink: 0;
  min-width: 36px;
}

.cr-progress-text {
  color: var(--color-foreground);
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

/* --- Expanded Runs Panel --- */
.cr-runs-panel {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding: 16px 20px;
  animation: agFadeIn 0.2s ease-out;
}

.cr-runs-title {
  font-family: var(--font-heading);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  margin-bottom: 10px;
}

.cr-runs-empty {
  font-size: 0.78rem;
  color: var(--color-faint);
  padding: 4px 0;
}

.cr-runs-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}

.cr-run-row {
  display: grid;
  grid-template-columns: 9rem 5.5rem 4rem 1fr;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
}

.cr-run-time {
  font-family: var(--font-mono);
  color: var(--color-muted);
  font-size: 0.68rem;
}

.cr-run-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.cr-run-duration {
  font-family: var(--font-mono);
  color: var(--color-muted);
  text-align: right;
  font-size: 0.68rem;
}

.cr-run-result {
  font-family: var(--font-mono);
  color: var(--color-muted);
  font-size: 0.68rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cr-run-error {
  color: var(--color-danger);
}

/* --- Empty State --- */
.cr-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5rem 1.5rem;
  text-align: center;
  animation: agCardIn 0.4s ease-out backwards;
}

.cr-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-xl);
  background: var(--color-accent-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--color-accent);
  margin-bottom: 1rem;
}

.cr-empty-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-foreground);
  margin-bottom: 0.35rem;
}

.cr-empty-desc {
  font-size: 0.82rem;
  color: var(--color-muted);
  max-width: 320px;
  line-height: 1.6;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .cr-grid {
    grid-template-columns: 1fr;
  }

  .cr-form-grid {
    grid-template-columns: 1fr;
  }

  .cr-card-details {
    grid-template-columns: 1fr;
  }

  .cr-run-row {
    grid-template-columns: 5rem auto 1fr;
  }

  .cr-run-duration {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cr-card {
    animation: none;
  }

  .cr-card:hover {
    transform: none;
  }
}

/* --- Light mode adjustments --- */
html[data-theme="light"] .cr-card {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .cr-card:hover {
  border-color: rgba(0, 0, 0, 0.15);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

html[data-theme="light"] .cr-detail {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .cr-progress {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .cr-form-card {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .cr-run-row {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.06);
}
