/* Project-scoped Agent Chat experience */

.project-chat {
  display: grid;
  min-height: 690px;
  grid-template-columns: 270px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(18, 52, 82, 0.13);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 24px 65px rgba(12, 39, 66, 0.11);
}

.pc-loading-shell {
  display: grid;
  min-height: 690px;
  grid-column: 1 / -1;
  place-items: center;
  align-content: center;
  gap: 5px;
  color: #63788b;
  text-align: center;
}

.pc-loading-shell strong,
.pc-empty strong {
  color: #0b1f35;
  font-size: 15px;
}

.pc-loading-shell p,
.pc-empty p {
  max-width: 520px;
  margin: 0;
  color: #63788b;
  font-size: 12px;
}

.pc-loader {
  width: 22px;
  height: 22px;
  margin-bottom: 10px;
  border: 2px solid #dce6ef;
  border-top-color: #1769ff;
  border-radius: 50%;
  animation: pc-spin 700ms linear infinite;
}

@keyframes pc-spin {
  to { transform: rotate(360deg); }
}

.pc-agent-rail {
  display: grid;
  max-height: 690px;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid rgba(18, 52, 82, 0.1);
  background:
    radial-gradient(circle at 10% 0, rgba(23, 105, 255, 0.09), transparent 18rem),
    linear-gradient(180deg, #f7faff, #f2f6fa);
}

.pc-rail-head {
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(18, 52, 82, 0.09);
  color: #526a7e;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.pc-rail-head strong {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid rgba(23, 105, 255, 0.12);
  border-radius: 50%;
  background: #e9f0ff;
  color: #1769ff;
  font-size: 11px;
}

.pc-agent-list {
  display: grid;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
  padding: 11px;
}

button.pc-agent {
  display: grid;
  min-height: 76px;
  grid-template-columns: 42px minmax(0, 1fr) 12px;
  gap: 11px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 15px;
  padding: 11px;
  background: transparent;
  color: #0b1f35;
  text-align: left;
  box-shadow: none;
}

button.pc-agent:hover {
  border-color: rgba(23, 105, 255, 0.13);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 9px 22px rgba(12, 39, 66, 0.05);
}

button.pc-agent.active {
  border-color: rgba(23, 105, 255, 0.2);
  background: #fff;
  box-shadow: 0 12px 28px rgba(23, 105, 255, 0.1), inset 3px 0 #1769ff;
}

.pc-agent-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(23, 105, 255, 0.11);
  border-radius: 14px;
  background: linear-gradient(135deg, #e6efff, #def8f4);
  color: #225188;
  font-size: 14px;
  font-weight: 850;
}

.pc-agent-avatar-large {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  font-size: 16px;
}

.pc-agent-copy {
  min-width: 0;
}

.pc-agent-copy strong,
.pc-agent-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pc-agent-copy strong {
  font-size: 13px;
}

.pc-agent-copy small {
  margin-top: 3px;
  color: #687d8f;
  font-size: 10px;
  font-weight: 570;
}

.pc-runtime {
  display: grid;
  width: 12px;
  height: 12px;
  place-items: center;
}

.pc-runtime span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9baab6;
}

.pc-runtime.is-running span {
  background: #0aa475;
  box-shadow: 0 0 0 4px rgba(10, 164, 117, 0.12);
}

.pc-conversation {
  display: grid;
  min-width: 0;
  grid-template-rows: auto auto minmax(300px, 1fr) auto;
  background:
    radial-gradient(circle at 75% -20%, rgba(23, 105, 255, 0.065), transparent 26rem),
    #fff;
}

.pc-conversation.pc-no-agents {
  display: grid;
  grid-template-rows: 1fr;
  place-items: center;
  padding: 30px;
}

.pc-no-agents .pc-empty {
  min-height: 360px;
}

.pc-no-agents .pc-empty button {
  margin-top: 13px;
}

.pc-chat-head {
  display: flex;
  min-height: 92px;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(18, 52, 82, 0.09);
}

.pc-chat-agent {
  display: flex;
  min-width: 220px;
  align-items: center;
  gap: 12px;
}

