/*!
 * hcg-date-picker - vanilla JS date, time, datetime, and range picker
 * Version: 1.0.0
 * Default styles for the date picker panel and calendar grid.
 * Override CSS variables (or use .hcg-date-picker-panel-dark) to theme light/dark.
 * License: MIT
 */

.hcg-date-picker {
  box-sizing: border-box;
}

.hcg-date-picker-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.hcg-date-picker-panel {
  /* Theme hooks: override these for light/dark or custom palettes. */
  --hcg-dp-bg: #fff;
  --hcg-dp-border: #e5e7eb;
  --hcg-dp-border-soft: #f3f4f6;
  --hcg-dp-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
  --hcg-dp-text: #111827;
  --hcg-dp-text-day: #1f2937;
  --hcg-dp-text-muted: #6b7280;
  --hcg-dp-weekday: #9ca3af;
  --hcg-dp-sunday: #ef4444;
  --hcg-dp-sunday-hover-bg: #fef2f2;
  --hcg-dp-sunday-hover: #dc2626;
  --hcg-dp-sunday-disabled: #fca5a5;
  --hcg-dp-surface: #f9fafb;
  --hcg-dp-hover-bg: #eef2ff;
  --hcg-dp-hover-border: #c7d2fe;
  --hcg-dp-hover-text: #4338ca;
  --hcg-dp-day-hover-text: #3730a3;
  --hcg-dp-accent: #4f46e5;
  --hcg-dp-accent-hover: #4338ca;
  --hcg-dp-accent-text: #fff;
  --hcg-dp-accent-muted: #e0e7ff;
  --hcg-dp-accent-soft: #a5b4fc;
  --hcg-dp-accent-focus: #6366f1;
  --hcg-dp-accent-focus-strong: #312e81;
  --hcg-dp-focus-ring: #fff;
  --hcg-dp-disabled: #d1d5db;
  --hcg-dp-danger-hover-bg: #fef2f2;
  --hcg-dp-danger-hover-border: #fecaca;
  --hcg-dp-danger-hover-text: #b91c1c;
  --hcg-dp-radius: 12px;
  --hcg-dp-radius-sm: 8px;
  --hcg-dp-z: 9999;
  --hcg-dp-font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  --hcg-dp-font-size: 14px;

  position: absolute;
  z-index: var(--hcg-dp-z);
  box-sizing: border-box;
  width: 280px;
  padding: 12px;
  background: var(--hcg-dp-bg);
  border: 1px solid var(--hcg-dp-border);
  border-radius: var(--hcg-dp-radius);
  box-shadow: var(--hcg-dp-shadow);
  font-family: var(--hcg-dp-font-family);
  font-size: var(--hcg-dp-font-size);
  color: var(--hcg-dp-text);
  user-select: none;
}

/* Built-in dark theme: theme: 'dark' or add .hcg-date-picker-panel-dark */
.hcg-date-picker-panel-dark {
  --hcg-dp-bg: #111827;
  --hcg-dp-border: #374151;
  --hcg-dp-border-soft: #1f2937;
  --hcg-dp-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  --hcg-dp-text: #f3f4f6;
  --hcg-dp-text-day: #e5e7eb;
  --hcg-dp-text-muted: #9ca3af;
  --hcg-dp-weekday: #6b7280;
  --hcg-dp-sunday: #f87171;
  --hcg-dp-sunday-hover-bg: #7f1d1d;
  --hcg-dp-sunday-hover: #fca5a5;
  --hcg-dp-sunday-disabled: #991b1b;
  --hcg-dp-surface: #1f2937;
  --hcg-dp-hover-bg: #312e81;
  --hcg-dp-hover-border: #4f46e5;
  --hcg-dp-hover-text: #c7d2fe;
  --hcg-dp-day-hover-text: #c7d2fe;
  --hcg-dp-accent: #6366f1;
  --hcg-dp-accent-hover: #818cf8;
  --hcg-dp-accent-text: #fff;
  --hcg-dp-accent-muted: #312e81;
  --hcg-dp-accent-soft: #818cf8;
  --hcg-dp-accent-focus: #818cf8;
  --hcg-dp-accent-focus-strong: #a5b4fc;
  --hcg-dp-focus-ring: #111827;
  --hcg-dp-disabled: #4b5563;
  --hcg-dp-danger-hover-bg: #7f1d1d;
  --hcg-dp-danger-hover-border: #991b1b;
  --hcg-dp-danger-hover-text: #fecaca;
}

