/* ============================================================
 * YALAP Cockpit — Wave 1-3 sidebar upgrades
 *
 * Injected by js/yalap-cockpit.js on top of the existing nav-header.
 * All new selectors are prefixed .yc- to avoid collisions with shared.css.
 * ============================================================ */

/* ---------- Shared tokens ---------- */
:root {
  --yc-hairline: rgba(255,255,255,0.06);
  --yc-dim:      rgba(255,255,255,0.55);
  --yc-ok:       #4ade80;
  --yc-warn:     #fbbf24;
  --yc-err:      #f87171;
  --yc-gold:     var(--gold, #C9A96E);
  --yc-palette-bg: #0f2e26;
  --yc-palette-border: rgba(201, 169, 110, 0.3);
}

/* ============================================================
 * WAVE 1.A — Live status strip
 * Replaces the plain clock with actionable counts.
 * ============================================================ */
.nav-clock {
  /* When cockpit is active we hide the vanilla clock because the
     status strip replaces it. Vanilla clock stays as fallback. */
}
body.yc-active .nav-clock { display: none; }

.yc-status {
  padding: 0.35rem 0.6rem 0.4rem;
  border-bottom: 1px solid var(--yc-hairline);
  margin-bottom: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

/* --- Time + date + sync all on one row --- */
.yc-time-block {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  min-height: 0;
}
.yc-time {
  font-size: 0.88rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--white);
  line-height: 1;
  flex-shrink: 0;
}
.yc-date {
  font-size: 0.56rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--yc-dim);
  line-height: 1;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Sync (inline, trailing on the time row) --- */
.yc-sync {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.55rem;
  color: var(--yc-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex-shrink: 0;
  line-height: 1;
}
.yc-sync-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 80px;
}

.yc-status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--yc-ok);
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.12);
  flex-shrink: 0;
}
.yc-status-dot.warn { background: var(--yc-warn); box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.14); }
.yc-status-dot.err  { background: var(--yc-err);  box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.14); animation: yc-pulse 1.8s ease-in-out infinite; }
.yc-status-dot.off  { background: rgba(255,255,255,0.25); box-shadow: none; }

/* --- Metrics row (compact inline) --- */
.yc-status-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--yc-hairline);
  border-radius: 5px;
  overflow: hidden;
}
.yc-metric {
  background: none;
  border: none;
  border-right: 1px solid var(--yc-hairline);
  padding: 0.3rem 0.15rem;
  color: var(--yc-dim);
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  transition: background 0.15s;
  display: flex;
  flex-direction: row;
  align-items: baseline;
  justify-content: center;
  gap: 0.3rem;
  line-height: 1;
}
.yc-metric:last-child { border-right: none; }
.yc-metric:hover { background: rgba(255,255,255,0.05); }
.yc-metric .n {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--white);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}
.yc-metric .l {
  font-size: 0.54rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--yc-dim);
}
.yc-metric.alert .n { color: var(--yc-gold); }

@keyframes yc-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

/* ============================================================
 * WAVE 2.A — AI prompt input (top of sidebar)
 * ============================================================ */
.yc-ai-input {
  margin: 0 0.55rem 0.65rem;
  position: relative;
}
.yc-ai-input input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--yc-hairline);
  border-radius: 7px;
  padding: 0.5rem 0.6rem 0.5rem 1.8rem;
  font-family: inherit;
  font-size: 0.75rem;
  color: var(--white);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
.yc-ai-input input::placeholder { color: var(--yc-dim); }
.yc-ai-input input:focus {
  border-color: var(--yc-gold);
  background: rgba(255,255,255,0.08);
}
.yc-ai-input::before {
  content: '✦';
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--yc-gold);
  font-size: 0.72rem;
  pointer-events: none;
}
.yc-ai-input .kbd {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.6rem;
  color: var(--yc-dim);
  pointer-events: none;
  letter-spacing: 0.05em;
}

/* ============================================================
 * WAVE 1.C — Recent items panel
 * ============================================================ */
