/* devCon AI — Apple-style chat widget */

.fepa-chat {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: var(--font-body);
}

/* ========== TRIGGER BUTTON ========== */
.fepa-trigger {
  position: relative;
  width: 60px;
  height: 60px;
  padding: 0;
  border-radius: 50%;
  background: var(--orange);
  color: #0a0a0a;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 320ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 220ms ease, background 180ms ease;
  box-shadow: 0 8px 24px -6px var(--orange-glow), 0 2px 6px rgba(0,0,0,0.3);
}
.fepa-trigger:hover {
  background: var(--orange-bright);
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 14px 32px -6px rgba(255, 140, 26, 0.5), 0 2px 8px rgba(0,0,0,0.35);
}
.fepa-trigger:active { transform: scale(0.94); }
.fepa-trigger svg { width: 26px; height: 26px; }

.fepa-trigger-icon-open,
.fepa-trigger-icon-close { display: block; transition: transform 220ms ease; }
.fepa-trigger-icon-close { display: none; }
.fepa-chat.open .fepa-trigger-icon-open { display: none; }
.fepa-chat.open .fepa-trigger-icon-close { display: block; }

.fepa-trigger-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  min-width: 28px;
  height: 18px;
  padding: 0 6px;
  background: #ef4444;
  color: #fff;
  border: 2px solid var(--bg);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 999px;
  display: grid;
  place-items: center;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}
.fepa-chat.open .fepa-trigger-badge { display: none; }

/* ========== PANEL ========== */
.fepa-panel {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 140px);
  background: rgba(18, 18, 20, 0.78);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 32px 64px -16px rgba(0, 0, 0, 0.65),
    0 8px 24px -8px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.96);
  transform-origin: bottom right;
  transition:
    opacity 260ms cubic-bezier(0.32, 0.72, 0, 1),
    transform 320ms cubic-bezier(0.32, 0.72, 0, 1);
}
.fepa-chat.open .fepa-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* ========== HEADER ========== */
.fepa-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.fepa-head-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.fepa-avatar {
  position: relative;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}
.fepa-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: contain;
  padding: 3px;
  background: rgba(255, 255, 255, 0.04);
  box-sizing: border-box;
  display: block;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4), inset 0 0 0 1px rgba(255,255,255,0.08);
}
.fepa-status {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22c55e;
  border: 2.5px solid rgba(18, 18, 20, 0.95);
}
.fepa-head-text { line-height: 1.25; }
.fepa-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.fepa-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 400;
}
.fepa-clear {
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fepa-clear svg { width: 16px; height: 16px; }
.fepa-clear:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}
.fepa-clear:active { transform: scale(0.88); }

/* ========== MESSAGES ========== */
.fepa-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.fepa-messages::-webkit-scrollbar { width: 6px; }
.fepa-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 3px; }
.fepa-messages::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.12); }
.fepa-messages::-webkit-scrollbar-track { background: transparent; }

