/* === Main Layout Container === */
#vlp-chat-outer-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  box-sizing: border-box;
}

/* === Chat Interface: Left + Right === */
#vlp-chat-interface {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 20px;
}

/* === Left Column: Coach Image === */
#vlp-chat-left {
  flex: 0 0 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#grace-image {
  width: 100%;
  max-width: 120px;
  object-fit: contain;
  margin-top: 10px;
}

#vlp-chat-left a {
  font-weight: bold;
  text-decoration: underline;
  margin-bottom: 10px;
  font-size: 14px;
  color: #0066ff;
}

/* === Right Column: Chat and Input === */
#vlp-chat-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* === Chat Output Area === */
#openai-assistant-response {
  max-height: 40vh;
  overflow-y: auto;
  padding: 15px 20px 45px 40px; /* top, right, bottom, left */
  margin-bottom: 20px;
  background: transparent;
  border: none;
  font-size: 16px;
  line-height: 1.5;
}

/* Speech-bubble styles for user and coach messages */
.vlp-msg-user {
  position: relative;
  display: block;
  width: fit-content;
  background: #ffffff;
  border: 2px solid #0066ff; /* brand blue */
  border-radius: 14px;
  padding: 12px 18px 12px 20px; /* interior spacing, extra left so text doesn't touch border */
  margin: 12px 0 12px auto; /* right-aligned bubble */
  max-width: 98%;
  text-align: left;
  box-sizing: border-box;
}
.vlp-msg-user img,
.vlp-msg-coach img {
  max-height: 24px;  /* 25% of previous clamp */
  max-width: 24px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: inline-block;
  vertical-align: middle;
}
.vlp-msg-user:after {
  content: "";
  position: absolute;
  right: -10px; top: 18px;
  width: 0; height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 10px solid #0066ff; /* tail color */
}

.vlp-msg-coach {
  position: relative;
  display: block;
  background: #ffffff;
  border: 2px solid #ff6600; /* brand orange */
  border-radius: 14px;
  padding: 12px 18px 12px 20px; /* interior spacing, extra left so text doesn't touch border */
  margin: 12px auto 12px 0; /* left-aligned bubble */
  max-width: 98%;
  text-align: left;
  box-sizing: border-box;
}
.vlp-msg-coach-body {
  display: block;
}
.vlp-msg-coach-wrap {
  display: block;
  margin: 12px auto 12px 0;
  max-width: 98%;
}
.vlp-msg-coach-wrap > .vlp-msg-coach {
  margin: 0;
  max-width: 100%;
}
.vlp-msg-coach:after {
  content: "";
  position: absolute;
  left: -10px; top: 18px;
  width: 0; height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 10px solid #ff6600;
}

/* === Input Form === */
#openai-assistant-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

#openai-assistant-input {
  width: 100%;
  font-size: 16px;
  padding: 10px;
  resize: vertical;
  border: 1px solid #ccc;
  border-radius: 6px;
}

.vlp-chat-disclaimer {
  font-size: 0.8rem;
  color: #888;
  margin-top: 6px;
  margin-bottom: 4px;
  line-height: 1.4;
}

/* Ensure gear container can sit above/right of the input */
.vlp-input-wrap {
  position: relative;
  overflow: visible;
}
#openai-settings-container {
  position: absolute;
  top: -30px;
  right: 0;
  z-index: 20;
}
#vlp-settings-icon {
  width: 22px;
  height: 22px;
  display: inline-block;
}

/* === Controls: Buttons + Gear Icon === */
#vlp-chat-controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  flex-wrap: wrap;
}

#vlp-chat-buttons {
  display: flex;
  gap: 10px;
}

#vlp-send-button,
#vlp-mic-button,
#vlp-mic-continuous-button {
  height: 48px;
  min-width: 120px;
  padding: 8px 16px;
  font-size: 16px;
  font-weight: bold;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;            /* Normalize emoji/icon vertical sizing (Safari) */
  white-space: nowrap;       /* Prevent wraps that push icons out of bounds */
  overflow: hidden;          /* Ensure oversized glyphs never spill outside */
  gap: 8px;                  /* Space between icon and label if both present */
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease-in-out;
}

/* Button icon/text wrappers for consistent cross-browser sizing (Safari-safe) */
#vlp-send-button .vlp-btn-icon,
#vlp-mic-button .vlp-btn-icon,
#vlp-mic-continuous-button .vlp-btn-icon {
  display: inline-block;
  line-height: 1;
  vertical-align: middle;
  font-size: 1.15em;         /* Slightly larger than text but within button bounds */
  max-height: 1.2em;         /* Clamp emoji render height on Safari */
  overflow: hidden;          /* Prevent rare overflows of color emoji glyphs */
}
#vlp-send-button .vlp-btn-text,
#vlp-mic-button .vlp-btn-text,
#vlp-mic-continuous-button .vlp-btn-text {
  line-height: 1;
  vertical-align: middle;
}

