/**
 * CronEditor Styles
 * @countermeasure/web-components
 *
 * Visual cron expression builder with tabs, value grids, and preview.
 */

/* ============================================================================
   CONTAINER
   ============================================================================ */
.cmm-cron-editor {
  display: flex;
  flex-direction: column;
  width: 100%;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md);
  background-color: hsl(var(--background));
  overflow: hidden;
}

/* ============================================================================
   TAB BAR
   ============================================================================ */
.cmm-cron-editor__tabs {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  border-bottom: 1px solid hsl(var(--border));
  overflow-x: auto;
  scrollbar-width: none;
}

.cmm-cron-editor__tabs::-webkit-scrollbar {
  display: none;
}

.cmm-cron-editor__tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.875rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
  font-weight: 400;
  white-space: nowrap;
  cursor: pointer;
  transition:
    color var(--transition-fast) ease,
    border-color var(--transition-fast) ease,
    background-color var(--transition-fast) ease;
}

.cmm-cron-editor__tab:hover {
  color: hsl(var(--foreground));
  background-color: hsl(var(--accent) / 0.3);
}

.cmm-cron-editor__tab:focus-visible {
  outline: 2px solid hsl(var(--focus-ring));
  outline-offset: -2px;
}

.cmm-cron-editor__tab--active {
  color: hsl(var(--foreground));
  font-weight: 500;
  border-bottom-color: hsl(var(--primary));
}

.cmm-cron-editor__tab--active:hover {
  background-color: transparent;
}

/* ============================================================================
   BODY (MODE SELECTOR + EDITOR)
   ============================================================================ */
.cmm-cron-editor__body {
  padding: 0.75rem;
}

/* ============================================================================
   MODE SELECTOR
   ============================================================================ */
.cmm-cron-editor__modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 0.75rem;
}

.cmm-cron-editor__mode {
  padding: 0.375rem 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background-color: hsl(var(--background));
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
  cursor: pointer;
  transition:
    color var(--transition-fast) ease,
    background-color var(--transition-fast) ease,
    border-color var(--transition-fast) ease;
}

.cmm-cron-editor__mode:hover {
  color: hsl(var(--foreground));
  border-color: hsl(var(--foreground));
}

.cmm-cron-editor__mode:focus-visible {
  outline: 2px solid hsl(var(--focus-ring));
  outline-offset: 2px;
}

.cmm-cron-editor__mode--active {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}

.cmm-cron-editor__mode--active:hover {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}

/* ============================================================================
   EDITOR AREA
   ============================================================================ */
.cmm-cron-editor__editor {
  min-height: 3rem;
}

.cmm-cron-editor__hint {
  margin: 0;
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
  font-style: italic;
}

/* ============================================================================
   VALUE GRID (SPECIFIC SELECTION)
   ============================================================================ */
.cmm-cron-editor__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.5rem, 1fr));
  gap: 0.25rem;
}

.cmm-cron-editor__grid-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2rem;
  padding: 0 0.25rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-size: 0.75rem;
  cursor: pointer;
  transition:
    color var(--transition-fast) ease,
    background-color var(--transition-fast) ease,
    border-color var(--transition-fast) ease;
}

.cmm-cron-editor__grid-item:hover {
  border-color: hsl(var(--primary));
  background-color: hsl(var(--accent) / 0.5);
}

.cmm-cron-editor__grid-item:focus-visible {
  outline: 2px solid hsl(var(--focus-ring));
  outline-offset: -1px;
}

.cmm-cron-editor__grid-item--active {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}

.cmm-cron-editor__grid-item--active:hover {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

/* ============================================================================
   RANGE / INTERVAL INPUT ROWS
   ============================================================================ */
.cmm-cron-editor__range-row,
.cmm-cron-editor__interval-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.cmm-cron-editor__field-label {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
}

.cmm-cron-editor__field-input {
  width: 4.5rem;
  height: 2rem;
  padding: 0 0.5rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-size: 0.8125rem;
  text-align: center;
  transition: border-color var(--transition-fast) ease;
}

.cmm-cron-editor__field-input:focus {
  outline: 2px solid hsl(var(--focus-ring));
  outline-offset: -1px;
  border-color: hsl(var(--primary));
}

/* Hide number input spinners */
.cmm-cron-editor__field-input::-webkit-inner-spin-button,
.cmm-cron-editor__field-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.cmm-cron-editor__field-input {
  -moz-appearance: textfield;
}

/* ============================================================================
   EXPRESSION OUTPUT
   ============================================================================ */
.cmm-cron-editor__expression {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border-top: 1px solid hsl(var(--border));
  background-color: hsl(var(--muted) / 0.3);
}

.cmm-cron-editor__expression-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
}

.cmm-cron-editor__expression-input {
  flex: 1;
  height: 2rem;
  padding: 0 0.5rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: monospace;
  font-size: 0.875rem;
  letter-spacing: 0.05em;
  transition: border-color var(--transition-fast) ease;
}

.cmm-cron-editor__expression-input:focus {
  outline: 2px solid hsl(var(--focus-ring));
  outline-offset: -1px;
  border-color: hsl(var(--primary));
}

/* ============================================================================
   HUMAN-READABLE PREVIEW
   ============================================================================ */
.cmm-cron-editor__preview {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  font-size: 0.8125rem;
  font-style: italic;
  background-color: hsl(var(--muted) / 0.15);
}

/* ============================================================================
   NEXT RUNS LIST
   ============================================================================ */
.cmm-cron-editor__next-runs {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid hsl(var(--border));
}

.cmm-cron-editor__next-runs-heading {
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  margin-bottom: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cmm-cron-editor__runs-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cmm-cron-editor__run {
  font-size: 0.8125rem;
  color: hsl(var(--foreground));
  padding: 0.25rem 0;
  border-bottom: 1px solid hsl(var(--border) / 0.5);
}

.cmm-cron-editor__run:last-child {
  border-bottom: none;
}

.cmm-cron-editor__no-runs {
  margin: 0;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  font-style: italic;
}