.hcg-date-picker-panel-range {
  width: max-content;
  max-width: calc(100vw - 24px);
}

.hcg-date-picker-panel-has-events {
  width: 300px;
}

.hcg-date-picker-panel-range.hcg-date-picker-panel-has-events {
  width: max-content;
}

.hcg-date-picker-dual {
  display: grid;
  grid-template-columns: 252px 252px;
  column-gap: 20px;
  row-gap: 8px;
  width: max-content;
}

.hcg-date-picker-panel-has-events .hcg-date-picker-dual {
  grid-template-columns: 272px 272px;
}

.hcg-date-picker-range-hint {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--hcg-dp-text-muted);
}

.hcg-date-picker-dual-header {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 32px 1fr 1fr 32px;
  align-items: center;
  column-gap: 8px;
}

.hcg-date-picker-dual-titles {
  grid-column: 2 / 4;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 20px;
}

.hcg-date-picker-dual-header > .hcg-date-picker-nav-prev {
  grid-column: 1;
}

.hcg-date-picker-dual-header > .hcg-date-picker-nav-next {
  grid-column: 4;
}

.hcg-date-picker-month-block {
  width: 252px;
  min-width: 0;
}

.hcg-date-picker-panel-has-events .hcg-date-picker-month-block {
  width: 272px;
}

@media (max-width: 600px) {
  .hcg-date-picker-panel-range {
    width: 280px;
    max-width: calc(100vw - 24px);
  }

  .hcg-date-picker-panel-has-events {
    width: 300px;
    max-width: calc(100vw - 24px);
  }

  .hcg-date-picker-panel-range.hcg-date-picker-panel-has-events {
    width: 300px;
  }

  .hcg-date-picker-dual {
    grid-template-columns: 1fr;
    width: 100%;
    column-gap: 0;
    row-gap: 12px;
  }

  .hcg-date-picker-panel-has-events .hcg-date-picker-dual {
    grid-template-columns: 1fr;
  }

  .hcg-date-picker-dual-header {
    grid-template-columns: 32px 1fr 32px;
  }

  .hcg-date-picker-dual-titles {
    grid-column: 2;
    grid-template-columns: 1fr;
    row-gap: 4px;
  }

  .hcg-date-picker-dual-header > .hcg-date-picker-nav-next {
    grid-column: 3;
  }

  .hcg-date-picker-month-block,
  .hcg-date-picker-panel-has-events .hcg-date-picker-month-block {
    width: 100%;
  }
}

.hcg-date-picker-panel[hidden] {
  display: none !important;
}

.hcg-date-picker-panel-inline {
  position: relative;
  z-index: 1;
  margin-top: 8px;
  box-shadow: none;
}

.hcg-date-picker-panel-disabled {
  pointer-events: none;
  opacity: 0.65;
}

.hcg-date-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.hcg-date-picker-title {
  flex: 1;
  height: 32px;
  border: 0;
  border-radius: var(--hcg-dp-radius-sm);
  background: transparent;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--hcg-dp-text);
  cursor: pointer;
}

.hcg-date-picker-title:hover:not(:disabled) {
  background: var(--hcg-dp-hover-bg);
  color: var(--hcg-dp-hover-text);
}

.hcg-date-picker-title:disabled {
  cursor: default;
  opacity: 1;
}

