/* Compatibility layer for the accepted V2 prototype shell.
   Load after styles.css and the unmodified v2-reference.css. */

body.v2-product {
  min-width: 320px;
  --navy-950: var(--navy);
  --navy-900: var(--accent);
  --navy-100: var(--soft);
  --ink-soft: var(--muted);
  --surface: var(--paper);
  --border: var(--line);
  --font-sans: var(--sans);
  --font-serif: var(--serif);
}

/* The reference sheet intentionally targets its one prototype aside. The
   product contains detail asides, so only the navigation keeps that shell. */
.v2-product aside:not(#sidebar) {
  position: static;
  inset: auto;
  width: auto;
  padding: 0;
  display: block;
  overflow: visible;
  border: 0;
  background: transparent;
  z-index: auto;
}

.v2-product #sidebar {
  width: var(--sidebar);
  background: #edf1f5;
  visibility: visible;
  transform: none;
}

.v2-product #sidebar .sidebar-scroll { padding: 28px 16px 16px; }
.v2-product #sidebar .tenant-name,
.v2-product #sidebar .workspace-name,
.v2-product #sidebar .nav-section-label,
.v2-product #sidebar .boundary-card { display: none !important; }

.v2-product #nav { display: grid; gap: 4px; }
.v2-product #nav .nav-item {
  position: relative;
  min-height: 44px;
  margin: 0;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
  text-decoration: none;
}
.v2-product #nav .nav-item:hover { background: var(--soft); }
.v2-product #nav .nav-item.active {
  background: var(--paper);
  color: var(--accent);
  font-weight: 600;
}
.v2-product #nav .nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  width: 2px;
  height: 16px;
  background: var(--gold);
}
.v2-product #nav .nav-item:nth-child(5) { margin-top: 12px; }
.v2-product #nav .nav-item svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  flex-shrink: 0;
}

.v2-product .shell { margin-left: var(--sidebar); }
.v2-product .shell > header {
  position: static;
  height: 60px;
  padding: 0 36px;
  background: var(--navy);
}
.v2-product .workspace {
  width: auto;
  max-width: 1072px;
  min-height: calc(100dvh - 120px);
  margin: auto;
  padding: 32px 44px 50px;
}

.v2-product .primary-button {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
}
.v2-product .primary-button:hover {
  border-color: var(--navy);
  background: var(--navy);
}
.v2-product .quiet-button {
  min-height: 44px;
  padding: 8px 7px;
  border-color: transparent;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
}
.v2-product .quiet-button:hover {
  border-color: transparent;
  background: var(--soft);
}

/* V2 supplies its own concise toolbar; the verbose pilot heading remains in
   the DOM for compatibility but is not duplicated visually. */
.v2-product .app-view > .page-heading { display: none; }
.v2-product .v2-page-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.v2-product .v2-page-tools h1 {
  margin: 0;
  font: 22px/1.45 var(--serif);
}
.v2-product .v2-page-tools .search {
  width: min(420px, 100%);
  min-height: 44px;
  margin: 0;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
}

.v2-product .v2-case-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 22px;
  border-bottom: 1px solid var(--line);
}
.v2-product .v2-case-tabs button {
  padding: 10px 14px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}
.v2-product .v2-case-tabs button:hover { background: var(--soft); }
.v2-product .v2-case-tabs button.active,
.v2-product .v2-case-tabs button[aria-selected="true"] {
  color: var(--accent);
  box-shadow: inset 0 -2px var(--gold);
  font-weight: 600;
}

.v2-product .v2-product-tabs { margin-bottom: 24px; }
.v2-product .v2-knowledge-live,
.v2-product #v2-settings-content { max-width: 800px; }
.v2-product .v2-personal-create {
  display: grid;
  gap: 12px;
  margin: 24px 0;
  padding: 18px 0;
  border-block: 1px solid var(--line);
}
.v2-product .v2-personal-create input,
.v2-product .v2-personal-create textarea { margin: 0; }
.v2-product .v2-personal-create .primary-button { justify-self: start; }
.v2-product #v2-knowledge-message { min-height: 24px; }
.v2-product #v2-knowledge-more { margin-top: 12px; }
.v2-product .v2-deferred-note {
  max-width: 70ch;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.v2-product [data-case-section][hidden] { display: none !important; }

/* Current server-rendered directories retain their IDs and controls while
   adopting the prototype's quiet row treatment. */
.v2-product .matter-list,
.v2-product .task-list,
.v2-product .knowledge-result-list,
.v2-product .member-list,
.v2-product .service-package-list,
.v2-product .agent-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  border-top: 1px solid var(--line);
}
.v2-product .matter-row,
.v2-product .task-row,
.v2-product .knowledge-card,
.v2-product .member-row,
.v2-product .service-package-card,
.v2-product .agent-card {
  min-height: 56px;
  margin: 0;
  padding: 13px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.v2-product .knowledge-card h3,
.v2-product .service-package-card h3 { font-size: 15px; }
.v2-product .agent-card > .status-badge {
  position: static;
  float: right;
}
.v2-product .agent-card h2 { margin: 0 0 6px; font-size: 15px; }
.v2-product .agent-card .agent-icon { display: none; }

@media (max-width: 1100px) {
  .v2-product { --sidebar: 200px; }
  .v2-product .workspace { padding: 28px 30px 50px; }
  .v2-product .shell > header { padding: 0 30px; }
}

@media (max-width: 700px) {
  .v2-product { --sidebar: 0px; font-size: 16px; }
  .v2-product .shell { margin-left: 0; }
  .v2-product #sidebar {
    width: 260px;
    visibility: hidden;
    transform: translateX(-100%);
    transition: transform 180ms, visibility 180ms;
    z-index: 61;
    box-shadow: 10px 0 40px #10223f22;
  }
  .v2-product #sidebar.open { visibility: visible; transform: translateX(0); }
  .v2-product .shell > header { height: 56px; padding: 0 16px; }
  .v2-product #drawer-toggle {
    display: block;
    min-width: 44px;
    padding: 8px;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 18px;
  }
  .v2-product .drawer-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 60;
    border: 0;
    border-radius: 0;
    background: #10223f66;
  }
  .v2-product .workspace { padding: 24px 20px 60px; }
  .v2-product .v2-page-tools { gap: 10px; }
  .v2-product .v2-page-tools .primary-button {
    white-space: nowrap;
    padding-inline: 12px;
    font-size: 12px;
  }
  .v2-product .v2-case-tabs { gap: 0; margin-bottom: 18px; }
  .v2-product .v2-case-tabs button { padding: 10px 12px; font-size: 12px; }
  .v2-product .matter-row,
  .v2-product .task-row,
  .v2-product .knowledge-card,
  .v2-product .member-row,
  .v2-product .service-package-card,
  .v2-product .agent-card { padding: 13px 0; }
}

