/* ==========================================================================
   Kancil PromptBar Stylesheet (Adapted from React Bits PromptBar)
   Native CSS for Blade Views with Dark/Light Mode & Accessibility
   ========================================================================== */

.prompt-bar {
  --pb-bg: var(--latar-kartu, #1e293b);
  --pb-ink: var(--tinta, #f8fafc);
  --pb-menu: var(--latar-elevasi, #1e293b);
  --pb-border: var(--garis, #334155);
  --pb-w: 100%;
  --pb-radius: 14px;
  --pb-press: 0.96;
  --pb-spark: #a78bfa;
  --pb-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --pb-muted: var(--tinta-2, #94a3b8);
  --pb-hover: color-mix(in srgb, var(--pb-ink) 8%, transparent);
  --pb-effort-fill: 50%;
  --pb-effort-x: 50%;

  position: relative;
  width: min(var(--pb-w), 100%);
  color: var(--pb-ink);
  font-family: inherit;
  font-size: 14px;
  line-height: 22px;
}

/* Light Theme Variables */
.prompt-bar {
  --pb-bg: #0b2f2a;
  --pb-ink: #eaf6f1;
  --pb-menu: #05120f;
  --pb-border: #1f4a42;
  --pb-muted: #a9bdb5;
  --pb-hover: rgba(255, 255, 255, 0.08);
}

/* 1. Menus (Popover Dropdowns: @ sources, / commands, model picker, effort slider) */
.prompt-bar__menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 50;
  padding: 6px;
  border-radius: 12px;
  background: var(--pb-menu);
  border: 1px solid var(--pb-border);
  box-shadow:
    0 10px 30px -10px rgba(0, 0, 0, 0.45),
    0 1px 3px rgba(0, 0, 0, 0.15);
  transform-origin: bottom center;
  animation: prompt-bar-pop 180ms var(--pb-ease-out) both;
  display: none;
}

.prompt-bar__menu[data-open="true"] {
  display: block;
}

.prompt-bar__menu[data-kind='model'] {
  right: auto;
  width: 220px;
  transform-origin: bottom left;
}

.prompt-bar__menu[data-kind='effort'] {
  right: auto;
  width: 260px;
  padding: 12px 14px 14px;
  transform-origin: bottom left;
}

@keyframes prompt-bar-pop {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Sliding Hover Glow Indicator */
.prompt-bar__glow {
  position: absolute;
  right: 6px;
  left: 6px;
  border-radius: 8px;
  background: var(--pb-hover);
  opacity: 0;
  pointer-events: none;
  transition:
    top 200ms var(--pb-ease-out),
    height 200ms var(--pb-ease-out),
    opacity 150ms ease;
}

/* Menu Row Items */
.prompt-bar__row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.prompt-bar__row-icon {
  display: inline-flex;
  flex: none;
  justify-content: center;
  align-items: center;
  width: 20px;
  color: color-mix(in srgb, var(--pb-ink) 70%, transparent);
}

.prompt-bar__row-name {
  flex: none;
  font-size: 13px;
  font-weight: 500;
}

.prompt-bar__row-desc {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--pb-muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.prompt-bar__row-tag {
  flex: none;
  margin-left: auto;
  color: var(--pb-muted);
  font-size: 11px;
  background: var(--pb-hover);
  padding: 2px 6px;
  border-radius: 4px;
}

.prompt-bar__row-check {
  display: inline-flex;
  flex: none;
  justify-content: center;
  align-items: center;
  width: 16px;
  opacity: 0;
  color: var(--aksen);
}

.prompt-bar__row[data-active="true"] .prompt-bar__row-check {
  opacity: 1;
}

.prompt-bar__empty {
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 10px;
  color: var(--pb-muted);
  font-size: 12px;
}

/* 2. Main Field Container */
.prompt-bar__field {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--pb-radius);
  background: var(--pb-bg);
  border: 1px solid var(--pb-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  cursor: text;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.prompt-bar__field:focus-within {
  border-color: var(--aksen);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--aksen) 25%, transparent);
}

/* Background Radial Glow on Max Effort */
.prompt-bar__field::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: radial-gradient(
    140% 120% at 0% 100%,
    color-mix(in srgb, var(--pb-spark) 28%, transparent),
    transparent 65%
  );
  opacity: 0;
  pointer-events: none;
  transition: opacity 500ms ease;
}

.prompt-bar[data-max] .prompt-bar__field::before {
  opacity: 1;
}

/* Sparks Canvas */
.prompt-bar__sparks {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  pointer-events: none;
}

/* 3. Attachment Chips */
.prompt-bar__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.prompt-bar__chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 4px 0 8px;
  border-radius: 6px;
  background: var(--pb-hover);
  border: 1px solid var(--pb-border);
  font-size: 12px;
  animation: prompt-bar-pop 200ms var(--pb-ease-out) both;
}

.prompt-bar__chip-name {
  max-width: 160px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.prompt-bar__chip-x {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  opacity: 0.65;
  cursor: pointer;
  outline: none;
  transition:
    opacity 120ms ease,
    background-color 120ms ease;
}

.prompt-bar__chip-x:hover {
  background: color-mix(in srgb, var(--pb-ink) 12%, transparent);
  opacity: 1;
}

/* 4. Textarea Input */
.prompt-bar__input {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 14px;
  line-height: 22px;
  resize: none;
  outline: none;
  overflow-wrap: anywhere;
  min-height: 22px;
  box-sizing: border-box;
}

.prompt-bar__input::placeholder {
  color: color-mix(in srgb, var(--pb-ink) 45%, transparent);
}

@media (pointer: coarse) {
  .prompt-bar__input {
    font-size: 16px;
  }
}

/* 5. Bottom Action Bar */
.prompt-bar__bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
}

.prompt-bar__spacer {
  flex: 1 1 auto;
}

/* Buttons (Tool, Pick, Send) */
.prompt-bar__tool,
.prompt-bar__pick,
.prompt-bar__send {
  flex: none;
  border: 0;
  font: inherit;
  cursor: pointer;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.prompt-bar__tool {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: color-mix(in srgb, var(--pb-ink) 60%, transparent);
  transition:
    background-color 150ms ease,
    color 150ms ease,
    transform 160ms var(--pb-ease-out);
}

.prompt-bar__tool:active {
  transform: scale(0.94);
}

.prompt-bar__pick {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  background: transparent;
  color: color-mix(in srgb, var(--pb-ink) 75%, transparent);
  font-size: 12px;
  font-weight: 500;
  transition:
    background-color 150ms ease,
    color 150ms ease;
}

.prompt-bar__tool[data-on="true"],
.prompt-bar__pick[data-on="true"] {
  background: var(--pb-hover);
  color: var(--pb-ink);
}

@media (hover: hover) and (pointer: fine) {
  .prompt-bar__tool:hover,
  .prompt-bar__pick:hover {
    background: var(--pb-hover);
    color: var(--pb-ink);
  }
}

.prompt-bar[data-max] .prompt-bar__pick[data-kind='effort'] {
  color: var(--pb-spark);
  font-weight: 600;
}

/* 6. Effort Slider Popup */
.prompt-bar__effort-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  line-height: 18px;
}

.prompt-bar__effort-title {
  color: var(--pb-muted);
}

.prompt-bar__effort-level {
  font-weight: 600;
}

.prompt-bar__effort-help {
  display: inline-flex;
  margin-left: auto;
  color: var(--pb-muted);
}

.prompt-bar__effort-ends {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  color: var(--pb-muted);
  font-size: 11px;
  line-height: 16px;
}

.prompt-bar__effort-track {
  position: relative;
  height: 22px;
  margin-top: 8px;
  border-radius: 11px;
  background: var(--pb-hover);
  cursor: pointer;
  outline: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.prompt-bar__effort-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--pb-effort-fill);
  border-radius: 11px;
  background: color-mix(in srgb, var(--pb-ink) 18%, transparent);
  transition:
    width 220ms var(--pb-ease-out),
    background-color 300ms ease;
}

.prompt-bar__effort-dot {
  position: absolute;
  top: 50%;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--pb-ink) 30%, transparent);
}