/* Any svg/img placed inside buttons will be constrained */
#vlp-send-button svg, #vlp-send-button img,
#vlp-mic-button svg, #vlp-mic-button img,
#vlp-mic-continuous-button svg, #vlp-mic-continuous-button img {
  width: 1.25em;
  height: 1.25em;
  object-fit: contain;
}

/* Hover Effects */
#vlp-send-button:hover,
#vlp-mic-button:hover,
#vlp-mic-continuous-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
  opacity: 0.95;
}

#vlp-send-button {
  background-color: #ff6600;
  color: white;
}

#vlp-mic-button,
#vlp-mic-continuous-button {
  background-color: #0066ff;
  color: white;
}

#vlp-settings-icon {
  font-size: 18px;
  cursor: pointer;
  margin-left: auto;
}

/* === Message History (below interface) === */
#vlp-message-log-container {
  margin-top: 30px;
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 10px;
}

/* === Response action bar (copy + feedback) === */
.vlp-msg-coach-wrap > .vlp-response-actions,
.vlp-msg-coach-wrap > .feedback-buttons,
#openai-assistant-response .vlp-response-actions,
#openai-assistant-response .feedback-buttons,
.vlp-response-actions,
.feedback-buttons {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: 4px;
  margin-left: 2px;
  padding: 0;
  min-height: 28px;
  background: none;
  border: none;
  box-shadow: none;
}

#openai-assistant-response .vlp-response-actions .vlp-response-action,
.vlp-msg-coach-wrap .vlp-response-actions .vlp-response-action,
.vlp-response-action,
.feedback-buttons .vlp-feedback-btn {
  all: unset;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0;
  border: none !important;
  border-radius: 0;
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  color: #8e8ea0;
  cursor: pointer;
  user-select: none;
  -webkit-appearance: none;
  appearance: none;
  font: inherit;
  line-height: 1;
  text-shadow: none;
  filter: none;
  transition: color 0.12s ease;
}

#openai-assistant-response .vlp-response-actions .vlp-response-action:hover,
.vlp-msg-coach-wrap .vlp-response-actions .vlp-response-action:hover,
.vlp-response-action:hover,
.feedback-buttons .vlp-feedback-btn:hover {
  color: #676767;
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  transform: none;
}

#openai-assistant-response .vlp-response-actions .vlp-response-action:focus,
.vlp-msg-coach-wrap .vlp-response-actions .vlp-response-action:focus,
.vlp-response-action:focus,
.feedback-buttons .vlp-feedback-btn:focus {
  outline: none;
}

#openai-assistant-response .vlp-response-actions .vlp-response-action:focus-visible,
.vlp-msg-coach-wrap .vlp-response-actions .vlp-response-action:focus-visible,
.vlp-response-action:focus-visible,
.feedback-buttons .vlp-feedback-btn:focus-visible {
  color: #676767;
  outline: none;
  box-shadow: none !important;
}

#openai-assistant-response .vlp-response-actions .vlp-response-action.is-selected,
.vlp-msg-coach-wrap .vlp-response-actions .vlp-response-action.is-selected,
.vlp-response-action.is-selected,
.feedback-buttons .vlp-feedback-btn.is-selected {
  color: #444;
}

#openai-assistant-response .vlp-response-actions .vlp-response-action.is-disabled,
.vlp-msg-coach-wrap .vlp-response-actions .vlp-response-action.is-disabled,
.vlp-response-action.is-disabled,
.feedback-buttons .vlp-feedback-btn.is-disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}

.vlp-response-action-icon,
.feedback-buttons .vlp-feedback-icon {
  display: block;
  width: 20px;
  height: 20px;
  pointer-events: none;
}

.vlp-response-action-status,
.feedback-buttons .feedback-message {
  font-size: 12px;
  color: #8e8ea0;
  margin-left: 6px;
  line-height: 1.2;
}

/* Share feedback modal (dislike) */
.vlp-feedback-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.vlp-feedback-modal.is-open {
  display: flex;
}

.vlp-feedback-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}

.vlp-feedback-modal__dialog {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  border: 1px solid #e5e5e5;
}

.vlp-feedback-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 8px;
}

.vlp-feedback-modal__title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #222;
}

.vlp-feedback-modal__close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #666;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.vlp-feedback-modal__close:hover {
  background: rgba(0, 0, 0, 0.05);
}

.vlp-feedback-modal__body {
  padding: 8px 18px 12px;
}

.vlp-feedback-modal__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.vlp-feedback-modal__chip {
  padding: 8px 12px;
  border: 1px solid #d8d8d8;
  border-radius: 999px;
  background: #fff;
  color: #333;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.vlp-feedback-modal__chip:hover {
  border-color: #bbb;
  background: #fafafa;
}

.vlp-feedback-modal__chip:focus {
  outline: none;
}

.vlp-feedback-modal__chip:focus-visible {
  border-color: #bbb;
  background: #fff;
  color: #333;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.12);
}

.vlp-feedback-modal__chip.is-selected {
  border-color: #0066ff;
  background: #f0f6ff;
  color: #004bb5;
}

.vlp-feedback-modal__chip.is-selected:focus-visible {
  border-color: #0066ff;
  background: #f0f6ff;
  color: #004bb5;
  box-shadow: 0 0 0 2px rgba(0, 102, 255, 0.2);
}