@media (max-width: 360px) {
  .v2-product .workspace { padding-inline: 16px; }
  .v2-product .v2-page-tools { align-items: stretch; flex-direction: column; }
  .v2-product .v2-page-tools .primary-button { width: 100%; }
}


/* Independent conversations and local direct entry retain the approved page hierarchy. */
.v2-product [data-retired-module],
.v2-product.v2-direct-workspace #login-screen,
.v2-product #conversations-view .overview-grid > section:first-child,
.v2-product #conversations-view .panel-header,
.v2-product #conversations-view #conversation-empty[hidden] { display: none !important; }
.v2-product #conversations-view .overview-grid { display: block; max-width: 900px; margin: 0 auto; }
.v2-product #conversations-view .overview-grid > section { border: 0; background: transparent; padding: 0; box-shadow: none; }
.v2-product #conversation-meta { font-size: 12px; color: var(--muted); margin: 0 0 20px; }
.v2-product #conversation-messages .message { border: 0; padding: 20px 0; border-bottom: 1px solid var(--line); background: transparent; }
.v2-product #conversation-messages .message.user { margin-left: 8%; }
.v2-product #conversation-messages p { white-space: pre-wrap; overflow-wrap: anywhere; }
.v2-product #conversation-messages .message-label { color: var(--navy); font-size: 12px; }
.v2-product #conversation-reply-form { margin-top: 24px; }
.v2-product #work-composer-message:empty { display: none; }
.v2-product .v2-case-tabs { margin-top: 12px; }
.v2-product #nav .nav-badge { display: none !important; }
.v2-product .v2-case-disclosure { margin: 20px 0 0; border-top: 1px solid var(--line); }
.v2-product .v2-case-disclosure > summary { min-height: 44px; padding: 12px 0; color: var(--muted); font-size: 13px; }
.v2-product .v2-case-disclosure .panel { margin-top: 10px; }
.v2-product #v2-case-overview > .primary-button { margin: 8px 0 16px; }
.v2-product #knowledge-view { display: flex; flex-direction: column; }
.v2-product #knowledge-view[hidden] { display: none !important; }
.v2-product #v2-knowledge-historical:not([hidden]),
.v2-product #v2-knowledge-live:not([hidden]),
.v2-product .knowledge-search-panel { display: contents; }
.v2-product #knowledge-search-form,
.v2-product #v2-knowledge-query-form { display: block; order: 1; width: 100%; max-width: 760px; }
.v2-product #v2-knowledge-tabs { order: 2; }
.v2-product #knowledge-view .dashboard-panel,
.v2-product #v2-knowledge-directory,
.v2-product #v2-knowledge-message,
.v2-product #v2-knowledge-more { order: 3; }
.v2-product #v2-personal-create { order: 4; }
.v2-product #knowledge-view .panel-header { display: none; }
.v2-product .v2-knowledge-filters { margin: 12px 0 0; }
.v2-product .v2-knowledge-filters > summary { min-height: 44px; padding: 10px 0; color: var(--muted); font-size: 13px; }
.v2-product .v2-knowledge-filters > div { margin: 10px 0; }
.v2-product #v2-case-create-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 24px; overflow-y: auto; }
.v2-product #v2-case-create-dialog .panel { padding: 0; border: 0; box-shadow: none; }
.v2-product .v2-client-management { border-top: 1px solid var(--line); margin-top: 20px; }
.v2-product .v2-client-management > summary { min-height: 44px; padding: 12px 0; color: var(--muted); font-size: 13px; }

/* Keep a failed case opening visible, with a retry, instead of bouncing back silently. */
.v2-product #matter-detail-view:has(#v2-case-load-error:not([hidden])) [data-case-page],
.v2-product #matter-detail-view:has(#v2-case-load-error:not([hidden])) .v2-case-tabs { display: none; }

.v2-product .v2-case-intro { margin: 12px 0 24px; color: var(--muted); line-height: 1.7; }
.v2-product .v2-case-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 18px 0; align-items: center; }
.v2-product #v2-case-summary { white-space: pre-wrap; overflow-wrap: anywhere; }
.v2-product .v2-result-tabs { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.v2-product #v2-case-conversations .directory-row { width: 100%; text-align: left; }
