/* ClovaBot (WP plugin) — UI aligned with Clova-dashboard chat (floating panel, not a side drawer) */
.clova-pc-widget {
  --clova-pc-accent-1: #667eea;
  --clova-pc-accent-2: #764ba2;
  /* comma-separated R,G,B for rgba(var(--clova-pc-accent-rgb), a); overridden via wp_add_inline_style */
  --clova-pc-accent-rgb: 102, 126, 234;
  --clova-pc-surface: #ffffff;
  --clova-pc-muted: #868e96;
  --clova-pc-text: #212529;
  --clova-pc-chat-bg: #f8f9fa;
  --clova-pc-radius-lg: 16px;
  --clova-pc-radius-md: 12px;
  --clova-pc-shadow: 0 12px 40px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);

  position: fixed;
  z-index: 999999;
  bottom: 1.5rem;
  right: 1.5rem;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--clova-pc-text);
}

.clova-pc-fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.75rem;
  height: 3.75rem;
  padding: 0;
  border: none !important;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--clova-pc-accent-1) 0%, var(--clova-pc-accent-2) 100%) !important;
  background-color: var(--clova-pc-accent-1) !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(var(--clova-pc-accent-rgb), 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.clova-pc-fab:hover,
.clova-pc-fab:focus-visible {
  transform: scale(1.06);
  box-shadow: 0 6px 22px rgba(var(--clova-pc-accent-rgb), 0.55);
  outline: 2px solid rgba(var(--clova-pc-accent-rgb), 0.45);
  outline-offset: 2px;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  background: linear-gradient(135deg, var(--clova-pc-accent-1) 0%, var(--clova-pc-accent-2) 100%) !important;
}

.clova-pc-fab:active {
  transform: scale(0.96);
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}

.clova-pc-widget .clova-pc-fab svg,
.clova-pc-widget .clova-pc-fab path {
  stroke: currentColor !important;
}

.clova-pc-fab-icon {
  flex-shrink: 0;
}

/* FAB hidden while chat is open — panel uses fixed positioning so layout does not depend on the button */
.clova-pc-widget.clova-pc-widget--open .clova-pc-fab {
  display: none;
}

.clova-pc-panel {
  display: flex;
  flex-direction: column;
  border-radius: var(--clova-pc-radius-lg);
  background: var(--clova-pc-surface);
  box-shadow: var(--clova-pc-shadow);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.06);
  min-height: 0;
}

.clova-pc-widget.clova-pc-widget--open .clova-pc-panel {
  position: fixed;
  z-index: 1000000;
  right: 1.5rem;
  bottom: 1.5rem;
  width: min(26rem, calc(100vw - 2rem));
  height: 75vh;
  max-height: 75vh;
}

.clova-pc-panel[hidden] {
  display: none !important;
}

.clova-pc {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  max-height: inherit;
}

.clova-pc--dock {
  height: 100%;
}

.clova-pc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1rem 0.875rem;
  border-bottom: 1px solid #e9ecef;
  background: var(--clova-pc-surface);
  flex-shrink: 0;
}

.clova-pc-header-text {
  min-width: 0;
}

.clova-pc-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #343a40;
}

