/* ============================================================
   ESA service shell — OFFICIAL SIDEBAR LAYOUT (uploaded attachment)
   Sidebar visual: responsive-pinned-sidebar-layout-w-popover, AS-IS
   (sidebar/sidebar.css is the byte-identical attachment; it owns the
   header, rail, popover panel, tree + grid transitions).
   This file only bridges the attachment layout to the shell:
   viewport stage + bottom chat dock + Bento card helpers.
   ============================================================ */

/* ---- App wrapper: attachment body grid (header | layout) ---- */
#esa-exoskeleton {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100dvh;
  min-height: 100dvh;
  padding: 0;
}

/* ---- Header bridge: attachment .header + existing ESA chrome ----
   (index.html inline styles are unlayered but EARLIER in document
   order — these later unlayered rules win the tie) */
.esa-header {
  height: var(--header-height, 60px);
  box-sizing: border-box;
  padding: 0 12px;
  margin: 0;
  gap: 10px;
  justify-content: flex-start;
}
.header .esa-status-badge { margin-left: auto; }
.header .esa-title { margin: 0 0.75rem; }
.header .user .name { color: canvasText; }

.avatar-fallback {
  display: grid;
  place-items: center;
  width: 24px;
  aspect-ratio: 1;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 600;
  color: canvasText;
  background: color-mix(in srgb, canvas, canvasText 25%);
  flex-shrink: 0;
}

/* ---- Viewport panel: attachment .content > main (bordered panel),
        split into scrolling stage + pinned bottom chat dock ---- */
.layout,
.content {
  min-height: 0;
  min-width: 0;
}

.esa-content-main {
  height: 100%;
  display: grid;
  grid-template-rows: 1fr auto;
  grid-template-areas:
    "stage"
    "chat";
  overflow: hidden;
}

/* ---- Viewport stage ---- */
.esa-render-area {
  display: block;
  grid-area: stage;
  overflow: auto;
  padding: 16px 20px;
  background: transparent;
  border: none;
  border-radius: 0;
  min-height: 0;
}

.esa-render-area > [data-esa-card] {
  display: none;
  max-width: 960px;
  margin: 0 auto;
}

.esa-render-area > [data-esa-card].esa-card-active {
  display: block;
  /* Grid-transition entrance (attachment tokens: --duration/--opacity/
     --blur/--translate set by sidebar/sidebar-tree.js) */
  animation: esa-card-in calc(var(--duration, 0.18) * 1s) cubic-bezier(0, 0, 0.58, 1);
}

@keyframes esa-card-in {
  from {
    opacity: var(--opacity, 0.4);
    translate: 0 calc(var(--translate, 12) * 1px);
    filter: blur(calc(var(--blur, 10) * 1px));
  }
  to {
    opacity: 1;
    translate: 0 0;
    filter: blur(0px);
  }
}

/* ---- chat area owned by ai-chatbot-dock.css (speakers on both ends) ---- */
#ai-chatbot,
#esa-ai-chatbot,
#esa-ingestion {
  min-width: 0;
}

/* ---- V6 typography bridge (attachment is the type authority):
        cards follow the ava-shell stack — bold sans titles like the
        uploaded Bento cards; no serif remnants of the old design ---- */
