/*
 * OPLEX — custom drop-down date picker styles.
 *
 * Companion to frontend/shared/js/oplexDatePicker.js. Two themes:
 *   - dark (default) — matches admin-standalone tokens
 *   - light          — opt-in via [data-theme="light"] on a parent element
 *
 * The native <input type="date"> stays in the DOM but is visually clipped
 * (not display:none, so it still ships its value with the form).
 */

/* ---------- Trigger wrap ---------- */

.oplex-date-wrap {
  position: relative;
  display: inline-flex;
  width: 100%;
  align-items: stretch;
}

.oplex-date-input--enhanced {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  pointer-events: none !important;
}

.oplex-date-trigger {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(255,255,255,0.10));
  background: var(--card-bg, #1e1e1e);
  color: var(--text-primary, #e5e7eb);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}

.oplex-date-trigger:hover {
  border-color: var(--border-hover, rgba(255,255,255,0.18));
  background: rgba(255, 255, 255, 0.02);
}

.oplex-date-trigger:focus-visible {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.oplex-date-trigger__value {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.oplex-date-trigger__value.is-empty::before {
  content: attr(data-empty);
  color: var(--text-muted, #6b7280);
  font-weight: 400;
}

.oplex-date-trigger svg {
  stroke: var(--text-secondary, #9ca3af);
  flex-shrink: 0;
}

/* ---------- Popup ---------- */

.oplex-date-popup {
  position: absolute;
  z-index: 9999;
  width: 320px;
  background: #1c1c1c;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 12px;
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.55),
    0 4px 12px rgba(0, 0, 0, 0.30);
  padding: 14px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  color: #e5e7eb;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}

.oplex-date-popup.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.oplex-date-popup__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 8px;
}

.oplex-date-popup__title {
  flex: 1;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: #f3f4f6;
  text-transform: capitalize;
  letter-spacing: -0.01em;
}

.oplex-date-popup__title span {
  font-weight: 500;
  color: #9ca3af;
  margin-left: 6px;
}

.oplex-date-nav {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  color: #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms, border-color 120ms;
}

.oplex-date-nav:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.16);
}

/* ---------- Weekday header row ---------- */

.oplex-date-popup__weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 6px;
}

.oplex-date-popup__wd {
  text-align: center;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b7280;
  padding: 6px 0;
}

.oplex-date-popup__wd.is-weekend {
  color: #ef4444;
}

/* ---------- Day grid ---------- */

.oplex-date-popup__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.oplex-date-cell {
  position: relative;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #e5e7eb;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 100ms, border-color 100ms, color 100ms;
  padding: 0;
}

.oplex-date-cell:hover {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.30);
}

.oplex-date-cell.is-other {
  color: #4b5563;
}

.oplex-date-cell.is-weekend {
  color: #f87171;
}

.oplex-date-cell.is-other.is-weekend {
  color: #7f1d1d;
}

/* Public holiday: gold accent + small dot indicator at bottom-right. */
.oplex-date-cell.is-holiday {
  color: #fbbf24;
}

.oplex-date-cell.is-holiday.is-other {
  color: rgba(251, 191, 36, 0.35);
}

.oplex-date-cell__dot {
  position: absolute;
  right: 5px;
  bottom: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fbbf24;
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.6);
}

.oplex-date-cell.is-other .oplex-date-cell__dot {
  background: rgba(251, 191, 36, 0.45);
  box-shadow: none;
}

/* Today: subtle ring before any selection styling kicks in. */
.oplex-date-cell.is-today {
  border-color: rgba(59, 130, 246, 0.45);
}

/* In-range (between range endpoints): soft band so the operator can
   verify the span before committing. */
.oplex-date-cell.is-in-range {
  background: rgba(59, 130, 246, 0.16);
  color: #c7d2fe;
}

.oplex-date-cell.is-in-range.is-weekend {
  color: #fca5a5;
}

.oplex-date-cell.is-in-range.is-holiday {
  color: #fde68a;
}

/* Selected endpoint: bold filled style — always wins over hover/range. */
.oplex-date-cell.is-selected,
.oplex-date-cell.is-selected:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border-color: #1d4ed8;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.45);
}

.oplex-date-cell.is-selected .oplex-date-cell__dot {
  background: #ffffff;
  box-shadow: none;
}

/* ---------- Footer (quick actions) ---------- */

.oplex-date-popup__footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.oplex-date-quick {
  flex: 1;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: #d1d5db;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms;
}

.oplex-date-quick:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.18);
  color: #f3f4f6;
}
