/* Colors/shapes intentionally mirror the daily-lesson Ask Saemi panel
   (modules/daily-lesson/Code/assets/css/lesson-mode.css's body.lesson-mode
   .ask-saemi-* rules) so this reads as the same feature, not a different
   product -- this widget just has its own floating container around that
   same look, since it has no lesson-workbench card to sit inside. */

.ask-saemi-float {
  /* Inline now -- rendered beside the translation/answer eye-buttons
     (modules/youtube-dictation/Code/shortcode-render.php's eye-group)
     instead of fixed at the viewport corner. Still `position: relative`
     (not `static`): the panel below is `position: absolute` relative to
     this element, same as before the launcher moved -- it just now pops up
     anchored to wherever this sits in the button row instead of a fixed
     screen corner. Kept as its own reusable widget either way: a future
     consumer that wants the old fixed-corner placement just wraps the
     output of saemi_ask_saemi_render_float_widget() in a `position: fixed`
     container of its own.  */
  position: relative;
  display: inline-flex;
  z-index: 6;
  font-family: "Inter", system-ui, sans-serif;
}

.ask-saemi-float,
.ask-saemi-float * {
  box-sizing: border-box;
}

.ask-saemi-float-launcher {
  /* Sized to match its siblings in the eye-group row
     (.saemi-yt-dictation-eye-btn is 40x40) rather than the larger standalone
     floating-corner size this had before. */
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(74, 112, 65, 0.16);
  background: #fff;
  box-shadow: 0 6px 16px rgba(67, 87, 51, 0.18);
  padding: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  overflow: visible;
  transition: transform 0.15s ease;
}

.ask-saemi-float-launcher:hover {
  transform: scale(1.05);
}

.ask-saemi-float-launcher-avatar {
  border-radius: 999px;
  overflow: hidden;
}

/* Hover tooltip: same look as the sibling eye-group icon buttons
   (.saemi-yt-dictation-eye-btn::after in yt-dictation.css) so this reads as
   one consistent row of icon buttons, not a different widget. */
.ask-saemi-float-launcher::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(51, 67, 30, 0.9);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
  pointer-events: none;
}

.ask-saemi-float-launcher:hover::after {
  opacity: 1;
  visibility: visible;
}

.ask-saemi-float-launcher-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ask-saemi-float-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  width: min(360px, calc(100vw - 40px));
  max-height: min(520px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  background: #fff;
  border: 1px solid rgba(74, 112, 65, 0.1);
  box-shadow: 0 20px 48px rgba(67, 87, 51, 0.24);
  overflow: hidden;
}

/* Same specificity as the browser's native [hidden]{display:none} rule, and
   loaded later, so without this !important override, setting .hidden=true
   in JS never actually hides these -- the close button "did nothing" bug. */
.ask-saemi-float-panel[hidden] {
  display: none !important;
}

/* Top-left corner: the panel's "free" edge -- it's anchored bottom-right to
   the launcher by default (right:0; bottom:calc(100% + 12px) above), so
   growing from the opposite corner is what visually makes sense, and needs
   no extra left/top bookkeeping since the browser naturally keeps the
   right/bottom edges fixed as width/height grow from an anchored box. */
.ask-saemi-float-resize-handle {
  /* Positioned fully INSIDE the panel's box (not a negative offset sitting
     partially outside it) -- the panel has overflow:hidden for its rounded
     corners/scroll areas, and a handle straddling that clip boundary
     reliably stopped receiving mousemove events partway through a drag in
     testing (confirmed: raw document-level mousemove capture went from
     4/16 events to 17/17 the moment this was moved fully inside the clip). */
  position: absolute;
  top: 0;
  left: 0;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: nwse-resize;
  touch-action: none;
  z-index: 6;
}

.ask-saemi-float-resize-handle::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 6px;
  width: 8px;
  height: 8px;
  border-top: 2px solid rgba(95, 111, 57, 0.35);
  border-left: 2px solid rgba(95, 111, 57, 0.35);
  border-radius: 3px 0 0 0;
}

.ask-saemi-float-resize-handle:hover::before {
  border-color: rgba(95, 111, 57, 0.6);
}

.ask-saemi-float-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  cursor: move;
  touch-action: none;
  user-select: none;
}

.ask-saemi-float-panel.is-dragging,
.ask-saemi-float-panel.is-resizing {
  transition: none;
  user-select: none;
}

.ask-saemi-float-header-title {
  flex: 1 1 auto;
  color: #5f6f39;
  font-weight: 900;
  font-size: 1rem;
}