.prompt-bar__effort-thumb {
  position: absolute;
  top: -3px;
  left: var(--pb-effort-x);
  width: 14px;
  height: 28px;
  margin-left: -7px;
  border-radius: 7px;
  background: var(--pb-ink);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition:
    left 220ms var(--pb-ease-out),
    background-color 300ms ease;
}

.prompt-bar[data-max] .prompt-bar__effort-fill {
  background: color-mix(in srgb, var(--pb-spark) 35%, transparent);
}

.prompt-bar[data-max] .prompt-bar__effort-thumb {
  background: var(--pb-spark);
}

/* 7. Mic Equalizer Indicator */
.prompt-bar__eq {
  display: flex;
  align-items: center;
  gap: 2.5px;
  height: 14px;
}

.prompt-bar__eq i {
  display: block;
  width: 2.5px;
  height: 100%;
  border-radius: 999px;
  background: currentColor;
  transform-origin: center;
  animation: prompt-bar-eq 900ms ease-in-out infinite;
}

.prompt-bar__eq i:nth-child(2) {
  animation-delay: 150ms;
}

.prompt-bar__eq i:nth-child(3) {
  animation-delay: 300ms;
}

@keyframes prompt-bar-eq {
  0%,
  100% {
    transform: scaleY(0.35);
  }
  50% {
    transform: scaleY(1);
  }
}

/* 8. Send Button & Morphing SVG Glyph */
.prompt-bar__send {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  background: color-mix(in srgb, var(--pb-ink) 12%, var(--pb-bg));
  color: color-mix(in srgb, var(--pb-ink) 55%, var(--pb-bg));
  transition:
    background-color 200ms ease,
    color 200ms ease,
    transform 160ms var(--pb-ease-out);
}

.prompt-bar__send:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.prompt-bar__send[data-armed="true"] {
  background: var(--aksen);
  color: #ffffff;
}

.prompt-bar__send[data-busy="true"] {
  background: var(--pb-ink);
  color: var(--pb-bg);
}

.prompt-bar__send[data-pressed="true"] {
  transform: scale(var(--pb-press));
}

.prompt-bar__glyph {
  display: block;
  width: 16px;
  height: 16px;
  transform-origin: 50% 50%;
  transition: transform 160ms var(--pb-ease-out);
}

/* Reduced Motion Accessibility */
@media (prefers-reduced-motion: reduce) {
  .prompt-bar__menu,
  .prompt-bar__chip {
    animation: none;
  }

  .prompt-bar__glow {
    transition: opacity 150ms ease;
  }

  .prompt-bar__effort-fill,
  .prompt-bar__effort-thumb {
    transition: background-color 300ms ease;
  }

  .prompt-bar__tool:active,
  .prompt-bar__send[data-pressed] {
    transform: none;
  }
}