.pc-head-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pc-head-line h2 {
  overflow: hidden;
  max-width: 280px;
  margin: 0;
  color: #0b1f35;
  font-size: 16px;
  letter-spacing: -0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pc-chat-agent p {
  margin: 3px 0 0;
  color: #63788b;
  font-size: 11px;
}

.pc-channel {
  flex: 0 0 auto;
  border: 1px solid rgba(23, 105, 255, 0.13);
  border-radius: 99px;
  padding: 4px 7px;
  background: #edf3ff;
  color: #1853ad;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.pc-channel-whatsapp {
  border-color: rgba(8, 119, 91, 0.14);
  background: #e5f8f1;
  color: #08775b;
}

.pc-conversation-control {
  display: flex;
  min-width: min(430px, 48%);
  align-items: flex-end;
  justify-content: flex-end;
  gap: 8px;
}

.pc-conversation-control label {
  width: min(320px, 100%);
  gap: 4px;
}

.pc-conversation-control label > span {
  color: #64798c;
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.pc-conversation-control select {
  min-height: 38px;
  padding: 7px 34px 7px 10px;
  font-size: 12px;
}

.pc-context-strip {
  display: grid;
  min-height: 48px;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 22px;
  border-bottom: 1px solid rgba(18, 52, 82, 0.08);
  background: #f8fbfd;
  color: #597085;
}

.pc-context-strip > span {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 7px;
  background: #e9f1ff;
  color: #1769ff;
}

.pc-context-strip p {
  margin: 0;
  font-size: 10px;
}

.pc-context-strip p strong {
  margin-right: 4px;
  color: #213d58;
}

.pc-message-scroll {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 28px clamp(22px, 4vw, 54px);
  scrollbar-color: #c6d4df transparent;
  scrollbar-width: thin;
}

.pc-message-list {
  display: grid;
  max-width: 900px;
  gap: 20px;
  margin: 0 auto;
}

.pc-message {
  display: grid;
  max-width: min(78%, 720px);
  gap: 7px;
}

.pc-message-coordinator {
  justify-self: end;
}

.pc-message-agent,
.pc-message-system {
  justify-self: start;
}

.pc-message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 3px;
}

.pc-message-meta strong {
  color: #38536d;
  font-size: 10px;
}

.pc-message-meta time {
  color: #8595a4;
  font-size: 9px;
}

.pc-message-content {
  border: 1px solid rgba(18, 52, 82, 0.1);
  border-radius: 5px 18px 18px;
  padding: 13px 15px;
  background: #f2f6fa;
  color: #1b354d;
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  box-shadow: 0 8px 20px rgba(12, 39, 66, 0.045);
}

.pc-message-coordinator .pc-message-content {
  border-color: rgba(23, 105, 255, 0.2);
  border-radius: 18px 5px 18px 18px;
  background: linear-gradient(135deg, #1769ff, #0960ed);
  color: #fff;
  box-shadow: 0 10px 25px rgba(23, 105, 255, 0.18);
}

.pc-message-system .pc-message-content {
  border-style: dashed;
  background: #fffaf1;
}

.pc-message-status {
  display: grid;
  gap: 2px;
  border: 1px solid rgba(164, 106, 36, 0.16);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff8ec;
  color: #795b35;
  font-size: 9px;
}

.pc-message-status strong {
  color: #9a5c11;
  font-size: 10px;
}

.pc-message-status.is-error {
  border-color: rgba(164, 58, 71, 0.16);
  background: #fff5f6;
  color: #76565c;
}

.pc-message-status.is-error strong {
  color: #a43a47;
}

.pc-evidence {
  border: 1px solid rgba(18, 52, 82, 0.1);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 9px;
}

.pc-evidence strong,
.pc-evidence span { display: block; }
.pc-evidence span { margin-top: 2px; opacity: 0.82; }
.pc-evidence.is-recorded { border-color: #dfce9b; background: #fff9e8; color: #765d16; }
.pc-evidence.is-live { border-color: #a9dccb; background: #effbf6; color: #17634f; }

.pc-message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 3px;
  opacity: 0.76;
  transition: opacity 160ms ease;
}

.pc-message:hover .pc-message-actions,
.pc-message:focus-within .pc-message-actions {
  opacity: 1;
}

.pc-message-actions button {
  min-height: 30px;
  border: 1px solid rgba(18, 52, 82, 0.1);
  padding: 5px 8px;
  background: #fff;
  color: #50687c;
  box-shadow: none;
  font-size: 9px;
}

.pc-message-actions button:hover:not(:disabled) {
  border-color: rgba(23, 105, 255, 0.23);
  background: #f2f6ff;
  color: #1555b5;
}

.pc-message-actions button.is-complete {
  border-color: rgba(8, 119, 91, 0.1);
  background: #e8f7f1;
  color: #08775b;
  opacity: 1;
}

.pc-message-actions button.pc-retry-reply {
  border-color: rgba(164, 58, 71, 0.18);
  background: #fff7f7;
  color: #8e3030;
}

.pc-empty,
.pc-error {
  display: grid;
  min-height: 100%;
  place-items: center;
  align-content: center;
  gap: 6px;
  color: #63788b;
  text-align: center;
}

.pc-empty-icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 8px;
  place-items: center;
  border: 1px solid rgba(23, 105, 255, 0.13);
  border-radius: 17px;
  background: linear-gradient(135deg, #e8f0ff, #e1f8f4);
  color: #1769ff;
  font-size: 21px;
}

.pc-prompts {
  display: flex;
  max-width: 760px;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 17px;
}

.pc-prompts button {
  min-height: 36px;
  border: 1px solid rgba(18, 52, 82, 0.11);
  border-radius: 99px;
  padding: 7px 11px;
  background: #fff;
  color: #395975;
  box-shadow: 0 7px 18px rgba(12, 39, 66, 0.05);
  font-size: 10px;
}

.pc-error {
  width: min(520px, 100%);
  min-height: 220px;
  margin: auto;
  border: 1px solid rgba(184, 63, 77, 0.15);
  border-radius: 18px;
  padding: 24px;
  background: #fff8f9;
}

.pc-error strong {
  color: #a43a47;
}

.pc-error p {
  margin: 0 0 9px;
  color: #76565c;
  font-size: 12px;
}

.pc-composer {
  display: grid;
  gap: 9px;
  margin: 0 clamp(18px, 4vw, 46px) 24px;
  border: 1px solid rgba(18, 52, 82, 0.14);
  border-radius: 18px;
  padding: 11px 12px 10px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 16px 42px rgba(12, 39, 66, 0.1);
}

.pc-composer:focus-within {
  border-color: rgba(23, 105, 255, 0.52);
  box-shadow: 0 0 0 4px rgba(23, 105, 255, 0.08), 0 18px 45px rgba(12, 39, 66, 0.12);
}

.pc-composer textarea {
  min-height: 58px;
  max-height: 180px;
  border: 0;
  padding: 4px 5px;
  resize: vertical;
  background: transparent;
  box-shadow: none;
  font-size: 13px;
}

.pc-composer textarea:focus-visible {
  box-shadow: none;
  outline: 0;
}

.pc-compose-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pc-compose-footer > span {
  color: #8091a0;
  font-size: 9px;
}

.pc-compose-footer button {
  min-height: 36px;
  padding: 7px 14px;
  font-size: 11px;
}

.pc-whatsapp-readonly {
  display: grid;
  min-height: 88px;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin: 0 clamp(18px, 4vw, 46px) 24px;
  border: 1px solid rgba(8, 119, 91, 0.16);
  border-radius: 17px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #effaf6, #f5fbf9);
}

.pc-readonly-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 12px;
  background: #dff5ed;
  color: #08775b;
}

.pc-whatsapp-readonly strong {
  color: #174b3e;
  font-size: 12px;
}

.pc-whatsapp-readonly p {
  margin: 2px 0 0;
  color: #5c786f;
  font-size: 10px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

@media (max-width: 1050px) {
  .project-chat {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .pc-chat-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .pc-conversation-control {
    width: 100%;
    min-width: 0;
    justify-content: flex-start;
  }

  .pc-conversation-control label {
    width: min(440px, 100%);
  }
}

@media (max-width: 760px) {
  .project-chat {
    min-height: 0;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .pc-agent-rail {
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid rgba(18, 52, 82, 0.1);
  }

  .pc-rail-head {
    min-height: 48px;
  }

  .pc-agent-list {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 9px 12px 13px;
    scroll-snap-type: x proximity;
  }

  button.pc-agent {
    min-width: 235px;
    scroll-snap-align: start;
  }

  .pc-conversation {
    min-height: 620px;
    grid-template-rows: auto auto minmax(320px, 1fr) auto;
  }

  .pc-chat-head {
    padding: 16px;
  }

  .pc-context-strip {
    padding-right: 14px;
    padding-left: 14px;
  }

  .pc-message-scroll {
    padding: 24px 16px;
  }

  .pc-message {
    max-width: 90%;
  }

  .pc-message-actions {
    opacity: 1;
  }

  .pc-composer,
  .pc-whatsapp-readonly {
    margin-right: 14px;
    margin-bottom: 16px;
    margin-left: 14px;
  }
}

@media (max-width: 520px) {
  .pc-chat-agent {
    min-width: 0;
  }

  .pc-head-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .pc-head-line h2 {
    max-width: 210px;
  }

  .pc-conversation-control {
    align-items: stretch;
    flex-direction: column;
  }

  .pc-new-chat {
    width: 100%;
  }

  .pc-context-strip {
    grid-template-columns: 22px minmax(0, 1fr);
  }

  .pc-context-strip button {
    grid-column: 2;
    justify-self: start;
  }

  .pc-message {
    max-width: 96%;
  }

  .pc-message-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .pc-message-actions button {
    width: 100%;
  }

  .pc-compose-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .pc-compose-footer > span {
    order: 2;
  }

  .pc-whatsapp-readonly {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .pc-whatsapp-readonly button {
    grid-column: 2;
    justify-self: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pc-loader { animation: none; }
}