.yc-recent {
  padding: 0.35rem 0.55rem;
  margin-bottom: 0.4rem;
}
.yc-recent-head {
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--yc-dim);
  padding: 0.3rem 0.3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.yc-recent-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.yc-recent-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.55rem;
  border-radius: 5px;
  color: var(--yc-dim);
  font-size: 0.72rem;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.yc-recent-item:hover {
  background: rgba(255,255,255,0.04);
  color: var(--white);
  text-decoration: none;
  border-left-color: rgba(201, 169, 110, 0.5);
}
.yc-recent-item .type {
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--yc-gold);
  opacity: 0.7;
  width: 28px;
  flex-shrink: 0;
}
.yc-recent-item .title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
 * WAVE 2.B — Health dots on nav items
 * ============================================================ */
.nav-item .yc-hd,
.nav-sub-item .yc-hd {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  margin-left: auto;
  flex-shrink: 0;
  background: rgba(255,255,255,0.15);
}
.nav-item .yc-hd.alert,
.nav-sub-item .yc-hd.alert { background: var(--yc-gold); box-shadow: 0 0 0 3px rgba(201,169,110,0.15); }
.nav-item .yc-hd.warn,
.nav-sub-item .yc-hd.warn  { background: var(--yc-warn); }
.nav-item,
.nav-sub-item { display: flex; align-items: center; }

/* ============================================================
 * WAVE 1.D — Notifications badge + panel
 * ============================================================ */