.hcg-date-picker-nav {
  width: 32px;
  height: 32px;
  border: 1px solid var(--hcg-dp-border);
  border-radius: var(--hcg-dp-radius-sm);
  background: var(--hcg-dp-surface);
  color: var(--hcg-dp-text-day);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.hcg-date-picker-nav:hover {
  background: var(--hcg-dp-hover-bg);
  border-color: var(--hcg-dp-hover-border);
  color: var(--hcg-dp-hover-text);
}

.hcg-date-picker-weekdays,
.hcg-date-picker-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.hcg-date-picker-weekday {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--hcg-dp-weekday);
  padding: 4px 0 8px;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hcg-date-picker-weekday-sunday {
  color: var(--hcg-dp-sunday);
}

.hcg-date-picker-day {
  height: 34px;
  border: 0;
  border-radius: var(--hcg-dp-radius-sm);
  background: transparent;
  color: var(--hcg-dp-text-day);
  font-size: 0.86rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.hcg-date-picker-panel-has-events .hcg-date-picker-day {
  height: 46px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 2px 1px;
  line-height: 1.1;
  overflow: hidden;
}

.hcg-date-picker-day-num {
  display: block;
  font-size: 0.86rem;
}

.hcg-date-picker-day-event {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 36px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.58rem;
  font-weight: 600;
  color: var(--hcg-dp-text-muted);
  line-height: 1.2;
  text-align: center;
}

.hcg-date-picker-day-event-empty {
  visibility: hidden;
}

.hcg-date-picker-day:hover:not(:disabled):not(.hcg-date-picker-day-selected):not(.hcg-date-picker-day-range-start):not(.hcg-date-picker-day-range-end) {
  background: var(--hcg-dp-hover-bg);
  color: var(--hcg-dp-day-hover-text);
}

.hcg-date-picker-day:hover:not(:disabled):not(.hcg-date-picker-day-selected):not(.hcg-date-picker-day-range-start):not(.hcg-date-picker-day-range-end) .hcg-date-picker-day-event {
  color: var(--hcg-dp-accent-focus);
}

.hcg-date-picker-day-sunday {
  color: var(--hcg-dp-sunday);
}

.hcg-date-picker-day-sunday:hover:not(:disabled):not(.hcg-date-picker-day-selected):not(.hcg-date-picker-day-range-start):not(.hcg-date-picker-day-range-end) {
  background: var(--hcg-dp-sunday-hover-bg);
  color: var(--hcg-dp-sunday-hover);
}

.hcg-date-picker-day:focus,
.hcg-date-picker-day-focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--hcg-dp-focus-ring), 0 0 0 4px var(--hcg-dp-accent-focus);
  z-index: 1;
  position: relative;
}

.hcg-date-picker-day-selected:focus,
.hcg-date-picker-day-selected.hcg-date-picker-day-focus,
.hcg-date-picker-day-range-start:focus,
.hcg-date-picker-day-range-end:focus {
  box-shadow: 0 0 0 2px var(--hcg-dp-focus-ring), 0 0 0 4px var(--hcg-dp-accent-focus-strong);
}

.hcg-date-picker-day-empty {
  visibility: hidden;
  pointer-events: none;
}

.hcg-date-picker-day-today {
  box-shadow: inset 0 0 0 1px var(--hcg-dp-accent-soft);
  font-weight: 700;
}

.hcg-date-picker-day-selected,
.hcg-date-picker-day-range-start,
.hcg-date-picker-day-range-end {
  background: var(--hcg-dp-accent);
  color: var(--hcg-dp-accent-text);
  font-weight: 700;
}

.hcg-date-picker-day-selected .hcg-date-picker-day-event,
.hcg-date-picker-day-range-start .hcg-date-picker-day-event,
.hcg-date-picker-day-range-end .hcg-date-picker-day-event {
  color: var(--hcg-dp-accent-muted);
}