.clova-pc-header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* Header + chrome buttons: scoped + !important so theme button:hover { color:#fff } cannot wash out labels/icons */
.clova-pc-widget .clova-pc-btn {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.clova-pc-widget .clova-pc-btn--ghost {
  padding: 0.35rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid #dee2e6 !important;
  background: #fff !important;
  background-color: #fff !important;
  color: #495057 !important;
  -webkit-text-fill-color: #495057 !important;
}

.clova-pc-widget .clova-pc-btn--ghost:hover,
.clova-pc-widget .clova-pc-btn--ghost:focus {
  background: #f1f3f5 !important;
  background-color: #f1f3f5 !important;
  color: #495057 !important;
  -webkit-text-fill-color: #495057 !important;
  border-color: #ced4da !important;
}

.clova-pc-widget .clova-pc-btn--ghost:active {
  background: #e9ecef !important;
  background-color: #e9ecef !important;
  color: #343a40 !important;
  -webkit-text-fill-color: #343a40 !important;
}

.clova-pc-widget .clova-pc-btn--icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid #dee2e6 !important;
  background: #fff !important;
  background-color: #fff !important;
  color: #495057 !important;
  -webkit-text-fill-color: #495057 !important;
}

.clova-pc-widget .clova-pc-btn--icon:hover,
.clova-pc-widget .clova-pc-btn--icon:focus {
  background: #f1f3f5 !important;
  background-color: #f1f3f5 !important;
  color: #495057 !important;
  -webkit-text-fill-color: #495057 !important;
  border-color: #ced4da !important;
}

.clova-pc-widget .clova-pc-btn--icon:active {
  background: #e9ecef !important;
  background-color: #e9ecef !important;
  color: #343a40 !important;
  -webkit-text-fill-color: #343a40 !important;
}

.clova-pc-widget .clova-pc-btn--icon svg,
.clova-pc-widget .clova-pc-btn--icon path {
  stroke: currentColor !important;
}

.clova-pc-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--clova-pc-chat-bg);
}

.clova-pc-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.5rem 1.25rem;
  gap: 0.65rem;
}

.clova-pc-empty[hidden] {
  display: none !important;
}

.clova-pc-empty-greeting {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #495057;
  align-self: stretch;
  width: 100%;
}

.clova-pc-empty-disclaimer {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.45;
  color: #868e96;
  align-self: stretch;
  width: 100%;
}

.clova-pc-starters {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  width: 100%;
  max-width: 20rem;
  margin-top: 0.35rem;
}

.clova-pc-starters:empty {
  display: none;
}

/* Scoped + !important: themes often set button/a:hover { color: #fff } which breaks these prompts */
.clova-pc-widget .clova-pc-starter-btn {
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid #dee2e6 !important;
  background: #fff !important;
  background-color: #fff !important;
  color: #495057 !important;
  -webkit-text-fill-color: #495057 !important;
  cursor: pointer;
  line-height: 1.35;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.clova-pc-widget .clova-pc-starter-btn:hover:not(:disabled),
.clova-pc-widget .clova-pc-starter-btn:focus:not(:disabled) {
  background: #f8f9fa !important;
  background-color: #f8f9fa !important;
  color: #495057 !important;
  -webkit-text-fill-color: #495057 !important;
  border-color: rgba(var(--clova-pc-accent-rgb), 0.35) !important;
  box-shadow: 0 1px 4px rgba(var(--clova-pc-accent-rgb), 0.12);
}

.clova-pc-widget .clova-pc-starter-btn:active:not(:disabled) {
  background: #f1f3f5 !important;
  background-color: #f1f3f5 !important;
  color: #343a40 !important;
  -webkit-text-fill-color: #343a40 !important;
}

.clova-pc-widget .clova-pc-starter-btn:focus-visible {
  outline: 2px solid rgba(var(--clova-pc-accent-rgb), 0.45);
  outline-offset: 2px;
}

.clova-pc-widget .clova-pc-starter-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  color: #495057 !important;
  -webkit-text-fill-color: #495057 !important;
}

.clova-pc-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  -webkit-overflow-scrolling: touch;
}

.clova-pc-messages[hidden] {
  display: none !important;
}

.clova-pc-messages::-webkit-scrollbar {
  width: 6px;
}

.clova-pc-messages::-webkit-scrollbar-track {
  background: #f1f3f5;
  border-radius: 3px;
}

.clova-pc-messages::-webkit-scrollbar-thumb {
  background: #adb5bd;
  border-radius: 3px;
}

.clova-pc-row {
  display: flex;
  animation: clova-pc-slide-in 0.28s ease;
}

