/* ============================================
 * popup-free pickers (LINE WebView 等の <select> 不安定環境向け)
 * 通常ブラウザでは何も影響しない (body.popup-free-mode が付いた時だけ activate)
 * ============================================ */

/* === trigger 共通 (カレンダー + 時刻) === */
.pf-cal-wrap,
.pf-time-wrap {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
}

.pf-cal-trigger,
.pf-time-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: #F9FBF2;
  border: 2px solid var(--border, #c5e1c8);
  border-radius: var(--radius-sm, 8px);
  color: var(--text, #1a3a1d);
  font-size: 1rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.pf-cal-trigger:hover,
.pf-time-trigger:hover,
.pf-cal-trigger:focus,
.pf-time-trigger:focus {
  outline: none;
  border-color: var(--primary, #2E7D32);
  background: #f4f9ed;
}

.pf-cal-trigger[aria-expanded="true"],
.pf-time-trigger[aria-expanded="true"] {
  border-color: var(--primary, #2E7D32);
  background: #f4f9ed;
}

.pf-cal-icon,
.pf-time-icon {
  font-size: 1.05rem;
  flex-shrink: 0;
}

.pf-cal-trigger-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 時刻 trigger は 開始/終了 を中央寄せで間隔を空けて表示 */
.pf-time-trigger-text {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-width: 0;
}

.pf-time-part {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.pf-time-part-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted, #888);
}

.pf-time-part-val {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.pf-time-sep {
  color: var(--text-muted, #888);
  flex-shrink: 0;
}

.pf-cal-placeholder {
  color: var(--text-muted, #888);
}

.pf-cal-caret,
.pf-time-caret {
  font-size: 0.8rem;
  color: var(--text-muted, #888);
  flex-shrink: 0;
  transition: transform 0.2s;
}

.pf-cal-trigger[aria-expanded="true"] .pf-cal-caret,
.pf-time-trigger[aria-expanded="true"] .pf-time-caret {
  transform: rotate(180deg);
}

/* === panel 共通 === */
.pf-cal-panel,
.pf-time-panel {
  margin: 8px 0 12px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--border, #c5e1c8);
  border-radius: var(--radius-md, 10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  animation: pf-panel-fade-in 0.15s ease-out;
}

@keyframes pf-panel-fade-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === カレンダー panel === */
.pf-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.pf-cal-nav {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--primary, #2E7D32);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.pf-cal-nav:hover,
.pf-cal-nav:focus {
  outline: none;
  background: #e8f5e9;
  border-color: var(--primary, #2E7D32);
}

.pf-cal-label {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text, #1a3a1d);
  text-align: center;
  flex: 1;
}

.pf-cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
}

.pf-cal-weekcell {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted, #888);
  padding: 4px 0;
}

.pf-cal-weekcell.pf-cal-sun {
  color: #d32f2f;
}

.pf-cal-weekcell.pf-cal-sat {
  color: #1976d2;
}

.pf-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.pf-cal-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text, #1a3a1d);
  padding: 0;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: rgba(46, 125, 50, 0.2);
  transition: background 0.1s, border-color 0.1s;
}

.pf-cal-cell.pf-cal-empty {
  color: #ccc;
  cursor: default;
  pointer-events: none;
}

.pf-cal-cell.pf-cal-sun {
  color: #d32f2f;
}

.pf-cal-cell.pf-cal-sat {
  color: #1976d2;
}

.pf-cal-cell.pf-cal-day:hover,
.pf-cal-cell.pf-cal-day:focus {
  outline: none;
  background: #e8f5e9;
}

.pf-cal-cell.pf-cal-today {
  border-color: var(--primary, #2E7D32);
  font-weight: 700;
}

.pf-cal-cell.pf-cal-selected {
  background: var(--primary, #2E7D32);
  color: #ffffff !important;
  border-color: var(--primary, #2E7D32);
  font-weight: 700;
}

.pf-cal-cell.pf-cal-selected.pf-cal-today {
  /* 選択中かつ今日 — 選択優先 */
  background: var(--primary, #2E7D32);
}

/* === 時刻 panel === */
.pf-time-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  background: #f1f8e9;
  padding: 4px;
  border-radius: 8px;
}

.pf-time-tab {
  flex: 1;
  padding: 10px 8px;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-muted, #888);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.pf-time-tab.pf-time-tab-active {
  background: #ffffff;
  color: var(--primary-dark, #1B5E20);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.pf-time-section-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted, #888);
  margin: 8px 0 4px;
}

.pf-time-hour-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.pf-time-min-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  margin-bottom: 12px;
}

.pf-time-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  font-size: 0.92rem;
  font-weight: 500;
  font-family: inherit;
  background: #F9FBF2;
  border: 1.5px solid var(--border, #c5e1c8);
  border-radius: 6px;
  color: var(--text, #1a3a1d);
  padding: 0;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: rgba(46, 125, 50, 0.2);
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.pf-time-cell:hover,
.pf-time-cell:focus {
  outline: none;
  background: #e8f5e9;
  border-color: var(--primary, #2E7D32);
}

.pf-time-cell.pf-time-selected {
  background: var(--primary, #2E7D32);
  color: #ffffff;
  border-color: var(--primary, #2E7D32);
  font-weight: 700;
}

.pf-time-done {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px;
  background: #f1f8e9;
  border: 1px solid var(--border, #c5e1c8);
  border-radius: 8px;
  color: var(--primary-dark, #1B5E20);
  font-weight: 600;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.pf-time-done:hover,
.pf-time-done:focus {
  outline: none;
  background: #e0f0d5;
}

/* === 汎用 select widget (繰り返し: パターン / 曜日 / 第N週) === */
.pf-select-wrap {
  position: relative;
  width: 100%;
}

.pf-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  background: #F9FBF2;
  border: 2px solid var(--border, #c5e1c8);
  border-radius: var(--radius-sm, 8px);
  color: var(--text, #1a3a1d);
  font-size: 1rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s, background 0.2s;
}

.pf-select-trigger:hover,
.pf-select-trigger:focus,
.pf-select-trigger[aria-expanded="true"] {
  outline: none;
  border-color: var(--primary, #2E7D32);
  background: #f4f9ed;
}

.pf-select-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pf-select-caret {
  font-size: 0.8rem;
  color: var(--text-muted, #888);
  flex-shrink: 0;
  transition: transform 0.2s;
}

.pf-select-trigger[aria-expanded="true"] .pf-select-caret {
  transform: rotate(180deg);
}

.pf-select-panel {
  /* 内容を押し下げず上に重なる overlay 型ドロップダウン (グワッと広がらない) */
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  z-index: 50;
  padding: 6px;
  background: #ffffff;
  border: 1px solid var(--border, #c5e1c8);
  border-radius: var(--radius-md, 10px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
  animation: pf-panel-fade-in 0.12s ease-out;
  max-height: 260px;
  overflow-y: auto;
}

.pf-select-option {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text, #1a3a1d);
  font-size: 1rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}

.pf-select-option:hover,
.pf-select-option:focus {
  outline: none;
  background: #e8f5e9;
}

.pf-select-option.pf-select-option-selected {
  background: var(--primary, #2E7D32);
  color: #ffffff;
  font-weight: 700;
}

/* === month picker widget (繰り返し: 期間 開始月 / 終了月) === */
.pf-month-wrap {
  position: relative;
  width: 100%;
}

.pf-month-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  background: #F9FBF2;
  border: 2px solid var(--border, #c5e1c8);
  border-radius: var(--radius-sm, 8px);
  color: var(--text, #1a3a1d);
  font-size: 1rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s, background 0.2s;
}

.pf-month-trigger:hover,
.pf-month-trigger:focus,
.pf-month-trigger[aria-expanded="true"] {
  outline: none;
  border-color: var(--primary, #2E7D32);
  background: #f4f9ed;
}

.pf-month-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pf-month-placeholder {
  color: var(--text-muted, #888);
}

.pf-month-caret {
  font-size: 0.8rem;
  color: var(--text-muted, #888);
  flex-shrink: 0;
  transition: transform 0.2s;
}

.pf-month-trigger[aria-expanded="true"] .pf-month-caret {
  transform: rotate(180deg);
}

.pf-month-panel {
  margin: 6px 0 4px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--border, #c5e1c8);
  border-radius: var(--radius-md, 10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  animation: pf-panel-fade-in 0.15s ease-out;
}

.pf-month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.pf-month-nav {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--primary, #2E7D32);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.pf-month-nav:hover,
.pf-month-nav:focus {
  outline: none;
  background: #e8f5e9;
  border-color: var(--primary, #2E7D32);
}

.pf-month-label {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text, #1a3a1d);
  text-align: center;
  flex: 1;
}

.pf-month-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.pf-month-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: inherit;
  background: #F9FBF2;
  border: 1.5px solid var(--border, #c5e1c8);
  border-radius: 6px;
  color: var(--text, #1a3a1d);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: rgba(46, 125, 50, 0.2);
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.pf-month-cell:hover,
.pf-month-cell:focus {
  outline: none;
  background: #e8f5e9;
  border-color: var(--primary, #2E7D32);
}

.pf-month-cell.pf-month-today {
  border-color: var(--primary, #2E7D32);
  font-weight: 700;
}

.pf-month-cell.pf-month-selected {
  background: var(--primary, #2E7D32);
  color: #ffffff;
  border-color: var(--primary, #2E7D32);
  font-weight: 700;
}

/* === narrow 画面 (≤ 360px) でも崩れない調整 === */
@media (max-width: 360px) {
  .pf-cal-cell {
    min-height: 36px;
    font-size: 0.88rem;
  }
  .pf-time-cell {
    min-height: 38px;
    font-size: 0.88rem;
  }
  .pf-cal-trigger,
  .pf-time-trigger {
    font-size: 0.95rem;
    padding: 10px 10px;
  }
  .pf-cal-panel,
  .pf-time-panel {
    padding: 10px;
  }
}