.fepa-msg {
  max-width: 85%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: fepa-in 320ms cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes fepa-in {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.fepa-msg-user { align-self: flex-end; align-items: flex-end; }
.fepa-msg-assistant { align-self: flex-start; align-items: flex-start; }

.fepa-msg-bubble {
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  border-radius: 20px;
  letter-spacing: -0.005em;
}
.fepa-msg-user .fepa-msg-bubble {
  background: linear-gradient(180deg, var(--orange-bright, #ffa040) 0%, var(--orange) 100%);
  color: #0a0a0a;
  border-bottom-right-radius: 6px;
  font-weight: 500;
  box-shadow: 0 2px 10px -2px rgba(255, 140, 26, 0.35);
}
.fepa-msg-assistant .fepa-msg-bubble {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-bottom-left-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.fepa-msg-time {
  font-size: 10.5px;
  color: var(--text-dim);
  font-family: inherit;
  font-weight: 400;
  letter-spacing: -0.005em;
  padding: 2px 4px 0;
  opacity: 0.55;
}

/* ========== Markdown inside bubbles ========== */
.fepa-msg-bubble p { margin: 0; }
.fepa-msg-bubble p + p { margin-top: 8px; }
.fepa-msg-bubble .fepa-h {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 6px;
  line-height: 1.35;
  color: var(--text);
}
.fepa-msg-bubble .fepa-h:not(:first-child) { margin-top: 12px; }
.fepa-msg-user .fepa-msg-bubble .fepa-h { color: #0a0a0a; }

.fepa-msg-bubble .fepa-list { margin: 6px 0; padding-left: 20px; }
.fepa-msg-bubble .fepa-list li { margin-bottom: 4px; line-height: 1.5; }
.fepa-msg-bubble .fepa-list li:last-child { margin-bottom: 0; }
.fepa-msg-bubble ol.fepa-list { list-style: decimal; }
.fepa-msg-bubble ul.fepa-list { list-style: disc; }
.fepa-msg-user .fepa-msg-bubble .fepa-list { color: #0a0a0a; }

.fepa-msg-bubble a {
  color: var(--orange);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}
.fepa-msg-user .fepa-msg-bubble a { color: #0a0a0a; font-weight: 600; }
.fepa-msg-bubble code {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 1.5px 6px;
  background: rgba(0,0,0,0.35);
  border-radius: 5px;
  color: var(--orange);
}
.fepa-msg-user .fepa-msg-bubble code { background: rgba(0,0,0,0.18); color: #0a0a0a; }
.fepa-msg-bubble strong { font-weight: 600; }
.fepa-msg-user .fepa-msg-bubble strong { color: #0a0a0a; }

.fepa-msg-bubble .fepa-code {
  display: block;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 8px 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--orange);
  overflow-x: auto;
  white-space: pre;
}
.fepa-msg-bubble .fepa-code code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: inherit;
}
.fepa-msg-user .fepa-msg-bubble .fepa-code {
  background: rgba(0,0,0,0.18);
  border-color: rgba(0,0,0,0.15);
  color: #0a0a0a;
}
.fepa-msg-bubble .fepa-code::-webkit-scrollbar { height: 4px; }
.fepa-msg-bubble .fepa-code::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* Typing dots */
.fepa-typing .fepa-msg-time { display: none; }

/* Language switch divider */
.fepa-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 6px 0;
  padding: 0 12px;
  animation: fepa-in 200ms ease-out;
}
.fepa-divider::before,
.fepa-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.06);
}
.fepa-divider span {
  font-size: 10.5px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  padding: 0 10px;
  white-space: nowrap;
}

.fepa-dots {
  display: inline-flex;
  gap: 4px;
  padding: 2px 0;
}
.fepa-dots i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: fepa-dot 1.2s infinite ease-in-out;
}
.fepa-dots i:nth-child(2) { animation-delay: 0.15s; }
.fepa-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes fepa-dot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.7); }
  40%           { opacity: 1;   transform: scale(1); }
}

/* ========== SUGGESTIONS ========== */
.fepa-suggs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 16px 14px;
}
.fepa-sugg {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  transition: all 180ms ease;
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.fepa-sugg:hover {
  color: var(--orange);
  border-color: rgba(255, 140, 26, 0.3);
  background: rgba(255, 140, 26, 0.1);
  transform: translateY(-1px);
}
.fepa-sugg:active { transform: scale(0.96); }

/* ========== INPUT ========== */
.fepa-form {
  padding: 10px 16px 18px;
  background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.15) 100%);
}
.fepa-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 5px 16px 5px 16px;
  transition: all 180ms ease;
}
.fepa-input-wrap:focus-within {
  border-color: rgba(255, 140, 26, 0.35);
  background: rgba(255,255,255,0.08);
  box-shadow: 0 0 0 3px rgba(255, 140, 26, 0.08);
}
.fepa-input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 9px 0;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  font: inherit;
  min-width: 0;
  letter-spacing: -0.005em;
}
.fepa-input:disabled { opacity: 0.5; }
.fepa-input::placeholder { color: var(--text-dim); }

.fepa-send {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  background: var(--orange);
  color: #0a0a0a;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
  box-shadow: 0 2px 8px -2px var(--orange-glow);
}
.fepa-send:hover { background: var(--orange-bright); transform: scale(1.05); }
.fepa-send:active { transform: scale(0.92); }
.fepa-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Mobile */
@media (max-width: 480px) {
  .fepa-chat { bottom: 16px; right: 16px; }
  .fepa-panel {
    width: calc(100vw - 24px);
    right: -8px;
    height: calc(100vh - 110px);
    max-height: 600px;
  }
}