.ava-shell .bento-card { font-family: inherit; }
.ava-shell .bento-title {
  font-family: inherit;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.ava-shell .bk-btn,
.ava-shell .bk-input { font-family: inherit; }

/* ---- Header chrome → glass topbar ---- */
.esa-header {
  background: transparent !important;
  border-bottom: 1px solid var(--bento-border, rgba(255, 255, 255, 0.06)) !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.esa-title { color: var(--bento-text-primary, #fff) !important; }
.esa-title span:first-child {
  background: var(--bento-gradient-cool, linear-gradient(135deg, #3b82f6, #8b5cf6));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.esa-status-badge {
  background: var(--bento-surface-dark, rgba(255, 255, 255, 0.03)) !important;
  border: 1px solid var(--bento-border, rgba(255, 255, 255, 0.06)) !important;
  color: var(--bento-text-secondary, rgba(255, 255, 255, 0.6)) !important;
}

/* ---- Calendar card (Bento tokens) ---- */
.bk-cal-grid {
  min-height: 14rem;
  align-content: start;
}
.bk-cal-cell {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--bk-text);
}
.bk-cal-cell.bk-cal-dim {
  color: var(--bk-text-3);
  opacity: 0.4;
}
.bk-cal-cell.bk-cal-today {
  background: linear-gradient(135deg, var(--bk-accent), var(--bk-accent-2));
  color: var(--bk-on-accent);
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(126, 200, 160, 0.35);
}

/* ---- Mobile: attachment mobile layer owns the popover; the stage
        keeps the chat dock pinned to the bottom ---- */
@media (max-width: 768px) {
  .esa-content-main {
    height: auto;
    min-height: calc(100dvh - var(--header-height, 60px));
  }

  .esa-render-area {
    padding: 16px 12px;
  }
}

/* ESA.Calendar v2 — full service calendar panel (NOT a bento card) with Green Shield dates */
.esa-cal-panel {
  width: 100%;
  max-width: 660px;
  margin: 0 auto;
  background: var(--bk-panel);
  border: 1px solid var(--bk-border);
  border-radius: 1rem;
  padding: 0.75rem 0.95rem 0.65rem;
  box-shadow: var(--bk-shadow);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.esa-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}
.esa-cal-nav { display: flex; gap: 0.4rem; }
.esa-cal-dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.35rem;
  justify-items: center;
  padding: 0 0.25rem;
}
.esa-cal-grid { justify-items: center; }
.esa-cal-grid .bk-cal-cell {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 0.4rem;
  cursor: pointer;
  position: relative;
}
.esa-cal-grid .bk-cal-cell.bk-cal-dim { cursor: default; }
.esa-cal-grid .bk-cal-cell.esa-cal-sun { color: var(--bk-text-3); }
.esa-cal-grid .bk-cal-cell.esa-cal-selected {
  outline: 1px solid var(--bk-line);
  outline-offset: 1px;
}
.esa-cal-grid .bk-cal-cell.esa-cal-gs::after {
  content: "";
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--bk-accent);
}
.esa-cal-grid .bk-cal-cell.esa-cal-oos::before {
  content: "";
  position: absolute;
  top: 3px;
  right: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--bk-warn);
}
.esa-cal-grid .bk-cal-cell.bk-cal-today.esa-cal-gs::after { background: var(--bk-on-accent); }
.esa-cal-detail {
  background: var(--bk-panel-2);
  border: 1px solid var(--bk-border-soft);
  border-radius: 0.6rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.65rem;
  line-height: 1.4;
  color: var(--bk-text-2);
}
.esa-cal-detail strong { color: var(--bk-text); font-weight: 700; }
.esa-cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
}
.esa-cal-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  color: var(--bk-text-3);
}
.esa-cal-legend .lg { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.esa-cal-legend .lg-due { background: var(--bk-accent); }
.esa-cal-legend .lg-oos { background: var(--bk-warn); }
.esa-cal-legend .lg-off { background: transparent; border: 1px solid var(--bk-text-3); }
.esa-cal-grid { min-height: 0; }
.esa-cal-grid .bk-cal-cell { width: 1.6rem; height: 1.6rem; font-size: 0.62rem; border-radius: 0.35rem; }
.esa-cal-grid .bk-cal-cell.esa-cal-gs::after { bottom: 2px; width: 4px; height: 4px; }
.esa-cal-grid .bk-cal-cell.esa-cal-oos::before { top: 2px; right: 3px; width: 4px; height: 4px; }

/* Calendar container — the Green Shield calendar is NOT a card: strip the
   wildcard [id^="esa-"] card chrome for this container only (shell show/hide
   logic still uses the #esa-calendar id). */
#esa-calendar {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  min-height: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  overflow: visible;
}
#esa-calendar::before { display: none; }