.ask-saemi-float-header-actions {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.ask-saemi-float-reset,
.ask-saemi-float-close {
  border: 0;
  background: none;
  color: #746b60;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 4px 6px;
  border-radius: 8px;
}

.ask-saemi-float-close:hover {
  background: rgba(107, 127, 61, 0.1);
}

.ask-saemi-float-info-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(241, 113, 8, 0.26);
  border-radius: 999px;
  background: #fff8ef;
  color: #a85b12;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.ask-saemi-float-info-button:hover,
.ask-saemi-float-info-button:focus-visible,
.ask-saemi-float-info-button[aria-expanded="true"] {
  border-color: rgba(241, 113, 8, 0.46);
  background: #fff2df;
  transform: translateY(-1px);
}

.ask-saemi-float-info-button[hidden] {
  display: none !important;
}

.ask-saemi-float-info-tooltip {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 5;
  width: min(260px, calc(100vw - 48px));
  padding: 10px 12px;
  border: 1px solid rgba(241, 113, 8, 0.18);
  border-radius: 14px;
  background: #fffaf4;
  color: #6b522f;
  box-shadow: 0 10px 24px rgba(92, 64, 27, 0.08);
}

.ask-saemi-float-info-tooltip[hidden] {
  display: none !important;
}

.ask-saemi-float-info-line {
  margin: 0;
  font-size: 0.79rem;
  line-height: 1.45;
}

.ask-saemi-float-info-line + .ask-saemi-float-info-line {
  margin-top: 4px;
}

.ask-saemi-float-info-link {
  display: inline-block;
  margin-top: 8px;
  color: #d96d0d;
  font-size: 0.79rem;
  font-weight: 700;
  line-height: 1.45;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ask-saemi-float-info-link[hidden] {
  display: none !important;
}

.ask-saemi-float-guest {
  padding: 20px 16px;
  color: #5f584f;
  text-align: center;
}

.ask-saemi-float-guest p {
  margin: 0 0 12px;
  line-height: 1.55;
}

.ask-saemi-float-login-link {
  display: inline-block;
  margin-top: 15px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid #f17108;
  background: rgba(255, 252, 249, 0.86);
  color: #131313;
  font-weight: 400;
  text-decoration: none;
}

.ask-saemi-float-chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
  padding: 0 16px 16px;
}

.ask-saemi-float-chat[hidden],
.ask-saemi-float-guest[hidden] {
  display: none !important;
}

.ask-saemi-float-thread {
  flex: 1 1 auto;
  min-height: 160px;
  max-height: 320px;
  overflow-y: auto;
  display: grid;
  gap: 14px;
  align-content: start;
  justify-items: start;
  padding: 4px 2px 14px;
}

.ask-saemi-float-bubble {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  padding: 12px 14px;
  border-radius: 18px;
  line-height: 1.55;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.ask-saemi-float-bubble-user {
  justify-self: end;
  background: #f3f3f2;
  color: #4c4b4b;
}

.ask-saemi-float-bubble-assistant {
  color: #3d4728;
  padding-left: 2px;
  padding-right: 2px;
}

.ask-saemi-float-bubble-system {
  justify-self: center;
  color: #a68b3d;
  font-size: 0.82rem;
  text-align: center;
  padding: 4px 10px;
}

.ask-saemi-float-typing {
  opacity: 0.6;
}

.ask-saemi-float-form {
  position: relative;
  display: grid;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid rgba(74, 112, 65, 0.08);
}

.ask-saemi-float-form textarea {
  width: 100%;
  resize: none;
  height: 52px;
  min-height: 52px;
  max-height: 120px;
  border-radius: 18px;
  border: 1px solid rgba(74, 112, 65, 0.12);
  padding: 14px 46px 14px 14px;
  font: inherit;
  color: #33431e;
  background: #fbfcf8;
}

.ask-saemi-float-form textarea:focus {
  outline: 3px solid rgba(240, 138, 36, 0.2);
  outline-offset: 2px;
}

.ask-saemi-float-send {
  position: absolute;
  right: 12px;
  /* Centered on the textarea, not the form: the form has padding-top:10px
     above the textarea, so top:50% of the form's own box sits 10px above
     the textarea's actual center. 36px = padding-top(10) + half the
     textarea's height(26). */
  top: 36px;
  transform: translateY(-50%);
  border: 0;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff901d, #f17108);
  color: #fff;
  font-weight: 900;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 14px 24px rgba(240, 113, 8, 0.16);
}

.ask-saemi-float-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.ask-saemi-float-composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  min-height: 20px;
}

.ask-saemi-float-usage {
  margin: 0;
  font-size: 0.78rem;
  color: #746b60;
  font-weight: 700;
}

.ask-saemi-float-usage[hidden] {
  display: none !important;
}

.ask-saemi-float-reset {
  flex: 0 0 auto;
  white-space: nowrap;
}

.ask-saemi-float-reset:hover {
  background: rgba(107, 127, 61, 0.1);
}

.ask-saemi-float-reset[hidden] {
  display: none !important;
}

@media (max-width: 480px) {
  .ask-saemi-float {
    right: 14px;
    bottom: 14px;
  }

  .ask-saemi-float-panel {
    width: calc(100vw - 28px);
  }
}
