:root{
  --apex-green:#0f7a3b;
  --apex-green-2:#14a05a;
  --apex-ink:#0b1b12;
  --apex-muted:#5c6b62;
  --apex-card: rgba(255,255,255,.92);
  --apex-border: rgba(15,122,59,.18);
  --apex-shadow: 0 18px 55px rgba(0,0,0,.18);
  --apex-shadow-green: 0 18px 55px rgba(20,160,90,.20);
  --apex-radius: 18px;
  --apex-font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
}

#apex-assist, #apex-assist-launcher{
  font-family: var(--apex-font);
  box-sizing: border-box;
}
#apex-assist * ,#apex-assist-launcher *{ box-sizing: border-box; }

/* Launcher (botão flutuante) */
#apex-assist-launcher{
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 999999;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px 10px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255,255,255,.92), rgba(255,255,255,.78));
  backdrop-filter: blur(10px);
  border: 1px solid var(--apex-border);
  box-shadow: var(--apex-shadow-green);
  cursor: pointer;
  user-select: none;
  min-width: 250px;
  transition: transform .15s ease, box-shadow .15s ease;
}
#apex-assist-launcher:hover{
  transform: translateY(-2px);
  box-shadow: 0 22px 65px rgba(20,160,90,.23);
}

.apex-launcher-avatar{
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: radial-gradient(circle at 30% 30%, rgba(20,160,90,.25), rgba(15,122,59,.10));
  border: 1px solid rgba(20,160,90,.25);
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
}
.apex-launcher-avatar img{ width: 26px; height: 26px; object-fit: contain; }

.apex-launcher-text{ line-height: 1.1; }
.apex-launcher-title{
  font-weight: 800;
  color: var(--apex-ink);
  font-size: 16px;
}
.apex-launcher-sub{
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--apex-muted);
}

.apex-launcher-dot{
  margin-left: auto;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #ff4d4d, #e60000);
  box-shadow: 0 0 0 4px rgba(255,77,77,.15);
}

/* Janela do chat */
#apex-assist{
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: 560px;
  max-height: calc(100vh - 24px);
  border-radius: var(--apex-radius);
  background: var(--apex-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--apex-border);
  box-shadow: var(--apex-shadow);
  overflow: hidden;
  z-index: 999999;
  display: none;
}

.apex-header{
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding: 14px 14px 12px;
  background: linear-gradient(135deg, rgba(15,122,59,.10), rgba(20,160,90,.06));
  border-bottom: 1px solid rgba(15,122,59,.12);
}
.apex-header-left{
  display:flex;
  align-items:center;
  gap: 10px;
}
.apex-header-avatar{
  width: 38px; height: 38px;
  border-radius: 14px;
  background: radial-gradient(circle at 30% 30%, rgba(20,160,90,.25), rgba(15,122,59,.10));
  border: 1px solid rgba(20,160,90,.25);
  display:flex; align-items:center; justify-content:center;
  overflow:hidden;
}
.apex-header-avatar img{ width: 22px; height: 22px; object-fit: contain; }
.apex-header-title{ font-weight: 900; color: var(--apex-ink); }
.apex-header-sub{ font-size: 12.5px; color: var(--apex-muted); margin-top: 1px; }

.apex-close{
  width: 38px; height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(15,122,59,.16);
  background: rgba(255,255,255,.7);
  cursor: pointer;
  font-size: 18px;
  transition: transform .12s ease;
}
.apex-close:hover{ transform: scale(1.03); }

.apex-body{
  height: calc(100% - 66px - 64px - 34px);
  padding: 12px;
  overflow: hidden;
}
.apex-chips{
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 2px 10px;
}
.apex-chip{
  border: 1px solid rgba(15,122,59,.18);
  background: rgba(255,255,255,.85);
  color: var(--apex-ink);
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 13px;
  cursor:pointer;
  box-shadow: 0 8px 18px rgba(20,160,90,.10);
  transition: transform .12s ease, background .12s ease;
}
.apex-chip:hover{ transform: translateY(-1px); background: rgba(255,255,255,.95); }

.apex-messages{
  height: calc(100% - 54px);
  overflow: auto;
  padding: 6px 2px 10px;
}

.apex-msg{
  display:flex;
  gap: 10px;
  margin: 10px 0;
}
.apex-msg .avatar{
  width: 28px; height: 28px;
  border-radius: 10px;
  background: rgba(15,122,59,.10);
  border: 1px solid rgba(15,122,59,.15);
  display:flex; align-items:center; justify-content:center;
  overflow:hidden;
  flex: 0 0 auto;
}
.apex-msg .avatar img{ width: 18px; height: 18px; object-fit: contain; }

.apex-bubble{
  max-width: 78%;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,.06);
  background: rgba(255,255,255,.92);
  color: var(--apex-ink);
  box-shadow: 0 10px 30px rgba(0,0,0,.07);
  font-size: 14px;
  line-height: 1.35;
  white-space: pre-wrap;
}
.apex-msg.user{ justify-content: flex-end; }
.apex-msg.user .avatar{ display:none; }
.apex-msg.user .apex-bubble{
  background: linear-gradient(135deg, rgba(15,122,59,.92), rgba(20,160,90,.86));
  color: white;
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 14px 38px rgba(15,122,59,.22);
}

.apex-footer{
  display:flex;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid rgba(15,122,59,.12);
  background: rgba(255,255,255,.8);
}
#apex-input{
  flex:1;
  height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.10);
  outline: none;
  font-size: 14px;
}
#apex-input:focus{
  border-color: rgba(20,160,90,.55);
  box-shadow: 0 0 0 4px rgba(20,160,90,.15);
}
#apex-send{
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 0;
  background: linear-gradient(135deg, var(--apex-green), var(--apex-green-2));
  color: white;
  font-weight: 800;
  cursor:pointer;
  box-shadow: 0 14px 35px rgba(15,122,59,.22);
}

.apex-disclaimer{
  padding: 8px 12px 10px;
  font-size: 12px;
  color: var(--apex-muted);
}

/* Mobile */
@media (max-width: 520px){
  #apex-assist{ width: calc(100vw - 24px); height: calc(100vh - 24px); }
  #apex-assist-launcher{ min-width: auto; }
  .apex-launcher-sub{ display:none; }
}