.clova-pc-row-user {
  justify-content: flex-end;
}

.clova-pc-row-assistant {
  justify-content: flex-start;
}

.clova-pc-bubble {
  max-width: 88%;
  padding: 0.65rem 0.9rem;
  border-radius: 1rem;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.clova-pc-bubble-user {
  background: linear-gradient(135deg, var(--clova-pc-accent-1) 0%, var(--clova-pc-accent-2) 100%);
  color: #fff;
  border-bottom-right-radius: 0.25rem;
}

.clova-pc-bubble-assistant {
  background: #fff;
  color: var(--clova-pc-text);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-bottom-left-radius: 0.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* Rendered markdown (assistant): avoid pre-wrap from code blocks collapsing layout */
.clova-pc-bubble-assistant--md {
  white-space: normal;
}

.clova-pc-bubble-assistant--md > *:first-child {
  margin-top: 0 !important;
}

.clova-pc-bubble-assistant--md > *:last-child {
  margin-bottom: 0 !important;
}

.clova-pc-bubble-assistant--md p {
  margin: 0 0 0.5rem 0;
  line-height: 1.5;
}

.clova-pc-bubble-assistant--md p:last-child {
  margin-bottom: 0;
}

.clova-pc-bubble-assistant--md ul,
.clova-pc-bubble-assistant--md ol {
  margin: 0 0 0.5rem 0;
  padding-left: 1.25rem;
}

.clova-pc-bubble-assistant--md li {
  margin: 0.15rem 0;
}

.clova-pc-bubble-assistant--md li p {
  margin: 0;
  display: inline;
}

.clova-pc-bubble-assistant--md code {
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, monospace;
  font-size: 0.88em;
  background: rgba(0, 0, 0, 0.06);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.clova-pc-bubble-assistant--md pre {
  margin: 0.5rem 0;
  padding: 0.65rem 0.75rem;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.86em;
  line-height: 1.45;
}

.clova-pc-bubble-assistant--md pre code {
  background: none;
  padding: 0;
}

.clova-pc-bubble-assistant--md a {
  color: var(--clova-pc-accent-1);
  text-decoration: underline;
  word-break: break-word;
}

.clova-pc-bubble-assistant--md a:hover {
  color: var(--clova-pc-accent-2);
}

.clova-pc-bubble-assistant--md strong {
  font-weight: 600;
}

.clova-pc-bubble-assistant--md blockquote {
  margin: 0.5rem 0;
  padding-left: 0.75rem;
  border-left: 3px solid #dee2e6;
  color: #495057;
}

.clova-pc-bubble-assistant--md h1,
.clova-pc-bubble-assistant--md h2,
.clova-pc-bubble-assistant--md h3,
.clova-pc-bubble-assistant--md h4 {
  margin: 0.65rem 0 0.35rem;
  font-weight: 600;
  line-height: 1.25;
}

.clova-pc-bubble-assistant--md h1:first-child,
.clova-pc-bubble-assistant--md h2:first-child,
.clova-pc-bubble-assistant--md h3:first-child {
  margin-top: 0;
}

.clova-pc-bubble-assistant--md h1 { font-size: 1.15em; }
.clova-pc-bubble-assistant--md h2 { font-size: 1.08em; }
.clova-pc-bubble-assistant--md h3 { font-size: 1.02em; }

.clova-pc-bubble-assistant--md hr {
  border: none;
  border-top: 1px solid #dee2e6;
  margin: 0.65rem 0;
}

.clova-pc-bubble-assistant--md table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.5rem 0;
  font-size: 0.9em;
}

.clova-pc-bubble-assistant--md th,
.clova-pc-bubble-assistant--md td {
  border: 1px solid rgba(0, 0, 0, 0.12);
  padding: 0.35rem 0.5rem;
  text-align: left;
}

.clova-pc-bubble-assistant--md th {
  background: rgba(0, 0, 0, 0.04);
  font-weight: 600;
}

.clova-pc-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.35rem 0;
  min-height: 1.5rem;
}

.clova-pc-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #adb5bd;
  animation: clova-pc-typing 1.35s ease-in-out infinite;
}

