/* Fepa AI - minimal modern chat matching devCon brand */

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

/* ========== TRIGGER BUTTON ========== */
.fepa-trigger {
  position: relative;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: var(--radius-full);
  background: var(--orange);
  color: #0a0a0a;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all var(--transition);
  box-shadow: 0 10px 28px -8px var(--orange-glow);
}
.fepa-trigger:hover {
  background: var(--orange-bright);
  transform: translateY(-2px);
  box-shadow: 0 14px 32px -8px rgba(255, 140, 26, 0.45);
}
.fepa-trigger:active { transform: scale(0.96); }
.fepa-trigger svg { width: 24px; height: 24px; }

.fepa-trigger-icon-open,
.fepa-trigger-icon-close { display: block; }
.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: -2px;
  right: -6px;
  background: var(--bg-card);
  color: var(--orange);
  border: 1px solid var(--orange);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  line-height: 1.2;
}
.fepa-chat.open .fepa-trigger-badge { display: none; }

/* ========== PANEL ========== */
.fepa-panel {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 400px;
  max-width: calc(100vw - 40px);
  height: 600px;
  max-height: calc(100vh - 130px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 180ms ease, transform 180ms ease;
}
.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: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.fepa-head-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.fepa-avatar {
  position: relative;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}
.fepa-avatar img {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  object-fit: cover;
  display: block;
}
.fepa-status {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid var(--bg-card);
}
.fepa-head-text { line-height: 1.2; }
.fepa-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.005em;
}
.fepa-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.fepa-clear {
  width: 28px;
  height: 28px;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.fepa-clear:hover {
  color: var(--orange);
  border-color: rgba(255, 140, 26, 0.3);
  background: var(--orange-dim);
}
.fepa-clear:active {
  transform: scale(0.92);
  background: rgba(255, 140, 26, 0.15);
}

/* ========== MESSAGES ========== */
.fepa-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
.fepa-messages::-webkit-scrollbar { width: 4px; }
.fepa-messages::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }
.fepa-messages::-webkit-scrollbar-track { background: transparent; }

.fepa-msg {
  max-width: 88%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  animation: fepa-in 200ms ease-out;
}
@keyframes fepa-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.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: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
  border-radius: var(--radius-lg);
}
.fepa-msg-user .fepa-msg-bubble {
  background: var(--orange);
  color: #0a0a0a;
  border-bottom-right-radius: 6px;
  font-weight: 500;
}
.fepa-msg-assistant .fepa-msg-bubble {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
}

.fepa-msg-time {
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  padding: 0 4px;
  opacity: 0.85;
}

/* ========== Markdown inside bubbles ========== */
.fepa-msg-bubble p {
  margin: 0;
}
.fepa-msg-bubble p + p {
  margin-top: 8px;
}
.fepa-msg-bubble .fepa-h {
  font-size: 13.5px;
  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: 11.5px;
  padding: 1px 5px;
  background: rgba(0,0,0,0.3);
  border-radius: var(--radius-sm);
  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.35);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 8px 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  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: var(--border);
}
.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: 5px; height: 5px;
  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.8); }
  40%           { opacity: 1;   transform: scale(1); }
}

/* ========== SUGGESTIONS ========== */
.fepa-suggs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 12px;
}
.fepa-sugg {
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.fepa-sugg:hover {
  color: var(--orange);
  border-color: rgba(255, 140, 26, 0.3);
  background: var(--orange-dim);
}
.fepa-sugg:active { transform: scale(0.96); }

/* ========== INPUT ========== */
.fepa-form {
  padding: 8px 16px 16px;
}
.fepa-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 5px 8px 5px 14px;
  transition: border-color var(--transition);
}
.fepa-input-wrap:focus-within {
  border-color: var(--border-strong);
}
.fepa-input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 0;
  font-size: 13px;
  color: var(--text);
  outline: none;
  font: inherit;
  min-width: 0;
}
.fepa-input:disabled { opacity: 0.5; }
.fepa-input::placeholder { color: var(--text-dim); }

.fepa-send {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  background: var(--orange);
  color: #0a0a0a;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.fepa-send:hover { background: var(--orange-bright); }
.fepa-send:active { transform: scale(0.92); }

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