/* ==========================================================================
   达播工作台 — datetime-picker.css
   三种模式：date(普通日期) | datetime(日期+时间) | range(同日时间范围)
   样式参考：飞书日历组件风格
   ========================================================================== */

.dtp {
  position: relative;
  display: block;
}

/* ---- 触发按钮 ---- */
.dtp-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--color-fg);
  font-size: var(--font-size-base);
  cursor: pointer;
  transition: border-color var(--motion-fast) var(--motion-ease-standard),
    box-shadow var(--motion-fast) var(--motion-ease-standard);
}
.dtp-trigger:hover { border-color: var(--input-focus-border); }
.dtp-trigger:focus-visible { outline: none; border-color: var(--input-focus-border); box-shadow: var(--focus-ring); }
.dtp-trigger__icon { color: var(--color-meta); display: inline-flex; flex-shrink: 0; }
.dtp-trigger__text {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-feature-settings: "tnum", "lnum";
  font-variant-numeric: tabular-nums;
}
.dtp-trigger:not(.is-filled) .dtp-trigger__text { color: var(--color-meta); }
.dtp-trigger__clear { display: none; color: var(--color-meta); flex-shrink: 0; }
.dtp-trigger__clear:hover { color: var(--color-danger); }

/* ---- 弹出面板基础 ---- */
.dtp-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: var(--z-dropdown, 1000);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  animation: dtp-fade-in var(--motion-base) var(--motion-ease-standard);
}
@keyframes dtp-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* hidden 必须优先于 .dtp-panel--datetime/range 的 display:flex，否则面板关不掉 */
.dtp-panel[hidden] { display: none !important; }

/* date 模式：窄面板 */
.dtp-panel--date {
  width: 296px;
}

/* month 模式：月份宫格窄面板 */
.dtp-panel--month {
  width: 296px;
}
.dtp-panel--month .dtp-panel__body {
  display: block;
}

/* datetime / range 模式：宽面板 flex 分栏 */
.dtp-panel--datetime,
.dtp-panel--range {
  display: flex;
  flex-direction: column;
}
.dtp-panel__body {
  display: flex;
}

/* ---- 日历区域 ---- */
.dtp-cal {
  flex-shrink: 0;
  padding: var(--space-3);
}
.dtp-panel--date .dtp-cal { width: 100%; }
.dtp-panel--datetime .dtp-cal,
.dtp-panel--range .dtp-cal { width: 296px; }

.dtp-cal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}
.dtp-cal__title {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-fg);
  border: none;
  background: transparent;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: background var(--motion-fast) var(--motion-ease-standard);
}
.dtp-cal__title:hover { background: var(--color-surface-2); }
.dtp-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-fg-2);
  cursor: pointer;
  transition: background var(--motion-fast) var(--motion-ease-standard);
}
.dtp-nav:hover { background: var(--color-surface-2); color: var(--color-fg); }

.dtp-cal__week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}
.dtp-cal__week span {
  text-align: center;
  font-size: var(--font-size-xs);
  color: var(--color-muted);
  padding: 4px 0;
  user-select: none;
}

.dtp-cal__days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.dtp-day {
  height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-fg);
  font-size: var(--font-size-sm);
  cursor: pointer;
  font-feature-settings: "tnum", "lnum";
  font-variant-numeric: tabular-nums;
  transition: background var(--motion-fast) var(--motion-ease-standard),
    color var(--motion-fast) var(--motion-ease-standard);
}
.dtp-day:hover { background: var(--color-primary-50); }
.dtp-day.is-out { color: var(--color-meta); opacity: 0.4; }
.dtp-day.is-today { color: var(--color-accent-text); font-weight: var(--font-weight-semibold); }
.dtp-day.is-picked { background: var(--color-accent); color: var(--color-accent-on); font-weight: var(--font-weight-medium); }
.dtp-day.is-picked:hover { background: var(--color-accent-hover); }
.dtp-day.is-holiday:not(.is-picked) { color: var(--color-danger); }

/* ---- 月份快速跳转面板 ---- */
.dtp-month-panel {
  padding: var(--space-3);
  width: 100%;
}
.dtp-month-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}
.dtp-month-panel__year {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-fg);
  user-select: none;
}
.dtp-month-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-fg-2);
  cursor: pointer;
  transition: background var(--motion-fast) var(--motion-ease-standard);
}
.dtp-month-nav:hover { background: var(--color-surface-2); color: var(--color-fg); }
.dtp-month-panel__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
}
.dtp-month-item {
  height: 40px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-fg);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: background var(--motion-fast) var(--motion-ease-standard),
    color var(--motion-fast) var(--motion-ease-standard);
}
.dtp-month-item:hover { background: var(--color-primary-50); }
.dtp-month-item.is-active {
  background: var(--color-accent);
  color: var(--color-accent-on);
  font-weight: var(--font-weight-medium);
}
.dtp-month-item.is-active:hover { background: var(--color-accent-hover); }

