/* ── Calendar pickers (date + time) ──
   KUI-style replacements for native <input type="date|time">. Native
   pickers render with the OS chrome and clash hard with the dark theme.

   Layout choice: triggers are styled to match `.ce-input` (same height,
   border, radius) so they slot into existing form rows without rework.
   Popovers live on document.body via `position: fixed`, anchored from
   trigger.getBoundingClientRect() — same pattern as cal-add-cal-popover. */

  /* ── Triggers ──────────────────────────────────────────────────── */
  .kc-dp-trigger,
  .kc-tp-trigger {
    width: 100%;
    height: 36px;
    padding: 0 var(--space-md);
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--space-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    color: var(--ink);
    font: inherit; font-size: var(--font-sm); cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
    text-align: left;
  }
  .kc-dp-trigger:hover,
  .kc-tp-trigger:hover { background: var(--raised); }
  .kc-dp-trigger[aria-expanded="true"],
  .kc-tp-trigger[aria-expanded="true"] {
    border-color: var(--accent);
  }
  .kc-dp-trigger--empty .kc-dp-trigger-text,
  .kc-tp-trigger--empty .kc-tp-trigger-text {
    color: var(--ink-muted);
  }
  .kc-dp-trigger-icon,
  .kc-tp-trigger-icon {
    color: var(--ink-muted);
    display: inline-flex; align-items: center;
    flex-shrink: 0;
  }

  /* ── DatePicker popover ─────────────────────────────────────────── */
  /* z-index bumped above .create-event-modal (z 1100) and the
     proposals overlay (z 1200) — picker is launched FROM those modals
     and must paint over them, not under. */
  .kc-dp-popover {
    display: none;
    position: fixed;
    width: 296px;
    background: var(--elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-m);
    box-shadow: var(--shadow-m);
    padding: 16px;
    z-index: 1300;
    flex-direction: column;
    gap: 8px;
  }
  .kc-dp-popover.visible { display: flex; }

  .kc-dp-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 4px;
  }
  .kc-dp-nav {
    width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: none;
    border-radius: var(--radius-s);
    color: var(--ink-muted); cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition), opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  }
  .kc-dp-nav:hover { background: var(--accent-soft); color: var(--ink); }
  .kc-dp-month-btn {
    flex: 1;
    height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    gap: 4px;
    background: transparent; border: none;
    border-radius: var(--radius-s);
    color: var(--ink); font: inherit; font-size: var(--font-sm); font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition), opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  }
  .kc-dp-month-btn:hover { background: var(--accent-soft); }
  .kc-dp-caret {
    color: var(--ink-muted);
    flex-shrink: 0;
  }

  .kc-dp-weekdays {
    display: grid; grid-template-columns: repeat(7, 1fr);
    gap: 0;
  }
  .kc-dp-weekday {
    height: 24px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--ink-muted);
    font-size: var(--font-2xs); font-weight: 600;
  }

  .kc-dp-grid {
    display: grid; grid-template-columns: repeat(7, 1fr);
    gap: 2px;
  }
  .kc-dp-day {
    position: relative;
    height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: none;
    border-radius: var(--radius-s);
    color: var(--ink); font: inherit; font-size: var(--font-sm);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition), opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  }
  .kc-dp-day:hover {
    background: var(--accent-soft);
  }
  .kc-dp-day--outside { color: var(--ink-ghost); }
  .kc-dp-day--disabled,
  .kc-dp-day--disabled:hover {
    opacity: 0.3;
    background: transparent;
    cursor: not-allowed;
  }
  .kc-dp-link[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
  }
  /* «Сегодня» — раньше было точкой под числом, теперь подсвечиваем
     цветом+весом (как Slack/Notion). Точка визуально мусорила. */
  .kc-dp-day--current {
    color: var(--accent);
    font-weight: 700;
  }
  .kc-dp-day--selected,
  .kc-dp-day--selected:hover {
    background: var(--accent); color: #fff;
  }
  .kc-dp-day--selected.kc-dp-day--current {
    color: #fff;
  }

  /* Year picker — same panel, replaces month grid when "Май 2026 ▾" is clicked. */
  .kc-dp-yeargrid {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    max-height: 192px; overflow-y: auto;
  }
  .kc-dp-year {
    height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: none;
    border-radius: var(--radius-s);
    color: var(--ink); font: inherit; font-size: var(--font-sm);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition), opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  }
  .kc-dp-year:hover { background: var(--accent-soft); }
  .kc-dp-year--selected,
  .kc-dp-year--selected:hover {
    background: var(--accent); color: #fff;
  }

  .kc-dp-foot {
    display: flex; justify-content: space-between;
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 4px;
  }
  .kc-dp-link {
    background: transparent; border: none;
    color: var(--ink); font: inherit; font-size: var(--font-md);
    font-weight: 600;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius-s);
    transition: background var(--transition), color var(--transition);
  }
  .kc-dp-link:hover { background: var(--accent-soft); color: var(--accent); }

  /* ── TimePicker popover ─────────────────────────────────────────── */
  /* Single-column dropdown a la Notion. anchored-end mode shows a
     duration suffix in the row ("15:30   30 мин"). */
  .kc-tp-popover {
    display: none;
    position: fixed;
    width: 180px; max-height: 280px;
    background: var(--elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-m);
    box-shadow: var(--shadow-m);
    padding: 4px;
    z-index: 1300;
    overflow-y: auto;
    flex-direction: column;
    /* Hide native scrollbar — list is short enough. */
    scrollbar-width: none;
  }
  .kc-tp-popover::-webkit-scrollbar { display: none; }
  .kc-tp-popover.visible { display: flex; }
  .kc-tp-row {
    flex-shrink: 0;
    height: 28px;
    padding: 0 10px;
    display: inline-flex; align-items: center; justify-content: space-between;
    background: transparent; border: none;
    border-radius: var(--radius-s);
    color: var(--ink); font: inherit; font-size: var(--font-sm);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition), opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  }
  .kc-tp-row:hover { background: var(--accent-soft); }
  .kc-tp-row--selected,
  .kc-tp-row--selected:hover {
    background: var(--accent); color: #fff;
  }
  .kc-tp-row--disabled,
  .kc-tp-row--disabled:hover {
    opacity: 0.3;
    background: transparent;
    cursor: not-allowed;
  }
  .kc-tp-row-suffix {
    color: var(--ink-muted);
    font-size: var(--font-xs);
    margin-left: 12px;
  }
  .kc-tp-row--selected .kc-tp-row-suffix {
    color: rgba(255,255,255,0.72);
  }