.hcg-date-picker-day-selected:hover:not(:disabled),
.hcg-date-picker-day-range-start:hover:not(:disabled),
.hcg-date-picker-day-range-end:hover:not(:disabled) {
  background: var(--hcg-dp-accent-hover);
  color: var(--hcg-dp-accent-text);
}

.hcg-date-picker-day-in-range {
  background: var(--hcg-dp-accent-muted);
  color: var(--hcg-dp-day-hover-text);
  border-radius: 0;
}

.hcg-date-picker-day-in-range .hcg-date-picker-day-event {
  color: var(--hcg-dp-accent-focus);
}

.hcg-date-picker-day-in-range.hcg-date-picker-day-sunday {
  color: var(--hcg-dp-sunday-hover);
}

.hcg-date-picker-day-disabled,
.hcg-date-picker-day:disabled {
  color: var(--hcg-dp-disabled);
  cursor: not-allowed;
  background: transparent;
}

.hcg-date-picker-day-disabled .hcg-date-picker-day-event,
.hcg-date-picker-day:disabled .hcg-date-picker-day-event {
  color: var(--hcg-dp-disabled);
}

.hcg-date-picker-day-disabled.hcg-date-picker-day-sunday,
.hcg-date-picker-day-sunday:disabled {
  color: var(--hcg-dp-sunday-disabled);
}

.hcg-date-picker-months,
.hcg-date-picker-years {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 4px;
}

.hcg-date-picker-month,
.hcg-date-picker-year {
  height: 42px;
  border: 0;
  border-radius: var(--hcg-dp-radius-sm);
  background: transparent;
  color: var(--hcg-dp-text-day);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.hcg-date-picker-month:hover,
.hcg-date-picker-year:hover {
  background: var(--hcg-dp-hover-bg);
  color: var(--hcg-dp-hover-text);
}

.hcg-date-picker-month-today,
.hcg-date-picker-year-today {
  box-shadow: inset 0 0 0 1px var(--hcg-dp-accent-soft);
}

.hcg-date-picker-month-selected,
.hcg-date-picker-year-selected {
  background: var(--hcg-dp-accent);
  color: var(--hcg-dp-accent-text);
}

.hcg-date-picker-month-selected:hover,
.hcg-date-picker-year-selected:hover {
  background: var(--hcg-dp-accent-hover);
  color: var(--hcg-dp-accent-text);
}

.hcg-date-picker-month-disabled,
.hcg-date-picker-year-disabled,
.hcg-date-picker-month:disabled,
.hcg-date-picker-year:disabled {
  color: var(--hcg-dp-disabled);
  cursor: not-allowed;
  background: transparent;
}

.hcg-date-picker-time {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--hcg-dp-border-soft);
}

.hcg-date-picker-hour,
.hcg-date-picker-minute,
.hcg-date-picker-meridiem {
  min-width: 64px;
  height: 34px;
  border: 1px solid var(--hcg-dp-border);
  border-radius: var(--hcg-dp-radius-sm);
  background: var(--hcg-dp-bg);
  color: var(--hcg-dp-text);
  font-size: 0.86rem;
  padding: 0 8px;
}

.hcg-date-picker-time-sep {
  font-weight: 700;
  color: var(--hcg-dp-text-muted);
}

.hcg-date-picker-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--hcg-dp-border-soft);
}

.hcg-date-picker-btn {
  flex: 1;
  height: 32px;
  border: 1px solid var(--hcg-dp-border);
  border-radius: var(--hcg-dp-radius-sm);
  background: var(--hcg-dp-surface);
  color: var(--hcg-dp-text-day);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.hcg-date-picker-btn:hover {
  background: var(--hcg-dp-hover-bg);
  border-color: var(--hcg-dp-hover-border);
  color: var(--hcg-dp-hover-text);
}

.hcg-date-picker-btn-clear:hover {
  background: var(--hcg-dp-danger-hover-bg);
  border-color: var(--hcg-dp-danger-hover-border);
  color: var(--hcg-dp-danger-hover-text);
}