.yc-notify-badge {
  position: absolute;
  top: -6px;
  right: -7px;
  background: var(--yc-gold);
  color: var(--evergreen-dark, #012d24);
  font-size: 0.55rem;
  font-weight: 700;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 1.5px solid var(--evergreen);
  line-height: 1;
  box-sizing: border-box;
}
.nav-user-mark { position: relative; overflow: visible; }
.yc-notify-badge[hidden] { display: none !important; }

.yc-notify-panel {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: min(400px, 92vw);
  background: var(--evergreen);
  border-left: 1px solid var(--yc-hairline);
  z-index: 1200;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  color: var(--white);
  box-shadow: -12px 0 32px rgba(0,0,0,0.3);
}
.yc-notify-panel.open { transform: translateX(0); }
.yc-notify-head {
  padding: 1.1rem 1.25rem 0.85rem;
  border-bottom: 1px solid var(--yc-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.yc-notify-head h3 {
  margin: 0;
  font-family: var(--f-display);
  font-size: 1rem;
  color: var(--white);
  font-weight: 500;
  letter-spacing: 0.04em;
}
.yc-notify-head-actions {
  display: flex; align-items: center; gap: 0.75rem;
}
.yc-notify-mark-all {
  background: none; border: 1px solid var(--yc-hairline);
  color: var(--yc-dim); font-size: 0.7rem; font-family: var(--f-body);
  padding: 4px 10px; border-radius: 4px; cursor: pointer;
  letter-spacing: 0.02em; transition: color 0.15s, border-color 0.15s;
}
.yc-notify-mark-all:hover { color: var(--white); border-color: var(--yc-gold); }
.yc-notify-close {
  background: none; border: none; color: var(--yc-dim);
  font-size: 1.5rem; cursor: pointer; padding: 0; line-height: 1;
}
.yc-notify-close:hover { color: var(--white); }
.yc-notify-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}
.yc-notify-item {
  padding: 0.8rem 1rem 0.8rem 0.75rem;
  border-bottom: 1px solid var(--yc-hairline);
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  text-decoration: none;
  color: var(--white);
  transition: background 0.15s, opacity 0.15s;
}
.yc-notify-item:hover { background: rgba(255,255,255,0.03); text-decoration: none; color: var(--white); }
.yc-notify-item.read { opacity: 0.55; }
.yc-notify-item.read .title { font-weight: 400; }
.yc-notify-dot {
  width: 6px; height: 6px; border-radius: 50%;
  flex-shrink: 0;
  background: transparent;
}
.yc-notify-dot.unread { background: var(--yc-gold); box-shadow: 0 0 0 2px rgba(201,169,110,0.22); }
.yc-notify-mark {
  background: none; border: 1px solid transparent; color: var(--yc-dim);
  width: 24px; height: 24px; border-radius: 4px; cursor: pointer;
  font-size: 0.85rem; line-height: 1; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.yc-notify-mark:hover { color: var(--white); border-color: var(--yc-hairline); background: rgba(255,255,255,0.05); }
.yc-notify-item .ic {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
  background: rgba(201,169,110,0.12);
  color: var(--yc-gold);
}
.yc-notify-item .ic.err { background: rgba(248,113,113,0.12); color: var(--yc-err); }
.yc-notify-item .body { flex: 1; min-width: 0; }
.yc-notify-item .title {
  font-size: 0.78rem;
  font-weight: 500;
  margin-bottom: 0.15rem;
  color: var(--white);
}
.yc-notify-item .meta {
  font-size: 0.65rem;
  color: var(--yc-dim);
  letter-spacing: 0.02em;
}
.yc-notify-empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--yc-dim);
  font-size: 0.85rem;
}

.yc-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.yc-backdrop.show { opacity: 1; pointer-events: auto; }

/* ============================================================
 * WAVE 1.B — Command palette (Cmd+K)
 * ============================================================ */
.yc-palette {
  position: fixed;
  top: 12vh;
  left: 50%;
  transform: translateX(-50%) scale(0.96);
  width: min(640px, 92vw);
  background: var(--yc-palette-bg);
  border: 1px solid var(--yc-palette-border);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.45), 0 0 0 1px rgba(255,255,255,0.04);
  z-index: 1300;
  display: flex;
  flex-direction: column;
  max-height: 72vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.18s cubic-bezier(.2,.9,.3,1.1);
  color: var(--white);
}
.yc-palette.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) scale(1);
}
.yc-palette-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--yc-hairline);
  padding: 1.1rem 1.25rem;
  font-family: inherit;
  font-size: 1.05rem;
  color: var(--white);
  outline: none;
  letter-spacing: 0.01em;
}
.yc-palette-input::placeholder { color: var(--yc-dim); }
.yc-palette-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}
.yc-palette-group-h {
  font-size: 0.55rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--yc-dim);
  padding: 0.8rem 1.25rem 0.4rem;
}
.yc-palette-item {
  padding: 0.6rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--white);
  text-decoration: none;
  border-left: 2px solid transparent;
}
.yc-palette-item:hover,
.yc-palette-item.active {
  background: rgba(201,169,110,0.08);
  border-left-color: var(--yc-gold);
  text-decoration: none;
  color: var(--white);
}
.yc-palette-item .type {
  width: 44px;
  flex-shrink: 0;
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--yc-gold);
}
.yc-palette-item .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yc-palette-item .hint { color: var(--yc-dim); font-size: 0.68rem; flex-shrink: 0; }
.yc-palette-footer {
  padding: 0.55rem 1.25rem;
  border-top: 1px solid var(--yc-hairline);
  display: flex;
  gap: 1rem;
  font-size: 0.62rem;
  color: var(--yc-dim);
  letter-spacing: 0.04em;
}
.yc-palette-footer .kbd {
  padding: 1px 6px;
  border: 1px solid var(--yc-hairline);
  border-radius: 3px;
  font-family: ui-monospace, Menlo, monospace;
  margin-right: 3px;
  color: var(--white);
  opacity: 0.7;
}
.yc-palette-empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--yc-dim);
  font-size: 0.85rem;
}

/* ============================================================
 * WAVE 2.C — Context-aware drill-down
 * ============================================================ */
.yc-context {
  margin: 0.2rem 0 0.6rem;
  padding: 0 0.55rem;
}
.yc-context-label {
  font-size: 0.56rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--yc-dim);
  padding: 0.3rem 0.55rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.yc-context-label strong { color: var(--yc-gold); font-weight: 500; letter-spacing: 0.04em; text-transform: none; font-size: 0.72rem; }