/* range 模式日期高亮 */
.dtp-day.is-in-range { background: var(--color-primary-50); border-radius: 0; }
.dtp-day.is-range-start {
  background: var(--color-accent);
  color: var(--color-accent-on);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.dtp-day.is-range-end {
  background: var(--color-accent);
  color: var(--color-accent-on);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.dtp-day.is-range-start.is-range-end {
  border-radius: var(--radius-sm);
}

/* ---- 时间列表区域（datetime 模式右侧）---- */
.dtp-times {
  width: 112px;
  border-left: 1px solid var(--color-border-soft);
  display: flex;
  flex-direction: column;
}
/* 时间输入框（时间列表顶部，可直接输入具体时间） */
.dtp-time-input {
  display: block;
  width: 100%;
  height: 28px;
  padding: 0 var(--space-2);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--color-fg);
  font-size: var(--font-size-sm);
  text-align: center;
  flex-shrink: 0;
  font-feature-settings: "tnum", "lnum";
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color var(--motion-fast) var(--motion-ease-standard);
}
.dtp-time-input:focus { border-color: var(--input-focus-border); box-shadow: var(--focus-ring); }
.dtp-time-input:disabled { opacity: 0.4; cursor: not-allowed; }
.dtp-time-input::placeholder { color: var(--color-meta); }
.dtp-times .dtp-time-input { margin: var(--space-2); width: auto; }
.dtp-range-col .dtp-time-input { margin-bottom: var(--space-1); }
.dtp-times__list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-1) 0;
  max-height: 300px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.dtp-times__list::-webkit-scrollbar { width: 4px; }
.dtp-times__list::-webkit-scrollbar-thumb { background: var(--color-gray-400); border-radius: 2px; }
.dtp-times__list::-webkit-scrollbar-track { background: transparent; }

.dtp-time-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 var(--space-2);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-fg);
  font-size: var(--font-size-sm);
  font-feature-settings: "tnum", "lnum";
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  width: 100%;
  transition: background var(--motion-fast) var(--motion-ease-standard);
}
.dtp-time-item:hover { background: var(--color-surface-2); }
.dtp-time-item.is-active {
  background: var(--color-accent);
  color: var(--color-accent-on);
  font-weight: var(--font-weight-medium);
}
.dtp-time-item.is-active:hover { background: var(--color-accent-hover); }
.dtp-time-item.is-disabled {
  color: var(--color-meta);
  opacity: 0.35;
  cursor: not-allowed;
}
.dtp-time-item.is-disabled:hover { background: transparent; }

/* ---- 范围时间面板（range 模式右侧）---- */
.dtp-range-panel {
  width: 224px;
  border-left: 1px solid var(--color-border-soft);
  display: flex;
  flex-direction: column;
  padding: var(--space-3);
  gap: var(--space-2);
}
.dtp-range-tbd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-1) 0;
}
.dtp-range-tbd__label {
  font-size: var(--font-size-sm);
  color: var(--color-fg);
  user-select: none;
}
.dtp-range-cols {
  display: flex;
  gap: var(--space-2);
  flex: 1;
  min-height: 0;
}
.dtp-range-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.dtp-range-col__label {
  font-size: var(--font-size-xs);
  color: var(--color-muted);
  margin-bottom: var(--space-1);
  text-align: center;
  user-select: none;
}
.dtp-range-col__list {
  flex: 1;
  overflow-y: auto;
  max-height: 240px;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.dtp-range-col__list::-webkit-scrollbar { width: 4px; }
.dtp-range-col__list::-webkit-scrollbar-thumb { background: var(--color-gray-400); border-radius: 2px; }
.dtp-range-col__list::-webkit-scrollbar-track { background: transparent; }
.dtp-range-col__list .dtp-time-item { height: 30px; font-size: var(--font-size-xs); }

/* 时间待定：禁用态 */
.dtp-range-cols.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ---- 底部操作栏 ---- */
.dtp-foot {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--color-border-soft);
  background: var(--color-surface);
}
.dtp-foot__btn {
  height: 28px;
  padding: 0 var(--space-3);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: background var(--motion-fast) var(--motion-ease-standard);
  white-space: nowrap;
}
.dtp-foot__today { color: var(--color-accent-text); }
.dtp-foot__today:hover { background: var(--color-primary-50); }
.dtp-foot__clear { color: var(--color-danger); margin-left: auto; }
.dtp-foot__clear:hover { background: var(--color-danger-bg); }
.dtp-foot__save {
  background: var(--color-accent);
  color: var(--color-accent-on);
  font-weight: var(--font-weight-medium);
  padding: 0 var(--space-4);
}
.dtp-foot__save:hover { background: var(--color-accent-hover); }
.dtp-foot__dur {
  font-size: var(--font-size-xs);
  color: var(--color-muted);
  font-feature-settings: "tnum", "lnum";
  font-variant-numeric: tabular-nums;
  margin-left: var(--space-2);
}

/* ---- 响应式：小屏面板右对齐 / 全宽 ---- */
@media (max-width: 520px) {
  .dtp-panel--datetime,
  .dtp-panel--range {
    position: fixed;
    left: 8px;
    right: 8px;
    top: auto;
    bottom: 8px;
    width: auto;
    max-height: 80vh;
  }
  .dtp-panel--datetime .dtp-cal,
  .dtp-panel--range .dtp-cal { width: 100%; border-bottom: 1px solid var(--color-border-soft); }
  .dtp-panel__body { flex-direction: column; }
  .dtp-times { width: 100%; border-left: none; border-top: 1px solid var(--color-border-soft); }
  .dtp-range-panel { width: 100%; border-left: none; border-top: 1px solid var(--color-border-soft); }
  .dtp-times__list { max-height: 160px; }
  .dtp-range-col__list { max-height: 160px; }
}