.clova-pc-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.clova-pc-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes clova-pc-typing {
  0%, 60%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-5px);
  }
}

@keyframes clova-pc-slide-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.clova-pc-form {
  flex-shrink: 0;
  padding: 0.75rem 1rem 1rem;
  background: var(--clova-pc-surface);
  border-top: 1px solid #e9ecef;
}

.clova-pc-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.clova-pc-input {
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.55rem 1rem;
  font: inherit;
  border: 1px solid #dee2e6;
  border-radius: 999px;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.clova-pc-widget .clova-pc-input {
  background: #fff !important;
  background-color: #fff !important;
  color: #212529 !important;
  -webkit-text-fill-color: #212529 !important;
  border-color: #dee2e6 !important;
}

.clova-pc-widget .clova-pc-input:hover:not(:disabled),
.clova-pc-widget .clova-pc-input:focus {
  color: #212529 !important;
  -webkit-text-fill-color: #212529 !important;
  background: #fff !important;
  background-color: #fff !important;
}

.clova-pc-input:focus {
  outline: none;
  border-color: var(--clova-pc-accent-1);
  box-shadow: 0 0 0 3px rgba(var(--clova-pc-accent-rgb), 0.2);
}

.clova-pc-input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.clova-pc-submit {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.65rem;
  height: 2.65rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: linear-gradient(135deg, var(--clova-pc-accent-1) 0%, var(--clova-pc-accent-2) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(var(--clova-pc-accent-rgb), 0.35);
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.clova-pc-widget .clova-pc-submit {
  background: linear-gradient(135deg, var(--clova-pc-accent-1) 0%, var(--clova-pc-accent-2) 100%) !important;
  background-color: var(--clova-pc-accent-1) !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  border: none !important;
}

.clova-pc-widget .clova-pc-submit:hover:not(:disabled),
.clova-pc-widget .clova-pc-submit:focus {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  background: linear-gradient(135deg, var(--clova-pc-accent-1) 0%, var(--clova-pc-accent-2) 100%) !important;
}

.clova-pc-submit:hover:not(:disabled) {
  transform: scale(1.04);
}

.clova-pc-widget .clova-pc-submit svg,
.clova-pc-widget .clova-pc-submit path {
  stroke: currentColor !important;
}

.clova-pc-submit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.clova-pc-submit-icon {
  display: block;
  flex-shrink: 0;
  /* Paper-plane path is heavier toward the tip; nudge down-left so it sits visually centered in the circle. */
  transform: translate(-0.09rem, 0.08rem);
}

.clova-pc--error {
  margin: 0;
  padding: 0.65rem 0.85rem;
  font-size: 0.875rem;
  color: #c92a2a;
  background: #fff5f5;
  border: 1px solid #ffc9c9;
  border-radius: var(--clova-pc-radius-md);
}

@media (max-width: 600px) {
  .clova-pc-widget {
    bottom: 1rem;
    right: 1rem;
  }

  .clova-pc-widget.clova-pc-widget--open .clova-pc-panel {
    right: 1rem;
    bottom: 1rem;
    width: calc(100vw - 2rem);
    height: min(75vh, calc(100dvh - 2rem));
    max-height: min(75vh, calc(100dvh - 2rem));
  }

  .clova-pc-fab {
    width: 3.5rem;
    height: 3.5rem;
  }
}

/* Short viewports: keep panel inside dynamic viewport (keyboard, mobile browser chrome) */
@media (max-height: 520px) {
  .clova-pc-widget.clova-pc-widget--open .clova-pc-panel {
    height: min(75vh, calc(100dvh - 1.5rem));
    max-height: min(75vh, calc(100dvh - 1.5rem));
  }
}