.yc-context-list { display: flex; flex-direction: column; gap: 1px; }
.yc-context-item {
  padding: 0.35rem 0.8rem;
  font-size: 0.72rem;
  color: var(--yc-dim);
  text-decoration: none;
  border-radius: 5px;
  border-left: 2px solid transparent;
}
.yc-context-item:hover { background: rgba(255,255,255,0.04); color: var(--white); text-decoration: none; border-left-color: rgba(201,169,110,0.4); }
.yc-context-item.active { color: var(--white); border-left-color: var(--yc-gold); }

/* ============================================================
 * WAVE 3.A — Icon-only collapse mode
 * ============================================================ */
body.yc-collapsed .nav-header {
  width: 62px !important;
  padding: 1.1rem 0 0.6rem !important;
}
body.yc-collapsed .nav-brand-mark { max-width: 42px !important; }
body.yc-collapsed .nav-brand { padding: 0.4rem 0.1rem 0.6rem !important; }
body.yc-collapsed .yc-status,
body.yc-collapsed .yc-ai-input,
body.yc-collapsed .yc-recent,
body.yc-collapsed .yc-context,
body.yc-collapsed .nav-clock,
body.yc-collapsed .nav-item span,
body.yc-collapsed .nav-sub-item span,
body.yc-collapsed .nav-parent-label,
body.yc-collapsed .nav-chev,
body.yc-collapsed .nav-user-name,
body.yc-collapsed .yc-hd,
body.yc-collapsed .nav-lang-value { display: none !important; }
body.yc-collapsed .nav-item,
body.yc-collapsed .nav-parent,
body.yc-collapsed .nav-sub-item {
  padding-left: 0 !important;
  padding-right: 0 !important;
  justify-content: center !important;
}
body.yc-collapsed .nav-user-mark { margin: 0 auto !important; }

/* ============================================================
 * WAVE 3.B — Keyboard shortcut map (? key)
 * ============================================================ */
.yc-keys {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  background: var(--yc-palette-bg);
  border: 1px solid var(--yc-palette-border);
  border-radius: 14px;
  padding: 1.5rem 2rem;
  z-index: 1300;
  box-shadow: 0 24px 64px rgba(0,0,0,0.45);
  color: var(--white);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.18s;
  max-width: 440px;
}
.yc-keys.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}
.yc-keys h3 {
  margin: 0 0 1rem;
  font-family: var(--f-display);
  font-weight: 500;
  color: var(--white);
  font-size: 1.1rem;
  letter-spacing: 0.04em;
}
.yc-keys dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem 1.1rem;
  margin: 0;
  font-size: 0.85rem;
}
.yc-keys dt { color: var(--yc-dim); }
.yc-keys dt kbd {
  font-family: ui-monospace, Menlo, monospace;
  background: rgba(255,255,255,0.06);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--white);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}
.yc-keys dd { margin: 0; color: var(--white); }

/* ============================================================
 * WAVE 3.C — "What's new" chip (pulsing gold dot)
 * ============================================================ */
.yc-whatsnew {
  margin: 0 0.55rem 0.45rem;
  padding: 0.4rem 0.6rem;
  background: rgba(201,169,110,0.06);
  border: 1px solid rgba(201,169,110,0.18);
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.68rem;
  color: var(--yc-gold);
  cursor: pointer;
  text-decoration: none;
  letter-spacing: 0.02em;
}
.yc-whatsnew::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--yc-gold);
  box-shadow: 0 0 0 0 rgba(201,169,110,0.5);
  animation: yc-beacon 2s infinite;
  flex-shrink: 0;
}
@keyframes yc-beacon {
  0%   { box-shadow: 0 0 0 0   rgba(201,169,110,0.5); }
  70%  { box-shadow: 0 0 0 8px rgba(201,169,110,0);   }
  100% { box-shadow: 0 0 0 0   rgba(201,169,110,0);   }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  body.yc-active .yc-status,
  body.yc-active .yc-recent,
  body.yc-active .yc-ai-input,
  body.yc-active .yc-context { display: none; }
  .yc-palette { top: 3vh; }
}