.vlp-feedback-modal__details {
  width: 100%;
  min-height: 96px;
  padding: 10px 12px;
  border: 1px solid #d8d8d8;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.45;
  resize: vertical;
  box-sizing: border-box;
}

.vlp-feedback-modal__details:focus {
  outline: none;
  border-color: #0066ff;
  box-shadow: 0 0 0 2px rgba(0, 102, 255, 0.15);
}

.vlp-feedback-modal__note {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: #777;
}

.vlp-feedback-modal__footer {
  display: flex;
  justify-content: flex-end;
  padding: 8px 18px 16px;
}

.vlp-feedback-modal__submit {
  padding: 8px 18px;
  border: none;
  border-radius: 999px;
  background: #0066ff;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.vlp-feedback-modal__submit:disabled {
  background: #d8d8d8;
  color: #888;
  cursor: not-allowed;
}

.vlp-feedback-modal__submit:not(:disabled):hover {
  background: #0052cc;
}

body.vlp-feedback-modal-open {
  overflow: hidden;
}

/* Clamp inline images/emojis in markdown-rendered content (chat history, detail rows) */
.markdown-content img,
.vlp-message-log-container img,
.vlp-styled-table img {
  max-height: 30px;  /* 25% of previous clamp */
  max-width: 30px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: inline-block;
  vertical-align: middle;
}

/* === Scroll Compensation for Sticky Input === */
body {
  padding-bottom: 180px;
}

/* === Responsive Design === */
@media screen and (max-width: 768px) {
  #vlp-chat-interface {
    flex-direction: column;
  }

  #vlp-chat-left {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 0 auto 6px;
  }

  #grace-image {
    width: 90vw;
    max-width: 90vw;
    height: auto;
    margin: 0 auto;
  }

  /* Buttons inline with info icon on mobile */
  #vlp-chat-buttons {
    display: flex !important;
    flex-wrap: wrap;
    column-gap: 8px;
    row-gap: 10px;
    align-items: center;
  }
  #vlp-send-button {
    flex: 1 1 100%;
  }
  #vlp-realtime-button {
    flex: 0 0 auto;
  }
  .vlp-audio-info-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    position: static;
  }

  /* Fix button sizing on mobile */
  #vlp-send-button,
  #vlp-mic-button,
  #vlp-mic-continuous-button,
  #vlp-realtime-button {
    min-width: auto !important;
    width: auto !important;
    max-width: 200px !important;
    height: 36px !important;
    font-size: 13px !important;
    margin-left: 0 !important;
    padding: 8px 14px !important;
    border-radius: 8px !important;
  }

  /* Tighter spacing between coach image and input */
  #openai-assistant-form {
    margin-top: 0;
  }

  /* Condense primary and realtime buttons; align info icon inline */
  #vlp-chat-buttons button,
  #vlp-realtime-button {
    height: 36px !important;
    min-width: 140px !important;
    font-size: 13px !important;
    padding: 8px 14px !important;
    border-radius: 8px !important;
  }
  .vlp-audio-info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    position: relative;
    top: 0;
  }

  #vlp-chat-controls-row {
    flex-direction: column;
    align-items: flex-start;
  }

  #vlp-settings-icon {
    align-self: flex-end;
    margin-top: 10px;
  }

  /* Let chat area grow with content on mobile; user scrolls the page, not a frame */
  #openai-assistant-response {
    max-height: none;
    min-height: 120px;
    overflow: visible;
    padding: 0;
    margin: 0 0 8px 0;
  }

  /* Chat history table fit on mobile */
  .vlp-message-log-container {
    max-height: 55vh;
    overflow-y: auto;
  }
  .vlp-message-log-container table {
    font-size: 12px;
    table-layout: fixed;
    width: 100%;
  }
  .vlp-message-log-container td,
  .vlp-message-log-container th {
    word-break: break-word;
  }
}

/* === Onboarding Coach Selector (filters and checkmark) === */
#vlp-onboarding-coach-selector .vlp-filters-row input,
#vlp-onboarding-coach-selector .vlp-filters-row select {
  font-size: 14px;
}

.vlp-coach-imgwrap .vlp-coach-check {
  position: absolute;
  top: 0;
  right: 0;
  background: #28a745;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 22px;
  z-index: 2;
}

/* Coach table image cell - fill cell, minimal padding */
.vlp-coach-table .vlp-coach-imgwrap {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}
.vlp-coach-table .vlp-coach-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Mobile: card layout - image full-width on top */
@media (max-width: 640px) {
  .vlp-coach-table,
  .vlp-coach-table tbody,
  .vlp-coach-table tr,
  .vlp-coach-table td {
    display: block;
  }
  .vlp-coach-table tr:first-child td:first-child {
    width: 100% !important;
    height: 200px;
    min-height: 200px;
  }
  .vlp-coach-table .vlp-coach-imgwrap {
    width: 100%;
    height: 100%;
    min-height: 196px;
  }
  .vlp-coach-table .vlp-coach-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}